-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New file structure as recommended by pytest, python tests
- Loading branch information
1 parent
0e870c8
commit d1ac77d
Showing
11 changed files
with
86 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/target | ||
Cargo.lock | ||
/.idea | ||
/rustfrc/__pycache__ | ||
/rustfrc/*.so | ||
/python/rustfrc/__pycache__ | ||
/rustfrc/*.so | ||
/tests/.pytest_cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[project] | ||
name = "rustfrc" | ||
version = "1.0.3" | ||
description = "Fast utility functions useful for Fourier Ring/Shell Correlation: binomial splitting of arrrays" | ||
description = "Fast utility functions useful for Fourier Ring/Shell Correlation: binomial splitting of arrays." | ||
readme = "README.md" | ||
requires-python = ">= 3.7" | ||
license = {text = "Apache-2.0"} | ||
|
@@ -22,7 +22,7 @@ dependencies = [ | |
[tool.poetry] | ||
name = "rustfrc" | ||
version = "1.0.3" | ||
description = "Fast utility functions useful for Fourier Ring/Shell Correlation: binomial splitting of arrays" | ||
description = "Fast utility functions useful for Fourier Ring/Shell Correlation: binomial splitting of arrays." | ||
authors = ["Tip ten Brink <[email protected]>"] | ||
|
||
[tool.poetry.dependencies] | ||
|
Empty file.
Binary file not shown.
File renamed without changes.
Binary file not shown.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
import rustfrc as r | ||
from python import rustfrc as r | ||
import numpy as np | ||
import time | ||
|
||
init_x = (np.ones((900, 700, 100))*30).astype(np.int32) | ||
init_x = (np.ones((900, 700, 100))*24.31) | ||
init_y = (np.ones((900, 700, 100))*30).astype(np.int32) | ||
init_z = np.ones((900, 700, 50))*30 | ||
|
||
|
||
start = time.perf_counter() | ||
x = r.binom_split(init_x) | ||
end = time.perf_counter() | ||
print(str(end - start) + " s") | ||
|
||
|
||
start2 = time.perf_counter() | ||
rng = np.random.default_rng() | ||
y = rng.binomial(init_y, 0.5) | ||
end2 = time.perf_counter() | ||
print(str(end2 - start2) + " s") | ||
# start = time.perf_counter() | ||
# x = r.binom_split(init_x) | ||
# end = time.perf_counter() | ||
# print(str(end - start) + " s") | ||
# | ||
# | ||
# start2 = time.perf_counter() | ||
# rng = np.random.default_rng() | ||
# y = rng.binomial(init_y, 0.5) | ||
# end2 = time.perf_counter() | ||
# print(str(end2 - start2) + " s") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import rustfrc | ||
import numpy as np | ||
import pytest | ||
|
||
|
||
def test_binom_split_negative(): | ||
a = np.ones((5, 5, 5))*20 | ||
a[3, 2, 1] = -1 | ||
|
||
with pytest.raises(ValueError): | ||
rustfrc.binom_split(a) | ||
|
||
|
||
def test_binom_split_ok(): | ||
max_val = 15 | ||
|
||
a = np.ones((3, 7))*max_val | ||
split_a = rustfrc.binom_split(a) | ||
|
||
assert np.amax(split_a) <= max_val | ||
assert np.amin(split_a) >= 0 |