Skip to content

Improve robustness to arbitrary input #67

@astrofrog

Description

@astrofrog

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions