Skip to content

Requre photutils 3+#10471

Open
larrybradley wants to merge 6 commits into
spacetelescope:mainfrom
larrybradley:photutils-future
Open

Requre photutils 3+#10471
larrybradley wants to merge 6 commits into
spacetelescope:mainfrom
larrybradley:photutils-future

Conversation

@larrybradley
Copy link
Copy Markdown
Member

@larrybradley larrybradley commented Apr 20, 2026

Resolves JP-nnnn

This PR uses a context manager for locally-scoped changes instead of relying on or potentially mutating a global photutils variable.

CC: @braingram

Tasks

  • If you have a specific reviewer in mind, tag them.
  • add a build milestone, i.e. Build 12.0 (use the latest build if not sure)
  • Does this PR change user-facing code / API? (if not, label with no-changelog-entry-needed)
    • write news fragment(s) in changes/: echo "changed something" > changes/<PR#>.<changetype>.rst (see changelog readme for instructions)
      • if your change breaks step-level or public API (as defined in the docs), also add a changes/<PR#>.breaking.rst news fragment
    • update or add relevant tests
    • update relevant docstrings and / or docs/ page
    • start a regression test and include a link to the running job (click here for instructions)
      • Do truth files need to be updated ("okified")?
        • after the reviewer has approved these changes, run okify_regtests to update the truth files
  • if a JIRA ticket exists, make sure it is resolved properly

@larrybradley larrybradley requested a review from a team April 20, 2026 19:10
@braingram
Copy link
Copy Markdown
Collaborator

Thanks! @tapastro mentioned bumping the pin to >=3. Since it's now out, would that be easier (perhaps using the same approach as you added in romancal)?

@larrybradley
Copy link
Copy Markdown
Member Author

Sure, I can do that. I wasn't sure if jwst was ready for that (romancal needs photutils 3+). I'll update this PR.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.44%. Comparing base (4c7ca23) to head (9704d47).

Files with missing lines Patch % Lines
jwst/extract_1d/ifu.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10471      +/-   ##
==========================================
+ Coverage   86.38%   86.44%   +0.05%     
==========================================
  Files         373      373              
  Lines       40095    40033      -62     
==========================================
- Hits        34638    34608      -30     
+ Misses       5457     5425      -32     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@larrybradley larrybradley changed the title Use context manager instead of global variable for photutils 3+ Requre photutils 3+ Apr 20, 2026
@larrybradley
Copy link
Copy Markdown
Member Author

I also bumped numpy >= 2.0 and astropy >= 6.1.4. Those are required for photutils >= 3.0.

@larrybradley
Copy link
Copy Markdown
Member Author

@larrybradley
Copy link
Copy Markdown
Member Author

The oldestdeps CI failures are unrelated -- due to PyparsingDeprecationWarning and ValueError: numpy.dtype size changed.

@melanieclarke melanieclarke added this to the Build 13.0 milestone Apr 22, 2026
@melanieclarke
Copy link
Copy Markdown
Collaborator

It looks like there are some significant differences in the regression tests, for the MIRI and NIRCam image3 results, looks like because the source catalog found some extra sources in both cases. Is that expected with the changes here?

Also, we'll need to update the oldest dependencies allowed to get the oldestdeps tests passing.

@larrybradley
Copy link
Copy Markdown
Member Author

Thanks, @melanieclarke . I updated the min versions of packaging and scikit-image and now the oldestdeps tests pass.

For the regression tests, it appears that the FGS, MIRI, and NIRCam i2d images have differences, which could lead to a slightly different number of sources in the downstream catalogs. Are the differences in the i2d images expected from other recent pipeline changes or dependency updates? For example, there are many differences in the MIRI image (https://github.com/spacetelescope/RegressionTests/actions/runs/24690043180/job/72209316131#step:42:1371), including the WCS (https://github.com/spacetelescope/RegressionTests/actions/runs/24690043180/job/72209316131#step:42:1270).

@melanieclarke
Copy link
Copy Markdown
Collaborator

Thanks, @melanieclarke . I updated the min versions of packaging and scikit-image and now the oldestdeps tests pass.

Thank you!

For the regression tests, it appears that the FGS, MIRI, and NIRCam i2d images have differences, which could lead to a slightly different number of sources in the downstream catalogs. Are the differences in the i2d images expected from other recent pipeline changes or dependency updates? For example, there are many differences in the MIRI image (https://github.com/spacetelescope/RegressionTests/actions/runs/24690043180/job/72209316131#step:42:1371), including the WCS (https://github.com/spacetelescope/RegressionTests/actions/runs/24690043180/job/72209316131#step:42:1270).

Our regression tests are clean with current dependencies, so it's not likely other pipeline changes. I expect a few pixels different from upgrading numpy and scipy, but nothing on the scale of the differences for the regtests on the branch here.

I think the i2d differences are because the tweakreg solution is slightly different in the image3 run, so all the pixels are shifted a little compared to the regtest truth files. So, not directly because of the source catalog differences (sorry I misspoke!), but presumably because the sources chosen in tweakreg are a little different with the changes here.

@larrybradley
Copy link
Copy Markdown
Member Author

Thanks. I'll need to investigate the tweakreg differences.

Copy link
Copy Markdown
Collaborator

@emolter emolter left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for handling this! I had just a few small comments.

Comment on lines +68 to +69
if isinstance(ellipticity, u.Quantity):
ellipticity = ellipticity.value
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why is an if...else necessary here? Shouldn't it always be one or the other, a Quantity or not?

JWSTSourceCatalog.convert_mjysr_to_jy(output_model)

min_separation = (
max(2, int(self.minsep_fwhm * self.kernel_fwhm + 0.5)) if self.minsep_fwhm else None
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Won't self.minsep_fwhm always be set as an attribute since it's in the spec, so there's no need for the None setting if undefined?

Comment on lines 24 to 26
# The tweakreg catalog output always uses 'xcentroid'/'ycentroid',
# but _rename_catalog_columns and user-supplied catalogs may use
# either the old or new photutils column names.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this comment still relevant?

def _find_sources(self, image_model):
# preserve original behavior
min_separation = (
max(2, int(self.minsep_fwhm * self.kernel_fwhm + 0.5)) if self.minsep_fwhm else None
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same here as for source catalog

Comment thread pyproject.toml
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants