Skip to content

Commit

Permalink
Merge pull request #1707 from larrybradley/repr2
Browse files Browse the repository at this point in the history
Do not use ellipsis in make_repr if parameter value is None
  • Loading branch information
larrybradley committed Feb 15, 2024
2 parents 72be037 + fa208a9 commit 1ed6dc1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 4 additions & 2 deletions photutils/background/background_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,12 @@ def __init__(self, data, box_size, *, mask=None, coverage_mask=None,
'bkg_estimator', 'bkgrms_estimator', 'interpolator')

def __repr__(self):
return make_repr(self, self._params, ellipsis=('data',))
ellipsis = ('data', 'mask', 'coverage_mask')
return make_repr(self, self._params, ellipsis=ellipsis)

def __str__(self):
return make_repr(self, self._params, ellipsis=('data',), long=True)
ellipsis = ('data', 'mask', 'coverage_mask')
return make_repr(self, self._params, ellipsis=ellipsis, long=True)

def _validate_array(self, array, name, shape=True):
if name in ('mask', 'coverage_mask') and array is np.ma.nomask:
Expand Down
5 changes: 2 additions & 3 deletions photutils/utils/_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ def make_repr(self, params, ellipsis=(), long=False):

cls_info = []
for param in params:
if param in ellipsis:
value = getattr(self, param)
if param in ellipsis and value is not None:
value = '...'
else:
value = getattr(self, param)
cls_info.append((param, value))

if long:
Expand Down

0 comments on commit 1ed6dc1

Please sign in to comment.