Skip to content

Commit adb999e

Browse files
fix error-raising docstring
1 parent 4cf96d1 commit adb999e

5 files changed

Lines changed: 15 additions & 14 deletions

File tree

pina/_src/callback/optim/switch_scheduler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def __init__(self, new_schedulers, epoch_switch):
2222
:type new_schedulers: pina.optim.TorchScheduler |
2323
list[pina.optim.TorchScheduler]
2424
:param int epoch_switch: The epoch at which the scheduler switch occurs.
25-
:raise AssertionError: If epoch_switch is less than 1.
26-
:raise ValueError: If each scheduler in ``new_schedulers`` is not an
25+
:raises AssertionError: If epoch_switch is less than 1.
26+
:raises ValueError: If each scheduler in ``new_schedulers`` is not an
2727
instance of :class:`pina.optim.TorchScheduler`.
2828
2929
Example:

pina/_src/model/spline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def basis(self, x, collection=False):
202202
:param torch.Tensor x: The points to be evaluated.
203203
:param bool collection: If True, returns a list of basis functions for
204204
all orders up to the spline order. Default is False.
205-
:raise ValueError: If ``collection`` is not a boolean.
205+
:raises ValueError: If ``collection`` is not a boolean.
206206
:return: The basis functions evaluated at x.
207207
:rtype: torch.Tensor | list[torch.Tensor]
208208
"""
@@ -290,7 +290,7 @@ def derivative(self, x, degree):
290290
:param x: The input tensor.
291291
:type x: torch.Tensor | LabelTensor
292292
:param int degree: The derivative degree to compute.
293-
:raise ValueError: If ``degree`` is not an integer.
293+
:raises ValueError: If ``degree`` is not an integer.
294294
:return: The derivative tensor.
295295
:rtype: torch.Tensor
296296
"""

pina/_src/model/spline_surface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ def derivative(self, x, degree_u, degree_v):
134134
parameter direction.
135135
:param int degree_v: The degree of the derivative along the second
136136
parameter direction.
137-
:raise ValueError: If ``degree_u`` is not an integer.
138-
:raise ValueError: If ``degree_v`` is not an integer.
137+
:raises ValueError: If ``degree_u`` is not an integer.
138+
:raises ValueError: If ``degree_v`` is not an integer.
139139
:return: The derivative tensor.
140140
:rtype: torch.Tensor
141141
"""

pina/_src/model/vectorized_spline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def basis(self, x, collection=False):
293293
:param torch.Tensor x: The points to be evaluated.
294294
:param bool collection: If True, returns a list of basis functions for
295295
all orders up to the spline order. Default is False.
296-
:raise ValueError: If ``collection`` is not a boolean.
296+
:raises ValueError: If ``collection`` is not a boolean.
297297
:raises ValueError: If ``x`` is not two-dimensional.
298298
:raises ValueError: If the number of input features does not match
299299
the number of univariate splines.

pina/_src/solver/autoregressive_solver/autoregressive_solver.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ def __init__(
6666
averages used for adaptive weighting are reset at the start of each
6767
epoch. Setting this parameter to ``False`` can improve training
6868
stability, especially when data are scarce. Default is ``True``.
69-
:raise ValueError: If the provided loss function is not compatible.
70-
:raise ValueError: If ``reset_weights_at_epoch_start`` is not a boolean.
69+
:raises ValueError: If the provided loss function is not compatible.
70+
:raises ValueError: If ``reset_weights_at_epoch_start`` is not a
71+
boolean.
7172
"""
7273
super().__init__(
7374
problem=problem,
@@ -147,7 +148,7 @@ def loss_autoregressive(
147148
:param input: The input tensor containing unroll windows.
148149
:type input: torch.Tensor | LabelTensor
149150
:param dict kwargs: Additional keyword arguments for loss computation.
150-
:raise ValueError: If ``input`` has less than 4 dimensions.
151+
:raises ValueError: If ``input`` has less than 4 dimensions.
151152
:return: The scalar loss value for the given batch.
152153
:rtype: torch.Tensor | LabelTensor
153154
"""
@@ -270,7 +271,7 @@ def predict(self, initial_state, n_steps, **kwargs):
270271
:type initial_state: torch.Tensor | LabelTensor
271272
:param int n_steps: The number of autoregressive steps to predict.
272273
:param dict kwargs: Additional keyword arguments.
273-
:raise ValueError: If the provided initial_state tensor has less than 3
274+
:raises ValueError: If the provided initial_state tensor has less than 3
274275
dimensions.
275276
:return: The predicted trajectory, including the initial state. It has
276277
shape ``[trajectories, n_steps + 1, *features]``, where the first
@@ -320,8 +321,8 @@ def unroll(data, unroll_length, n_unrolls=None, randomize=True):
320321
If ``None``, all valid windows are returned. Default is ``None``.
321322
:param bool randomize: If ``True``, starting indices are randomly
322323
permuted before applying ``n_unrolls``. Default is ``True``.
323-
:raise ValueError: If the input ``data`` has less than 3 dimensions.
324-
:raise ValueError: If ``unroll_length`` is greater or equal to the
324+
:raises ValueError: If the input ``data`` has less than 3 dimensions.
325+
:raises ValueError: If ``unroll_length`` is greater or equal to the
325326
number of time steps in ``data``.
326327
:return: A tensor of unrolled windows.
327328
:rtype: torch.Tensor | LabelTensor
@@ -358,7 +359,7 @@ def _get_start_idx(n_steps, unroll_length, n_unrolls=None, randomize=True):
358359
If ``None``, all valid windows are returned. Default is ``None``.
359360
:param bool randomize: If ``True``, starting indices are randomly
360361
permuted before applying ``n_unrolls``. Default is ``True``.
361-
:raise ValueError: If ``unroll_length`` is greater or equal to the
362+
:raises ValueError: If ``unroll_length`` is greater or equal to the
362363
number of time steps in ``data``.
363364
:return: A tensor of starting indices for unroll windows.
364365
:rtype: torch.Tensor

0 commit comments

Comments
 (0)