Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/limix/ndarray-listener
Implementation of the Observer pattern for NumPy arrays.
https://github.com/limix/ndarray-listener
numpy observer-pattern
Last synced: about 2 months ago
JSON representation
Implementation of the Observer pattern for NumPy arrays.
- Host: GitHub
- URL: https://github.com/limix/ndarray-listener
- Owner: limix
- License: mit
- Created: 2016-10-09T15:25:43.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-05-17T15:07:35.000Z (over 3 years ago)
- Last Synced: 2024-11-07T10:53:33.129Z (2 months ago)
- Topics: numpy, observer-pattern
- Language: Python
- Homepage:
- Size: 77.1 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ndarray-listener
Implementation of the [Observer pattern](https://en.wikipedia.org/wiki/Observer_pattern) for NumPy arrays.
## Example
```python
from numpy import array
from ndarray_listener import ndla = ndl(array([-0.5, 0.1, 1.1]))
class Observer(object):
def __init__(self):
self.called_me = Falsedef __call__(self, _):
self.called_me = Trueo = 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
```bash
pip install ndarray-listener
```## Running the tests
Install dependencies
```bash
pip install pytest
```then run
```python
python -c "import ndarray_listener; ndarray_listener.test()"
```## Documentation
[Documentation](https://ndarray-listener.readthedocs.io/en/latest/)
## Authors
* [Danilo Horta](https://github.com/horta)
## License
This project is licensed under the [MIT License](https://raw.githubusercontent.com/limix/ndarray-listener/master/LICENSE.md).