astrofrog / astrofrog/fast-histogram

Improve how we generate test cases with hypothesis

Open
#47 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
C
Stars
281
Forks
28
PR merge metrics
No merged PRs in 30d

Description

At the moment, the ``test_1d_compare_with_numpy`` and ``test_2d_compare_with_numpy`` tests are slightly hacky in how they generate test cases. Here's the code for the 1-d case:

https://github.com/astrofrog/fast-histogram/blob/4dbb898d1ad221587262cfb609ef5ae93bda7715/fast_histogram/tests/test_histogram.py#L17-L39

What I'm trying to do is generate two arrays ``x`` and ``w`` 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?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in fast_histogram/tests/test_histogram.py at the referenced lines for test_1d_compare_with_numpy and test_2d_compare_with_numpy. Read how the current Hypothesis data is generated, then run these tests; done means both tests generate x and w directly with matching float dtype, shape, and value range without the current cast-and-split approach.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.