Skip to main content

narr

# #| 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

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

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

Install

pip install -e .

# install from pypi
pip install narr

nbdev

# 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

# 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:

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

or from conda

$ conda install -c dsm-72 narr

or from pypi

$ pip install narr

Documentation

Documentation can be found hosted on GitHub repository pages. Additionally you can find package manager specific guidelines on conda and pypi respectively.

# import numpy as np
# from typing import Callable

Subclassing NamedArray

# 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

# 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]]])
# 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)
# 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)
# 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)
# Trajectories(arr).transpose('obsv', 0, 2).to_obsv_x_traj()
NameError: name 'aggr' is not defined

Metadata

Release files for narr 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for narr 0.0.1
File Size Uploaded
narr-0.0.1.tar.gz 16.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for narr 0.0.1
File Interpreter ABI Platform
narr-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 32.3 kB

Release files / narr-0.0.1.tar.gz

Download URL narr-0.0.1.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5e117c892c5f06f3382ce53cc97e737c7500c646e4d1148d1364413a54c40495
BLAKE2b-256 checksum
How to use checksums
8708bad950f573e24721cf3af2093c058c15429682e6e97ccf8a5e77b39ad28b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / narr-0.0.1-py3-none-any.whl

Download URL narr-0.0.1-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43d7fd1615dfd67e72c6e30bc19a258c92510d58a871dbeb32a769c9fa2ecf5a
BLAKE2b-256 checksum
How to use checksums
3644ddaefd87d3fd86153ca5ceac5932363c5554b94e284de650bbc2c6945e04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page