Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
0x00b1 committed Jun 6, 2024
1 parent 7aa4b4d commit 1670b5a
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 39 deletions.
7 changes: 6 additions & 1 deletion docs/beignet.special.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# beignet.special

::: beignet.special.dawson_integral_f
## Error and Related Functions

::: beignet.special.error_erf
::: beignet.special.error_erfc
::: beignet.special.error_erfi

## Dawson and Fresnel Integrals

::: beignet.special.dawson_integral_f
::: beignet.special.faddeeva_w
55 changes: 55 additions & 0 deletions tests/beignet/special/test__dawson_integral_f.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import beignet.special
import hypothesis
import hypothesis.strategies
import scipy
import torch


@hypothesis.strategies.composite
def _strategy(function):
x, y = torch.meshgrid(
torch.linspace(
function(
hypothesis.strategies.floats(
min_value=-10,
max_value=-10,
),
),
function(
hypothesis.strategies.floats(
min_value=10,
max_value=10,
),
),
steps=128,
dtype=torch.float64,
),
torch.linspace(
function(
hypothesis.strategies.floats(
min_value=-10,
max_value=-10,
),
),
function(
hypothesis.strategies.floats(
min_value=10,
max_value=10,
),
),
steps=128,
dtype=torch.float64,
),
indexing="xy",
)

input = x + 1.0j * y

return input, scipy.special.dawsn(input)


@hypothesis.given(_strategy())
def test_dawson_integral_f(data):
input, output = data

torch.testing.assert_close(beignet.special.dawson_integral_f(input), output)
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ def _strategy(function):
max_value=10,
),
),
steps=function(
hypothesis.strategies.integers(
min_value=128,
max_value=512,
),
),
steps=128,
dtype=torch.float64,
),
torch.linspace(
Expand All @@ -42,12 +37,7 @@ def _strategy(function):
max_value=10,
),
),
function(
hypothesis.strategies.integers(
min_value=128,
max_value=512,
),
),
steps=128,
dtype=torch.float64,
),
indexing="xy",
Expand All @@ -59,7 +49,7 @@ def _strategy(function):


@hypothesis.given(_strategy())
def test_erf(data):
def test_error_erf(data):
input, output = data

torch.testing.assert_close(beignet.special.error_erf(input), output)
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ def _strategy(function):
max_value=10,
),
),
steps=function(
hypothesis.strategies.integers(
min_value=128,
max_value=512,
),
),
steps=128,
dtype=torch.float64,
),
torch.linspace(
Expand All @@ -42,12 +37,7 @@ def _strategy(function):
max_value=10,
),
),
function(
hypothesis.strategies.integers(
min_value=128,
max_value=512,
),
),
steps=128,
dtype=torch.float64,
),
indexing="xy",
Expand All @@ -59,7 +49,7 @@ def _strategy(function):


@hypothesis.given(_strategy())
def test_erfc(data):
def test_error_erfc(data):
input, output = data

torch.testing.assert_close(beignet.special.error_erfc(input), output)
55 changes: 55 additions & 0 deletions tests/beignet/special/test__error_erfi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import beignet.special
import hypothesis
import hypothesis.strategies
import scipy
import torch


@hypothesis.strategies.composite
def _strategy(function):
x, y = torch.meshgrid(
torch.linspace(
function(
hypothesis.strategies.floats(
min_value=-10,
max_value=-10,
),
),
function(
hypothesis.strategies.floats(
min_value=10,
max_value=10,
),
),
steps=128,
dtype=torch.float64,
),
torch.linspace(
function(
hypothesis.strategies.floats(
min_value=-10,
max_value=-10,
),
),
function(
hypothesis.strategies.floats(
min_value=10,
max_value=10,
),
),
steps=128,
dtype=torch.float64,
),
indexing="xy",
)

input = x + 1.0j * y

return input, scipy.special.erfi(input)


@hypothesis.given(_strategy())
def test_error_erfi(data):
input, output = data

torch.testing.assert_close(beignet.special.error_erfi(input), output)
14 changes: 2 additions & 12 deletions tests/beignet/special/test__faddeeva_w.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ def _strategy(function):
max_value=10,
),
),
steps=function(
hypothesis.strategies.integers(
min_value=128,
max_value=512,
),
),
steps=128,
dtype=torch.float64,
),
torch.linspace(
Expand All @@ -42,12 +37,7 @@ def _strategy(function):
max_value=10,
),
),
function(
hypothesis.strategies.integers(
min_value=128,
max_value=512,
),
),
steps=128,
dtype=torch.float64,
),
indexing="xy",
Expand Down

0 comments on commit 1670b5a

Please sign in to comment.