arrayclasses


Namearrayclasses JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/Ivorforce/python-arrayclass
SummaryAnalogue to dataclass that uses a numpy-backed array to store values.
upload_time2023-05-26 19:46:14
maintainer
docs_urlNone
authorLukas Tenbrink
requires_python>=3.9,<4.0
licenseMIT
keywords numpy dataclass
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # arrayclass

A small `@dataclass`-like decorator for python classes. The class will store its values in a single contiguous [numpy](https://numpy.org) array. It can also be converted to and from plain numpy arrays.

## Installation

`poetry add dataclasses` or `pip install dataclasses`

## Usage

```py
import arrayclasses

@arrayclasses.arrayclass
class State:
    x: float
    y: tuple[float, float]
    z: float

# Object creation
state = State(x=5, y=(0, 1), z=0)
print(np.x)  # Prints 5.0
print(np.y)  # Prints np.array([0.0, 1.0])
state.y = 2.0
print(np.y)  # Prints np.array([2.0, 2.0])

# Array conversion.
state = arrayclasses.from_array((5, 0, 1, 0))
print(np.array(state))  # prints np.array([5.0, 0.0, 1.0, 0.0])
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Ivorforce/python-arrayclass",
    "name": "arrayclasses",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "numpy,dataclass",
    "author": "Lukas Tenbrink",
    "author_email": "lukas.tenbrink@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e1/04/2a6133173836f8a0414df7d1f1b34b04bb77122cd4be72bb6f47c2496200/arrayclasses-0.1.3.tar.gz",
    "platform": null,
    "description": "# arrayclass\n\nA small `@dataclass`-like decorator for python classes. The class will store its values in a single contiguous [numpy](https://numpy.org) array. It can also be converted to and from plain numpy arrays.\n\n## Installation\n\n`poetry add dataclasses` or `pip install dataclasses`\n\n## Usage\n\n```py\nimport arrayclasses\n\n@arrayclasses.arrayclass\nclass State:\n    x: float\n    y: tuple[float, float]\n    z: float\n\n# Object creation\nstate = State(x=5, y=(0, 1), z=0)\nprint(np.x)  # Prints 5.0\nprint(np.y)  # Prints np.array([0.0, 1.0])\nstate.y = 2.0\nprint(np.y)  # Prints np.array([2.0, 2.0])\n\n# Array conversion.\nstate = arrayclasses.from_array((5, 0, 1, 0))\nprint(np.array(state))  # prints np.array([5.0, 0.0, 1.0, 0.0])\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Analogue to dataclass that uses a numpy-backed array to store values.",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/Ivorforce/python-arrayclass",
        "Repository": "https://github.com/Ivorforce/python-arrayclass"
    },
    "split_keywords": [
        "numpy",
        "dataclass"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3b3939d223d3a3bf55a2078cc1341d76a38f689cbc467d4f97325ea7faa5feac",
                "md5": "5400a842d6c528cb31bde5b8d37d17e6",
                "sha256": "43a0984fd63076e5dca7a133d0546c3f8b0c4419c06c0376d6e60c58584d182d"
            },
            "downloads": -1,
            "filename": "arrayclasses-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5400a842d6c528cb31bde5b8d37d17e6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 4666,
            "upload_time": "2023-05-26T19:46:12",
            "upload_time_iso_8601": "2023-05-26T19:46:12.082212Z",
            "url": "https://files.pythonhosted.org/packages/3b/39/39d223d3a3bf55a2078cc1341d76a38f689cbc467d4f97325ea7faa5feac/arrayclasses-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e1042a6133173836f8a0414df7d1f1b34b04bb77122cd4be72bb6f47c2496200",
                "md5": "15cb0827ee3b38c80a002a27ebe10f8e",
                "sha256": "3863b739ec010eecd7e7c5db4bf58a64424775eeb6d146964f1e008e9abdb237"
            },
            "downloads": -1,
            "filename": "arrayclasses-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "15cb0827ee3b38c80a002a27ebe10f8e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 3792,
            "upload_time": "2023-05-26T19:46:14",
            "upload_time_iso_8601": "2023-05-26T19:46:14.120794Z",
            "url": "https://files.pythonhosted.org/packages/e1/04/2a6133173836f8a0414df7d1f1b34b04bb77122cd4be72bb6f47c2496200/arrayclasses-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-26 19:46:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Ivorforce",
    "github_project": "python-arrayclass",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "arrayclasses"
}
        
Elapsed time: 0.13355s