SliceableList

class PlasmaCalcs.dimensions.dimension_tools.dimension_value.SliceableList(iterable=(), /)

Bases: list

list that returns a new instance of type(self) when sliced.

Also permits slicing by an iterable (take one element for each index in the iterable).

Methods

__getitem__(ii, **kw_new)

return self[ii], giving element from self if int(ii) possible, else new instance of type(self).

append(object, /)

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count(value, /)

Return number of occurrences of value.

extend(iterable, /)

Extend list by appending elements from the iterable.

index(value[, start, stop])

Return first index of value.

insert(index, object, /)

Insert object before index.

inserted(i, element, **kw_new)

return copy of self but with element inserted at i.

pop([index])

Remove and return item at index (default last).

remove(value, /)

Remove first occurrence of value.

reverse()

Reverse *IN PLACE*.

sort(*[, key, reverse])

Sort the list in ascending order and return None.

_display_contents(f1[, f2, thresh1, thresh2])

return str to display self's contents, probably using f1(element) for each element.

_new(*args, **kw)

return new instance of type(self), with these args and kw.

_repr_simple()

return simple repr for self; includes type, len, and a repr_simple for a few elements.

_short_repr()

return a shorter repr of self; just includes type & len.

Attributes

size

__getitem__(ii, **kw_new)

return self[ii], giving element from self if int(ii) possible, else new instance of type(self).

_display_contents(f1, f2=<class 'str'>, *, thresh1=4, thresh2=UNSET)

return str to display self’s contents, probably using f1(element) for each element.

f1: callable of element -> str
“full-ish” repr for each element. Reasonable to use a detailed repr.
Gets called if only showing a few elements from self,
i.e. if len(self) <= thresh1, or if len(self) > thresh2.
(when len(self) > thresh2, result tells only len(self), self[0], self[1], and self[-1])
f2: callable of element -> str
abbreviated repr for each element. Should return short string.
Gets called if showing a decent number of elements from self,
i.e. if thresh1 < len(self) <= thresh2.
thresh1: int, see above
thresh2: UNSET or int, see above.
If UNSET, use DEFAULTS.DIMENSION_VALUE_LIST_DISPLAY_MAXLEN
(to see repr for all entries in self consider using list(self).)
_new(*args, **kw)

return new instance of type(self), with these args and kw.

_repr_simple()

return simple repr for self; includes type, len, and a repr_simple for a few elements.

if less than 4 elements, just uses repr_simple for the elements (doesn’t include len).
_short_repr()

return a shorter repr of self; just includes type & len.

append(object, /)

Append object to the end of the list.

clear()

Remove all items from list.

copy()

Return a shallow copy of the list.

count(value, /)

Return number of occurrences of value.

extend(iterable, /)

Extend list by appending elements from the iterable.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

insert(index, object, /)

Insert object before index.

inserted(i, element, **kw_new)

return copy of self but with element inserted at i. kwargs passed to new self.__init__.

pop(index=-1, /)

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove(value, /)

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse()

Reverse *IN PLACE*.

sort(*, key=None, reverse=False)

Sort the list in ascending order and return None.

The sort is in-place (i.e. the list itself is modified) and stable (i.e. the

order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them,
ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.