Ebounds

class gdt.core.data_primitives.Ebounds(interval=None)[source]

Bases: Intervals

A primitive class defining a set of energy bounds.

An interval may be accessed by using indices.

Parameters:

interval (EnergyRange, optional) – An interval to initialize with

Attributes Summary

intervals

The list of intervals

num_intervals

The number of intervals

range

The full range spanned by the intervals

Methods Summary

as_list()

Return the intervals as a list of tuples.

contains(value[, inclusive])

Determine if the intervals contains a value.

from_bounds(low_bounds, high_bounds)

Create a new Intervals object from a list of lower and upper bounds.

from_list(interval_list)

Create a new Intervals object from a list of tuples.

high_edges()

Return a list of the high edges.

index(value)

Return the index of the interval that contains the value.

insert(interval)

Insert a new interval

intersection(intervals1, intervals2)

Return a new Intervals object that is the intersection of two existing Intervals objects.

low_edges()

Return a list of the low edges.

merge(intervals1, intervals2)

Return a new Intervals object that is a merge of two existing Intervals objects.

Attributes Documentation

intervals

The list of intervals

Type:

(list)

num_intervals

The number of intervals

Type:

(int)

range

The full range spanned by the intervals

Type:

(float, float)

Methods Documentation

as_list()

Return the intervals as a list of tuples.

Returns:

[(float, float), …]

contains(value, inclusive=True)

Determine if the intervals contains a value.

Parameters:
  • value (float) – The input value to check

  • inclusive (bool, optional) – If True, then includes the edges of the range for the check, otherwise it is edge-exclusive. Default is True.

Returns:

bool – True if the value is in the intervals, False otherwise

classmethod from_bounds(low_bounds, high_bounds)

Create a new Intervals object from a list of lower and upper bounds.

Parameters:
  • low_bounds (list) – The lower bounds of the intervals

  • high_bounds (list) – The upper bounds of the intervals

Returns:

Intervals

classmethod from_list(interval_list)

Create a new Intervals object from a list of tuples.

Parameters:

interval_list ([(float, float), ...]) – A list of interval tuples

Returns:

Intervals

high_edges()

Return a list of the high edges.

Returns:

(list)

index(value)

Return the index of the interval that contains the value.

Note :

If the value is precisely on the boundary of two intervals, the first interval index will be returned.

Parameters:

value (float) – The input value

Returns:

(int)

insert(interval)

Insert a new interval

Parameters:

interval (Range) – The interval to insert

classmethod intersection(intervals1, intervals2)

Return a new Intervals object that is the intersection of two existing Intervals objects.

Parameters:
  • intervals1 (Intervals) – Intervals to be intersected

  • intervals2 (Intervals) – Intervals to be intersected

Returns:

Intervals

low_edges()

Return a list of the low edges.

Returns:

(list)

classmethod merge(intervals1, intervals2)

Return a new Intervals object that is a merge of two existing Intervals objects.

Parameters:
  • intervals1 (Intervals) – Intervals to be merged

  • intervals2 (Intervals) – Intervals to be merged

Returns:

(Intervals)