Cube objects

class cr.cube.cube.Cube(response, cube_idx=None, transforms=None, population=None, mask_size=0)

Provides access to individual slices on a cube-result.

It also provides some attributes of the overall cube-result.

cube_idx must be None (or omitted) for a single-cube CubeSet. This indicates the CubeSet contains only a single cube and influences behaviors like CA-as-0th.

available_measures

frozenset of available CUBE_MEASURE members in the cube response.

counts
counts_with_missings

ndarray of weighted, unweighted or valid counts including missing values.

The difference from .counts is that this property includes value for missing categories.

covariance

Optional float64 ndarray of the cube_covariance if the measure exists.

cube_index

Offset of this cube within its CubeSet.

description

Return the description of the cube.

dimension_types

Tuple of DIMENSION_TYPE member for each dimension of cube.

dimensions

_ApparentDimensions object providing access to visible dimensions.

A cube involving a multiple-response (MR) variable has two dimensions for that variable (subvariables and categories dimensions), but is “collapsed” into a single effective dimension for cube-user purposes (its categories dimension is supressed). This collection will contain a single dimension for each MR variable and therefore may have fewer dimensions than appear in the cube response.

has_weighted_counts

True if cube response has weighted count data.

inflate()

Return new Cube object with rows-dimension added.

A multi-cube (tabbook) response formed from a function (e.g. mean()) on a numeric variable arrives without a rows-dimension.

means

Optional float64 ndarray of the cube_means if the measure exists.

missing

Get missing count of a cube.

n_responses

Total (int) number of responses considered.

name

Return the name of the cube.

If the cube has 2 diensions, return the name of the second one. In case of a different number of dimensions, default to returning the name of the last one. In case of no dimensions, return the empty string.

ndim

int count of dimensions for this cube.

overlaps

Optional float64 ndarray of cube_overlaps if the measure exists.

The array has as many dimensions as there are defined in the cube query, plus the extra subvariables dimension as the last dimension.

partitions

Sequence of _Slice, _Strand, or _Nub objects from this cube-result.

population_fraction

The filtered/unfiltered ratio for cube response.

This value is required for properly calculating population on a cube where a filter has been applied. Returns 1.0 for an unfiltered cube. Returns np.nan if the unfiltered count is zero, which would otherwise result in a divide-by-zero error.

stddev

Optional float64 ndarray of the cube_stddev if the measure exists.

sums

Optional float64 ndarray of the cube_sum if the measure exists.

title

str alternate-name given to cube-result.

This value is suitable for naming a Strand when displayed as a column. In this use-case it is a stand-in for the columns-dimension name since a strand has no columns dimension.

unweighted_counts

ndarray of unweighted counts, valid elements only.

Unweighted counts are drawn from the result.counts field of the cube result. These counts are always present, even when the measure is numeric and there are no count measures. These counts are always unweighted, regardless of whether the cube is “weighted”.

In case of presence of valid counts in the cube response the counts are replaced with the valid counts measure.

unweighted_valid_counts

Optional float64 ndarray of unweighted_valid_counts if the measure exists.

valid_counts_summary

Optional ndarray of summary valid counts

valid_overlaps

Optional float64 ndarray of cube_valid_overlaps if the measure exists.

The array has as many dimensions as there are defined in the cube query, plus the extra subvariables dimension as the last dimension.

weighted_counts

ndarray of weighted counts, valid elements only.

In case of presence of valid counts in the cube response the weighted counts are replaced with the valid counts measure.

weighted_valid_counts

Optional float64 ndarray of weighted_valid_counts if the measure exists.