Package: cr.cube
crunch-cubeOpen Source Python implementation of the API for working with CrunchCubesIntroductionThis package contains the implementation of the CrunchCube API. It is used to
extract useful information from CrunchCube responses (we'll refer to them ascubesin the subsequent text).Cubesare obtained from theCrunch.ioplatform, as JSON responses to the specificqueriescreated by the user.
These queries specify which data the user wants to extract from the Crunch.io
system. The most common usage is to obtain the following:Cross correlation between different variableMargins of the cross tabcubeProportions of the cross tabcube(e.g. proportions of each single element to the entire sample size)PercentagesWhen the data is obtained from the Crunch.io platform, it needs to be
interpreted to the form that's convenient for a user. The actual shape of thecubeJSON contains many internal details, which are not of essence to the
end-user (but are still necessary for propercubefunctionality).The job of this library is to provide a convenient API that handles those
intricacies, and enables the user to quickly and easily obtain (extract) the
relevant data from thecube. Such data is best represented in a table-like
format. For this reason, the most of the API functions return some form of thendarraytype, from thenumpypackage. Each function is explained in greater
detail, uner its own section, under the API subsection of this document.InstallationThecr.cubepackage can be installed by using thepip install:pip install cr.cubeFor developersFor development mode,cr.cubeneeds to be installed from the local checkout
of thecrunch-cuberepository. It is strongly advised to usevirtualenv.
Assuming you've created and activated a virtual environmentvenv, navigate
to the top-level folder of the repo, on the local file system, and run:pip install -e .orpython setup.py developRunning testsTo setup and run tests, you will need to installcr.cubeas well as testing
dependencies. To do this, from the root directory, simply run:pip install -e .[testing]And then tests can be run usingpy.testin the root directory:pytestUsageAfter thecr.cubepackage has been successfully installed, the usage is as
simple as:>>> from cr.cube.cube import Cube

>>> ### Obtain the crunch cube JSON payload using app.crunch.io, pycrunch, rcrunch or scrunch
>>> ### And store it in the 'cube_JSON_response' variable

>>> cube = Cube(cube_JSON_response)
>>> print(cube)
Cube(name='MyCube', dimension_types='CAT x CAT')
>>> cube.counts
np.array([[1169, 547],
          [1473, 1261]])APIas_arrayTabular, or matrix, representation of thecube. The detailed description can
be foundhere.marginCalculates margins of thecube. The detailed description can be foundhere.proportionsCalculates proportions of single variable elements to the whole sample size.
The detailed description can be foundhere.percentagesCalculates percentages of single variable elements to the whole sample size.
The detailed description can be foundhere.Changes3.0.41Removedeepcopyfrom dimension module due to a performance issue3.0.40Fix bug with weighted vs unweighted in pairwise effect calculation3.0.39Remove cube response deepcopy due to a performance issue3.0.38Improve calculation of DoF for pairwise comparisonUse effective counts as column bases for DoF3.0.37Add squared counts as a cube measureEnable calculating pairwise stats with effective denominator3.0.36Fix bug in pairwise sig values for means.3.0.35Fix bug where categorical dimension would sometimes be interpreted asMR_CATS.For a complete list of changes seehistory.