A fast, lossless MCNP input parser with whole-geometry editing.
Project description
migjorn (Python)
Fast, lossless MCNP input parsing with whole-geometry editing, backed by a Rust core.
Run the examples with uv (no manual build)
uv builds the Rust extension for you. From the
repository root:
# Script tour — one command, builds + runs:
uv run crates/migjorn-py/examples/migjorn_demo.py
# Notebook (interactive) — the [notebook] extra pulls in jupyterlab/ipykernel/nbconvert:
uv run --with "./crates/migjorn-py[notebook]" \
jupyter lab crates/migjorn-py/examples/migjorn_demo.ipynb
# Notebook (execute headless, refresh outputs in place):
uv run --with "./crates/migjorn-py[notebook]" \
jupyter nbconvert --to notebook --execute --inplace \
crates/migjorn-py/examples/migjorn_demo.ipynb
The script carries its dependency (the local migjorn package) as inline
PEP 723 metadata, so uv run compiles the
extension via maturin into an isolated environment automatically.
Use in an IDE (VS Code / Jupyter kernel)
To run the notebook against a persistent, selectable interpreter (rather than
uv's ephemeral uv run environments), create a .venv that contains both
migjorn and ipykernel. From this directory (crates/migjorn-py):
uv sync --no-editable --extra notebook
This builds the extension and installs the notebook stack (jupyterlab, ipykernel,
nbconvert) into crates/migjorn-py/.venv. Then, in your IDE, select the kernel /
interpreter:
crates/migjorn-py/.venv/Scripts/python.exe # Windows
crates/migjorn-py/.venv/bin/python # macOS / Linux
A kernel without ipykernel (e.g. a bare uv venv, or uv sync without
--extra notebook) will fail to start for the notebook — that missing package is
the usual cause. After changing the Rust code, re-run
uv sync --no-editable --extra notebook (or maturin develop) to rebuild.
Why
--no-editable? An editable install points a.pthat the externalpython/source dir; Pylance often won't follow that to find the stubs, so you get no autocomplete/typing. A non-editable install placesmigjorn/__init__.pyiandpy.typedphysically insite-packages, which every type checker resolves. (Trade-off: after editing the code you must re-sync to pick up changes.)
Install (development, without uv)
pip install maturin
cd crates/migjorn-py
maturin develop --release
To build a wheel: maturin build --release (produces an abi3 wheel that works
on CPython 3.9+).
To build a Windows wheel on Linux, use maturin build --release --target x86_64-pc-windows-msvc -m crates/migjorn-py/Cargo.toml -i python3.12.
Quick start
import migjorn
model = migjorn.parse(open("model.mcnp").read())
# or: model = migjorn.Model.from_file("model.mcnp")
print(model) # Model(cells=..., surfaces=..., ...)
print(model.num_cells, model.num_surfaces)
# Look up by number (fast; uses an id index).
s = model.surface(113)
print(s.id, s.kind, s.coeffs) # 113 'PX' [-10.0]
c = model.cell(800)
print(c.material, c.density, c.signed_surfaces)
# --- In-place value edits (write straight through, lossless elsewhere) ------
c.material = 124 # replace the material
c.density = -7.93 # replace the density
# Assigning a material to a *void* cell just works: it gains a placeholder
# density of 0.0 (never raises, so it's safe in a loop). Set the real density
# next; assigning material 0 makes the cell void again and drops the density.
void = model.cell(2)
void.material = 5 # 5 0 ... (placeholder density 0.0)
void.density = -2.0 # 5 -2.0 ...
void.material = 0 # 0 ... (void again, density dropped)
# Diagnostics (empty on a clean parse).
for d in model.diagnostics:
print(d.severity, d.message)
# --- Whole-geometry renumbering -------------------------------------------
# Definitions AND every reference are updated consistently.
model.offset_surfaces(1_000_000) # fast: shift all surface numbers
model.renumber_cells(lambda n: n + 500) # callable: once per distinct cell id
model.renumber_surfaces({1: 100, 2: 200}) # or an explicit dict
# Lossless re-emission: only edited numbers change; comments/spacing preserved.
model.save("model_renumbered.mcnp")
text = str(model) # or model.to_source()
Type checking / IDE support
The package is typed (PEP 561): the compiled extension is the private
migjorn._migjorn submodule, wrapped by the migjorn package which ships type
stubs (python/migjorn/__init__.pyi) and a py.typed marker. Pylance, pyright,
and mypy pick these up automatically once the wheel is installed — no more
"unknown import"/"untyped" warnings. When you change the bindings in
src/lib.rs, update python/migjorn/__init__.pyi to match.
Notes
model.cells/model.surfaces/model.materials/model.transforms/model.data_cardsreturn full lists. For very large models prefer the id lookups (model.cell(id),model.surface(id)) and thenum_*counts.- Everything is documented inline:
help(migjorn.Model),help(migjorn.Surface).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file migjorn-0.2.3.tar.gz.
File metadata
- Download URL: migjorn-0.2.3.tar.gz
- Upload date:
- Size: 120.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5f6e84d078b6130b7f09c4eb1218f683d92e4fe7d30dba664e1aa68ee5e3e0d
|
|
| MD5 |
f6cde58d0532bd8ad97474f88398fa11
|
|
| BLAKE2b-256 |
40d5b444c4eb5bfca6a263e54538d3a81c2ea96bbf2e0bd0525cb28359f1571e
|
Provenance
The following attestation bundles were made for migjorn-0.2.3.tar.gz:
Publisher:
release.yml on AlvaroCubi/migjorn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
migjorn-0.2.3.tar.gz -
Subject digest:
d5f6e84d078b6130b7f09c4eb1218f683d92e4fe7d30dba664e1aa68ee5e3e0d - Sigstore transparency entry: 2172980231
- Sigstore integration time:
-
Permalink:
AlvaroCubi/migjorn@52001b31d09a7a12b2e20484966857eb4de95274 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/AlvaroCubi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@52001b31d09a7a12b2e20484966857eb4de95274 -
Trigger Event:
push
-
Statement type:
File details
Details for the file migjorn-0.2.3-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: migjorn-0.2.3-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 368.9 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db1d3d6362296a554b97192121d54fda53f15207638368aca147e751ef4333f2
|
|
| MD5 |
6716f7e09514c870dcfae07d3adc1cc9
|
|
| BLAKE2b-256 |
ad78fed7ca6dd6487ba097de9653dc340d6c7a009fe415e1f8cb883f27e7b746
|
Provenance
The following attestation bundles were made for migjorn-0.2.3-cp39-abi3-win_amd64.whl:
Publisher:
release.yml on AlvaroCubi/migjorn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
migjorn-0.2.3-cp39-abi3-win_amd64.whl -
Subject digest:
db1d3d6362296a554b97192121d54fda53f15207638368aca147e751ef4333f2 - Sigstore transparency entry: 2172980286
- Sigstore integration time:
-
Permalink:
AlvaroCubi/migjorn@52001b31d09a7a12b2e20484966857eb4de95274 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/AlvaroCubi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@52001b31d09a7a12b2e20484966857eb4de95274 -
Trigger Event:
push
-
Statement type:
File details
Details for the file migjorn-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: migjorn-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 485.5 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcb02b5729051d47da481269eabbf5a0a608c11c6ec8adc01ef8a844ac4ba39a
|
|
| MD5 |
1ee97784cf84f671db61f090b93b1a19
|
|
| BLAKE2b-256 |
0ca085392dd68b7d018bdfb353971715f450bf80427b7f3aaa8fd63b20140fe8
|
Provenance
The following attestation bundles were made for migjorn-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on AlvaroCubi/migjorn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
migjorn-0.2.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
dcb02b5729051d47da481269eabbf5a0a608c11c6ec8adc01ef8a844ac4ba39a - Sigstore transparency entry: 2172980303
- Sigstore integration time:
-
Permalink:
AlvaroCubi/migjorn@52001b31d09a7a12b2e20484966857eb4de95274 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/AlvaroCubi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@52001b31d09a7a12b2e20484966857eb4de95274 -
Trigger Event:
push
-
Statement type:
File details
Details for the file migjorn-0.2.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: migjorn-0.2.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 475.2 kB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83cec30ce7bbd35663993cfe9b84582ca1319d979b89e3692b1fbdcfdb708e32
|
|
| MD5 |
5a7aad9331d89a163127cc26eca2e097
|
|
| BLAKE2b-256 |
907ba5205dd2aa7442b3508fac986a7b936ab9511612a3249c8f712e0aa0f175
|
Provenance
The following attestation bundles were made for migjorn-0.2.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on AlvaroCubi/migjorn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
migjorn-0.2.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
83cec30ce7bbd35663993cfe9b84582ca1319d979b89e3692b1fbdcfdb708e32 - Sigstore transparency entry: 2172980274
- Sigstore integration time:
-
Permalink:
AlvaroCubi/migjorn@52001b31d09a7a12b2e20484966857eb4de95274 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/AlvaroCubi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@52001b31d09a7a12b2e20484966857eb4de95274 -
Trigger Event:
push
-
Statement type:
File details
Details for the file migjorn-0.2.3-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: migjorn-0.2.3-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 447.7 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95d769304862e760841e443bfe7dc168a3a17a6fb57b66522e3f01a11c32fefa
|
|
| MD5 |
8dd96482b1b2ef590bfaa57d9ae2130a
|
|
| BLAKE2b-256 |
188d152376523b047a5deda2b06d221c9fb3f7a462701c4df0237c2d30e7b2fb
|
Provenance
The following attestation bundles were made for migjorn-0.2.3-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on AlvaroCubi/migjorn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
migjorn-0.2.3-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
95d769304862e760841e443bfe7dc168a3a17a6fb57b66522e3f01a11c32fefa - Sigstore transparency entry: 2172980316
- Sigstore integration time:
-
Permalink:
AlvaroCubi/migjorn@52001b31d09a7a12b2e20484966857eb4de95274 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/AlvaroCubi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@52001b31d09a7a12b2e20484966857eb4de95274 -
Trigger Event:
push
-
Statement type:
File details
Details for the file migjorn-0.2.3-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: migjorn-0.2.3-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 465.3 kB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3eb13b6b5d6c44a2f2702de96ca7992249a341586b61de4096639b59b27ab23
|
|
| MD5 |
bae3d337c656438697c65d78a5818c2f
|
|
| BLAKE2b-256 |
3e2873472a5e5e0c3b962b71fcab03428d1db2ec17dc254af8af29d3e2b634e9
|
Provenance
The following attestation bundles were made for migjorn-0.2.3-cp39-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on AlvaroCubi/migjorn
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
migjorn-0.2.3-cp39-abi3-macosx_10_12_x86_64.whl -
Subject digest:
d3eb13b6b5d6c44a2f2702de96ca7992249a341586b61de4096639b59b27ab23 - Sigstore transparency entry: 2172980250
- Sigstore integration time:
-
Permalink:
AlvaroCubi/migjorn@52001b31d09a7a12b2e20484966857eb4de95274 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/AlvaroCubi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@52001b31d09a7a12b2e20484966857eb4de95274 -
Trigger Event:
push
-
Statement type: