@@ -55,7 +55,9 @@ class PositiveSequenceError(ValidationError):
5555 """Raised when a sequence contains non-positive elements."""
5656
5757 def __init__ (self , name : str , seq : Sequence [Any ]) -> None :
58- super ().__init__ (f"All elements in '{ name } ' must be greater than 0; got { seq !r} " )
58+ super ().__init__ (
59+ f"All elements in '{ name } ' must be greater than 0; got { seq !r} "
60+ )
5961
6062
6163class ListOfListsError (ValidationError ):
@@ -69,9 +71,7 @@ class ParameterError(ValidationError):
6971 """Raised when a parameter falls outside its allowed range."""
7072
7173 def __init__ (self , name : str , value : Any , constraint : str ) -> None :
72- super ().__init__ (
73- f"Invalid value for '{ name } ': { value !r} . { constraint } "
74- )
74+ super ().__init__ (f"Invalid value for '{ name } ': { value !r} . { constraint } " )
7575
7676
7777_ALLOWED_CENSORING = {"uniform" , "exponential" }
@@ -108,16 +108,19 @@ def _to_float_array(seq: Sequence[Any], name: str) -> NDArray[np.float64]:
108108 except (TypeError , ValueError ) as exc :
109109 raise NumericSequenceError (name , seq ) from exc
110110
111+
111112def ensure_numeric_sequence (seq : Sequence [Any ], name : str ) -> None :
112113 """Ensure all elements of ``seq`` are numeric."""
113114 _to_float_array (seq , name )
114115
116+
115117def ensure_positive_sequence (seq : Sequence [float ], name : str ) -> None :
116118 """Ensure all elements of ``seq`` are positive."""
117119 arr = _to_float_array (seq , name )
118120 if np .any (arr <= 0 ):
119121 raise PositiveSequenceError (name , seq )
120122
123+
121124def ensure_censoring_model (model_cens : str ) -> None :
122125 """Validate that the censoring model is supported."""
123126 ensure_in_choices (model_cens , "model_cens" , _ALLOWED_CENSORING )
0 commit comments