lonboard.traits¶
lonboard.traits ¶
New traits for our custom serialization.
Refer to traitlets.readthedocs.io/en/stable/defining_traits.html for documentation on how to define new traitlet types.
A5Accessor ¶
Bases: FixedErrorTraitType
A trait to validate A5 cell input.
Various input is allowed:
- A numpy
ndarraywith an object, S16, or uint64 data type. - A pandas
Serieswith an object or uint64 data type. - A pyarrow string, large string, string view array, or uint64 array, or a chunked array of those types.
- Any Arrow string, large string, string view array, or uint64 array, or a chunked array of those types from a library that implements the Arrow PyCapsule Interface.
ArrowTableTrait ¶
Bases: FixedErrorTraitType
A trait to validate input for a geospatial Arrow-backed table.
Allowed input includes:
- A pyarrow
Tableor containing a geometry column with GeoArrow metadata. - Any GeoArrow table from a library that implements the Arrow PyCapsule Interface.
ColorAccessor ¶
Bases: FixedErrorTraitType
A trait to validate input for a deck.gl color accessor.
Various input is allowed:
- A
listortuplewith three or four integers, ranging between 0 and 255 (inclusive). This will be used as the color for all objects. - A
strrepresenting a hex color or "well known" color interpretable by matplotlib.colors.to_rgba. See also matplotlib's list of named colors. - A numpy
ndarraywith two dimensions and data typenp.uint8. The size of the second dimension must be3or4, and will correspond to either RGB or RGBA colors. - A pyarrow
FixedSizeListArrayorChunkedArraycontainingFixedSizeListArrays. The inner size of the fixed size list must be3or4and its child must have typeuint8. - Any Arrow fixed size list array from a library that implements the Arrow PyCapsule Interface.
You can use helpers in the lonboard.colormap module (i.e.
apply_continuous_cmap) to simplify
constructing numpy arrays for color values.
DashArrayAccessor ¶
Bases: FixedErrorTraitType
A trait to validate input for a deck.gl dash accessor.
Primarily used in
PathStyleExtension.
Various input is allowed:
- A
listortuplewith 2 integers. This defines the dash size and gap size respectively. - A numpy
ndarraywith two dimensions and numeric data type. The size of the second dimension must be2. - A pyarrow
FixedSizeListArrayorChunkedArraycontainingFixedSizeListArrays. The inner size of the fixed size list must be2. - Any Arrow fixed size list array from a library that implements the Arrow PyCapsule Interface.
FilterCategoryAccessor ¶
Bases: FixedErrorTraitType
Validate input for get_filter_category.
A trait to validate input for the get_filter_category accessor added by the
DataFilterExtension, which can
have between 1 and 4 values per row.
Various input is allowed:
- An
intorfloat. This will be used as the value for all objects. Thecategory_sizeof theDataFilterExtensioninstance must be 1. - A one-dimensional numpy
ndarraywith a numeric data type. Each value in the array will be used as the value for the object at the same row index. Thecategory_sizeof theDataFilterExtensioninstance must be 1. - A two-dimensional numpy
ndarraywith a numeric data type. Each value in the array will be used as the value for the object at the same row index. Thecategory_sizeof theDataFilterExtensioninstance must match the size of the second dimension of the array. - A pandas
Serieswith a numeric data type. Each value in the array will be used as the value for the object at the same row index. Thecategory_sizeof theDataFilterExtensioninstance must be 1. - A pyarrow
FloatArray,DoubleArrayorChunkedArraycontaining either aFloatArrayorDoubleArray. Each value in the array will be used as the value for the object at the same row index. Thecategory_sizeof theDataFilterExtensioninstance must be 1.
Alternatively, you can pass any corresponding Arrow data structure from a library
that implements the Arrow PyCapsule
Interface.
- A pyarrow FixedSizeListArray or
ChunkedArray containing FixedSizeListArrays. The category_size of
the DataFilterExtension instance
must match the list size.
Alternatively, you can pass any corresponding Arrow data structure from a library that implements the Arrow PyCapsule Interface.
FilterValueAccessor ¶
Bases: FixedErrorTraitType
Validate input for get_filter_value.
A trait to validate input for the get_filter_value accessor added by the
DataFilterExtension, which can
have between 1 and 4 float values per row.
Various input is allowed:
- An
intorfloat. This will be used as the value for all objects. Thefilter_sizeof theDataFilterExtensioninstance must be 1. - A one-dimensional numpy
ndarraywith a numeric data type. This will be casted to an array of data typenp.float32. Each value in the array will be used as the value for the object at the same row index. Thefilter_sizeof theDataFilterExtensioninstance must be 1. - A two-dimensional numpy
ndarraywith a numeric data type. This will be casted to an array of data typenp.float32. Each value in the array will be used as the value for the object at the same row index. Thefilter_sizeof theDataFilterExtensioninstance must match the size of the second dimension of the array. - A pandas
Serieswith a numeric data type. This will be casted to an array of data typenp.float32. Each value in the array will be used as the value for the object at the same row index. Thefilter_sizeof theDataFilterExtensioninstance must be 1. - A pyarrow
FloatArray,DoubleArrayorChunkedArraycontaining either aFloatArrayorDoubleArray. Each value in the array will be used as the value for the object at the same row index. Thefilter_sizeof theDataFilterExtensioninstance must be 1.
Alternatively, you can pass any corresponding Arrow data structure from a library
that implements the Arrow PyCapsule
Interface.
- A pyarrow FixedSizeListArray or
ChunkedArray containing FixedSizeListArrays. The child
array of the fixed size list must be of floating point type. The filter_size of
the DataFilterExtension instance
must match the list size.
Alternatively, you can pass any corresponding Arrow data structure from a library that implements the Arrow PyCapsule Interface.
FixedErrorTraitType ¶
Bases: TraitType
A custom subclass of traitlets.TraitType.
This is because its error method ignores the info passed in. See
#71 and
ipython/traitlets!884.
error ¶
error(
obj: HasTraits | None,
value: Any,
error: Exception | None = None,
info: str | None = None,
) -> NoReturn
Raise a TraitError.
Parameters¶
obj : HasTraits or None
The instance which owns the trait. If not
object is given, then an object agnostic
error will be raised.
value : any
The value that caused the error.
error : Exception (default: None)
An error that was raised by a child trait.
The arguments of this exception should be
of the form (value, info, *traits).
Where the value and info are the
problem value, and string describing the
expected value. The traits are a series
of :class:TraitType instances that are
"children" of this one (the first being
the deepest).
info : str (default: None)
A description of the expected value. By
default this is infered from this trait's
info method.
FloatAccessor ¶
Bases: FixedErrorTraitType
A trait to validate input for a deck.gl float accessor.
Various input is allowed:
- An
intorfloat. This will be used as the value for all objects. - A numpy
ndarraywith a numeric data type. This will be casted to an array of data typenp.float32. Each value in the array will be used as the value for the object at the same row index. - A pandas
Serieswith a numeric data type. This will be casted to an array of data typenp.float32. Each value in the array will be used as the value for the object at the same row index. - A pyarrow
FloatArray,DoubleArrayorChunkedArraycontaining either aFloatArrayorDoubleArray. Each value in the array will be used as the value for the object at the same row index. - Any Arrow floating point array from a library that implements the Arrow PyCapsule
Interface.
This includes data structures from
geoarrow-rust.
H3Accessor ¶
Bases: FixedErrorTraitType
A trait to validate h3 cell input.
Various input is allowed:
- A numpy
ndarraywith an object, S15, or uint64 data type. - A pandas
Serieswith an object or uint64 data type. - A pyarrow string, large string, string view array, or uint64 array, or a chunked array of those types.
- Any Arrow string, large string, string view array, or uint64 array, or a chunked array of those types from a library that implements the Arrow PyCapsule Interface.
MapHeightTrait ¶
NormalAccessor ¶
Bases: FixedErrorTraitType
A representation of a deck.gl "normal" accessor.
This is primarily used in the [lonboard.PointCloudLayer].
Acceptable inputs:
- A list or tuple with three int or float values. This will be used as the
normal for all objects.
- A numpy ndarray with two dimensions and floating point type. The size of the
second dimension must be 3, i.e. its shape must be (N, 3).
- a pyarrow FixedSizeListArray or ChunkedArray containing FixedSizeListArrays
where the size of the inner fixed size list 3. The child array must have type
float32.
- Any Arrow array that matches the above restrictions from a library that implements
the Arrow PyCapsule
Interface.
PointAccessor ¶
Bases: FixedErrorTraitType
A representation of a deck.gl point accessor.
Various input is allowed:
- A numpy
ndarraywith two dimensions and data typenp.float64. The size of the second dimension must be2or3, and will correspond to either XY or XYZ positions. - A pyarrow
FixedSizeListArray,StructArrayorChunkedArraycontainingFixedSizeListArrays orStructArrays. The inner size of the fixed size list must be2or3and its child must be of floating point type. - Any Arrow fixed size list or struct array from a library that implements the Arrow PyCapsule Interface.
TextAccessor ¶
Bases: FixedErrorTraitType
A trait to validate input for a deck.gl text accessor.
Various input is allowed:
- A
str. This will be used as the value for all objects. - A numpy
ndarraywith a string data type. Each value in the array will be used as the value for the object at the same row index. - A pandas
Serieswith a string data type. Each value in the array will be used as the value for the object at the same row index. - A pyarrow
StringArrayorChunkedArraycontaining aStringArray. Each value in the array will be used as the value for the object at the same row index.
TimestampAccessor ¶
Bases: FixedErrorTraitType
A representation of a deck.gl coordinate-timestamp accessor.
deck.gl handles timestamps on the GPU as float32 values. This class will validate that the input timestamps are representable as float32 integers, and will automatically reduce the precision of input data if necessary to fit inside a float32.
Accepted input includes:
- A pyarrow
ListArraycontaining a temporal array such as a TimestampArray. Each value in the array will be used as the value for the object at the same row index. - Any Arrow list array containing a temporal array from a library that implements the Arrow PyCapsule Interface.
VariableLengthTuple ¶
Bases: Container
An instance of a Python tuple with variable numbers of elements of the same type.
__init__ ¶
__init__(
trait: T | Sentinel = None,
default_value: tuple[T, ...] | Sentinel | None = Undefined,
minlen: int = 0,
maxlen: int = maxsize,
**kwargs: Any
) -> None
Create a tuple trait type.
The default value is created by doing list(default_value),
which creates a copy of the default_value.
trait can be specified, which restricts the type of elements
in the container to that TraitType.
If only one arg is given and it is not a Trait, it is taken as
default_value:
c = List([1, 2, 3])
Parameters¶
trait : TraitType [ optional ] the type for restricting the contents of the Container. If unspecified, types are not checked. default_value : SequenceType [ optional ] The default value for the Trait. Must be list/tuple/set, and will be cast to the container type. minlen : Int [ default 0 ] The minimum length of the input list maxlen : Int [ default sys.maxsize ] The maximum length of the input list kwargs: passed on to traitlets.Container.