array-to-latex


Namearray-to-latex JSON
Version 0.92 PyPI version JSON
download
home_pagehttps://github.com/josephcslater/array_to_latex/
SummaryReturn Numpy and Pandas arrays as formatted LaTeX arrays.
upload_time2024-06-19 14:45:38
maintainerNone
docs_urlNone
authorJoseph C. Slater
requires_pythonNone
licenseNone
keywords latex array format numpy scipy
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            Convert NumPy/SciPy arrays and Pandas Dataframes to formatted LaTeX arrays
==========================================================================

.. image:: https://badge.fury.io/py/array-to-latex.png/
    :target: http://badge.fury.io/py/array-to-latex

.. image:: https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg
    :target: https://saythanks.io/to/josephcslater

.. image:: http://pepy.tech/badge/array-to-latex
   :target: http://pepy.tech/project/array-to-latex
   :alt: PyPi Download stats

.. image:: https://mybinder.org/badge_logo.svg
   :target: https://mybinder.org/v2/gh/josephcslater/array_to_latex/master?filepath=Examples.ipynb

The module ``array_to_latex`` converts a NumPy/SciPy array or Pandas Numerical DataFrame to a LaTeX 
array or table using `Python 3.x style`_ formatting of the result or a format usable for plotting within LaTeX using pgfplots. Note that as of *0.83* it **does** add 
the column formatting arguments (for example, `{ccc...}`) when the user chooses to use `array`. I'm happy 
to have someone create a better solution but this at least makes a copied array immediately usable. I 
prefer `bmatrix` or similar. `

Play with it on `mybinder.org`_!

A NumPy-focused re-envisioned converter based, in part, on this is 
`numpyarray_to_latex <https://github.com/benmaier/numpyarray_to_latex>`_. Also, available 
*pip install*. It incorporates more sophisticated "sub" markup capabilities. Check it out!

Recent updates follow, with a more complete list towards the end of this document. If you don't see the current version in this list it's likely because I (again) forgot to update it when pushing out a new version. Please see the `readme`_ on GitHub.

| *0.81*: Bug fixes in requirements and to_clp
| *0.82*: Raise ImportError exception when incorrect datatype used.
| *0.83*: Now puts a default format in when returning as an `array` object.
| *0.90*: Add ``coords`` format for use in plotting within LaTeX using pgfplots.
| *0.91*: Improve the output for scientific `e` notation.
| *0.92*: Allow np.array consisting of strings to be converted (Thanks to Tesla2000)

Install using ``pip install --user array_to_latex`` from your command prompt, **not the Python prompt**.

Please read the help. It explains all options. To try it, see `the online mybinder.org demo <https://mybinder.org/v2/gh/josephcslater/array_to_latex/master?filepath=Examples.ipynb>`_. It documents illustrates application to numerical Pandas DataFrames.

.. code:: python

    import numpy as np
    import array_to_latex as a2l
    A = np.array([[1.23456, 23.45678],[456.23, 8.239521]])
    a2l.to_ltx(A, frmt = '{:6.2f}', arraytype = 'array')

will print the LaTeX code to your output.

.. code:: python

    import numpy as np
    import array_to_latex as a2l
    A = np.array([[1.23456, 23.45678],[456.23, 8.239521]])
    latex_code = a2l.to_ltx(A, frmt = '{:6.2f}', arraytype = 'bmatrix', print_out=False)

will put the LaTeX code into variable ``latex_code``.

.. code:: python

    import numpy as np
    import array_to_latex as a2l
    A = np.array([[1.23456, 23.45678],[456.23, 8.239521]])
    a2l.to_clp(A, frmt = '{:6.2f}', arraytype = 'bmatrix')

will put the array onto your clipboard.

If you will be using the same conversion over and over, you can define your own by using a ``lambda`` function:

.. code:: python

    to_tex = lambda A : a2l.to_ltx(A, frmt = '{:6.2f}', arraytype = 'bmatrix', mathform=True)
    to_tex(A)

so you can now use your function ``to_tex`` repeatedly with your specified settings. More detailed information on usage is in the help.

.. code:: python

    import array_to_latex as a2l
    help(a2l.to_ltx)

Interesting alternative approaches are `np_array_to_latex <https://github.com/bbercovici/np_array_to_latex>`_ and `tab2latex (convert numpy array to longtable file) <https://pypi.org/project/tab2latex/>`_.

Like this module, `buy me a coffee! <https://www.buymeacoffee.com/s6BCSuEiU>`_. 

| *New in* 0.37: Now handles complex arrays.
| *New in* 0.38: Aligns columns neatly.
| **0.40: Critical upgrade- 0.37-0.38 formatted incorrectly.**
| **0.41: Critical upgrade- 0.37-0.40 formatted incorrectly.**
| *New in* 0.43: Now handles 1-D Arrays. See new option ``row``
| *New in* 0.50: Now works with Pandas DataFrames
| *0.51*: Bug fix- remove extra blank lines in DataFrame tabular output
| *0.52*: A few documentation typos fixed. No code changed.
| *0.60*: Now handles strings in Pandas Dataframes. Fixes bug in exponentials and handling of exponentials. Please report errors!
| *0.61*: Minor documentation improvements. No code changed.
| *0.70*: Added ``mathform``. When set to ``True`` (default), returns 10 to superscript form.
| *0.71*: Line breaks broke ``readme.rst`` on ``pypi``. No code change.
| *0.72*: Line breaks broke ``readme.rst`` on ``pypi``. No code change.
| *0.73*: pypi won't handle mathjax. It makes me sad. No code change.
| *0.74*: Not released
| *0.75*: output improvements (short-lived release)
| *0.76*: Printing made better, allows outputs, added ``print_out``
|         boolean to turn off printing
| *0.80*: Return to previous interface while still enabling returned
|         LaTeX string.
| *0.81*: Bug fixes in requirements and to_clp
| *0.82*: Raise ImportError exception when incorrect datatype used.
| *0.83*: Add formatting defaults when using array versus bmatrix, etc.
| *0.90*: Add ``coords`` format for use in plotting within LaTeX using pgfplots.
| *0.91*: Improve the output for scientific `e` notation.
| *0.92*: Allow np.array consisting of strings to be converted (Thanks to Tesla2000)


.. _`Python 3.x style`: https://docs.python.org/3.7/library/string.html
.. _`mybinder.org`: https://mybinder.org/v2/gh/josephcslater/array_to_latex/master?filepath=Examples.ipynb
.. _`readme`: https://github.com/josephcslater/array_to_latex/blob/master/README.rst

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/josephcslater/array_to_latex/",
    "name": "array-to-latex",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "latex, array, format, numpy, scipy",
    "author": "Joseph C. Slater",
    "author_email": "joseph.c.slater@gmail.com",
    "download_url": null,
    "platform": null,
    "description": "Convert NumPy/SciPy arrays and Pandas Dataframes to formatted LaTeX arrays\n==========================================================================\n\n.. image:: https://badge.fury.io/py/array-to-latex.png/\n    :target: http://badge.fury.io/py/array-to-latex\n\n.. image:: https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg\n    :target: https://saythanks.io/to/josephcslater\n\n.. image:: http://pepy.tech/badge/array-to-latex\n   :target: http://pepy.tech/project/array-to-latex\n   :alt: PyPi Download stats\n\n.. image:: https://mybinder.org/badge_logo.svg\n   :target: https://mybinder.org/v2/gh/josephcslater/array_to_latex/master?filepath=Examples.ipynb\n\nThe module ``array_to_latex`` converts a NumPy/SciPy array or Pandas Numerical DataFrame to a LaTeX \narray or table using `Python 3.x style`_ formatting of the result or a format usable for plotting within LaTeX using pgfplots. Note that as of *0.83* it **does** add \nthe column formatting arguments (for example, `{ccc...}`) when the user chooses to use `array`. I'm happy \nto have someone create a better solution but this at least makes a copied array immediately usable. I \nprefer `bmatrix` or similar. `\n\nPlay with it on `mybinder.org`_!\n\nA NumPy-focused re-envisioned converter based, in part, on this is \n`numpyarray_to_latex <https://github.com/benmaier/numpyarray_to_latex>`_. Also, available \n*pip install*. It incorporates more sophisticated \"sub\" markup capabilities. Check it out!\n\nRecent updates follow, with a more complete list towards the end of this document. If you don't see the current version in this list it's likely because I (again) forgot to update it when pushing out a new version. Please see the `readme`_ on GitHub.\n\n| *0.81*: Bug fixes in requirements and to_clp\n| *0.82*: Raise ImportError exception when incorrect datatype used.\n| *0.83*: Now puts a default format in when returning as an `array` object.\n| *0.90*: Add ``coords`` format for use in plotting within LaTeX using pgfplots.\n| *0.91*: Improve the output for scientific `e` notation.\n| *0.92*: Allow np.array consisting of strings to be converted (Thanks to Tesla2000)\n\nInstall using ``pip install --user array_to_latex`` from your command prompt, **not the Python prompt**.\n\nPlease read the help. It explains all options. To try it, see `the online mybinder.org demo <https://mybinder.org/v2/gh/josephcslater/array_to_latex/master?filepath=Examples.ipynb>`_. It documents illustrates application to numerical Pandas DataFrames.\n\n.. code:: python\n\n    import numpy as np\n    import array_to_latex as a2l\n    A = np.array([[1.23456, 23.45678],[456.23, 8.239521]])\n    a2l.to_ltx(A, frmt = '{:6.2f}', arraytype = 'array')\n\nwill print the LaTeX code to your output.\n\n.. code:: python\n\n    import numpy as np\n    import array_to_latex as a2l\n    A = np.array([[1.23456, 23.45678],[456.23, 8.239521]])\n    latex_code = a2l.to_ltx(A, frmt = '{:6.2f}', arraytype = 'bmatrix', print_out=False)\n\nwill put the LaTeX code into variable ``latex_code``.\n\n.. code:: python\n\n    import numpy as np\n    import array_to_latex as a2l\n    A = np.array([[1.23456, 23.45678],[456.23, 8.239521]])\n    a2l.to_clp(A, frmt = '{:6.2f}', arraytype = 'bmatrix')\n\nwill put the array onto your clipboard.\n\nIf you will be using the same conversion over and over, you can define your own by using a ``lambda`` function:\n\n.. code:: python\n\n    to_tex = lambda A : a2l.to_ltx(A, frmt = '{:6.2f}', arraytype = 'bmatrix', mathform=True)\n    to_tex(A)\n\nso you can now use your function ``to_tex`` repeatedly with your specified settings. More detailed information on usage is in the help.\n\n.. code:: python\n\n    import array_to_latex as a2l\n    help(a2l.to_ltx)\n\nInteresting alternative approaches are `np_array_to_latex <https://github.com/bbercovici/np_array_to_latex>`_ and `tab2latex (convert numpy array to longtable file) <https://pypi.org/project/tab2latex/>`_.\n\nLike this module, `buy me a coffee! <https://www.buymeacoffee.com/s6BCSuEiU>`_. \n\n| *New in* 0.37: Now handles complex arrays.\n| *New in* 0.38: Aligns columns neatly.\n| **0.40: Critical upgrade- 0.37-0.38 formatted incorrectly.**\n| **0.41: Critical upgrade- 0.37-0.40 formatted incorrectly.**\n| *New in* 0.43: Now handles 1-D Arrays. See new option ``row``\n| *New in* 0.50: Now works with Pandas DataFrames\n| *0.51*: Bug fix- remove extra blank lines in DataFrame tabular output\n| *0.52*: A few documentation typos fixed. No code changed.\n| *0.60*: Now handles strings in Pandas Dataframes. Fixes bug in exponentials and handling of exponentials. Please report errors!\n| *0.61*: Minor documentation improvements. No code changed.\n| *0.70*: Added ``mathform``. When set to ``True`` (default), returns 10 to superscript form.\n| *0.71*: Line breaks broke ``readme.rst`` on ``pypi``. No code change.\n| *0.72*: Line breaks broke ``readme.rst`` on ``pypi``. No code change.\n| *0.73*: pypi won't handle mathjax. It makes me sad. No code change.\n| *0.74*: Not released\n| *0.75*: output improvements (short-lived release)\n| *0.76*: Printing made better, allows outputs, added ``print_out``\n|         boolean to turn off printing\n| *0.80*: Return to previous interface while still enabling returned\n|         LaTeX string.\n| *0.81*: Bug fixes in requirements and to_clp\n| *0.82*: Raise ImportError exception when incorrect datatype used.\n| *0.83*: Add formatting defaults when using array versus bmatrix, etc.\n| *0.90*: Add ``coords`` format for use in plotting within LaTeX using pgfplots.\n| *0.91*: Improve the output for scientific `e` notation.\n| *0.92*: Allow np.array consisting of strings to be converted (Thanks to Tesla2000)\n\n\n.. _`Python 3.x style`: https://docs.python.org/3.7/library/string.html\n.. _`mybinder.org`: https://mybinder.org/v2/gh/josephcslater/array_to_latex/master?filepath=Examples.ipynb\n.. _`readme`: https://github.com/josephcslater/array_to_latex/blob/master/README.rst\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Return Numpy and Pandas arrays as formatted LaTeX arrays.",
    "version": "0.92",
    "project_urls": {
        "Homepage": "https://github.com/josephcslater/array_to_latex/"
    },
    "split_keywords": [
        "latex",
        " array",
        " format",
        " numpy",
        " scipy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "46fc36f04896f937329af390a66067070bae2ec7c2511286359a00ff16bca924",
                "md5": "3b18b9f88aed6cdb4456369bad30eb48",
                "sha256": "1a476781d4149161421472a9078095bf9ed26ba08a810ab4ffe4a937e8318de7"
            },
            "downloads": -1,
            "filename": "array_to_latex-0.92-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3b18b9f88aed6cdb4456369bad30eb48",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5971,
            "upload_time": "2024-06-19T14:45:38",
            "upload_time_iso_8601": "2024-06-19T14:45:38.351522Z",
            "url": "https://files.pythonhosted.org/packages/46/fc/36f04896f937329af390a66067070bae2ec7c2511286359a00ff16bca924/array_to_latex-0.92-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-19 14:45:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "josephcslater",
    "github_project": "array_to_latex",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "array-to-latex"
}
        
Elapsed time: 0.27125s