narr


Namenarr JSON
Version 0.0.1 PyPI version JSON
download
home_pagehttps://github.com/dsm-72/narr
SummaryLiteral Enum
upload_time2023-09-12 19:40:49
maintainer
docs_urlNone
authordsm-72
requires_python>=3.11
licenseApache Software License 2.0
keywords named arrays narr nymstr fuzstr synset ispec xarray xarr xarray-like numpy np
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # narr

<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

``` python
# #| hide
# from narr.strs import snake_case
# from narr.axes import NamedAxis, NamedAxes
# from narr.errs import NamedArrayDimsError
# from narr.mixs import NamedArrayDynamicAttrsMixin
# from narr.narr import NamedArray
# from narr.traj import (
#     TrajectoryDim, GeneTrajectoryDim,
#     ObservationTrajectories, FeatureTrajectories,
#     CellularTrajectories, ExpressionTrajectories,
#     Trajectories, GeneTrajectories,
# )
```

## Developer Guide

### Setup

``` sh
# create conda environment
$ mamba env create -f env.yml

# update conda environment
$ mamba env update -n narr --file env.yml
```

### Install

``` sh
pip install -e .

# install from pypi
pip install narr
```

### nbdev

``` sh
# activate conda environment
$ conda activate narr

# make sure the narr package is installed in development mode
$ pip install -e .

# make changes under nbs/ directory
# ...

# compile to have changes apply to the narr package
$ nbdev_prepare
```

### Publishing

``` sh
# publish to pypi
$ nbdev_pypi

# publish to conda
$ nbdev_conda --build_args '-c conda-forge'
$ nbdev_conda --mambabuild --build_args '-c conda-forge -c dsm-72'
```

# Usage

## Installation

Install latest from the GitHub
[repository](https://github.com/dsm-72/narr):

``` sh
$ pip install git+https://github.com/dsm-72/narr.git
```

or from [conda](https://anaconda.org/dsm-72/narr)

``` sh
$ conda install -c dsm-72 narr
```

or from [pypi](https://pypi.org/project/narr/)

``` sh
$ pip install narr
```

## Documentation

Documentation can be found hosted on GitHub
[repository](https://github.com/dsm-72/narr)
[pages](https://dsm-72.github.io/narr/). Additionally you can find
package manager specific guidelines on
[conda](https://anaconda.org/dsm-72/narr) and
[pypi](https://pypi.org/project/narr/) respectively.

``` python
# import numpy as np
# from typing import Callable
```

### Subclassing NamedArray

``` python
# class Trajectories(NamedArray):
#     DIMS = NamedAxes([NamedAxis(dim.name, i) for i, dim in enumerate(TrajectoryDim)])
    
#     def to_obsv_x_traj(self, aggr: Callable = np.mean):
#         agg_arr = aggr(np.asarray(self.transpose(
#             TrajectoryDim.obsv.name, TrajectoryDim.traj.name, TrajectoryDim.feat.name,            
#         )), axis=2)
#         return ObservationTrajectories(agg_arr)
        
#     def to_feat_x_traj(self, aggr: Callable = np.mean):
#         agg_arr = aggr(np.asarray(self.transpose(
#             TrajectoryDim.feat.name, TrajectoryDim.traj.name, TrajectoryDim.obsv.name,            
#         )), axis=2)
#         return FeatureTrajectories(agg_arr)
```

### Using NamedArray Subclass Trajectories

``` python
# arr = np.random.randint(0, 10, (3, 5, 10))
# arr
```

    array([[[9, 7, 1, 4, 8, 2, 3, 3, 3, 1],
            [0, 3, 8, 7, 2, 9, 9, 9, 1, 7],
            [0, 8, 5, 3, 3, 8, 8, 1, 3, 8],
            [3, 6, 9, 1, 8, 7, 7, 3, 1, 3],
            [0, 0, 2, 9, 1, 6, 6, 8, 1, 7]],

           [[5, 9, 5, 7, 3, 2, 1, 0, 9, 5],
            [9, 8, 7, 3, 1, 7, 6, 6, 0, 5],
            [8, 2, 9, 7, 2, 9, 4, 4, 0, 8],
            [2, 8, 2, 2, 0, 6, 6, 8, 6, 9],
            [5, 5, 2, 2, 3, 5, 9, 9, 3, 4]],

           [[3, 6, 4, 6, 3, 2, 4, 6, 9, 0],
            [7, 1, 6, 7, 7, 2, 6, 2, 2, 8],
            [2, 3, 6, 2, 5, 5, 2, 6, 2, 0],
            [3, 9, 8, 5, 1, 5, 7, 8, 7, 9],
            [9, 2, 1, 5, 2, 7, 0, 7, 4, 3]]])

``` python
# Trajectories(arr)
```

    Trajectories([[[9, 7, 1, 4, 8, 2, 3, 3, 3, 1],
                   [0, 3, 8, 7, 2, 9, 9, 9, 1, 7],
                   [0, 8, 5, 3, 3, 8, 8, 1, 3, 8],
                   [3, 6, 9, 1, 8, 7, 7, 3, 1, 3],
                   [0, 0, 2, 9, 1, 6, 6, 8, 1, 7]],

                  [[5, 9, 5, 7, 3, 2, 1, 0, 9, 5],
                   [9, 8, 7, 3, 1, 7, 6, 6, 0, 5],
                   [8, 2, 9, 7, 2, 9, 4, 4, 0, 8],
                   [2, 8, 2, 2, 0, 6, 6, 8, 6, 9],
                   [5, 5, 2, 2, 3, 5, 9, 9, 3, 4]],

                  [[3, 6, 4, 6, 3, 2, 4, 6, 9, 0],
                   [7, 1, 6, 7, 7, 2, 6, 2, 2, 8],
                   [2, 3, 6, 2, 5, 5, 2, 6, 2, 0],
                   [3, 9, 8, 5, 1, 5, 7, 8, 7, 9],
                   [9, 2, 1, 5, 2, 7, 0, 7, 4, 3]]])
                   (3 traj, 5 obsv, 10 feat)

``` python
# Trajectories(arr).transpose(1, 0, 2)
```

    Trajectories([[[9, 7, 1, 4, 8, 2, 3, 3, 3, 1],
                   [5, 9, 5, 7, 3, 2, 1, 0, 9, 5],
                   [3, 6, 4, 6, 3, 2, 4, 6, 9, 0]],

                  [[0, 3, 8, 7, 2, 9, 9, 9, 1, 7],
                   [9, 8, 7, 3, 1, 7, 6, 6, 0, 5],
                   [7, 1, 6, 7, 7, 2, 6, 2, 2, 8]],

                  [[0, 8, 5, 3, 3, 8, 8, 1, 3, 8],
                   [8, 2, 9, 7, 2, 9, 4, 4, 0, 8],
                   [2, 3, 6, 2, 5, 5, 2, 6, 2, 0]],

                  [[3, 6, 9, 1, 8, 7, 7, 3, 1, 3],
                   [2, 8, 2, 2, 0, 6, 6, 8, 6, 9],
                   [3, 9, 8, 5, 1, 5, 7, 8, 7, 9]],

                  [[0, 0, 2, 9, 1, 6, 6, 8, 1, 7],
                   [5, 5, 2, 2, 3, 5, 9, 9, 3, 4],
                   [9, 2, 1, 5, 2, 7, 0, 7, 4, 3]]])
                   (5 obsv, 3 traj, 10 feat)

``` python
# Trajectories(arr).transpose('obsv', 0, 2)
```

    Trajectories([[[9, 7, 1, 4, 8, 2, 3, 3, 3, 1],
                   [5, 9, 5, 7, 3, 2, 1, 0, 9, 5],
                   [3, 6, 4, 6, 3, 2, 4, 6, 9, 0]],

                  [[0, 3, 8, 7, 2, 9, 9, 9, 1, 7],
                   [9, 8, 7, 3, 1, 7, 6, 6, 0, 5],
                   [7, 1, 6, 7, 7, 2, 6, 2, 2, 8]],

                  [[0, 8, 5, 3, 3, 8, 8, 1, 3, 8],
                   [8, 2, 9, 7, 2, 9, 4, 4, 0, 8],
                   [2, 3, 6, 2, 5, 5, 2, 6, 2, 0]],

                  [[3, 6, 9, 1, 8, 7, 7, 3, 1, 3],
                   [2, 8, 2, 2, 0, 6, 6, 8, 6, 9],
                   [3, 9, 8, 5, 1, 5, 7, 8, 7, 9]],

                  [[0, 0, 2, 9, 1, 6, 6, 8, 1, 7],
                   [5, 5, 2, 2, 3, 5, 9, 9, 3, 4],
                   [9, 2, 1, 5, 2, 7, 0, 7, 4, 3]]])
                   (5 obsv, 3 traj, 10 feat)

``` python
# Trajectories(arr).transpose('obsv', 0, 2).to_obsv_x_traj()
```

    NameError: name 'aggr' is not defined

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dsm-72/narr",
    "name": "narr",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "",
    "keywords": "named arrays narr nymstr fuzstr synset ispec xarray xarr xarray-like numpy np",
    "author": "dsm-72",
    "author_email": "sumner.magruder@yale.edu",
    "download_url": "https://files.pythonhosted.org/packages/87/08/bad950f573e24721cf3af2093c058c15429682e6e97ccf8a5e77b39ad28b/narr-0.0.1.tar.gz",
    "platform": null,
    "description": "# narr\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\n``` python\n# #| hide\n# from narr.strs import snake_case\n# from narr.axes import NamedAxis, NamedAxes\n# from narr.errs import NamedArrayDimsError\n# from narr.mixs import NamedArrayDynamicAttrsMixin\n# from narr.narr import NamedArray\n# from narr.traj import (\n#     TrajectoryDim, GeneTrajectoryDim,\n#     ObservationTrajectories, FeatureTrajectories,\n#     CellularTrajectories, ExpressionTrajectories,\n#     Trajectories, GeneTrajectories,\n# )\n```\n\n## Developer Guide\n\n### Setup\n\n``` sh\n# create conda environment\n$ mamba env create -f env.yml\n\n# update conda environment\n$ mamba env update -n narr --file env.yml\n```\n\n### Install\n\n``` sh\npip install -e .\n\n# install from pypi\npip install narr\n```\n\n### nbdev\n\n``` sh\n# activate conda environment\n$ conda activate narr\n\n# make sure the narr package is installed in development mode\n$ pip install -e .\n\n# make changes under nbs/ directory\n# ...\n\n# compile to have changes apply to the narr package\n$ nbdev_prepare\n```\n\n### Publishing\n\n``` sh\n# publish to pypi\n$ nbdev_pypi\n\n# publish to conda\n$ nbdev_conda --build_args '-c conda-forge'\n$ nbdev_conda --mambabuild --build_args '-c conda-forge -c dsm-72'\n```\n\n# Usage\n\n## Installation\n\nInstall latest from the GitHub\n[repository](https://github.com/dsm-72/narr):\n\n``` sh\n$ pip install git+https://github.com/dsm-72/narr.git\n```\n\nor from [conda](https://anaconda.org/dsm-72/narr)\n\n``` sh\n$ conda install -c dsm-72 narr\n```\n\nor from [pypi](https://pypi.org/project/narr/)\n\n``` sh\n$ pip install narr\n```\n\n## Documentation\n\nDocumentation can be found hosted on GitHub\n[repository](https://github.com/dsm-72/narr)\n[pages](https://dsm-72.github.io/narr/). Additionally you can find\npackage manager specific guidelines on\n[conda](https://anaconda.org/dsm-72/narr) and\n[pypi](https://pypi.org/project/narr/) respectively.\n\n``` python\n# import numpy as np\n# from typing import Callable\n```\n\n### Subclassing NamedArray\n\n``` python\n# class Trajectories(NamedArray):\n#     DIMS = NamedAxes([NamedAxis(dim.name, i) for i, dim in enumerate(TrajectoryDim)])\n    \n#     def to_obsv_x_traj(self, aggr: Callable = np.mean):\n#         agg_arr = aggr(np.asarray(self.transpose(\n#             TrajectoryDim.obsv.name, TrajectoryDim.traj.name, TrajectoryDim.feat.name,            \n#         )), axis=2)\n#         return ObservationTrajectories(agg_arr)\n        \n#     def to_feat_x_traj(self, aggr: Callable = np.mean):\n#         agg_arr = aggr(np.asarray(self.transpose(\n#             TrajectoryDim.feat.name, TrajectoryDim.traj.name, TrajectoryDim.obsv.name,            \n#         )), axis=2)\n#         return FeatureTrajectories(agg_arr)\n```\n\n### Using NamedArray Subclass Trajectories\n\n``` python\n# arr = np.random.randint(0, 10, (3, 5, 10))\n# arr\n```\n\n    array([[[9, 7, 1, 4, 8, 2, 3, 3, 3, 1],\n            [0, 3, 8, 7, 2, 9, 9, 9, 1, 7],\n            [0, 8, 5, 3, 3, 8, 8, 1, 3, 8],\n            [3, 6, 9, 1, 8, 7, 7, 3, 1, 3],\n            [0, 0, 2, 9, 1, 6, 6, 8, 1, 7]],\n\n           [[5, 9, 5, 7, 3, 2, 1, 0, 9, 5],\n            [9, 8, 7, 3, 1, 7, 6, 6, 0, 5],\n            [8, 2, 9, 7, 2, 9, 4, 4, 0, 8],\n            [2, 8, 2, 2, 0, 6, 6, 8, 6, 9],\n            [5, 5, 2, 2, 3, 5, 9, 9, 3, 4]],\n\n           [[3, 6, 4, 6, 3, 2, 4, 6, 9, 0],\n            [7, 1, 6, 7, 7, 2, 6, 2, 2, 8],\n            [2, 3, 6, 2, 5, 5, 2, 6, 2, 0],\n            [3, 9, 8, 5, 1, 5, 7, 8, 7, 9],\n            [9, 2, 1, 5, 2, 7, 0, 7, 4, 3]]])\n\n``` python\n# Trajectories(arr)\n```\n\n    Trajectories([[[9, 7, 1, 4, 8, 2, 3, 3, 3, 1],\n                   [0, 3, 8, 7, 2, 9, 9, 9, 1, 7],\n                   [0, 8, 5, 3, 3, 8, 8, 1, 3, 8],\n                   [3, 6, 9, 1, 8, 7, 7, 3, 1, 3],\n                   [0, 0, 2, 9, 1, 6, 6, 8, 1, 7]],\n\n                  [[5, 9, 5, 7, 3, 2, 1, 0, 9, 5],\n                   [9, 8, 7, 3, 1, 7, 6, 6, 0, 5],\n                   [8, 2, 9, 7, 2, 9, 4, 4, 0, 8],\n                   [2, 8, 2, 2, 0, 6, 6, 8, 6, 9],\n                   [5, 5, 2, 2, 3, 5, 9, 9, 3, 4]],\n\n                  [[3, 6, 4, 6, 3, 2, 4, 6, 9, 0],\n                   [7, 1, 6, 7, 7, 2, 6, 2, 2, 8],\n                   [2, 3, 6, 2, 5, 5, 2, 6, 2, 0],\n                   [3, 9, 8, 5, 1, 5, 7, 8, 7, 9],\n                   [9, 2, 1, 5, 2, 7, 0, 7, 4, 3]]])\n                   (3 traj, 5 obsv, 10 feat)\n\n``` python\n# Trajectories(arr).transpose(1, 0, 2)\n```\n\n    Trajectories([[[9, 7, 1, 4, 8, 2, 3, 3, 3, 1],\n                   [5, 9, 5, 7, 3, 2, 1, 0, 9, 5],\n                   [3, 6, 4, 6, 3, 2, 4, 6, 9, 0]],\n\n                  [[0, 3, 8, 7, 2, 9, 9, 9, 1, 7],\n                   [9, 8, 7, 3, 1, 7, 6, 6, 0, 5],\n                   [7, 1, 6, 7, 7, 2, 6, 2, 2, 8]],\n\n                  [[0, 8, 5, 3, 3, 8, 8, 1, 3, 8],\n                   [8, 2, 9, 7, 2, 9, 4, 4, 0, 8],\n                   [2, 3, 6, 2, 5, 5, 2, 6, 2, 0]],\n\n                  [[3, 6, 9, 1, 8, 7, 7, 3, 1, 3],\n                   [2, 8, 2, 2, 0, 6, 6, 8, 6, 9],\n                   [3, 9, 8, 5, 1, 5, 7, 8, 7, 9]],\n\n                  [[0, 0, 2, 9, 1, 6, 6, 8, 1, 7],\n                   [5, 5, 2, 2, 3, 5, 9, 9, 3, 4],\n                   [9, 2, 1, 5, 2, 7, 0, 7, 4, 3]]])\n                   (5 obsv, 3 traj, 10 feat)\n\n``` python\n# Trajectories(arr).transpose('obsv', 0, 2)\n```\n\n    Trajectories([[[9, 7, 1, 4, 8, 2, 3, 3, 3, 1],\n                   [5, 9, 5, 7, 3, 2, 1, 0, 9, 5],\n                   [3, 6, 4, 6, 3, 2, 4, 6, 9, 0]],\n\n                  [[0, 3, 8, 7, 2, 9, 9, 9, 1, 7],\n                   [9, 8, 7, 3, 1, 7, 6, 6, 0, 5],\n                   [7, 1, 6, 7, 7, 2, 6, 2, 2, 8]],\n\n                  [[0, 8, 5, 3, 3, 8, 8, 1, 3, 8],\n                   [8, 2, 9, 7, 2, 9, 4, 4, 0, 8],\n                   [2, 3, 6, 2, 5, 5, 2, 6, 2, 0]],\n\n                  [[3, 6, 9, 1, 8, 7, 7, 3, 1, 3],\n                   [2, 8, 2, 2, 0, 6, 6, 8, 6, 9],\n                   [3, 9, 8, 5, 1, 5, 7, 8, 7, 9]],\n\n                  [[0, 0, 2, 9, 1, 6, 6, 8, 1, 7],\n                   [5, 5, 2, 2, 3, 5, 9, 9, 3, 4],\n                   [9, 2, 1, 5, 2, 7, 0, 7, 4, 3]]])\n                   (5 obsv, 3 traj, 10 feat)\n\n``` python\n# Trajectories(arr).transpose('obsv', 0, 2).to_obsv_x_traj()\n```\n\n    NameError: name 'aggr' is not defined\n",
    "bugtrack_url": null,
    "license": "Apache Software License 2.0",
    "summary": "Literal Enum",
    "version": "0.0.1",
    "project_urls": {
        "Homepage": "https://github.com/dsm-72/narr"
    },
    "split_keywords": [
        "named",
        "arrays",
        "narr",
        "nymstr",
        "fuzstr",
        "synset",
        "ispec",
        "xarray",
        "xarr",
        "xarray-like",
        "numpy",
        "np"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3644ddaefd87d3fd86153ca5ceac5932363c5554b94e284de650bbc2c6945e04",
                "md5": "ad02b796019abe6be5403b2fafe03fb3",
                "sha256": "43d7fd1615dfd67e72c6e30bc19a258c92510d58a871dbeb32a769c9fa2ecf5a"
            },
            "downloads": -1,
            "filename": "narr-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ad02b796019abe6be5403b2fafe03fb3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 16086,
            "upload_time": "2023-09-12T19:40:47",
            "upload_time_iso_8601": "2023-09-12T19:40:47.947803Z",
            "url": "https://files.pythonhosted.org/packages/36/44/ddaefd87d3fd86153ca5ceac5932363c5554b94e284de650bbc2c6945e04/narr-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8708bad950f573e24721cf3af2093c058c15429682e6e97ccf8a5e77b39ad28b",
                "md5": "980afb3b457f2fc9177e075669ead86c",
                "sha256": "5e117c892c5f06f3382ce53cc97e737c7500c646e4d1148d1364413a54c40495"
            },
            "downloads": -1,
            "filename": "narr-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "980afb3b457f2fc9177e075669ead86c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 16248,
            "upload_time": "2023-09-12T19:40:49",
            "upload_time_iso_8601": "2023-09-12T19:40:49.884695Z",
            "url": "https://files.pythonhosted.org/packages/87/08/bad950f573e24721cf3af2093c058c15429682e6e97ccf8a5e77b39ad28b/narr-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-12 19:40:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dsm-72",
    "github_project": "narr",
    "github_not_found": true,
    "lcname": "narr"
}
        
Elapsed time: 1.66703s