Interval#

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

Bases: object

A 1-d integer interval with positive size.

Intervals should generally be constructed by a classmethod factory (e.g. hull or from_size) or the factory slicing 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:
  • start (int) – Inclusive minimum point in the interval.

  • stop (int) – 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(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.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)#

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:

bool | numpy.ndarray

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.

Parameters:

padding (int) – Number of points to add to each side of the interval.

Return type:

Interval

classmethod from_legacy(legacy)#

Convert from an lsst.geom.IntervalI instance.

Parameters:

legacy (Any) – Legacy lsst.geom.IntervalI instance to convert.

Return type:

Interval

classmethod from_size(size, start=0)#

Construct an interval from its size and optional start.

Parameters:
  • size (int) – Number of points in the interval.

  • start (int, default: 0) – Inclusive minimum point in the interval.

Return type:

Interval

classmethod hull(first, *args)#

Construct an interval that includes all of the given points and/or intervals.

Parameters:
  • first (int | Interval) – First point or interval to include in the hull.

  • *args (int | Interval) – Additional points and/or intervals to include in the hull.

Return type:

Interval

intersection(other)#

Return an interval that is contained by both self and other.

When there is no overlap between the intervals, NoOverlapError is raised.

Parameters:

other (Interval) – Interval to intersect with this one.

Return type:

Interval

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 (if step is also not provided) is the size of the interval, i.e. equivalent to the arange property (but converted to float).

  • step (float | None, default: None) – Set n such that the distance between points is equal to or just less than this. Mutually exclusive with n.

Returns:

Array of float values.

Return type:

numpy.ndarray

See also

numpy.linspace

padded(padding)#

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

Parameters:

padding (int) – Number of points to add to each side of the interval.

Return type:

Interval

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.

This assumes other.contains(self).

Parameters:

other (Interval) – Interval whose values correspond to the container being sliced.

Return type:

slice

to_legacy()#

Convert to an lsst.geom.IntervalI instance.

Return type:

Any

This page was last modified on .