Skip to main content

Simple, general, pure Python vectors

Project description

Simple, general, pure Python vectors defines an infinite-dimensional Vector type for all your vectoring needs. Instances of Vector are immutable and come with a wide array of useful operations and features.

hypervector is in the public domain.

A few explanatory examples

Hello world

>>> from hypervector import Vector
>>> (Vector(1, 2, 1) + Vector(3, 0, 2)).xy
Vector(4, 2)

King of infinite (vector) space

>>> vec = Vector(2, 4)
>>> (vec[0], vec[1], vec[2], vec[1114111])
(2, 4, 0, 0)


>>> vec_1, vec_2 = Vector(1, 2, 3), Vector(3, 2, 1)
>>> Vector.cross(vec_1, vec_2)
Vector(-4.0, 8.0, -4.0)
>>> [, vec) for vec in (vec_1, vec_2)]
[0.0, 0.0]
>>> vec_3 = Vector(-1, 8, 3, 2)
>>> Vector.cross(vec_1, vec_2, vec_3)
Vector(8.0, -16.0, 8.0, 56.0)
>>> [, vec) for vec in (vec_1, vec_2, vec_3)]
[0.0, 0.0, 0.0]


hypervector uses py.test and hypothesis, with tox as a test runner.

The unit tests can be run with tox. If you run into any slow data generation errors, use
tox -- --hypothesis-profile=allow-slow instead.

Why infinite dimensions?

Because generalizing things is fun and having infinite dimensions is somewhat easier and simpler than having an abstract Vector type with arbitrary (but finite) dimensions.

It is worth noting that Vector plays a little fast and loose with the concept of infinite dimensions, as it has a concept of “relevant” dimensions which is exposed through iteration, string representations, and a few other places to a lesser extent.
Similarly, there is no way to have a Vector with infinite non-zero components.

How fast is hypervector?

Dunno. Probably pretty slow. If you need speed, use numpy.


There are many other libraries with similar features to hypervector. Some notable examples:
  • numpy

  • pyeuclid — Has (among other things) Vector2 and Vector3 types. Also has packages for Python 2 and Python 3.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hypervector-0.0.1.tar.gz (8.5 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page