Py-Pypr
Py-Pypr is a pure Python library for functional shift operators, enabling readable and intuitive multi-step data transformation pipelines.
Features
-
Chainable pipelines for data transformation.
-
Functional programming style with decorators.
-
Lightweight and easy to use.
Installation
To install Py-Pypr, use pip or uv:
uv pip install py-pypr
pip install py-pypr
Usage
Basic Example
from py_pypr import PypObject, Pypline
# Create a PypObject
data = PypObject(" hello world ")
# pipelines
strip_pipeline = Pypline(str.strip)
uppercase_pipeline = Pypline(str.upper)
# Chain pipelines
data >> strip_pipeline >> uppercase_pipeline
# Get the result
print(data.result()) # Output: "HELLO WORLD"
Using the pypr Decorator
from py_pypr import PypObject, pypr
@pypr
def replace_spaces(data: str) -> str:
return data.replace(" ", "_")
# Create a PypObject
data = PypObject("hello world")
# Apply the decorated function
data >> replace_spaces
# Get the result
print(data.result()) # Output: "hello_world"
Advanced Example
import numpy as np
from py_pypr import PypObject, Pypline, pypr
stepwise = True
# Define object
arr = PypObject(np.ones((3, 120, 120)))
# Establish transforms
def add_to_upperleft(np_arr: np.ndarray, val: int | float) -> np.ndarray:
y, x = np.array(np_arr.shape[1:]) // 2
return np_arr[:, :y, :x] + val # return is required
@pypr(val=12)
def mul_righthalf(np_arr: np.ndarray, val: int | float) -> np.ndarray:
x = np.array(np_arr.shape[2:]) // 2
np_arr[:, :, x.item():] *= val
return np_arr
# Create Pypline
add_5_top_left = Pypline(add_to_upperleft, 5)
if stepwise:
# Transform iteratively
arr.data.mean() # start value (1.0)
for pyp in (add_5_top_left, mul_righthalf):
_ = arr >> pyp
arr.data.mean() # new value (6.0; 39.0)
else:
# Transform single line
arr >> add_5_top_left >> mul_righthalf
arr.data.mean() # new value (39.0)
Documentation
For detailed documentation, visit the GitHub repository.
License
Py-Pypr is licensed under the BSD 3-Clause License. See the LICENSE file for details.
Metadata
Release files for py-pypr 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_pypr-0.1.0.tar.gz | 5.8 kB | Without provenance | Details for py_pypr-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_pypr-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for py_pypr-0.1.0-py3-none-any.whl |
Total release size: 11.5 kB
Release files / py_pypr-0.1.0.tar.gz
| Download URL | py_pypr-0.1.0.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0068444ca48842c90a93bbba57d9c53008d3c0a1dd0022f74815c2fbcc2829a8
|
|
BLAKE2b-256 checksum How to use checksums |
df1e93f522626b37f97465dd5405b96580b7845db4d5b482f0c2286aa5a0d682
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.29
|
Release files / py_pypr-0.1.0-py3-none-any.whl
| Download URL | py_pypr-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7dfce7e07c7d355f80fd572543ad5173bfb3021146b642bc4c933f77027eba17
|
|
BLAKE2b-256 checksum How to use checksums |
2e5e2784067baf964c303fc3c5bb6e5bfe674237736e31e517fba817cdf2f8f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.29
|
Security for py-pypr 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.