Metadata-Version: 2.4
Name: codecraftai-analysis-statistical
Version: 1.2.1
Summary: Code Craft AI Statistical Analysis Library -- SAS-comparable DATA-step semantics in Python.
License-Expression: LicenseRef-CodeCraftAI-Source-Available
License-File: LICENSE.md
Keywords: python,statistics,sas,data-step,automation,analytics
Author: Code Craft AI LLC
Author-email: info@code-craft.ai
Requires-Python: >=3.10,<4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: POSIX
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: codecraftai-foundations (>=1.0.0,<2.0.0)
Requires-Dist: numpy (>=2.0,<3.0.0)
Project-URL: Homepage, https://github.com/code-craft-ai-company/codecraftai-analysis-statistical
Project-URL: Issues, https://github.com/code-craft-ai-company/codecraftai-analysis-statistical/issues
Project-URL: Repository, https://github.com/code-craft-ai-company/codecraftai-analysis-statistical
Description-Content-Type: text/x-rst

================================
codecraftai-analysis-statistical
================================

Patterns for authoring and porting statistical analysis jobs to Python whose
results are *directly comparable* to the equivalent SAS jobs. Built around a
reference SAS DATA-step execution model (the correctness oracle), an IR
front end for inspectable user logic, a hybrid columnar / sequential
executor for speed, and database source readers that follow the
SAS/ACCESS-engine pattern.

Public namespace: ``ccai.analysis.statistical``.

Documentation
=============
- `Architecture / design <specs/DESIGN.md>`_
- `Build roadmap <specs/ROADMAP.md>`_
- `Overview & mental model <userguide/20-00-overview-and-mental-model.rst>`_
- `Porting SAS jobs to Python <userguide/20-07-porting-sas-jobs-to-python.rst>`_

Quick example
=============

.. code-block:: python

    from ccai.analysis.statistical import (ObservationEngine, SetReader)

    sales = [{"region": "East", "customer": "A", "amount": 10},
             {"region": "East", "customer": "A", "amount": 15},
             {"region": "East", "customer": "B", "amount": 7}]

    def accumulate(pdv):
        if pdv.first["customer"] is True:
            pdv["total"] = 0
        pdv["total"] = pdv["total"] + pdv["amount"]
        if pdv.last["customer"] is True:
            pdv.output()
        return

    rows = list(ObservationEngine(
        reader=SetReader(source=sales, by=["region", "customer"]),
        logic=accumulate, by=["region", "customer"],
        retain={"total": 0}))

Tests
=====

This package uses ``testbase`` exclusively. After ``rehome-repository`` and
``setup-environment`` complete::

    source .venv/bin/activate
    testbase testing run --root source/testroots/ccai \
        --includes=ccai.tests.singlehost --output=./.output

