Skip to main content

bisect-list

Find bad values in a list, logarithmically (FAST!)!

install

poetry add bisect-list

usage

bisect_exception(values, func)

Logarithmically removes items that don't trigger an exception.

Useful for finding the minimal list of items that triggers an excetpion.

from unittest.mock import MagicMock

from bisect_list import bisect_exception

def error_3705_and_7399(values):
    if 3705 in values and 7399 in values:
        raise Exception(f"Never mix 2 with 5!")

mock_func = MagicMock(side_effect=error_3705_and_7399)

values = list(range(10_000))
result = bisect_exception(values, mock_func)
assert result == [3705, 7399]

assert mock_func.call_count == 53

bisect_same_exception(values, func)

Same as bisect_exception, except makes sure the type of the exception is the same as when calling func(values) before starting the bisection.

from bisect_list import bisect_same_exception

class SpecialException(Exception):
    pass

def error_2_and_5(values):
    if 2 in values and 5 in values:
        raise SpecialException(f"Never mix 2 with 5!")
    raise Exception("different exception")

values = [1, 2, 3, 4, 5, 6, 7, 8, 9]
result = bisect_same_exception(values, error_2_and_5)
assert result == [2, 5]

biest(values, test)

from bisect_list import bisect

result = bisect(
    [1, 2, 3, 4, 5, 6, 7, 8, 9],
    test=lambda xs: 2 in xs and 8 in xs
)
assert result == [2, 8]

license

MIT

Metadata

Release files for bisect-list 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 bisect-list 0.1.1
File Size Uploaded Provenance Actions
bisect_list-0.1.1.tar.gz 3.5 kB Without provenance Details for bisect_list-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 7.7 kB

Release files / bisect_list-0.1.1.tar.gz

Download URL bisect_list-0.1.1.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
befee8700588d07bcf0b52c80d1463156209ab4755c21d5730147e6bd23f9d2d
BLAKE2b-256 checksum
How to use checksums
cfebf0308d7406a40369336ef76806cabf1d88be7d7ae14a0002d670449723c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.11.0 Darwin/22.3.0

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

Download URL bisect_list-0.1.1-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23eda24319d61b1cba6638b27a53fcfb9f28dd7bf4c5b85c3abcc61357353603
BLAKE2b-256 checksum
How to use checksums
a3cafc949e5dcf91113937d392cb8993fb6cf9439e450a32dfaedf7cdf757158
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.2 CPython/3.11.0 Darwin/22.3.0

Security for bisect-list 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