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
Built Distribution
File details
Details for the file ndarray_listener-2.0.1.tar.gz
.
File metadata
- Download URL: ndarray_listener-2.0.1.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b740e733fa41612891f8b5eaec6d03794f696099b85c65e83d2669ae220455f |
|
MD5 | e254dcdd74558adf21f69facedeb387d |
|
BLAKE2b-256 | 5487ff4cdcaf6cde67c03b0ba426c59e9ae5cf772b27a1f9ae33f770309d4667 |
File details
Details for the file ndarray_listener-2.0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: ndarray_listener-2.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c6f971075817d9339492c563a972f957b90bf67be5ce887958eb26a6c418d47 |
|
MD5 | 344549f7183a139517ef023f4e31147f |
|
BLAKE2b-256 | 2e8466a78c0f666e4fb1c00bb3f7c76365aa454a5e9222a2ade0129724116042 |