Skip to content

Implementation of the Observer pattern for NumPy arrays.

License

Notifications You must be signed in to change notification settings

limix/ndarray-listener

Repository files navigation

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.

About

Implementation of the Observer pattern for NumPy arrays.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages