Skip to main content

pyarrlib

A small Python utility library for working with arrays and nested array structures.

This project provides simple helper functions for reversing arrays, computing numeric aggregates, and traversing nested sequences to count or flatten leaf values.

Features

  • reverse_arr(array): reverse a sequence
  • sum_arr(array): compute the sum of numeric values
  • multiplication_arr(array): compute the product of numeric values
  • leafs(array): flatten nested integer arrays
  • num_of_leafs(array): count integer leaf nodes in nested arrays
  • len_arr(array): count all scalar leaves in nested arrays

Installation

From the repository root, install in editable mode:

python -m pip install -e .

If you prefer not to install, you can run code directly from this project by ensuring the repository root is on PYTHONPATH.

Usage

from scr import reverse_arr, sum_arr, multiplication_arr, leafs, num_of_leafs, len_arr, ArrayTypeError

print(reverse_arr([1, 'hello', 3, True]))
# [True, 3, 'hello', 1]

print(sum_arr([1, 5, 4, 3, 8]))
# 21

print(multiplication_arr([4, 1, 2, 5, 7]))
# 280

nested = [[1, 2, [3]], [4, [5, 6]]]
print(leafs(nested))
# [1, 2, 3, 4, 5, 6]
print(num_of_leafs(nested))
# 6
print(len_arr(nested))
# 6

API Reference

reverse_arr(array)

Return a new sequence with the elements in reverse order.

sum_arr(array)

Return the sum of numeric values in the array.

If a non-numeric element is encountered, the function returns the sentinel class ArrayTypeError.

multiplication_arr(array)

Return the product of numeric values in the array.

If a non-numeric element is found, the function returns ArrayTypeError.

leafs(array)

Return a flat list containing all integer leaf values from a nested array structure.

num_of_leafs(array)

Count integer leaf nodes recursively in a nested array structure.

len_arr(array)

Count all scalar leaf values in a nested array structure. Supported scalar types include int, str, float, and bool.

Running the included checks

The repository includes a simple assertion-based test file.

python tests/test.py

Project structure

  • pyproject.toml – package metadata and build configuration
  • README.md – project documentation
  • scr/arrpy.py – array utility functions and error type
  • scr/multidim_arr.py – nested array traversal functions
  • tests/test.py – example assertions covering core behavior

License

This project is licensed under MIT.

Metadata

Release files for pyattlib 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyattlib 0.1.1
File Size Uploaded Provenance
pyattlib-0.1.1.tar.gz 4.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyattlib 0.1.1
File Interpreter ABI Platform
pyattlib-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.4 kB

Release files / pyattlib-0.1.1.tar.gz

Download URL pyattlib-0.1.1.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9d8114252ddcd9680e13f8d552a14b889b179287ff3d20694f11d4d9cacae746
BLAKE2b-256 checksum
How to use checksums
d6bdaf6629176c43385d63bc43cd05ce04bbe3392d56b7a742d3ae7906f8c66c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.15.0a5

Release files / pyattlib-0.1.1-py3-none-any.whl

Download URL pyattlib-0.1.1-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
deb25d11284bac3450ef2a7528da0d5e544d61ec0bd9ddfa2848aa52d17022b6
BLAKE2b-256 checksum
How to use checksums
2e144208120322ddd12d8782ed3446fd90e606a07b2272a5b9b4e1b747cbda41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.15.0a5

Security for pyattlib 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page