Skip to main content

SweetPea

Build Status
typecheck
acceptance (fast)
acceptance (slow)
package

SweetPea is a domain-specific language for specifying factorial experimental designs and synthesizing trial sequences from those design specifications. An explanation of factorial experimental designs and how to build and manipulate them in SweetPea can be found in the SweetPea Guide.

See also the paper describing SweetPea, but beware that the API has changed. The main changes are replacing most functions with classes, changing some function names, and simplifying the organization to just a sweetpea module that exports everything.

SweetPea includes a synthesizer to generate sequences of trials that satisfy the design's constraints. The goal is to generate sequences that are unbiased: every possible sequence of trials that satifies the design constraints is equally likely to be generated, which avoids correlations that are not part of the experiment's definition. With current technologies, SweetPea achieves that goal for designs with either simple constraints or a small number of combinations. SweetPea can also generate samples that seem uniform in practice for medium-sized designs, although without a formal guarantee. Generating unbiased samples for large designs remains an area of active research and development.

For designs that do not involve constraints that span trials within a sequence, SweetPea can directly sample with combinatoric techniques. Realistic designs often involve transition constraints or other cross-trial constraints, however. For those cases, SweetPea's primary sampling strategy compiles an experiment design into a boolean formula; compilation ensures a 1-to-1 correspondence between distinct satisfying assignments to the boolean formula and distinct trial sequences, so that uniformly sampling solutions to the boolean formula imples a unform sample of trial sequences. SweetPea uses CMSGen and UniGen to sample solutions to the boolean formula. CMSGen generates samples that appear to be well distributed in practice, but CMSGen lacks a formal guarantee of uniformity. UniGen provides statistical guarantees that the solutions it finds are approximately uniformly probable, but its approach is tractable only for the smallest designs that are expressed with SweetPea.

Dependencies

SweetPea requires Python 3.9 or later.

Installation

There are two ways to install SweetPea: from the Python Package Index (PyPI), or from source.

Installing from PyPI

SweetPea can be installed from PyPI via pip:

$ pip install sweetpea

Installing from Source

Clone this repository, install SweetPea's dependencies, and install SweetPea itself:

$ git clone https://github.com/sweetpea-org/sweetpea-py.git
$ cd sweetpea-py
$ pip install -r requirements.txt
$ pip install .

❗ Important!

The pip install . command installs SweetPea locally, but it will not automatically check for updates. If you intend to manually update your local copy of SweetPea, you should instead do pip install -e . to tell pip to use the source dynamically.


Examples

There are example programs in the example_programs directory, and there is a detailed explanation of how to use SweetPea in the SweetPea Guide.

API Documentation

The SweetPea API is documented in the API section of the SweetPea Guide.

Contributing

Information on how to contribute to SweetPea's development can be found in the Contributing section of the SweetPea Guide.

Metadata

Release files for sweetpea 0.2.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sweetpea 0.2.15
File Size Uploaded Provenance Actions
sweetpea-0.2.15.tar.gz 184.7 kB Without provenance Details for sweetpea-0.2.15.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sweetpea 0.2.15
File Interpreter ABI Platform Actions
sweetpea-0.2.15-py3-none-any.whl Python 3 none any Details for sweetpea-0.2.15-py3-none-any.whl

Total release size: 418.2 kB

Release files / sweetpea-0.2.15.tar.gz

Download URL sweetpea-0.2.15.tar.gz
Size 184.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a24a6123d28f2623a818018a1114f25babe8db434c89fb5636042d0f1c93404d
BLAKE2b-256 checksum
How to use checksums
a05d1a67aa6aa3d1e3e503174d168d165077dcce09906152e7a39e7faebc7033
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.6

Release files / sweetpea-0.2.15-py3-none-any.whl

Download URL sweetpea-0.2.15-py3-none-any.whl
Size 233.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0bed758533badb82bb13db19555bb0a7266242f067fdd1a122e6cb969a428130
BLAKE2b-256 checksum
How to use checksums
43a09c5f633322d4fa4b4d1a19078fd0fdaa72216a31a1779e4114a3a91f7af7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.6

Security for sweetpea 0.2.15

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.15 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page