Skip to main content

Subpaths

Finding common subpaths and counting occurrences of all subpaths between paths.

Examples

Finding common subpaths between paths

from pprint import pprint
from subpaths.subpaths import find_all_common_subpaths_between

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

pprint(find_all_common_subpaths_between(path_a, path_b, path_c))

Will return:

{(3, 4)}

Counting all subpaths between paths

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.2.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.2.0
File Size Uploaded
subpaths-0.2.0.tar.gz 2.8 kB Details

Built distribution (wheel)

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

Total release size: 7.1 kB

Release files / subpaths-0.2.0.tar.gz

Download URL subpaths-0.2.0.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4e3b9deaa5c519844d253d3f1d29568b79cc9c649378b336c560cb70182ace0f
BLAKE2b-256 checksum
How to use checksums
d2ea2ac1931758c8fc53c231466c1b5efe8424c1cbc26ca6ebedcd0bcbd7ca94
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.2.0-py3-none-any.whl

Download URL subpaths-0.2.0-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de76e58820992ce18fd4e11eb7ca349385bf3f58c7c6bc19a28876a4494ffefd
BLAKE2b-256 checksum
How to use checksums
31a98e22833920850b94e7efc55b2a25214b5473da5ed19fee7092d68d8a046d
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 history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

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