fortran-magic


Namefortran-magic JSON
Version 0.8 PyPI version JSON
download
home_pagehttps://github.com/mgaitan/fortran_magic
SummaryAn extension for IPython that help to use Fortran in your interactive session.
upload_time2023-06-16 11:02:30
maintainer
docs_urlNone
authorMartin Gaitan
requires_python
licenseBSD
keywords ipython notebook fortran f2py science
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =============
Fortran magic
=============

.. image:: https://img.shields.io/pypi/v/fortran-magic
   :target: https://pypi.python.org/pypi/fortran-magic
   :alt: PyPI
   
.. image:: https://img.shields.io/pypi/dm/fortran-magic
   :target: https://pypi.python.org/pypi/fortran-magic
   :alt: PyPI - Downloads
   

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`__

__ documentation_
.. _documentation:  http://nbviewer.ipython.org/urls/raw.github.com/mgaitan/fortran_magic/master/documentation.ipynb


Install
=======

You can install or upgrade via pip

    pip install -U fortran-magic


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]: import sys

           if sys.platform.startswith("win"):
               # Depends of system, python builds, and compilers compatibility.
               # See `documentation.ipnb`.
               %fortran_config --fcompiler=gnu95 --compiler=mingw32

    In[3]: %%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[4]:  f1(1.0, 2.1415)
    Out[4]: 9.26574066397734e-05


See the documentation_ for further details.



Changelog
=========

0.8 / 2023-06-08
----------------

- Fix use deprecating ``imp`` module (removed from Python 3.12b2)

- Fix exponential duplication any not boolean flags of
  ``%%fortran_config``

- Include stored ``%%fortran_config``'s args in hashing

- Don't rebuild cell if the module already loaded and hash not changed
  (Unix don't reload already loaded shared library with same name.
  Windows can't rewrite already loaded DLL)

- Repair fortran highlighting in a ``%%fortran`` cell for ``nbclassic``
  (Fortran highlighting for ``JupyterLab`` - unimplemented, for
  ``IPython 3.x`` - removed)

- Printing compilers diagnostics for build errors by ``%%fortran``
  without ``-vvv`` flag

`Serguei E. Leontiev`_

.. _Serguei E. Leontiev: https://github.com/Serge3leo


0.7.1 / 2023-04-12
------------------

- Synchronize version number in fortranmagic.py & setup.py (2023-04-10,
  https://github.com/Serge3leo)

- Patch fortran source in compiled object. (029d890, 2020-08-01,
  https://github.com/mgaitan)

- Fix deprecation warning (3667bc1, 2017-08-18, https://github.com/guihigashi)
  [IPython.utils.path removed from IPython 8.x]

- Simplify f2py execution. (d8a058f, 2016-06-04, https://github.com/QuLogic)
  Don't change directories, and don't mangle `sys.argv`. The former can be
  specified directly in the `Popen` constructor, and the latter is cruft
  from when the f2py module was imported directly.


0.7 / 2016-03-13
----------------

- Fix cross compatibility with older NumPy and Python 3. (15ab10c)

Thanks to `Elliott Sales de Andrade`_ for this contribution

.. _Elliott Sales de Andrade: https://github.com/QuLogic


0.6 / 2015-12-02
----------------

- Decode text before printing
- Call f2py module instead of binary (numpy >=1.10 is mandatory)
- Check if f2py command failed

Thanks to `Juan Luis Cano Rodríguez`_ for this contribution

.. _Juan Luis Cano Rodríguez: https://github.com/Juanlu001


0.5 / 2015-01-21
----------------

- Call f2py via subprocess. It fixes problems finding fortran compilers under Windows. (Thanks to `David Powell`_ )

.. _David Powell: https://github.com/DavidPowell

0.4.3 / 2013-12-09
-------------------

- Fix two python3.2+ incompatibilities (Thanks `Ramon Crehuet`_ for the report)

.. _Ramon Crehuet: https://github.com/rcrehuet

0.4.2 / 2013-10-08
------------------

- Implement the ``--extra`` option (Thanks to `Denis Vasilyev`_ for the help)
- Include ``%%fortran``'s args in the hashing, so the same cell are
  recompiled with the same code but different arguments

.. _Denis Vasilyev: https://github.com/Vutshi

0.3 / 2013-10-03
------------------

- Added ``%fortran_config`` to set and persist default arguments
  for ``%%fortran``
- Improve documentation

0.2.1 / 2013-09-24
------------------

- Packaged and registered in pypi
- Starting a version's changelog

0.2 / 2013-09-19
----------------

- Fortran highlighting in a ``%%fortran`` cell
- Works (or it should) in any platform (linux/windows/osx)
  and with py3 (thanks to `Bradley Froehle`_)
- Many f2py's arguments exposed as magic arguments
- Verbosity handling
- Improved documentation

.. _Bradley Froehle: https://github.com/bfroehle

0.1 / 2013-09-08
----------------

- First public release

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mgaitan/fortran_magic",
    "name": "fortran-magic",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "ipython notebook fortran f2py science",
    "author": "Martin Gaitan",
    "author_email": "gaitan@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a3/30/a2f06c456501bf4a5f142e6fc635a87fcf21b0480653f87184b73f11da42/fortran-magic-0.8.tar.gz",
    "platform": null,
    "description": "=============\nFortran magic\n=============\n\n.. image:: https://img.shields.io/pypi/v/fortran-magic\n   :target: https://pypi.python.org/pypi/fortran-magic\n   :alt: PyPI\n   \n.. image:: https://img.shields.io/pypi/dm/fortran-magic\n   :target: https://pypi.python.org/pypi/fortran-magic\n   :alt: PyPI - Downloads\n   \n\nCompile and import symbols from a cell with Fortran code, using f2py.\n\n------\n\n..  attention::\n    I am looking for collaborators to maintain this project. If you are interested, \n    please open an issue (or PRs) with your proposals for improvements and volunteer to be a maintainer. \n\n------\n\nThe contents of the cell are written to a `.f90` file in the\ndirectory `IPYTHONDIR/fortran` using a filename with the hash of the\ncode. This file is then compiled. The resulting module\nis imported and all of its symbols are injected into the user's\nnamespace.\n\n:homepage: https://github.com/mgaitan/fortran_magic\n:documentation: see `this notebook`__\n\n__ documentation_\n.. _documentation:  http://nbviewer.ipython.org/urls/raw.github.com/mgaitan/fortran_magic/master/documentation.ipynb\n\n\nInstall\n=======\n\nYou can install or upgrade via pip\n\n    pip install -U fortran-magic\n\n\nBasic usage\n===========\n\nOnce it's installed, you can load it with ``%load_ext fortranmagic``.\nThen put your Fortran code in a cell started with the cell magic ``%%fortran``. For example::\n\n\n    In[1]: %load_ext fortranmagic\n\n    In[2]: import sys\n\n           if sys.platform.startswith(\"win\"):\n               # Depends of system, python builds, and compilers compatibility.\n               # See `documentation.ipnb`.\n               %fortran_config --fcompiler=gnu95 --compiler=mingw32\n\n    In[3]: %%fortran\n\n           subroutine f1(x, y, z)\n                real, intent(in) :: x,y\n                real, intent(out) :: z\n\n                z = sin(x+y)\n\n           end subroutine f1\n\n\nEvery symbol is automatically imported. So the subroutine `f1` is already available in your python session as a function::\n\n    In[4]:  f1(1.0, 2.1415)\n    Out[4]: 9.26574066397734e-05\n\n\nSee the documentation_ for further details.\n\n\n\nChangelog\n=========\n\n0.8 / 2023-06-08\n----------------\n\n- Fix use deprecating ``imp`` module (removed from Python 3.12b2)\n\n- Fix exponential duplication any not boolean flags of\n  ``%%fortran_config``\n\n- Include stored ``%%fortran_config``'s args in hashing\n\n- Don't rebuild cell if the module already loaded and hash not changed\n  (Unix don't reload already loaded shared library with same name.\n  Windows can't rewrite already loaded DLL)\n\n- Repair fortran highlighting in a ``%%fortran`` cell for ``nbclassic``\n  (Fortran highlighting for ``JupyterLab`` - unimplemented, for\n  ``IPython 3.x`` - removed)\n\n- Printing compilers diagnostics for build errors by ``%%fortran``\n  without ``-vvv`` flag\n\n`Serguei E. Leontiev`_\n\n.. _Serguei E. Leontiev: https://github.com/Serge3leo\n\n\n0.7.1 / 2023-04-12\n------------------\n\n- Synchronize version number in fortranmagic.py & setup.py (2023-04-10,\n  https://github.com/Serge3leo)\n\n- Patch fortran source in compiled object. (029d890, 2020-08-01,\n  https://github.com/mgaitan)\n\n- Fix deprecation warning (3667bc1, 2017-08-18, https://github.com/guihigashi)\n  [IPython.utils.path removed from IPython 8.x]\n\n- Simplify f2py execution. (d8a058f, 2016-06-04, https://github.com/QuLogic)\n  Don't change directories, and don't mangle `sys.argv`. The former can be\n  specified directly in the `Popen` constructor, and the latter is cruft\n  from when the f2py module was imported directly.\n\n\n0.7 / 2016-03-13\n----------------\n\n- Fix cross compatibility with older NumPy and Python 3. (15ab10c)\n\nThanks to `Elliott Sales de Andrade`_ for this contribution\n\n.. _Elliott Sales de Andrade: https://github.com/QuLogic\n\n\n0.6 / 2015-12-02\n----------------\n\n- Decode text before printing\n- Call f2py module instead of binary (numpy >=1.10 is mandatory)\n- Check if f2py command failed\n\nThanks to `Juan Luis Cano Rodr\u00edguez`_ for this contribution\n\n.. _Juan Luis Cano Rodr\u00edguez: https://github.com/Juanlu001\n\n\n0.5 / 2015-01-21\n----------------\n\n- Call f2py via subprocess. It fixes problems finding fortran compilers under Windows. (Thanks to `David Powell`_ )\n\n.. _David Powell: https://github.com/DavidPowell\n\n0.4.3 / 2013-12-09\n-------------------\n\n- Fix two python3.2+ incompatibilities (Thanks `Ramon Crehuet`_ for the report)\n\n.. _Ramon Crehuet: https://github.com/rcrehuet\n\n0.4.2 / 2013-10-08\n------------------\n\n- Implement the ``--extra`` option (Thanks to `Denis Vasilyev`_ for the help)\n- Include ``%%fortran``'s args in the hashing, so the same cell are\n  recompiled with the same code but different arguments\n\n.. _Denis Vasilyev: https://github.com/Vutshi\n\n0.3 / 2013-10-03\n------------------\n\n- Added ``%fortran_config`` to set and persist default arguments\n  for ``%%fortran``\n- Improve documentation\n\n0.2.1 / 2013-09-24\n------------------\n\n- Packaged and registered in pypi\n- Starting a version's changelog\n\n0.2 / 2013-09-19\n----------------\n\n- Fortran highlighting in a ``%%fortran`` cell\n- Works (or it should) in any platform (linux/windows/osx)\n  and with py3 (thanks to `Bradley Froehle`_)\n- Many f2py's arguments exposed as magic arguments\n- Verbosity handling\n- Improved documentation\n\n.. _Bradley Froehle: https://github.com/bfroehle\n\n0.1 / 2013-09-08\n----------------\n\n- First public release\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "An extension for IPython that help to use Fortran in your interactive session.",
    "version": "0.8",
    "project_urls": {
        "Homepage": "https://github.com/mgaitan/fortran_magic"
    },
    "split_keywords": [
        "ipython",
        "notebook",
        "fortran",
        "f2py",
        "science"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "29b45558fc0b4f7e403a4f5f43ebc88999e3b2b91e4858eb075a3cf9ad802aad",
                "md5": "d367edee75f918313e3e00d79fe3c565",
                "sha256": "af08fe345d9a0d6eb1128abb346003b0be51da43a4ba7adf97186d4cb91e5c79"
            },
            "downloads": -1,
            "filename": "fortran_magic-0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d367edee75f918313e3e00d79fe3c565",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 9293,
            "upload_time": "2023-06-16T11:02:29",
            "upload_time_iso_8601": "2023-06-16T11:02:29.444726Z",
            "url": "https://files.pythonhosted.org/packages/29/b4/5558fc0b4f7e403a4f5f43ebc88999e3b2b91e4858eb075a3cf9ad802aad/fortran_magic-0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a330a2f06c456501bf4a5f142e6fc635a87fcf21b0480653f87184b73f11da42",
                "md5": "645962109d18442a3102ae8ec2c982ea",
                "sha256": "d5dcdbbc930cd47c3fadaf34775d25934014c7adfd86392a2dfccfec663b8ac5"
            },
            "downloads": -1,
            "filename": "fortran-magic-0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "645962109d18442a3102ae8ec2c982ea",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 15054,
            "upload_time": "2023-06-16T11:02:30",
            "upload_time_iso_8601": "2023-06-16T11:02:30.994696Z",
            "url": "https://files.pythonhosted.org/packages/a3/30/a2f06c456501bf4a5f142e6fc635a87fcf21b0480653f87184b73f11da42/fortran-magic-0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-16 11:02:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mgaitan",
    "github_project": "fortran_magic",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fortran-magic"
}
        
Elapsed time: 0.07810s