Skip to main content

Implementation of the Observer pattern for NumPy arrays

Project description

PyPI-Status Conda-Forge-Status Conda-Downloads

Build-Status Codacy-Grade License-Badge Doc-Status

Implementation of the Observer pattern for NumPy arrays.

Example

from numpy import array
from ndarray_listener import ndarray_listener as 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

The recommended way of installing it is via conda

conda install -c conda-forge ndarray-listener

An alternative way would be via pip

pip install ndarray-listener

Running the tests

After installation, you can test it

python -c "import ndarray_listener; ndarray_listener.test()"

as long as you have pytest.

Authors

License

This project is licensed under the MIT License - see the License file for details.

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

ndarray-listener-1.0.26.tar.gz (5.3 kB view details)

Uploaded Source

File details

Details for the file ndarray-listener-1.0.26.tar.gz.

File metadata

File hashes

Hashes for ndarray-listener-1.0.26.tar.gz
Algorithm Hash digest
SHA256 44a18bba0a6353440f7831782e01ede253078144d17b8b8a48a8936347e1538d
MD5 3ba92fb29757dc05de45c1deb2f866d4
BLAKE2b-256 e7614c80218e4e3aec0474dcf94a43ef704510f39e628f27cec761c18a8b49b8

See more details on using hashes here.

Supported by

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