Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions photutils/aperture/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@

import astropy.units as u
import numpy as np
from astropy.utils import minversion

__all__ = ['ApertureMask']

COPY_IF_NEEDED = False if not minversion(np, '2.0') else None


class ApertureMask:
"""
Expand All @@ -39,7 +36,7 @@ def __init__(self, data, bbox):
self.bbox = bbox
self._mask = (self.data == 0)

def __array__(self, dtype=None, copy=COPY_IF_NEEDED):
def __array__(self, dtype=None, copy=None):
"""
Array representation of the mask data array (e.g., for
matplotlib).
Expand Down
5 changes: 1 addition & 4 deletions photutils/aperture/tests/test_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@
import astropy.units as u
import numpy as np
import pytest
from astropy.utils import minversion
from numpy.testing import assert_allclose, assert_almost_equal

from photutils.aperture.bounding_box import BoundingBox
from photutils.aperture.circle import CircularAnnulus, CircularAperture
from photutils.aperture.mask import ApertureMask
from photutils.aperture.rectangle import RectangularAnnulus

NUMPY_LT_2_0 = not minversion(np, '2.0')
COPY_IF_NEEDED = False if NUMPY_LT_2_0 else None
POSITIONS = [(-20, -20), (-20, 20), (20, -20), (60, 60)]


Expand Down Expand Up @@ -51,7 +48,7 @@ def test_mask_copy():
# no copy; copy=None returns a copy only if __array__ returns a copy
# copy=None was introduced in NumPy 2.0
mask = ApertureMask(np.ones((10, 10)), bbox)
mask_copy = np.array(mask, copy=COPY_IF_NEEDED)
mask_copy = np.array(mask, copy=None)
mask_copy[0, 0] = 100.0
assert mask.data[0, 0] == 100.0

Expand Down
14 changes: 2 additions & 12 deletions photutils/psf/model_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
Define tools to plot Gridded PSF models.
"""

import astropy
import numpy as np
from astropy.utils import minversion
from astropy.visualization import simple_norm

__all__ = []
Expand Down Expand Up @@ -142,21 +140,13 @@ def plot_grid(self, *, ax=None, vmax_scale=None, peak_norm=False,
vmax_scale = 0.03
vmax = data.max() * vmax_scale
vmin = -vmax
if minversion(astropy, '6.1'):
norm = simple_norm(data, 'linear', vmin=vmin, vmax=vmax)
else:
norm = simple_norm(data, 'linear', min_cut=vmin, max_cut=vmax)
norm = simple_norm(data, 'linear', vmin=vmin, vmax=vmax)
else:
if vmax_scale is None:
vmax_scale = 1.0
vmax = data.max() * vmax_scale
vmin = vmax / 1.0e4
if minversion(astropy, '6.1'):
norm = simple_norm(data, 'log', vmin=vmin, vmax=vmax,
log_a=1.0e4)
else:
norm = simple_norm(data, 'log', min_cut=vmin, max_cut=vmax,
log_a=1.0e4)
norm = simple_norm(data, 'log', vmin=vmin, vmax=vmax, log_a=1.0e4)

# Set up the coordinate axes to later set tick labels based on
# detector ePSF coordinates. This sets up axes to have, behind the
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ exclude = [

# GL08: docstrings defined by a decorator
'\.plot_grid$',
'PSFPhotometry\.make_model_image$',
'PSFPhotometry\.make_residual_image$',
'IterativePSFPhotometry\.make_model_image$',
'IterativePSFPhotometry\.make_residual_image$',

# GL08: docstrings inherited from base classes
'\.to_mask$',
Expand Down