Interval#
- final class lsst.images.Interval(start, stop)#
Bases:
objectA 1-d integer interval with positive size.
Intervals should generally be constructed by a classmethod factory (e.g.
hullorfrom_size) or thefactoryslicing proxy:interval = Interval.factory[a:b]
This can be more verbose than invoking __init__ directly, but since it uses Python’s syntax for half-inclusive ranges it’s easier for readers to immediately see how the endpoints are interpreted.
- Parameters:
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(other)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.
-
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.
- range#
An iterable over all values in the interval (
__builtins__.range).
Methods Documentation
- contains(other)#
Test whether this interval fully contains another or one or more points.
- Parameters:
other (
Interval|int|float|TypeAliasType) – Another interval to compare to, or one or more position values as a scalar or any array-like.- Returns:
If a single interval or value was passed, a single
bool. If an array-like was passed, an array with the broadcasted shape.- Return type:
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”.
- dilated_by(padding)#
Return a new interval padded by the given amount on both sides.
- classmethod from_legacy(legacy)#
Convert from an
lsst.geom.IntervalIinstance.- Parameters:
legacy (
Any) – Legacylsst.geom.IntervalIinstance to convert.- Return type:
- classmethod from_size(size, start=0)#
Construct an interval from its size and optional start.
- classmethod 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.When there is no overlap between the intervals,
NoOverlapErroris raised.
- linspace(n=None, *, step=None)#
Return an array of values that spans the interval.
- Parameters:
n (
int|None, default:None) – How many values to return. The default (ifstepis also not provided) is the size of the interval, i.e. equivalent to thearangeproperty (but converted tofloat).step (
float|None, default:None) – Setnsuch that the distance between points is equal to or just less than this. Mutually exclusive withn.
- Returns:
Array of
floatvalues.- Return type:
See also
- 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.This assumes
other.contains(self).
- to_legacy()#
Convert to an
lsst.geom.IntervalIinstance.- Return type: