Skip to content

Commit 7ffe43e

Browse files
authored
Merge pull request #295 from jhlegarreta/sty/allow-fit-predict-return-none
STY: Allow `fit_predict` to return `None`
2 parents 8a38940 + 24fc664 commit 7ffe43e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/nifreeze/model/base.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"""Base infrastructure for nifreeze's models."""
2424

2525
from abc import ABC, ABCMeta, abstractmethod
26-
from typing import Union
2726
from warnings import warn
2827

2928
import numpy as np
@@ -104,7 +103,7 @@ def __init__(self, dataset, **kwargs):
104103
warn(mask_absence_warn_msg, stacklevel=2)
105104

106105
@abstractmethod
107-
def fit_predict(self, index: int | None = None, **kwargs) -> Union[np.ndarray, None]:
106+
def fit_predict(self, index: int | None = None, **kwargs) -> np.ndarray | None:
108107
"""
109108
Fit and predict the indicated index of the dataset (abstract signature).
110109
@@ -140,7 +139,7 @@ def __init__(self, dataset, predicted=None, **kwargs):
140139
if self._locked_fit is None:
141140
raise TypeError("This model requires the predicted map at initialization")
142141

143-
def fit_predict(self, *_, **kwargs) -> np.ndarray:
142+
def fit_predict(self, *_, **kwargs) -> np.ndarray | None:
144143
"""Return the reference map."""
145144

146145
# No need to check fit (if not fitted, has raised already)

0 commit comments

Comments
 (0)