Skip to main content

finds direct and nested intersections of lists

Project description

finds direct and nested intersections of lists

pip install cythonintersectgroupercython

Tested against Windows 10 / Python 3.11 / Anaconda

Important!

The module will be compiled when you import it for the first time. Cython and a C/C++ compiler must be installed!

Find the intersection of the input lists and numpy arrays and return a dictionary containing
the direct intersections, nested intersections, quantity of intersections, arrays with ID,
different values, mapped IDs, hashes, and check numpy array.

Parameters:
- list_: The input list of lists or numpy arrays
- debug: A flag to enable debugging (default: False)

Returns:
A dictionary containing the following keys:
- direct_intersections: A dictionary containing the direct intersections of the input lists and numpy arrays
- nested_intersections: An array containing the nested intersections of the input lists and numpy arrays
- qty_of_intersections: A dictionary containing the quantity of intersections for each input list or numpy array
- arrays_with_id: An array containing the arrays with ID
- different_values: The count of different values
- mapped_ids: A dictionary containing the mapped IDs
from cythonintersectgroupercython import find_intersection_of_lists
list_ = [
[5, 3, 4, 5],
[5, 11, 12, 3],
[52, 34],
[34, 111, 112],
[1000, 300],
[300, 5000],
]
inters=find_intersection_of_lists(list_)
print(inters)

# {
#     "direct_intersections": {
#         0: array([1], dtype=int64),
#         1: array([0], dtype=int64),
#         2: array([3], dtype=int64),
#         3: array([2], dtype=int64),
#         4: array([5], dtype=int64),
#         5: array([4], dtype=int64),
#     },
#     "nested_intersections": array(
#         [
#             [0, 1, -1, -1, -1, -1],
#             [0, 1, -1, -1, -1, -1],
#             [-1, -1, 2, 3, -1, -1],
#             [-1, -1, 2, 3, -1, -1],
#             [-1, -1, -1, -1, 4, 5],
#             [-1, -1, -1, -1, 4, 5],
#         ],
#         dtype=int64,
#     ),
#     "qty_of_intersections": {0: 2, 1: 2, 2: 1, 3: 1, 4: 1, 5: 1},
#     "arrays_with_id": array(
#         [
#             [0, 1, 2, 0],
#             [0, 3, 4, 1],
#             [5, 6, -1, -1],
#             [6, 8, 9, -1],
#             [10, 11, -1, -1],
#             [11, 12, -1, -1],
#         ],
#         dtype=int8,
#     ),
#     "different_values": 13,
#     "mapped_ids": {
#         0: 5,
#         1: 3,
#         2: 4,
#         3: 11,
#         4: 12,
#         5: 52,
#         6: 34,
#         7: "DUMMYVAL",
#         8: 111,
#         9: 112,
#         10: 1000,
#         11: 300,
#         12: 5000,
#     },
# }


list_ = [
[5, 3, 4, 5],
[5, 11, 12, 3],
[52, 34],
[34, 111, 112],
[1000, 300, 34],
[300, 5000],
]
inters = find_intersection_of_lists(list_)
print(inters)


# {
#     "direct_intersections": {
#         0: array([1], dtype=int64),
#         1: array([0], dtype=int64),
#         2: array([3, 4], dtype=int64),
#         3: array([2, 4], dtype=int64),
#         4: array([2, 3, 5], dtype=int64),
#         5: array([4], dtype=int64),
#     },
#     "nested_intersections": array(
#         [
#             [0, 1, -1, -1, -1, -1],
#             [0, 1, -1, -1, -1, -1],
#             [-1, -1, 2, 3, 4, 5],
#             [-1, -1, 2, 3, 4, 5],
#             [-1, -1, 2, 3, 4, 5],
#             [-1, -1, 2, 3, 4, 5],
#         ],
#         dtype=int64,
#     ),
#     "qty_of_intersections": {0: 2, 1: 2, 2: 2, 3: 2, 4: 3, 5: 1},
#     "arrays_with_id": array(
#         [
#             [0, 1, 2, 0],
#             [0, 3, 4, 1],
#             [5, 6, -1, -1],
#             [6, 8, 9, -1],
#             [10, 11, 6, -1],
#             [11, 12, -1, -1],
#         ],
#         dtype=int8,
#     ),
#     "different_values": 13,
#     "mapped_ids": {
#         0: 5,
#         1: 3,
#         2: 4,
#         3: 11,
#         4: 12,
#         5: 52,
#         6: 34,
#         7: "DUMMYVAL",
#         8: 111,
#         9: 112,
#         10: 1000,
#         11: 300,
#         12: 5000,
#     },
# }

Project details


Release history Release notifications | RSS feed

This version

0.10

Download files

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

Source Distribution

cythonintersectgroupercython-0.10.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file cythonintersectgroupercython-0.10.tar.gz.

File metadata

File hashes

Hashes for cythonintersectgroupercython-0.10.tar.gz
Algorithm Hash digest
SHA256 93ff892584f146244a1ecb6456aea951f6eeef1884e2d8c159b40c8787a2f6d5
MD5 999b1f3202ca8e193c0d990d8ece3d2e
BLAKE2b-256 b2e02c79a6c7fa6a0fc5279a498bd574ce76874a30ce6a151f70c249103a4418

See more details on using hashes here.

File details

Details for the file cythonintersectgroupercython-0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for cythonintersectgroupercython-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 834587e0b03ded0857e61a6e70cc7a4c1ea019a1fdd54513c8ab15b8943c364b
MD5 d16e719df69a5c86d589f8a6a0b9337a
BLAKE2b-256 911012bb5c2249564817d8b1a4335db18592514ce9e417dfff1eb82836f517cd

See more details on using hashes here.

Supported by

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