Interval#

final class lsst.images.Interval(start: int, stop: int)#

Bases: object

A 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 int from an interval returns a shifted interval.

Interval implements the necessary hooks to be included directly in a pydantic.BaseModel, even though it is neither a built-in type nor a Pydantic model itself.

Attributes Summary

absolute

A factory for constructing a contained Interval using slice syntax and absolute coordinates.

arange

An array of all the values in the interval (numpy.ndarray).

center

The center of the interval (float).

factory

A factory for creating intervals using slice syntax.

local

A factory for constructing a contained Interval using a slice relative to the start of this one (IntervalSliceFactory).

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 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.IntervalI instance.

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 self and other.

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 slice that corresponds to the values in this interval when the items of the container being sliced correspond to other.

to_legacy()

Convert to an lsst.geom.IntervalI instance.

Attributes Documentation

absolute#

A factory for constructing a contained Interval using 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 Interval using a slice relative to the start of this one (IntervalSliceFactory).

Notes#

This factory interprets slices as “local” coordinates, in which 0 corresponds to self.start. Negative bounds are relative to self.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.ndarray

If 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”.

dilated_by(padding: int) Interval#

Return a new interval padded by the given amount on both sides.

classmethod from_legacy(legacy: Any) Interval#

Convert from an lsst.geom.IntervalI instance.

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 self and other.

When there is no overlap between the intervals, NoOverlapError is 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 step is also not provided) is the size of the interval, i.e. equivalent to the arange property (but converted to float).

step

Set n such that the distance between points is equal to or just less than this. Mutually exclusive with n.

Returns#

numpy.ndarray

Array of float values.

See Also#

numpy.linspace

padded(padding: int) Interval#

Return a new interval expanded by the given padding on either side.

slice_within(other: Interval) slice#

Return the slice that corresponds to the values in this interval when the items of the container being sliced correspond to other.

This assumes other.contains(self).

to_legacy() Any#

Convert to an lsst.geom.IntervalI instance.