Skip to content

Commit

Permalink
docstring and type-checks for set_lims
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Nov 13, 2023
1 parent 861661d commit 5f8a005
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions jdaviz/configs/default/plugins/viewers.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ def user_api(self):
return ViewerUserApi(self, expose=expose)

def set_lims(self, x_min=None, x_max=None, y_min=None, y_max=None):
"""
Set viewer axes limits.
Parameters
----------
x_min : float or None, optional
lower-limit of x-axis (in current axes units)
x_max: float or None, optional
upper-limit of x-axis (in current axes units)
y_min : float or None, optional
lower-limit of y-axis (in current axes units)
y_max: float or None, optional
upper-limit of y-axis (in current axes units)
"""
for val in (x_min, x_max, y_min, y_max):
if val is not None and not isinstance(val, (float, int)):
raise TypeError('all arguments must be None, int, or float')

with delay_callback(self.state, 'x_min', 'x_max', 'y_min', 'y_max'):
if x_min is not None:
self.state.x_min = x_min
Expand Down

0 comments on commit 5f8a005

Please sign in to comment.