mattress package¶
- mattress.includes()[source]¶
 Provides access to mattress C++ headers.
- Returns:
 Path to a directory containing the mattress header.
- Return type:
 
Submodules¶
mattress.InitializedMatrix module¶
- class mattress.InitializedMatrix.InitializedMatrix(ptr)[source]¶
 Bases:
objectPointer to an initialized
tatami::matrix, for use in C++ code. Instances of this class should only be created by developers and used within package functions; this is done by passing theptraddress to C++ and casting it to amattress::BoundMatrix. AllInitializedMatrixinstances 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 garbage collection.- 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
grouprepresented 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 sum 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
grouprepresented by each row.
- column_variances_by_group(group, num_threads=1)[source]¶
 Convenience method to compute the column-wise variance 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 variances for that group, across all columns of the matrix; and a list containing the unique levels of
grouprepresented by each row.
- property ptr¶
 An address to a
mattress::BoundMatrixinstance, to be passed as auintptr_tto C++ for casting.
- 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
grouprepresented by each column.
- row_sums_by_group(group, num_threads=1)[source]¶
 Convenience method to compute the row-wise sum 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
grouprepresented by each column.
- row_variances_by_group(group, num_threads=1)[source]¶
 Convenience method to compute the row-wise variance 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 variances for that group, across all rows of the matrix; and a list containing the unique levels of
grouprepresented by each column.
- mattress.InitializedMatrix.chunk_grid(x)[source]¶
 See
chunk_grid().- Return type:
 
- mattress.InitializedMatrix.is_masked(x)[source]¶
 See
is_masked().- Return type:
 
- mattress.InitializedMatrix.is_sparse(x)[source]¶
 See
is_sparse().
mattress.initialize module¶
- mattress.initialize.initialize(x)[source]¶
 Initialize an
InitializedMatrixfrom a Python matrix representation. This prepares the matrix for use in C++ code that can accept atatami::Matrixinstance.- Parameters:
 x (
Any) – Any matrix-like object.- Raises:
 NotImplementedError – if x is not supported.
- Return type:
 - Returns:
 A pointer to tatami object.