Skip to content

Commit 0c65fab

Browse files
committed
Add exceptions to docstrings
1 parent e719090 commit 0c65fab

File tree

1 file changed

+71
-3
lines changed

1 file changed

+71
-3
lines changed

src/astro_image_display_api/interface_definition.py

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ def set_cuts(self, cuts: tuple | BaseInterval, image_label: str | None = None) -
6969
image_label : str, optional
7070
The label of the image to set the cuts for. If not given and there is
7171
only one image loaded, the cuts for that image are set.
72+
73+
Raises
74+
------
75+
TypeError
76+
If the `cuts` parameter is not a tuple or an `astropy.visualization.BaseInterval`
77+
object.
78+
79+
ValueError
80+
If the `image_label` is not provided when there are multiple images loaded,
81+
or if the `image_label` does not correspond to a loaded image.
7282
"""
7383
raise NotImplementedError
7484

@@ -88,6 +98,12 @@ def get_cuts(self, image_label: str | None = None) -> BaseInterval:
8898
-------
8999
cuts : `~astropy.visualization.BaseInterval`
90100
The Astropy interval object representing the current cuts.
101+
102+
Raises
103+
------
104+
ValueError
105+
If the `image_label` is not provided when there are multiple images loaded,
106+
or if the `image_label` does not correspond to a loaded image.
91107
"""
92108
raise NotImplementedError
93109

@@ -105,6 +121,15 @@ def set_stretch(self, stretch: BaseStretch, image_label: str | None = None) -> N
105121
image_label : str, optional
106122
The label of the image to set the cuts for. If not given and there is
107123
only one image loaded, the cuts for that image are set.
124+
125+
Raises
126+
------
127+
TypeError
128+
If the `stretch` is not a valid `BaseStretch` object
129+
130+
ValueError
131+
if the `image_label` is not provided when there are multiple images loaded
132+
or if the `image_label` does not correspond to a loaded image.
108133
"""
109134
raise NotImplementedError
110135

@@ -194,6 +219,11 @@ def save(self, filename: str | os.PathLike, overwrite: bool = False) -> None:
194219
overwrite : bool, optional
195220
If `True`, overwrite the file if it exists. Default is
196221
`False`.
222+
223+
Raises
224+
------
225+
FileExistsError
226+
If the file already exists and `overwrite` is `False`.
197227
"""
198228
raise NotImplementedError
199229

@@ -229,6 +259,13 @@ def load_catalog(self, table: Table, x_colname: str = 'x', y_colname: str = 'y',
229259
A dictionary that specifies the style of the markers used to
230260
represent the catalog. See `ImageViewerInterface.set_catalog_style`
231261
for details.
262+
263+
Raises
264+
------
265+
ValueError
266+
If the `table` does not contain the required columns, or if
267+
the `catalog_label` is not provided when there are multiple
268+
catalogs loaded.
232269
"""
233270
raise NotImplementedError
234271

@@ -262,6 +299,13 @@ def set_catalog_style(
262299
-----
263300
The following shapes are supported: "circle", "square", "crosshair", "plus",
264301
"diamond".
302+
303+
Raises
304+
------
305+
ValueError
306+
If there are multiple catalog styles set and the user has not
307+
specified a `catalog_label` for which to set the style, or if
308+
an style is set for a catalog that does not exist.
265309
"""
266310
raise NotImplementedError
267311

@@ -270,6 +314,15 @@ def get_catalog_style(self, catalog_label: str | None = None) -> dict:
270314
"""
271315
Get the style of the catalog markers.
272316
317+
Parameters
318+
----------
319+
catalog_label : str, optional
320+
The name of the catalog. If not given and there is
321+
only one catalog loaded, the style for that catalog is returned.
322+
If there are multiple catalogs and no label is provided, an error
323+
is raised. If the label is not does not correspond to a loaded
324+
catalog, an empty dictionary is returned.
325+
273326
Returns
274327
-------
275328
dict
@@ -281,6 +334,7 @@ def get_catalog_style(self, catalog_label: str | None = None) -> dict:
281334
ValueError
282335
If there are multiple catalog styles set and the user has not
283336
specified a `catalog_label` for which to get the style.
337+
284338
"""
285339
raise NotImplementedError
286340

@@ -292,8 +346,16 @@ def remove_catalog(self, catalog_label: str | list[str] | None = None) -> None:
292346
Parameters
293347
----------
294348
catalog_label : str, optional
295-
The name of the marker set to remove. If the value is ``"all"``,
296-
then all markers will be removed.
349+
The name of the catalog to remove. The value ``'*'`` can be used to
350+
remove all catalogs. If not given and there is
351+
only one catalog loaded, that catalog is removed.
352+
353+
Raises
354+
------
355+
ValueError
356+
If the `catalog_label` is not provided when there are multiple
357+
catalogs loaded, or if the `catalog_label` does not correspond to a
358+
loaded catalog.
297359
"""
298360
raise NotImplementedError
299361

@@ -324,6 +386,11 @@ def get_catalog(self, x_colname: str = 'x', y_colname: str = 'y',
324386
table : `astropy.table.Table`
325387
The table containing the marker positions. If no markers match the
326388
``catalog_label`` parameter, an empty table is returned.
389+
390+
Raises
391+
------
392+
ValueError
393+
If the `catalog_label` is not provided when there are multiple catalogs loaded.
327394
"""
328395
raise NotImplementedError
329396

@@ -408,6 +475,7 @@ def get_viewport(self, sky_or_pixel: str | None = None, image_label: str | None
408475
-------
409476
ValueError
410477
If the `sky_or_pixel` parameter is not one of 'sky', 'pixel', or `None`, or if
411-
the `image_label` is not provided when there are multiple images loaded.
478+
the `image_label` is not provided when there are multiple images loaded, or if
479+
the `image_label` does not correspond to a loaded image.
412480
"""
413481
raise NotImplementedError

0 commit comments

Comments
 (0)