Skip to main content

A wrapper around python lists that implement type safety and element-wise operations like numpy. Additionally, if the uncertainties package is installed, arrays of ufloats can be used

Project description

Smart Arrays

I created this project for two reasons. For a college project I wanted to have the flexibility of numpy arrays (which I absolutely love), especialy their ability to do element-wise operations and type safety (in Python, when doing math, I hate it that if you use simple lists, any element can be of any type. I need type safety!), but didn't want to have to use a library so big. I also wanted to try to understand how would one come to implement something like numpy arrays' api. This library is the result.

Everything stems out of the class SmartArray, which is a simple wrapper around a list, that has static size and is type safe. There is also a SmartList, which is the same but its size is mutable. I'll provide a list below with all available objects

Object name Fixed size? Implements collections.abc
SmartArray Yes Sequence[T]
SmartList No MutableSequence[T] (almost)
SmartArrayNumber Yes Set[C]
SmartListNumber No MutableSet[C]
SmartArrayComplex Yes Set[complex]
SmartListComplex No MutableSet[complex]
SmartArrayFloat Yes Set[float]
SmartListFloat No MutableSet[float]
SmartArrayInt Yes Set[int]
SmartListInt No MutableSet[int]
SmartArrayBool Yes Set[bool]
SmartListBool No MutableSet[bool]
UncertaintiesArray Yes Set[ufloat] (almost)
UncertaintiesList No MutableSet[ufloat] (almost)

Where T is any type and C is bound to complex. That means complex, float, int or bool. Also, if you have installed the uncertainties package, you can also use the UncertaintiesArray and UncertaintiesList. These work like SmartArrayNumber and SmartListNumber (except for some boolean, logic and binary operations) but their type is ufloat. That means that any arithmetical operation propagates the error, element-wise!

In utils I wrote some utility functions for these Arrays/Lists, for example way to save and load arrays to and from disk.

In stats I wrote functions to do some statistical analysis.

I'm very busy with college, but I'll try to keep updating this to make it more friendly for users. :)

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

smart_arrays-0.0.1.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smart_arrays-0.0.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file smart_arrays-0.0.1.tar.gz.

File metadata

  • Download URL: smart_arrays-0.0.1.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.19

File hashes

Hashes for smart_arrays-0.0.1.tar.gz
Algorithm Hash digest
SHA256 107bcf1cb8e3ac4fcc68a528992594f2c1603b7d4e75940ed67288755d8c7db0
MD5 f8cd232e74ea9c4b9eceb5425ccf22a3
BLAKE2b-256 3dbe198dad353d04cc5ed3bed06e364056f9c838a89a3b02b8335e3ef879df00

See more details on using hashes here.

File details

Details for the file smart_arrays-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: smart_arrays-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.19

File hashes

Hashes for smart_arrays-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1474ec30a0c637f75ac99ad0cc704c2b3d5ae679761c2fa7c7b7438f236fbe31
MD5 7d809b232199c4b8a31f8d4b76af3bae
BLAKE2b-256 5a6f4103423e31969c2e93cb5b78fbdb0b68a84ffcd5d2c11667d5e08cb6e8e2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page