Metadata-Version: 2.1
Name: bcdict
Version: 0.5.0
Summary: Python dictionary with broadcast support.
Home-page: https://github.com/mariushelf/bcdict
License: MIT
Author: Marius Helf
Author-email: marius@happyyeti.tech
Requires-Python: >=3.7.1,<4.0.0
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: Implementation :: PyPy
Provides-Extra: docs
Requires-Dist: Sphinx (>=4.5.0,<5.0.0); extra == "docs"
Requires-Dist: importlib-metadata (>=4.11.3,<5.0.0); python_version < "3.8"
Requires-Dist: myst-nb (>=0.13.2,<0.14.0); extra == "docs"
Requires-Dist: pandas (==1.3.1); (python_version < "3.10" and implementation_name == "cpython") and (extra == "docs")
Requires-Dist: scikit-learn (==1.0.2); (python_version < "3.10" and implementation_name == "cpython") and (extra == "docs")
Requires-Dist: sphinx-autobuild (>=2021.3.14,<2022.0.0); extra == "docs"
Requires-Dist: sphinx-book-theme (>=0.3.2,<0.4.0); extra == "docs"
Requires-Dist: sphinx-copybutton (>=0.5.0,<0.6.0); extra == "docs"
Requires-Dist: sphinx-panels (>=0.6.0,<0.7.0); extra == "docs"
Requires-Dist: sphinxcontrib-mermaid (>=0.7.1,<0.8.0); extra == "docs"
Project-URL: Documentation, https://bcdict.readthedocs.io
Project-URL: Repository, https://github.com/mariushelf/bcdict
Description-Content-Type: text/markdown

[![Tests](https://github.com/mariushelf/bcdict/actions/workflows/cicd.yaml/badge.svg)](https://github.com/mariushelf/bcdict/actions/workflows/cicd.yaml)
[![codecov](https://codecov.io/gh/mariushelf/bcdict/branch/master/graph/badge.svg)](https://codecov.io/gh/mariushelf/bcdict)
[![PyPI version](https://badge.fury.io/py/bcdict.svg)](https://pypi.org/project/bcdict/)
[![Documentation Status](https://readthedocs.org/projects/bcdict/badge/?version=latest)](https://bcdict.readthedocs.io/en/latest/?badge=latest)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)


# Broadcast Dictionary


Python dictionary with broadcast support.

Behaves like a regular dictionary.

Allows to apply operations to all its values at once.
Whithout loops, whithout dict comprehension.

## Installation

```bash
pip install bcdict
```

## Usage

```python
from bcdict import BCDict
>>> d = BCDict({"a": "hello", "b": "world!"})
>>> d
{'a': 'hello', 'b': 'world!'}
```


Regular element access:
```python
>>> d['a']
'hello'
```


Regular element assignments
```python
>>> d['a'] = "Hello"
>>> d
{'a': 'Hello', 'b': 'world!'}
```

Calling functions:
```python
>>> d.upper()
{'a': 'HELLO', 'b': 'WORLD!'}
```

Slicing:
```python
>>> d[1:3]
{'a': 'el', 'b': 'or'}
```

Applying functions:
```python
>>> d.pipe(len)
{'a': 5, 'b': 6}
```

When there is a conflict between an attribute in the values and an attribute in
`BCDict`, use the attribute accessor explicitly:

```python
>>> d.a.upper()
{'a': 'HELLO', 'b': 'WORLD!'}
```

Slicing with conflicting keys:
```python
>>> n = BCDict({1:"hello", 2: "world"})
>>> n[1]
'hello'
>>> # Using the attribute accessor:
>>> n.a[1]
{1: 'e', 2: 'o'}
```

## Next steps

See the [introduction notebook](docs/source/examples/introduction.ipynb) and other
[examples](docs/source/examples/examples.md).

Also check out the full documentation on
[bcdict.readthedocs.io](https://bcdict.readthedocs.io/en/latest/).


## Changelog

### v0.5.0
* feature: broadcast attribute and item assignment
* fix: broadcast slicing with `.a` accessor

### v0.4.3
* fix: unpickling causes recursion error

### v0.4.2
* docs: improve the documenation

### v0.4.1
* fix: sphinxcontrib-mermaid gets installed as default dependency, should be dev dependency

### v0.4.0
* new functions `eq()` and `ne()` for equality/inequality with broadcast support

### v0.3.0
* new functions in `bcdict` package:
  * `apply()`
  * `broadcast()`
  * `broadcast_arg()`
  * `broadcast_kwarg()`
* docs: write some documentation and host it on [readthedocs](https://bcdict.readthedocs.io/en/latest/)

### v0.2.0
* remove `item()` function. Use `.a[]` instead.

### v0.1.0
* initial release


Original repository: [https://github.com/mariushelf/bcdict](https://github.com/mariushelf/bcdict)

Author: Marius Helf
([helfsmarius@gmail.com](mailto:helfsmarius@gmail.com))

