Skip to main content

Subpaths

Finding common subpaths between paths.

Example

from pprint import pprint
from subpaths.subpaths import find_all_subpath_occurrences

path_a = [1, 2, 3, 4, 5]

pprint(find_all_subpath_occurrences(path_a))

path_b = [3, 4, 5, 7]
path_c = [2, 3, 4, 8, 9, 7]

pprint(find_all_subpath_occurrences(path_a, path_b, path_c))

Will return:

defaultdict(<class 'int'>,
            {(1, 2): 1,
             (1, 2, 3): 1,
             (1, 2, 3, 4): 1,
             (1, 2, 3, 4, 5): 1,
             (2, 3): 1,
             (2, 3, 4): 1,
             (2, 3, 4, 5): 1,
             (3, 4): 1,
             (3, 4, 5): 1,
             (4, 5): 1})
defaultdict(<class 'int'>,
            {(1, 2): 1,
             (1, 2, 3): 1,
             (1, 2, 3, 4): 1,
             (1, 2, 3, 4, 5): 1,
             (2, 3): 2,
             (2, 3, 4): 2,
             (2, 3, 4, 5): 1,
             (2, 3, 4, 8): 1,
             (2, 3, 4, 8, 9): 1,
             (2, 3, 4, 8, 9, 7): 1,
             (3, 4): 3,
             (3, 4, 5): 2,
             (3, 4, 5, 7): 1,
             (3, 4, 8): 1,
             (3, 4, 8, 9): 1,
             (3, 4, 8, 9, 7): 1,
             (4, 5): 2,
             (4, 5, 7): 1,
             (4, 8): 1,
             (4, 8, 9): 1,
             (4, 8, 9, 7): 1,
             (5, 7): 1,
             (8, 9): 1,
             (8, 9, 7): 1,
             (9, 7): 1})

Download

pip install subpaths

Future Improvements

  • Bound the shorted and longest paths to generate and count

Metadata

Release files for subpaths 0.1.0

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

Source distribution (sdist)

Source distribution for subpaths 0.1.0
File Size Uploaded Provenance Actions
subpaths-0.1.0.tar.gz 2.4 kB Without provenance Details for subpaths-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 6.3 kB

Release files / subpaths-0.1.0.tar.gz

Download URL subpaths-0.1.0.tar.gz
Size 2.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ac67203aa4e53093b7bd39cd471ea740e265a8b16482f3087c89fdc314df5565
BLAKE2b-256 checksum
How to use checksums
038eed60f7dabe146c7ec74bc9fa681b235d5172ba9a138306e044ba0967eac4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

Release files / subpaths-0.1.0-py3-none-any.whl

Download URL subpaths-0.1.0-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2ba71412fc5afbc7bca8764c3b9805185c814dbc398cd1be319f9afc94dc15f0
BLAKE2b-256 checksum
How to use checksums
2cb8bf91a196dfb26e62485531b3422c8b54457549496620441f6c902eb5ac03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

Security for subpaths 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.

Release history Release notifications | RSS feed

This release

0.1.0 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