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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for smart_arrays-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1474ec30a0c637f75ac99ad0cc704c2b3d5ae679761c2fa7c7b7438f236fbe31 |
|
MD5 | 7d809b232199c4b8a31f8d4b76af3bae |
|
BLAKE2b-256 | 5a6f4103423e31969c2e93cb5b78fbdb0b68a84ffcd5d2c11667d5e08cb6e8e2 |