About
ndvector is yet another vector math library for Python3. Where numpy focuses on everything including the kitchen sink, ndvector is intended to provide a simple, pythonic, object oriented API for vector math in n dimensions.
License
Apache License 2.0 (see LICENSE)
Requirements
python >= 3.5
Usage
Usage attempts to be about what you expect. Simply import the library, create Point and Vector objects, and do math with them.
from n_dimension import Vector
v1 = Vector(1.0, 0.0)
v2 = Vector(-1.0, 1.0)
v3 = v1 + v2
print(v3) # => Vector ‹0.0, 1.0›
API
Given:
- s a scalar (float)
- p, p# are instances of Point
- v, v# are instances of Vector
Class Point:
- constructor - create a Point from one or more float parameters, a tuple
of floats, or a list of floats
- properties:
- dimension - the dimension of the Point
- operators:
- 'p + v' addition of a Vector to a Point to get the Point at the tip of
the Vector if the tail of the vector is moved to the Point
- 'p1 - p2' subtraction of a Point from a Point to get the Vector between
the Points
- 'p1 == p2' equality (See Note 1)
- 'p1 != p2' not equality (See Note 1)
Class Vector:
- constructor - create a Vector from one or more float parameters, a tuple
of floats, or a list of floats
- properties:
- dimension - the dimension of the vector
- magnitude - the magnitude of the vector
- operators
- 'v1 + v2' vector addition
- 'v1 - v2' vector subtraction
- 'v1 * v2' scalar aka dot product (v1 * v2 => scalar)
- 'v * s' scale vector
- 'v1 @ v2' vector aka cross product (v1 * v2 => vector) (See Note 2)
- 'v1 == v2' equality (See Note 1)
- 'v1 != v2' not equality (See Note 1)
- methods
- angle() - find the angle in radians between the vector and another vector
- normalize() - find a unit vector with the same direction as the vector
Notes
- testing for equality when floats are involved is tricky. n_dimension considers two floats to be equal if the absolute value of their difference is less than a certain amount; currently 0.000001 seems to work well. This may be refined after more testing
- only implemented for Vectors of dimension three (3)
Testing
Testing is done using tox and pytest. See
https://tox.readthedocs.io/en/latest/ for information about installing tox.
Run the tests by cloning the source repository, changing into the local
working directory, and invoking tox.
git clone https://github.com/tkegan/n_dimension.git
cd n_dimension
tox
To Do
-
Create better API documentation
-
Investigate accelerated performance by moving some functionality to compiled code but only if the pure python implementation can be kept as a fallback
Contribute
I welcome pull requests against the GitHub repository. If extending the API, please include tests. I will not merge changes to the API until tests are in place and passing.
Metadata
Release files for ndvector 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ndvector-1.1.0.tar.gz | 4.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ndvector-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.9 kB
Release files / ndvector-1.1.0.tar.gz
| Download URL | ndvector-1.1.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c474181967349080923bb035c600a687abdb072cdf6d32413d0d6e474e76c3e1
|
|
BLAKE2b-256 checksum How to use checksums |
176fc67c7863a96afa30eb37137b360090e58bf6b8efa451f258f9ea2f8b35d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
|
Release files / ndvector-1.1.0-py3-none-any.whl
| Download URL | ndvector-1.1.0-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce893f2cfc45b57b1591911cc2dcce89e9a9b5af57c790ccfd65d2f83f25db9d
|
|
BLAKE2b-256 checksum How to use checksums |
e880fed8d650556918899c20705fe88231580427e02c24deef375dcbeadabdb3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
|
Security for ndvector 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.