Skip to main content

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

Documentation

Authors

License

This project is licensed under the MIT License.

Project details


Download files

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

Files for ndarray-listener, version 2.0.1
Filename, size File type Python version Upload date Hashes
Filename, size ndarray_listener-2.0.1-py2.py3-none-any.whl (5.9 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size ndarray_listener-2.0.1.tar.gz (5.4 kB) File type Source Python version None Upload date Hashes View

Supported by

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