pyface.data_view.data_models.array_data_model module¶
Provides an N-dimensional array data model implementation.
This module provides a concrete implementation of a data model for an n-dim numpy array.
- class pyface.data_view.data_models.array_data_model.ArrayDataModel(**traits)[source]¶
Bases:
AbstractDataModel
,HasRequiredTraits
A data model for an n-dim array.
This data model presents the data from a multidimensional array hierarchically by dimension. The underlying array must be at least 2 dimensional.
Values are adapted by the
value_type
trait. This provides sensible default values for integer, float and text dtypes, but other dtypes may need the user of the class to supply an appropriate value type class to adapt values.There are additional value types which provide data sources for row headers, column headers, and the label of the row header column. The defaults are likely suitable for most cases, but can be overriden if required.
- data = _AtLeastTwoDArray()¶
The array being displayed. This must have dimension at least 2.
- index_manager = Instance(TupleIndexManager, args=())¶
The index manager that helps convert toolkit indices to data view indices.
- label_header_type = Instance( …¶
The value type of the row index column header.
- column_header_type = Instance( …¶
The value type of the column titles.
- row_header_type = Instance( …¶
The value type of the row titles.
- value_type = Instance(AbstractValueType, allow_none=False, required=True)¶
The type of value being displayed in the data model.
- get_column_count()[source]¶
How many columns in the data view model.
The number of columns is the size of the last dimension of the array.
- Returns
column_count – The number of columns in the data view model, which is the size of the last dimension of the array.
- Return type
non-negative int
- can_have_children(row)[source]¶
Whether or not a row can have child rows.
A row is a leaf row if the length of the index is one less than the dimension of the array: the final coordinate for the value will be supplied by the column index.
- Parameters
row (sequence of int) – The indices of the row as a sequence from root to leaf.
- Returns
can_have_children – Whether or not the row can ever have child rows.
- Return type
- get_row_count(row)[source]¶
Whether or not the row currently has any child rows.
The number of rows in a non-leaf row is equal to the size of the next dimension.
- Parameters
row (sequence of int) – The indices of the row as a sequence from root to leaf.
- Returns
has_children – Whether or not the row currently has child rows.
- Return type
- get_value(row, column)[source]¶
Return the Python value for the row and column.
- Parameters
row (sequence of int) – The indices of the row as a sequence from root to leaf.
- Returns
row_count – The number of child rows that the row has.
- Return type
non-negative int
- can_set_value(row, column)[source]¶
Whether the value in the indicated row and column can be set.
This returns False for row and column headers, but True for all array values.
- Parameters
row (sequence of int) – The indices of the row as a sequence from root to leaf.
column (sequence of int) – The indices of the column as a sequence of length 0 or 1.
- Returns
can_set_value – Whether or not the value can be set.
- Return type
- set_value(row, column, value)[source]¶
Return the Python value for the row and column.
- Parameters
row (sequence of int) – The indices of the row as a sequence from root to leaf.
column (sequence of int) – The indices of the column as a sequence of length 1.
- Returns
value – The value represented by the given row and column.
- Return type
Any
- get_value_type(row, column)[source]¶
Return the value type of the given row and column.
This method returns the value of
column_header_type
for column headers, the value ofrow_header_type
for row headers, the value oflabel_header_type
for the top-left corner value, the value ofvalue_type
for all array values, andno_value
for everything else.- Parameters
row (sequence of int) – The indices of the row as a sequence from root to leaf.
column (sequence of int) – The indices of the column as a sequence of length 0 or 1.
- Returns
value_type – The value type of the given row and column.
- Return type