tidypath


Nametidypath JSON
Version 1.3.6 PyPI version JSON
download
home_pagehttps://github.com/medinajorge/tidypath
SummaryAutomatically store/load data in a tidy, efficient way.
upload_time2024-04-26 08:35:49
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/96/61/f407034d6be6abf300d63a4729c087d63f9e4f5252240a8b47a071ebd9e5/tidypath-1.3.6.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.3.6",
    "project_urls": {
        "Download": "https://github.com/medinajorge/tidypath/archive/refs/tags/v1.0.5.tar.gz",
        "Homepage": "https://github.com/medinajorge/tidypath"
    },
    "split_keywords": [
        "tidy",
        " project organization",
        " project",
        " organization",
        " path",
        " storage"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9661f407034d6be6abf300d63a4729c087d63f9e4f5252240a8b47a071ebd9e5",
                "md5": "c511178ec471545089b031e845c49572",
                "sha256": "b041f4bdf0f90096266ce5e24faf3ba30c7809311ab709d1bb302b4cdedd8a37"
            },
            "downloads": -1,
            "filename": "tidypath-1.3.6.tar.gz",
            "has_sig": false,
            "md5_digest": "c511178ec471545089b031e845c49572",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 30596,
            "upload_time": "2024-04-26T08:35:49",
            "upload_time_iso_8601": "2024-04-26T08:35:49.059504Z",
            "url": "https://files.pythonhosted.org/packages/96/61/f407034d6be6abf300d63a4729c087d63f9e4f5252240a8b47a071ebd9e5/tidypath-1.3.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-26 08:35:49",
    "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.24975s