An IPython extension for compiling and using Fortran code interactively.
Project description
Fortran magic
Compile and import symbols from a cell with Fortran code, using f2py.
Attention: I am looking for collaborators to maintain this project. If you are interested, please open an issue (or PRs) with your proposals for improvements and volunteer to be a maintainer.
The contents of the cell are written to a .f90 file in the directory
IPYTHONDIR/fortran using a filename with the hash of the code. This file is then
compiled. The resulting module is imported and all of its symbols are injected into
the user's namespace.
- Homepage: https://github.com/mgaitan/fortran_magic
- Documentation: see this notebook
Install
You can install or upgrade via uv:
uv add fortran-magic
Or via pip:
pip install -U fortran-magic
Or run directly
uv run --with=fortran-magic ipython
Basic usage
Once it's installed, you can load it with %load_ext fortranmagic. Then put your
Fortran code in a cell started with the cell magic %%fortran. For example:
In[1]: %load_ext fortranmagic
In[2]: %%fortran
subroutine f1(x, y, z)
real, intent(in) :: x,y
real, intent(out) :: z
z = sin(x+y)
end subroutine f1
Every symbol is automatically imported. So the subroutine f1 is already available in
your python session as a function:
In[3]: f1(1.0, 2.1415)
Out[3]: 9.26574066397734e-05
Tests
Run tests with:
uv run --group dev pytest
See the documentation for further details.
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 Distribution
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 fortran_magic-1.0.tar.gz.
File metadata
- Download URL: fortran_magic-1.0.tar.gz
- Upload date:
- Size: 25.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a34ef0a0bc535bd45c7afb7ba027f74b156bf0ed8abf5f7c11d01fe185591520
|
|
| MD5 |
c1a726bcbca2b88cf631861ee7f5a955
|
|
| BLAKE2b-256 |
c038e7a6bcba8d28c45cc3b0498bf0a0ea61ac27962a8214de1e123ded462843
|
Provenance
The following attestation bundles were made for fortran_magic-1.0.tar.gz:
Publisher:
release.yml on mgaitan/fortran_magic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fortran_magic-1.0.tar.gz -
Subject digest:
a34ef0a0bc535bd45c7afb7ba027f74b156bf0ed8abf5f7c11d01fe185591520 - Sigstore transparency entry: 2295041650
- Sigstore integration time:
-
Permalink:
mgaitan/fortran_magic@f95e0e1890df420f7799f40f96eaf8d96bb8e514 -
Branch / Tag:
refs/tags/1.0 - Owner: https://github.com/mgaitan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f95e0e1890df420f7799f40f96eaf8d96bb8e514 -
Trigger Event:
release
-
Statement type:
File details
Details for the file fortran_magic-1.0-py3-none-any.whl.
File metadata
- Download URL: fortran_magic-1.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28aff14396b3afb470655e29c688c64c90dd478db749733ffa3f46bdacf37dc3
|
|
| MD5 |
c28dc99daf5a16dab55aa48985b081f2
|
|
| BLAKE2b-256 |
499424b8af11f5f7e6dc6c9ef7842bb773e82f466557d6efeacf891119104bba
|
Provenance
The following attestation bundles were made for fortran_magic-1.0-py3-none-any.whl:
Publisher:
release.yml on mgaitan/fortran_magic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fortran_magic-1.0-py3-none-any.whl -
Subject digest:
28aff14396b3afb470655e29c688c64c90dd478db749733ffa3f46bdacf37dc3 - Sigstore transparency entry: 2295041809
- Sigstore integration time:
-
Permalink:
mgaitan/fortran_magic@f95e0e1890df420f7799f40f96eaf8d96bb8e514 -
Branch / Tag:
refs/tags/1.0 - Owner: https://github.com/mgaitan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f95e0e1890df420f7799f40f96eaf8d96bb8e514 -
Trigger Event:
release
-
Statement type: