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

WIP: Ruff #184

Open
wants to merge 17 commits into
base: back-subtract
Choose a base branch
from
Open

WIP: Ruff #184

wants to merge 17 commits into from

Conversation

jeanconn
Copy link
Contributor

@jeanconn jeanconn commented Nov 29, 2024

Description

Ruff

Interface impacts

Testing

Unit tests

  • Mac
(ska3-flight-latest) flame:chandra_aca jean$ git rev-parse HEAD
9aea615ee5f84fd7ceb1106c6f0bc9adaf539a47
(ska3-flight-latest) flame:chandra_aca jean$ pytest
================================================================================== test session starts ===================================================================================
platform darwin -- Python 3.11.8, pytest-8.0.2, pluggy-1.4.0
PyQt5 5.15.9 -- Qt runtime 5.15.8 -- Qt compiled 5.15.8
rootdir: /Users/jean/git
configfile: pytest.ini
plugins: astropy-0.11.0, qt-4.4.0, cov-5.0.0, timeout-2.2.0, remotedata-0.4.1, anyio-4.3.0, filter-subpackage-0.2.0, doctestplus-1.2.1, astropy-header-0.2.2, hypothesis-6.112.0, arraydiff-0.6.1, mock-3.14.0
collected 231 items                                                                                                                                                                      

chandra_aca/tests/test_aca_image.py ...................                                                                                                                            [  8%]
chandra_aca/tests/test_all.py ........................                                                                                                                             [ 18%]
chandra_aca/tests/test_attitude.py .............................................................                                                                                   [ 45%]
chandra_aca/tests/test_dark_model.py ............                                                                                                                                  [ 50%]
chandra_aca/tests/test_dark_subtract.py ........                                                                                                                                   [ 53%]
chandra_aca/tests/test_drift.py ..........................                                                                                                                         [ 64%]
chandra_aca/tests/test_maude_decom.py .........................                                                                                                                    [ 75%]
chandra_aca/tests/test_planets.py ...............                                                                                                                                  [ 82%]
chandra_aca/tests/test_psf.py ...                                                                                                                                                  [ 83%]
chandra_aca/tests/test_residuals.py ss...                                                                                                                                          [ 85%]
chandra_aca/tests/test_star_probs.py .................................                                                                                                             [100%]

==================================================================================== warnings summary ====================================================================================
chandra_aca/chandra_aca/tests/test_residuals.py::test_obc
  /Users/jean/miniforge3/envs/ska3-flight-latest/lib/python3.11/site-packages/django/utils/encoding.py:266: DeprecationWarning: 'locale.getdefaultlocale' is deprecated and slated for removal in Python 3.15. Use setlocale(), getencoding() and getlocale() instead.
    encoding = locale.getdefaultlocale()[1] or 'ascii'

chandra_aca/chandra_aca/tests/test_residuals.py::test_obc
  /Users/jean/miniforge3/envs/ska3-flight-latest/lib/python3.11/site-packages/django/http/request.py:1: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13
    import cgi

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================= 229 passed, 2 skipped, 2 warnings in 66.54s (0:01:06)

Independent check of unit tests by [REVIEWER NAME]

  • [PLATFORM]:

Functional tests

No functional testing.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 15 out of 30 changed files in this pull request and generated no suggestions.

Files not reviewed (15)
  • .github/workflows/black.yml: Language not supported
  • .github/workflows/flake8.yml: Language not supported
  • chandra_aca/centroid_resid.py: Evaluated as low risk
  • chandra_aca/darkbins.py: Evaluated as low risk
  • chandra_aca/dark_model.py: Evaluated as low risk
  • chandra_aca/attitude.py: Evaluated as low risk
  • chandra_aca/tests/test_attitude.py: Evaluated as low risk
  • chandra_aca/drift.py: Evaluated as low risk
  • chandra_aca/aca_image.py: Evaluated as low risk
  • chandra_aca/tests/test_aca_image.py: Evaluated as low risk
  • chandra_aca/tests/test_all.py: Evaluated as low risk
  • chandra_aca/plot.py: Evaluated as low risk
  • chandra_aca/planets.py: Evaluated as low risk
  • chandra_aca/tests/test_dark_model.py: Evaluated as low risk
  • chandra_aca/star_probs.py: Evaluated as low risk
Copy link
Member

@taldcroft taldcroft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good, thanks!

frames and not blobs
), "Specify only one of 'frames' or blobs"
# check that only one of blobs or frames is set
if blobs and frames:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not logically equivalent to the original.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@@ -340,7 +341,7 @@ def plot_stars(
r, c = yagzag_to_pixels(zeros, yz_ticks)
ax.set_yticks(c)
ax.set_yticklabels(yz_ticks)
ax.grid()
ax.grid(grid)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woohoo, caught a bug!

@@ -1022,22 +1053,22 @@ def guide_count(mags, t_ccd, count_9th=False):
ref_t_ccd = -10.9
ref_mags0 = (9.0 if count_9th else 9.95) + np.array([0.0, 0.2, 0.3, 0.4])
ref_mags = {}
for t_ccd in np.unique(t_ccds):
for t in np.unique(t_ccds):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid single-letter variable names. Instead you could use t_ccd_.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I used t_ccd_local in the other spot.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case t_ccd_unique would work and be meaningful.

@@ -423,7 +422,7 @@ def test_aca_image_operators():
def test_flicker_numba():
a = ACAImage(np.linspace(0, 800, 9).reshape(3, 3))
a.flicker_init(flicker_mean_time=1000, flicker_scale=1.5, seed=10)
for ii in range(10):
for _ii in range(10):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ is the preferred variable for an unused loop parameter. You don't need to bother changing this in test code but keep it in mind for the future.

Copy link
Contributor Author

@jeanconn jeanconn Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was the VS code preference to make underscore named throw-away vars - I assume so that they could actually be accessed in test failure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ behaves like any other variable to Python and pytest. It is just humans and linters that give it a special meaning.

@jeanconn
Copy link
Contributor Author

PS I hadn't asked for review yet until #174 is reviewed and merged.

@taldcroft
Copy link
Member

PS I hadn't asked for review yet until #174 is reviewed and merged.

Oops, I guess I just got excited. And ruff review is about where I'm at today.

@jeanconn jeanconn changed the title Ruff WIP: Ruff Nov 29, 2024
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

Successfully merging this pull request may close these issues.

2 participants