resultwizard


Nameresultwizard JSON
Version 0.1 PyPI version JSON
download
home_page
SummaryIntelligent interface between Python-computed values and your LaTeX work
upload_time2024-03-16 23:00:42
maintainer
docs_urlNone
authorPaul Obernolte (paul019), Dominic Plein (Splines)
requires_python>=3.8
licenseMIT License Copyright (c) 2023-2024 Paul Obernolte (paul019), Dominic Plein (Splines) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords latex variable science result value rounding significant figures jupyter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
  <img src="https://github.com/paul019/ResultWizard/assets/37160523/8576038a-3867-470b-8f42-90b60ea92042" width="120px" />
  <div align="center">
    <h3 align="center">ResultWizard</h3>
    <p><strong>Intelligent interface between Python-computed values and your LaTeX work</strong></p>
  </div>
</div>

> [!important]  
> ResultWizard is currently fully functional but still in its *alpha* stage. We're happy to receive your feedback. Basic usage is as follows. A more comprehensive documentation will be available as soon as the package is stable.


## Installation & usage
Install the package via pip.

```sh
pip install resultwizard
```

Then you can use `ResultWizard` in your Python code:

```python
import resultwizard as wiz
wiz.config_init(print_auto=True)

# your complex calculations
# ...
value = 42.0
uncertainty = 3.14
wiz.res("length atom", value, uncertainty, r"\per\mm\cubed")

wiz.export("results.tex")
```

Then add the following line to your LaTeX document right before `\begin{document}`:

```
\input{results.tex}
```

Note that `ResultWizard` requires the following LaTeX packages: [`siunitx`](https://ctan.org/pkg/siunitx) and [`ifthen`](https://ctan.org/pkg/ifthen). They are imported in the `results.tex` file via `\usepackage{...}` statements. The package `ifthen` is always presented in a LaTeX distribution. You may have to install the `siunitx` package, which is a widely used package in the scientific community to typeset units, e.g. you can use strings like `\kg\per\cm`.

You can now go ahead and reference the variable in your LaTeX document in any math environment, e.g.:

```latex
\begin{align}
    \resLengthAtom
\end{align}
```

You can also only use a specific part of the result, e.g. the unit, the value itself etc.

```latex
\begin{align}
    \resLengthAtom[unit]
\end{align}
```


## Troubleshooting: LaTeX doesn't build

If your LaTeX document doesn't build, there might be several reasons. Try to find out what's wrong by looking at the log file of your LaTeX compiler (sometimes you have to scroll way up to find the error responsible for the failing build). Also open the `results.tex` file to see if your editor/IDE shows any errors there. You might encounter one of the following errors:

> [!WARNING] 
> This troubleshooting section does not yet apply to the first alpha release of `ResultWizard`. It's just here for one of the next alpha versions.

<details>

<summary><strong>Package siunitx: Invalid number.</strong></summary>

TL;DR: You have an **old version of `siunitx`**. Please update it or use the `siunitx_fallback` option in the `config_init` method.

In version [`v3.1.0 (2022-04-25)`](https://github.com/josephwright/siunitx/blob/main/CHANGELOG.md#v310---2022-04-25), `siunitx` introduced "support for multiple uncertainty values in both short and long form in input". We make use of this feature in `ResultWizard`.

Unfortunately, it may be the case that you're using an older version of `siunitx`. Especially if you've installed LaTeX via a package manager (e.g. you installed `siunitx` via `sudo apt install texlive-science`). To determine your version, include the following line in your LaTeX document:

```latex
\listfiles % add this before \begin{document}
```

Then, compile your document and check the log for the version of `siunitx`. If it's older than `v3.1.0 (2022-04-25)`, don't despair. We have two solutions for you:

**Solution 1: Don't update `siunitx` and stick with your old version**

Sure, fine, we won't force you to update `siunitx` (although we'd recommend it). To keep using your old version, specify the following key in the `config_init` method:

```python
wiz.config_init(siunitx_fallback=True)
```

Note that with this "solution", you won't be able to fully customize the output of the result in your LaTeX document. For example, we will use a `±` between the value and the uncertainty, e.g. `3.14 ± 0.02`. You won't be able to change this in your `sisetup` by doing:

```latex
\sisetup{separate-uncertainty=false}
```

to get another format like `3.14(2)`. There are also some [other `siunitx` options](https://texdoc.org/serve/siunitx/0) that won't work with `ResultWizard`, e.g. `exponent-product`. If you're fine with this, go ahead and use the `siunitx_fallback` option. If not, consider updating `siunitx` to at least version `v3.1.0`.

**Solution 2: Update `siunitx` (recommended)**

How the update process works depends on your LaTeX distribution and how you installed it. E.g. you might be using `TeX Live` on `Ubuntu` and installed packages via `apt`, e.g. `sudo apt install texlive-science` (which includes the LaTeX `siunitx`). These pre-built packages are often outdated, e.g. for Ubuntu 22.04 LTS (jammy), the `siunitx` package that comes with the `texlive-science` package is `3.0.4`. Therefore, you might have to update `siunitx` manually. See an overview on how to install individual LaTeX packages on Linux [here](https://tex.stackexchange.com/a/73017/).

A quick solution might be to simply install a new version of `siunitx` manually to your system. There's a great and short Ubuntu guide on how to install LaTeX packages manually [here](https://help.ubuntu.com/community/LaTeX#Installing_packages_manually). The following commands are based on this guide. We will download the version `3.1.11 (2022-12-05)` from GitHub (this is the last version before `3.2` where things might get more complicated to install) and install it locally. Nothing too fancy. Execute the following commands in your terminal:

```sh
# Install "unzip", a tool to extract zip files
sudo apt install unzip

# Download v3.1.11 of siunitx from GitHub
curl -L https://github.com/josephwright/siunitx/releases/download/v3.1.11/siunitx-ctan.zip > siunitx-ctan-3.1.11.zip

# Unzip the file
unzip ./siunitx-ctan-3.1.11.zip
cd siunitx/

# Run LaTeX on the .ins file to produce a usable .sty file
# (The .sty file is needed when you use \usepackage{siunitx}
# in your LaTeX document)
latex siunitx.ins

# Create a new directory in your home directory
# to store the new package .sty file
mkdir -p ~/texmf/tex/latex/siunitx
cp siunitx.sty ~/texmf/tex/latex/siunitx/

# Make LaTeX recognize the new package by pointing it to the new directory
texhash ~/texmf/

# 🙌 Done. Try to rebuild your LaTeX document again.

# If you don't wan't the new siunitx version anymore, just run the following
# command to remove the .sty file. LaTeX will then use the version of siunitx
# it finds somewhere else in your system.
rm ~/texmf/tex/latex/siunitx/siunitx.sty
```

Compiling your latex document again, you should see version `v3.1.11` of `siunitx` in the log file. And it should build, yeah 🎉. Don't forget to remove the `\listfiles` from your LaTeX document to avoid cluttering your log file (which is ironic for LaTeX, we know).

</details>

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "resultwizard",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "latex,variable,science,result,value,rounding,significant figures,jupyter",
    "author": "Paul Obernolte (paul019), Dominic Plein (Splines)",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/ea/e2/0036ad6d0a92b9dfbd5b8bf167e04835a368dadf38144986603ce7cc6e72/resultwizard-0.1.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n  <img src=\"https://github.com/paul019/ResultWizard/assets/37160523/8576038a-3867-470b-8f42-90b60ea92042\" width=\"120px\" />\n  <div align=\"center\">\n    <h3 align=\"center\">ResultWizard</h3>\n    <p><strong>Intelligent interface between Python-computed values and your LaTeX work</strong></p>\n  </div>\n</div>\n\n> [!important]  \n> ResultWizard is currently fully functional but still in its *alpha* stage. We're happy to receive your feedback. Basic usage is as follows. A more comprehensive documentation will be available as soon as the package is stable.\n\n\n## Installation & usage\nInstall the package via pip.\n\n```sh\npip install resultwizard\n```\n\nThen you can use `ResultWizard` in your Python code:\n\n```python\nimport resultwizard as wiz\nwiz.config_init(print_auto=True)\n\n# your complex calculations\n# ...\nvalue = 42.0\nuncertainty = 3.14\nwiz.res(\"length atom\", value, uncertainty, r\"\\per\\mm\\cubed\")\n\nwiz.export(\"results.tex\")\n```\n\nThen add the following line to your LaTeX document right before `\\begin{document}`:\n\n```\n\\input{results.tex}\n```\n\nNote that `ResultWizard` requires the following LaTeX packages: [`siunitx`](https://ctan.org/pkg/siunitx) and [`ifthen`](https://ctan.org/pkg/ifthen). They are imported in the `results.tex` file via `\\usepackage{...}` statements. The package `ifthen` is always presented in a LaTeX distribution. You may have to install the `siunitx` package, which is a widely used package in the scientific community to typeset units, e.g. you can use strings like `\\kg\\per\\cm`.\n\nYou can now go ahead and reference the variable in your LaTeX document in any math environment, e.g.:\n\n```latex\n\\begin{align}\n    \\resLengthAtom\n\\end{align}\n```\n\nYou can also only use a specific part of the result, e.g. the unit, the value itself etc.\n\n```latex\n\\begin{align}\n    \\resLengthAtom[unit]\n\\end{align}\n```\n\n\n## Troubleshooting: LaTeX doesn't build\n\nIf your LaTeX document doesn't build, there might be several reasons. Try to find out what's wrong by looking at the log file of your LaTeX compiler (sometimes you have to scroll way up to find the error responsible for the failing build). Also open the `results.tex` file to see if your editor/IDE shows any errors there. You might encounter one of the following errors:\n\n> [!WARNING] \n> This troubleshooting section does not yet apply to the first alpha release of `ResultWizard`. It's just here for one of the next alpha versions.\n\n<details>\n\n<summary><strong>Package siunitx: Invalid number.</strong></summary>\n\nTL;DR: You have an **old version of `siunitx`**. Please update it or use the `siunitx_fallback` option in the `config_init` method.\n\nIn version [`v3.1.0 (2022-04-25)`](https://github.com/josephwright/siunitx/blob/main/CHANGELOG.md#v310---2022-04-25), `siunitx` introduced \"support for multiple uncertainty values in both short and long form in input\". We make use of this feature in `ResultWizard`.\n\nUnfortunately, it may be the case that you're using an older version of `siunitx`. Especially if you've installed LaTeX via a package manager (e.g. you installed `siunitx` via `sudo apt install texlive-science`). To determine your version, include the following line in your LaTeX document:\n\n```latex\n\\listfiles % add this before \\begin{document}\n```\n\nThen, compile your document and check the log for the version of `siunitx`. If it's older than `v3.1.0 (2022-04-25)`, don't despair. We have two solutions for you:\n\n**Solution 1: Don't update `siunitx` and stick with your old version**\n\nSure, fine, we won't force you to update `siunitx` (although we'd recommend it). To keep using your old version, specify the following key in the `config_init` method:\n\n```python\nwiz.config_init(siunitx_fallback=True)\n```\n\nNote that with this \"solution\", you won't be able to fully customize the output of the result in your LaTeX document. For example, we will use a `\u00b1` between the value and the uncertainty, e.g. `3.14 \u00b1 0.02`. You won't be able to change this in your `sisetup` by doing:\n\n```latex\n\\sisetup{separate-uncertainty=false}\n```\n\nto get another format like `3.14(2)`. There are also some [other `siunitx` options](https://texdoc.org/serve/siunitx/0) that won't work with `ResultWizard`, e.g. `exponent-product`. If you're fine with this, go ahead and use the `siunitx_fallback` option. If not, consider updating `siunitx` to at least version `v3.1.0`.\n\n**Solution 2: Update `siunitx` (recommended)**\n\nHow the update process works depends on your LaTeX distribution and how you installed it. E.g. you might be using `TeX Live` on `Ubuntu` and installed packages via `apt`, e.g. `sudo apt install texlive-science` (which includes the LaTeX `siunitx`). These pre-built packages are often outdated, e.g. for Ubuntu 22.04 LTS (jammy), the `siunitx` package that comes with the `texlive-science` package is `3.0.4`. Therefore, you might have to update `siunitx` manually. See an overview on how to install individual LaTeX packages on Linux [here](https://tex.stackexchange.com/a/73017/).\n\nA quick solution might be to simply install a new version of `siunitx` manually to your system. There's a great and short Ubuntu guide on how to install LaTeX packages manually [here](https://help.ubuntu.com/community/LaTeX#Installing_packages_manually). The following commands are based on this guide. We will download the version `3.1.11 (2022-12-05)` from GitHub (this is the last version before `3.2` where things might get more complicated to install) and install it locally. Nothing too fancy. Execute the following commands in your terminal:\n\n```sh\n# Install \"unzip\", a tool to extract zip files\nsudo apt install unzip\n\n# Download v3.1.11 of siunitx from GitHub\ncurl -L https://github.com/josephwright/siunitx/releases/download/v3.1.11/siunitx-ctan.zip > siunitx-ctan-3.1.11.zip\n\n# Unzip the file\nunzip ./siunitx-ctan-3.1.11.zip\ncd siunitx/\n\n# Run LaTeX on the .ins file to produce a usable .sty file\n# (The .sty file is needed when you use \\usepackage{siunitx}\n# in your LaTeX document)\nlatex siunitx.ins\n\n# Create a new directory in your home directory\n# to store the new package .sty file\nmkdir -p ~/texmf/tex/latex/siunitx\ncp siunitx.sty ~/texmf/tex/latex/siunitx/\n\n# Make LaTeX recognize the new package by pointing it to the new directory\ntexhash ~/texmf/\n\n# \ud83d\ude4c Done. Try to rebuild your LaTeX document again.\n\n# If you don't wan't the new siunitx version anymore, just run the following\n# command to remove the .sty file. LaTeX will then use the version of siunitx\n# it finds somewhere else in your system.\nrm ~/texmf/tex/latex/siunitx/siunitx.sty\n```\n\nCompiling your latex document again, you should see version `v3.1.11` of `siunitx` in the log file. And it should build, yeah \ud83c\udf89. Don't forget to remove the `\\listfiles` from your LaTeX document to avoid cluttering your log file (which is ironic for LaTeX, we know).\n\n</details>\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023-2024 Paul Obernolte (paul019), Dominic Plein (Splines)  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Intelligent interface between Python-computed values and your LaTeX work",
    "version": "0.1",
    "project_urls": {
        "Changelog": "https://github.com/paul019/ResultWizard/blob/main/CHANGELOG.md",
        "Homepage": "https://github.com/paul019/ResultWizard",
        "Issues": "https://github.com/paul019/ResultWizard/issues",
        "Repository": "https://github.com/paul019/ResultWizard"
    },
    "split_keywords": [
        "latex",
        "variable",
        "science",
        "result",
        "value",
        "rounding",
        "significant figures",
        "jupyter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ca454f8c4ee2c8670cca372e5d9e995b23765025bdadece0e14cd7244b41d8f7",
                "md5": "6cafb900692a691dce099e860b84bba8",
                "sha256": "66fa2983e290b89b3073f8db1d4b712b83011f0fdfc1c35905116632504584c7"
            },
            "downloads": -1,
            "filename": "resultwizard-0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6cafb900692a691dce099e860b84bba8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 20306,
            "upload_time": "2024-03-16T23:00:41",
            "upload_time_iso_8601": "2024-03-16T23:00:41.071896Z",
            "url": "https://files.pythonhosted.org/packages/ca/45/4f8c4ee2c8670cca372e5d9e995b23765025bdadece0e14cd7244b41d8f7/resultwizard-0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eae20036ad6d0a92b9dfbd5b8bf167e04835a368dadf38144986603ce7cc6e72",
                "md5": "bb27ca4c07763052912e709783ece34e",
                "sha256": "786a10c898beec27671ef32b5c7dd9afce52973380439ee17b23504835b3ebbd"
            },
            "downloads": -1,
            "filename": "resultwizard-0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "bb27ca4c07763052912e709783ece34e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 19706,
            "upload_time": "2024-03-16T23:00:42",
            "upload_time_iso_8601": "2024-03-16T23:00:42.839607Z",
            "url": "https://files.pythonhosted.org/packages/ea/e2/0036ad6d0a92b9dfbd5b8bf167e04835a368dadf38144986603ce7cc6e72/resultwizard-0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-16 23:00:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "paul019",
    "github_project": "ResultWizard",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "resultwizard"
}
        
Elapsed time: 0.21258s