-
Notifications
You must be signed in to change notification settings - Fork 28
Start enforcing the Ruff RUF rules #251
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,40 +60,43 @@ def test_version_with_embedded_liberfa(): | |
| assert erfa.__version__.startswith(erfa.version.erfa_version) | ||
|
|
||
|
|
||
| def test_erfa_wrapper(): | ||
| """ | ||
| Runs a set of tests that mostly make sure vectorization is | ||
| working as expected | ||
| """ | ||
| @pytest.mark.parametrize( | ||
| ("ra", "dec", "jd", "shape"), | ||
| [ | ||
| pytest.param(0.0, 0.0, 2456855.5, (), id="scalar"), | ||
| pytest.param( | ||
| 0.0, 0.0, np.linspace(2456855.5, 2456856.5, 5), (5,), id="simple array" | ||
| ), | ||
| pytest.param( | ||
| np.linspace(0.0, np.pi * 2.0, 5)[:, None, None], | ||
| np.linspace(-np.pi / 2.0, np.pi / 2.0, 4)[:, None], | ||
| np.linspace(2456855.5, 2456856.5, 3), | ||
| (5, 4, 3), | ||
| id="broadcasting", | ||
| ), | ||
| ], | ||
| ) | ||
| def test_atco13_shape(ra, dec, jd, shape): | ||
| assert ( | ||
| erfa.atco13( | ||
| ra, dec, 0, 0, 0, 0, jd, 0, 0, 0, np.pi / 4, 0, 0, 0, 1014, 0, 0, 0.5 | ||
| ).aob.shape | ||
| == shape | ||
| ) | ||
|
|
||
|
|
||
| jd = np.linspace(2456855.5, 2456855.5+1.0/24.0/60.0, 60*2+1) | ||
| ra = np.linspace(0.0, np.pi*2.0, 5) | ||
| dec = np.linspace(-np.pi/2.0, np.pi/2.0, 4) | ||
|
|
||
| aob, zob, hob, dob, rob, eo = erfa.atco13( | ||
| 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, jd, | ||
| 0.0, 0.0, 0.0, np.pi/4.0, 0.0, 0.0, 0.0, 1014.0, 0.0, 0.0, 0.5) | ||
| assert aob.shape == (121,) | ||
|
|
||
| aob, zob, hob, dob, rob, eo = erfa.atco13( | ||
| 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, jd[0], | ||
| 0.0, 0.0, 0.0, np.pi/4.0, 0.0, 0.0, 0.0, 1014.0, 0.0, 0.0, 0.5) | ||
| assert aob.shape == () | ||
|
|
||
| aob, zob, hob, dob, rob, eo = erfa.atco13( | ||
| ra[:, None, None], dec[None, :, None], 0.0, 0.0, 0.0, 0.0, jd[None, None, :], | ||
| 0.0, 0.0, 0.0, np.pi/4.0, 0.0, 0.0, 0.0, 1014.0, 0.0, 0.0, 0.5) | ||
| (aob.shape) == (5, 4, 121) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no |
||
|
|
||
| iy, im, id, ihmsf = erfa.d2dtf("UTC", 3, jd, 0.0) | ||
| assert iy.shape == (121,) | ||
| assert ihmsf.shape == (121,) | ||
| assert ihmsf.dtype == erfa.dt_hmsf | ||
|
|
||
| iy, im, id, ihmsf = erfa.d2dtf("UTC", 3, jd[0], 0.0) | ||
| assert iy.shape == () | ||
| assert ihmsf.shape == () | ||
| assert ihmsf.dtype == erfa.dt_hmsf | ||
| @pytest.mark.parametrize( | ||
| ("jd", "shape"), | ||
| [ | ||
| pytest.param(2456855.5, (), id="scalar"), | ||
| pytest.param([2456855.5, 2456855.75, 2456856.25], (3,), id="array"), | ||
| ], | ||
| ) | ||
| def test_d2dtf_shape(jd, shape): | ||
| result = erfa.d2dtf("UTC", 3, jd, 0.0) | ||
| assert result.iy.shape == shape | ||
| assert result.ihmsf.shape == shape | ||
| assert result.ihmsf.dtype == erfa.dt_hmsf | ||
|
|
||
|
|
||
| def test_angle_ops(): | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,6 +74,7 @@ extend-select = [ | |
| "PT", | ||
| "PTH", | ||
| "RET", | ||
| "RUF", | ||
| "S101", | ||
| "SIM", | ||
| "UP", | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This does not look like the original one
Do I miss something?
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.
I made the arrays smaller because I didn't see the point in forcing the tests to run with larger arrays, but the tests are still checking that the output shape is correct. I did also change the range of
jdvalues to shorten setup, but that shouldn't matter because with or without my patch the asserts here only care about the shape of the outputs, not about the values within.