Skip to content
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 robustness to arbitrary input #67

Open
astrofrog opened this issue Oct 17, 2023 · 0 comments
Open

Improve robustness to arbitrary input #67

astrofrog opened this issue Oct 17, 2023 · 0 comments

Comments

@astrofrog
Copy link
Owner

I started trying to add some full hypothesis tests such as:


# First some tests with hypothesis value generation to make sure our
# implementation doesn't crash, and do basic checks of validity of the output.

@given(values=arrays(dtype='<f8', shape=st.integers(0, 50),
                     elements=st.floats(-1000, 1000, allow_subnormal=False),
                     unique=True),
       nx=st.integers(1, 10),
       xmin=st.floats(-1e10, 1e10),
       xmax=st.floats(-1e10, 1e10),
       weights=st.booleans(),
       dtype=st.sampled_from(['>f4', '<f4', '>f8', '<f8']))
@settings(max_examples=1000)
def test_1d_basic(values, nx, xmin, xmax, weights, dtype):
    size = len(values) // 2
    w = values[:size] if weights else None
    x = values[size:]
    fast = histogram1d(x, bins=nx, weights=w, range=(xmin, xmax))
    assert np.sum(fast) == np.sum((x < xmax) & (x >= xmin))

but this crashes with a segmentation fault currently, so need to investigate further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant