cmdstanjupyter
This extension provides syntax highlighting for Stan code in JupyterLab, as well as a %%stan magic command
to define Stan models in Jupyter notebooks and build them with CmdStanPy.
Requirements
- JupyterLab >= 4.0.0
Install
To install the extension, execute:
pip install cmdstanjupyter
Note: this does not install CmdStanPy for you, in case you are only interested
in Stan syntax highlighting and not the %%stan magic!
Install it separately using pip or conda!
Usage
To use the magic in your notebook, you need to lead the extension:
%load_ext cmdstanjupyter
To define a stan model inside a jupyter notebook, start a cell with the %%stan
magic. You can also provide a variable name, which is the variable name that
the cmdstanpy.CmdStanModel object will be assigned to. For example:
%%stan paris_female_births
data {
int male;
int female;
}
parameters {
real<lower=0, upper=1> p;
}
model {
female ~ binomial(male + female, p);
}
When you run this cell, cmdstanjupyter will create a cmdstanpy CmdStanModel object,
which will compile your model and allow you to sample from it.
If the above code was stored in a file births.stan, the following is equivalent:
%stanf births.stan paris_female_births
To use your compiled model:
fit = paris_female_births.sample(
data={'male': 251527, 'female': 241945},
)
Credits
The %magic is heavily based on the previous jupyterstan package. The highlighting code is inspired by jupyterlab-stata-highlight.
Metadata
Release files for cmdstanjupyter 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cmdstanjupyter-2.1.0.tar.gz | 90.4 kB | Without provenance | Details for cmdstanjupyter-2.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cmdstanjupyter-2.1.0-py3-none-any.whl | Python 3 | none | any | Details for cmdstanjupyter-2.1.0-py3-none-any.whl |
Total release size: 110.2 kB
Release files / cmdstanjupyter-2.1.0.tar.gz
| Download URL | cmdstanjupyter-2.1.0.tar.gz |
|---|---|
| Size | 90.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e5fa21ecc73f842d6881cef4f379bd97c3ab97da94cb3b5f2a10df8c6c80bbf
|
|
BLAKE2b-256 checksum How to use checksums |
fd6b8ed1917e5110aa79b142196c65a08127158056fc9803024d3a12f07aa850
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / cmdstanjupyter-2.1.0-py3-none-any.whl
| Download URL | cmdstanjupyter-2.1.0-py3-none-any.whl |
|---|---|
| Size | 19.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1564121ac0a5e97ee49b68e8cc991da08976287c9fa4a9a9cccbf170a49715d4
|
|
BLAKE2b-256 checksum How to use checksums |
4dbdfb0bd8723e699193a19d6b5cd11ead27cae12f7126da86dad9e795dc32a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Security for cmdstanjupyter 2.1.0
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.