Implementation of the Observer pattern for NumPy arrays
Project description
ndarray-listener
Implementation of the Observer pattern for NumPy arrays.
Example
from numpy import array
from ndarray_listener import ndl
a = ndl(array([-0.5, 0.1, 1.1]))
class Observer(object):
def __init__(self):
self.called_me = False
def __call__(self, _):
self.called_me = True
o = Observer()
a.talk_to(o)
print(o.called_me)
a[0] = 1.2
print(o.called_me)
The output should be
False
True
Install
From command line, enter
pip install ndarray-listener
Running the tests
Install dependencies
pip install pytest
then run
python -c "import ndarray_listener; ndarray_listener.test()"
Documentation
Authors
License
This project is licensed under the MIT License.
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
ndarray_listener-2.0.1.tar.gz
(5.4 kB
view hashes)
Built Distribution
Close
Hashes for ndarray_listener-2.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c6f971075817d9339492c563a972f957b90bf67be5ce887958eb26a6c418d47 |
|
MD5 | 344549f7183a139517ef023f4e31147f |
|
BLAKE2b-256 | 2e8466a78c0f666e4fb1c00bb3f7c76365aa454a5e9222a2ade0129724116042 |