Interval#
- final class lsst.images.Interval(start: int, stop: int)#
Bases:
objectA 1-d integer interval with positive size.
Parameters#
- start
Inclusive minimum point in the interval.
- stop
One past the maximum point in the interval.
Notes#
Adding or subtracting an
intfrom an interval returns a shifted interval.Intervalimplements the necessary hooks to be included directly in apydantic.BaseModel, even though it is neither a built-in type nor a Pydantic model itself.Attributes Summary
A factory for constructing a contained
Intervalusing slice syntax and absolute coordinates.An array of all the values in the interval (
numpy.ndarray).The center of the interval (
float).A factory for creating intervals using slice syntax.
A factory for constructing a contained
Intervalusing a slice relative to the start of this one (IntervalSliceFactory).Inclusive maximum point in the interval (
int).Inclusive minimum point in the interval (
int).An iterable over all values in the interval (
__builtins__.range).Size of the interval (
int).Inclusive minimum point in the interval (
int).One past the maximum point in the interval (
int).Methods Summary
contains()Test whether this interval fully contains another or one or more points.
dilated_by(padding)Return a new interval padded by the given amount on both sides.
from_legacy(legacy)Convert from an
lsst.geom.IntervalIinstance.from_size(size[, start])Construct an interval from its size and optional start.
hull(first, *args)Construct an interval that includes all of the given points and/or intervals.
intersection(other)Return an interval that is contained by both
selfandother.linspace([n, step])Return an array of values that spans the interval.
padded(padding)Return a new interval expanded by the given padding on either side.
slice_within(other)Return the
slicethat corresponds to the values in this interval when the items of the container being sliced correspond toother.Convert to an
lsst.geom.IntervalIinstance.Attributes Documentation
- absolute#
A factory for constructing a contained
Intervalusing slice syntax and absolute coordinates.Notes#
Slice bounds that are absent are replaced with the bounds of
self.
- arange#
An array of all the values in the interval (
numpy.ndarray).Array values are integers.
- center#
The center of the interval (
float).
- factory: ClassVar[IntervalSliceFactory] = <lsst.images._geom.IntervalSliceFactory object>#
A factory for creating intervals using slice syntax.
For example:
interval = Interval.factory[2:5]
- local#
A factory for constructing a contained
Intervalusing a slice relative to the start of this one (IntervalSliceFactory).Notes#
This factory interprets slices as “local” coordinates, in which
0corresponds toself.start. Negative bounds are relative toself.stop, as is usually the case for Python sequences.
- max#
Inclusive maximum point in the interval (
int).
- min#
Inclusive minimum point in the interval (
int).
- range#
An iterable over all values in the interval (
__builtins__.range).
- size#
Size of the interval (
int).
- start#
Inclusive minimum point in the interval (
int).
- stop#
One past the maximum point in the interval (
int).
Methods Documentation
- contains(other: Interval | int | float) bool#
- contains(other: ndarray) ndarray
Test whether this interval fully contains another or one or more points.
Parameters#
- other
Another interval to compare to, or one or more position values.
Returns#
bool|numpy.ndarrayIf a single interval or value was passed, a single
bool. If an array was passed, an array with the same shape.
Notes#
In order to yield the desired behavior for floating-point arguments, points are actually tested against an interval that is 0.5 larger on both sides: this makes positions within the outer boundary of pixels (but beyond the centers of those pixels, which have integer positions) appear “on the image”.
- classmethod from_legacy(legacy: Any) Interval#
Convert from an
lsst.geom.IntervalIinstance.
- classmethod from_size(size: int, start: int = 0) Interval#
Construct an interval from its size and optional start.
- classmethod hull(first: int | Interval, *args: int | Interval) Interval#
Construct an interval that includes all of the given points and/or intervals.
- intersection(other: Interval) Interval#
Return an interval that is contained by both
selfandother.When there is no overlap between the intervals,
NoOverlapErroris raised.
- linspace(n: int | None = None, *, step: float | None = None) ndarray#
Return an array of values that spans the interval.
Parameters#
- n
How many values to return. The default (if
stepis also not provided) is the size of the interval, i.e. equivalent to thearangeproperty (but converted tofloat).- step
Set
nsuch that the distance between points is equal to or just less than this. Mutually exclusive withn.
Returns#
- numpy.ndarray
Array of
floatvalues.
See Also#
numpy.linspace
- slice_within(other: Interval) slice#
Return the
slicethat corresponds to the values in this interval when the items of the container being sliced correspond toother.This assumes
other.contains(self).
- to_legacy() Any#
Convert to an
lsst.geom.IntervalIinstance.