-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve how we generate test cases with hypothesis #47
Labels
Comments
Maybe an @st.composite
def pairs_of_arrays(draw, shapes, dtypes, **kwargs):
shape = draw(shapes)
dtype = draw(dtypes)
arr_strat = arrays(shape, dtype, **kwargs)
return draw(st.tuples(arr_strat, arr_strat))
@given(
x_and_w=pairs_of_arrays(
shapes=array_shapes(max_dims=2),
dtypes=st.sampled_from(['>f4', '<f4', '>f8', '<f8']),
elements=st.floats(-1000, 1000),
unique=True,
),
...
)
def test_1d_or_2d_compare_with_numpy(x_and_w, nx, xmin, xmax, use_weights):
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
At the moment, the
test_1d_compare_with_numpy
andtest_2d_compare_with_numpy
tests are slightly hacky in how they generate test cases. Here's the code for the 1-d case:fast-histogram/fast_histogram/tests/test_histogram.py
Lines 17 to 39 in 4dbb898
What I'm trying to do is generate two arrays
x
andw
which have the same dtype (either 32-bit or 64-bit floats, big or little endian), have the same 1-d size (sampled between 0 and 200), and have values in the range -1000, 1000. So at the moment I generate a 64-bit array, cast it inside the test, then split it into two. It would be cleaner to be able to directly generate the two arrays directly with the correct dtype, but I can't figure out how to do this.@Zac-HD - do you have any suggestions how I might be able to achieve this in a cleaner way?
The text was updated successfully, but these errors were encountered: