mattress package¶
Submodules¶
mattress.TatamiNumericPointer module¶
- class mattress.TatamiNumericPointer.TatamiNumericPointer(ptr, obj)[source]¶
Bases:
object
Pointer to a tatami numeric matrix allocated by C++ code. Instances of this class should only be created by developers and used within package functions; this is done by fetching the
ptr
attribute and casting it to aMattress*
in C++ code. Pointers are expected to be transient within a Python session; they should not be serialized, nor should they be visible to end users. Each instance will automatically free the C++-allocated memory upon its own destruction.- column(c)[source]¶
Access a column from the tatami matrix. This method is primarily intended for troubleshooting and should not be used to iterate over the matrix in production code. (Do that in C++ instead.)
- column_medians_by_group(group, num_threads=1)[source]¶
Convenience method to compute the column-wise median for each group of row.
- Parameters:
- Return type:
- Returns:
Tuple containing a 2-dimensional array where each row represents a group and contains the column-wise medians for that group, across all columns of the matrix; and a list containing the unique levels of
group
represented by each row.
- column_nan_counts(num_threads=1)[source]¶
Convenience method to count the number of NaNs on each column.
- column_sums_by_group(group, num_threads=1)[source]¶
Convenience method to compute the column-wise median for each group of row.
- Parameters:
- Return type:
- Returns:
Tuple containing a 2-dimensional array where each row represents a group and contains the column-wise sums for that group, across all columns of the matrix; and a list containing the unique levels of
group
represented by each row.
- row(r)[source]¶
Access a row from the tatami matrix. This method is primarily intended for troubleshooting and should not be used to iterate over the matrix in production code. (Do that in C++ instead.)
- row_medians_by_group(group, num_threads=1)[source]¶
Convenience method to compute the row-wise median for each group of columns.
- Parameters:
- Return type:
- Returns:
Tuple containing a 2-dimensional array where each column represents a group and contains the row-wise medians for that group, across all rows of the matrix; and a list containing the unique levels of
group
represented by each column.
- row_sums_by_group(group, num_threads=1)[source]¶
Convenience method to compute the row-wise median for each group of columns.
- Parameters:
- Return type:
- Returns:
Tuple containing a 2-dimensional array where each column represents a group and contains the row-wise sums for that group, across all rows of the matrix; and a list containing the unique levels of
group
represented by each column.
- mattress.TatamiNumericPointer.extract_dense_array_tatami(x, subset)[source]¶
See
extract_dense_array()
.- Return type:
mattress.interface module¶
- mattress.interface.tatamize(x)[source]¶
Converts Python matrix representations to a tatami pointer.
- Parameters:
x (
Any
) – Any matrix-like object.- Raises:
NotImplementedError – if x is not supported.
- Return type:
- Returns:
A pointer to tatami object.