Families/ adding base version of exponential family#67
Families/ adding base version of exponential family#67domosedy wants to merge 10 commits intoPySATL:mainfrom
Conversation
779438f to
12516ff
Compare
| @dataclass(frozen=True, slots=True) | ||
| class IntervalND: | ||
| intervals: list[Interval1D] | ||
|
|
||
| def contains(self, x: Number | NumericArray) -> bool | BoolArray: | ||
| if not hasattr(x, "__iter__"): | ||
| x = np.array([x]) | ||
|
|
||
| return all( | ||
| x_coordinate in interval | ||
| for interval, x_coordinate in zip(self.intervals, x, strict=True) | ||
| ) | ||
|
|
||
| def __contains__(self, x: object) -> bool: | ||
| """Check if a single point is in the interval.""" | ||
| return bool(self.contains(cast(Number, x))) |
There was a problem hiding this comment.
Strange implementation of the contains method. If we check whether a point is contained in an N-dimensional interval, then at least we must accept an array of N elements, if we want to check M Points at once, then we must accept an array of M x N. You definitely don't need to implement the magic method __contains__ here
There was a problem hiding this comment.
I think the case when we check M points at once isn't really needed.
__contains__ method is mandatory for in operator
| type ParametrizedFunction = Callable[[Parametrization, Any], Any] | ||
| type SupportArg = Callable[[Parametrization], Support | None] | None | ||
| type NumberParameter = Number | NumericArray |
There was a problem hiding this comment.
Move those types to types.py. SupportArg is already used in parametric_family.py so change there as well. NumberParameter is a bad naming, better smth like ArrayLikeNumeric or
There was a problem hiding this comment.
This type is not ArrayLike it's one of Number or Array. So I really don't know how to name this type
66f7d09 to
f67f3fd
Compare
f67f3fd to
2d470c9
Compare
No description provided.