-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
prefer use of new-style NumPy random API in tests #5450
Conversation
This PR currently is only for modernizing the random call styles in the tests and does not make any API or behavior changes. I think we can address unifying |
No, indeed, since the order of labels as 'integers' (which they are not) doesn't bear any specific meaning. By the way, I'm in favour of closing this issue: #5049
Absolutely!
All good then. |
Oh, iirc #5357 did that (updating expected results) for a few tests. Ok, let's leave these remaining pieces to a subsequent PR. |
Perhaps a bigger concern in the case of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; thanks @grlee77!
@@ -56,18 +53,16 @@ def test_structural_similarity_image(): | |||
@pytest.mark.parametrize('seed', [1, 2, 3, 5, 8, 13]) | |||
@pytest.mark.parametrize('dtype', [np.float16, np.float32, np.float64]) | |||
def test_structural_similarity_grad(seed, dtype): | |||
N = 30 | |||
N = 60 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change, just out of curiosity? 🙂
Description
This PR follows up on #5357, mainly removing residual use of
np.random.RandomState
from test classes. This changes here are mostly trivial, but I have a couple specific points that may be worth considering:1.) Regarding
segmentation.slice
andsegmentation.quickshift
. For those two, there are a lot of tests which check specific label values as below:scikit-image/skimage/segmentation/tests/test_slic.py
Lines 28 to 31 in e4cc469
Is it really important to check that the specific values occur in this order? If not, we could replace with something like just verifying there is only a single, unique label within each region (The correct overall number of labels is already checked separately)
etc.
2.) There is one residual use of
RandomState
used when performingslic
with a mask.scikit-image/skimage/segmentation/slic_superpixels.py
Line 38 in e4cc469
There are a couple of test results that seem to assume the existing initial seed points based on the current RandomState seed, so if we really want to remove that we have to update those test cases with new expected results. I just added a comment to that effect rather than switching it here. Similarly for a specific seed used to compare to precomputed results in one of the
unsupervised_wiener
test cases.Checklist
./doc/examples
(new features only)./benchmarks
, if your changes aren't covered by anexisting benchmark
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.