tidypath


Nametidypath JSON
Version 1.4.9 PyPI version JSON
download
home_pagehttps://github.com/medinajorge/tidypath
SummaryAutomatically store/load data in a tidy, efficient way.
upload_time2024-10-31 11:52:50
maintainerNone
docs_urlNone
authorJorge Medina Hernández
requires_python>=3
licenseNone
keywords tidy project organization project organization path storage
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Tidypath

For people that have to compute and store a large variety of data and/or figures.

## Keep your files tidy!

Don't spend time creating directories, deciding filenames, saving, loading, etc. Decorators `savefig` & `savedata` will do it for you.

- `savedata` computes output and stores it in the first function call. Future calls reads it from memory. Default LZMA compression
- `savefig`  saves output figure.

Although recommended, it is not needed to start a new project using `tidypath`. You can continue using your previous code and apply `tidypath` on new code.

### savedata
Example function `slow_computation` in module `package.subpackages.module`
```
@savedata("x+z")
def slow_computation(x, y, *args, z=1, **kwargs):
    ...
    return result
```
1. Apply to function (result of any type).
2. Choose the variables to record in the filenames.
3. Optionally, choose file extension and other specifications. Supported: `lzma` (default), `bz2`, `npz`, `csv`, `JSON`.
4. Result will be saved at `data/subpackages/module/slow_computation/x-'x'_z-'z'_.lzma` ('x' = value of x passed to `slow_computation` during call)
5. If you want to recompute and overwrite, you can pass `overwrite=True` to `slow_computation`. The decorator adds the arguments: `save`, `overwrite`, `keys` and `funcname_in_filename`.

### savefig
```
@savefig("kwargs")
def plot_results(*args, **kwargs):
    ...
    return figure
```
- Same steps as  `savedata`. Only difference is the output type.
- Supports `matplotlib` and `plotly` and all figure extensions (`png`, `eps`, ...) including `html` (`plotly`).
- Decorator adds the same arguments as `savedata` plus `return_fig` (`bool`).

### Adaptable to code modifications
Caching data depends on the specific variables set to store, since they define the filenames. Suppose we want to add a new variable `method` indicating a new method for computing the results, but already computed results are still useful. We can

1. Modify the variables to record in the `savedata` decorator:

        @savedata("x+z")     =>    @savedata("x+z+method")

2. Assign `method='original'` to all existing pre-computed files:

        add_arg(slow_computation, method='original')
    
3. Now access is granted for the already computed data, and data corresponding to new methods will be stored in separate files.

Use the functions `add_arg`, `modify_arg`, `delete_arg` to ensure cached data is loaded after modifying function arguments.

## Example
- [Defining functions](https://github.com/medinajorge/tidypath/blob/master/tests/analysis/variable1/measurement1.py)
- [Calling functions & modifying args](https://github.com/medinajorge/tidypath/blob/master/tests/Example.ipynb)

## Docs
[Github pages](https://medinajorge.github.io/tidypath/)

## Install
    pip install tidypath

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/medinajorge/tidypath",
    "name": "tidypath",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": null,
    "keywords": "tidy, project organization, project, organization, path, storage",
    "author": "Jorge Medina Hern\u00e1ndez",
    "author_email": "medinahdezjorge@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/64/4c/a02ef40af146564b37cfa3a241ee19a38c554611e77928d74cabad6d56c4/tidypath-1.4.9.tar.gz",
    "platform": null,
    "description": "# Tidypath\n\nFor people that have to compute and store a large variety of data and/or figures.\n\n## Keep your files tidy!\n\nDon't spend time creating directories, deciding filenames, saving, loading, etc. Decorators `savefig` & `savedata` will do it for you.\n\n- `savedata` computes output and stores it in the first function call. Future calls reads it from memory. Default LZMA compression\n- `savefig`  saves output figure.\n\nAlthough recommended, it is not needed to start a new project using `tidypath`. You can continue using your previous code and apply `tidypath` on new code.\n\n### savedata\nExample function `slow_computation` in module `package.subpackages.module`\n```\n@savedata(\"x+z\")\ndef slow_computation(x, y, *args, z=1, **kwargs):\n    ...\n    return result\n```\n1. Apply to function (result of any type).\n2. Choose the variables to record in the filenames.\n3. Optionally, choose file extension and other specifications. Supported: `lzma` (default), `bz2`, `npz`, `csv`, `JSON`.\n4. Result will be saved at `data/subpackages/module/slow_computation/x-'x'_z-'z'_.lzma` ('x' = value of x passed to `slow_computation` during call)\n5. If you want to recompute and overwrite, you can pass `overwrite=True` to `slow_computation`. The decorator adds the arguments: `save`, `overwrite`, `keys` and `funcname_in_filename`.\n\n### savefig\n```\n@savefig(\"kwargs\")\ndef plot_results(*args, **kwargs):\n    ...\n    return figure\n```\n- Same steps as  `savedata`. Only difference is the output type.\n- Supports `matplotlib` and `plotly` and all figure extensions (`png`, `eps`, ...) including `html` (`plotly`).\n- Decorator adds the same arguments as `savedata` plus `return_fig` (`bool`).\n\n### Adaptable to code modifications\nCaching data depends on the specific variables set to store, since they define the filenames. Suppose we want to add a new variable `method` indicating a new method for computing the results, but already computed results are still useful. We can\n\n1. Modify the variables to record in the `savedata` decorator:\n\n        @savedata(\"x+z\")     =>    @savedata(\"x+z+method\")\n\n2. Assign `method='original'` to all existing pre-computed files:\n\n        add_arg(slow_computation, method='original')\n    \n3. Now access is granted for the already computed data, and data corresponding to new methods will be stored in separate files.\n\nUse the functions `add_arg`, `modify_arg`, `delete_arg` to ensure cached data is loaded after modifying function arguments.\n\n## Example\n- [Defining functions](https://github.com/medinajorge/tidypath/blob/master/tests/analysis/variable1/measurement1.py)\n- [Calling functions & modifying args](https://github.com/medinajorge/tidypath/blob/master/tests/Example.ipynb)\n\n## Docs\n[Github pages](https://medinajorge.github.io/tidypath/)\n\n## Install\n    pip install tidypath\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Automatically store/load data in a tidy, efficient way.",
    "version": "1.4.9",
    "project_urls": {
        "Download": "https://github.com/medinajorge/tidypath/archive/refs/tags/v1.4.5.tar.gz",
        "Homepage": "https://github.com/medinajorge/tidypath"
    },
    "split_keywords": [
        "tidy",
        " project organization",
        " project",
        " organization",
        " path",
        " storage"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "644ca02ef40af146564b37cfa3a241ee19a38c554611e77928d74cabad6d56c4",
                "md5": "98660618dd5bae624c0a123c8b6f3b05",
                "sha256": "9922708f4afec08ac3ccb9e2113448238aaeac4b9dbf8cb7a855e87699edd58b"
            },
            "downloads": -1,
            "filename": "tidypath-1.4.9.tar.gz",
            "has_sig": false,
            "md5_digest": "98660618dd5bae624c0a123c8b6f3b05",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 30917,
            "upload_time": "2024-10-31T11:52:50",
            "upload_time_iso_8601": "2024-10-31T11:52:50.466668Z",
            "url": "https://files.pythonhosted.org/packages/64/4c/a02ef40af146564b37cfa3a241ee19a38c554611e77928d74cabad6d56c4/tidypath-1.4.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-31 11:52:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "medinajorge",
    "github_project": "tidypath",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "tidypath"
}
        
Elapsed time: 0.34652s