Skip to main content

Recursive subset comparison for complex nested Python data structures

Project description

deepset - Recursive Subset Comparison for Python

PyPI version Python versions License

Recursive subset comparison for complex nested Python data structures. Express relationships like "this nested structure is contained within that one" naturally.

Quick Start

from deepset import deepset

# Set subsets
assert deepset({1, 2}) <= {1, 2, 3}  # True

# Nested structures  
assert deepset({('a', frozenset({2}))}) <= {('a', frozenset({2, 3}))}  # True

# Sequential lists (order matters, gaps allowed)
assert deepset([1, 3]) <= [1, 2, 3, 4]  # True

# Dictionary subsets
assert deepset({'a': 1}) <= {'a': 1, 'b': 2}  # True

# Mixed nested
data1 = {'sets': {frozenset({1, 2})}, 'lists': [[1, 2]]}
data2 = {'sets': {frozenset({1, 2, 3})}, 'lists': [[1, 2, 3]]}
assert deepset(data1) <= data2  # True

Installation

pip install deepset

Comparison Types

Sets: Traditional subset semantics

assert deepset({1, 2}) < {1, 2, 3}  # True (strict subset)
assert deepset({frozenset({1, 2})}) <= {frozenset({1, 2, 3})}  # Recursive

Lists/Tuples: Sequential subset (order preserved, gaps allowed)

assert deepset([1, 3]) <= [1, 2, 3, 4]  # True
assert not deepset([1, 3]) <= [3, 1]    # False (wrong order)

Dictionaries: Key subset + recursive value comparison

assert deepset({'a': 1}) <= {'a': 1, 'b': 2}       # True (extra key)
assert deepset({'a': [1, 2]}) <= {'a': [1, 2, 3]}  # True (recursive)

All Operators: <, <=, ==, >=, > supported

Development

git clone https://github.com/pjkundert/python-deepset.git
cd python-deepset

# Standard development (with user provided Python, package installation)
make install-dev   # Install dev dependencies
make test          # Run tests
make style         # Format code (autopep8, black, isort)
make build         # Build package

# Nix environment (recommended for reproducible builds)
make nix-venv                   # Enter Nix + venv environment
make nix-venv-test              # Run tests in Nix environment
make nix-venv-unit-test_name    # Run specific test class

# Multi-version testing
TARGET=py310 make nix-venv-test # Test with Python 3.10
TARGET=py312 make nix-venv-test # Test with Python 3.12

License

MIT License - Perry Kundert perry@dominionrnd.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deepset-1.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deepset-1.1.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file deepset-1.1.0.tar.gz.

File metadata

  • Download URL: deepset-1.1.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for deepset-1.1.0.tar.gz
Algorithm Hash digest
SHA256 77bdb3acbc483a92f5b6eac17c09d865e1ee02193b3eabc0c65b490438c6ba6a
MD5 0c8d1c75a0ce5b7c0e852b6983c82b60
BLAKE2b-256 952dd0ed5b077ebfa6daee86085fcac5ae6c189bf97a6ae20031f9f063734255

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepset-1.1.0.tar.gz:

Publisher: release.yml on pjkundert/python-deepset

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file deepset-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: deepset-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for deepset-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b01d547ed572e54a0644ee5cbd7c7961d1c4b9445004687307141da072a447f9
MD5 e6696de790455d7e69448fde35977f7c
BLAKE2b-256 0a3fcb033b4f39b58ac4ba043f73b5bf272c90a97471de514707eee8390310e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for deepset-1.1.0-py3-none-any.whl:

Publisher: release.yml on pjkundert/python-deepset

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page