API reference

See modules for a short description of each modules. For a full listing of the contents of all modules, see the module contents overview.

The API reference makes heavy use of a type language; for example, to describe exactly what arguments can be passed to a function.

Modules

algorithms Various algorithms, e.g.
asyncio Extensions to asyncio.
click click utilities
configuration Configuration loaders, currently only from configuration files
data_frame Extensions to pandas.DataFrame
debug Debug utilities.
dict dict utilities
exceptions Exception classes: UserException and InvalidOperationError.
function Function manipulation, like functools.
hashlib hashlib additions
http HTTP utilities.
inspect Similar to inspect module.
iterable Utility functions for working with iterables.
logging Logging utilities.
multi_dict multi-dict utilities. Multi-dicts can map keys to multiple values.
observable Observable collections.
path Extensions to pathlib.
pymysql pymysql utilities. Contains only patch, patches pymysql to be compatible with numpy and others.
series Utilities for working with pandas.Series.
set Set utilities.
sqlalchemy sqlalchemy utilities. Contains pretty sql formatting and temporarily enabling sqlalchemy logging
test Test utilities.

Module contents overview

algorithms

multi_way_partitioning Greedily divide weighted items equally across bins (multi-way partition problem)
spread_points_in_hypercube Place points in a unit hypercube such that the minimum distance between points is approximately maximal.
toset_from_tosets Create totally ordered set (toset) from tosets.

asyncio

stubborn_gather Stubbornly wait for awaitables, despite some of them raising

click

argument Like click.argument, but by default required=True
assert_runs Invoke click command and assert it completes successfully
option Like click.option, but by default show_default=True, required=True
password_option Like click.option, but by default prompt=True, hide_input=True, show_default=False, required=True.

configuration

ConfigurationLoader Loads a single configuration from one or more files

data_frame

assert_equals Assert 2 data frames are equal
equals Get whether 2 data frames are equal
replace_na_with_none Replace NaN values in pd.DataFrame with None
split_array_like Split cells with array_like values along row axis.

debug

pretty_memory_info Get pretty memory info message

dict

pretty_print_head Pretty print some items of a dict
DefaultDict Replacement for collections.defaultdict, its default value factory takes a
invert Invert dict by swapping each value with its key
assign Assign one dict to the other through mutations

exceptions

UserException Exception with message to show the user.
InvalidOperationError When an operation is illegal/invalid (in the current state), regardless of what arguments you throw at it.

function

compose Compose functions

hashlib

base85_digest Get base 85 encoded digest of hash

http

download Download an HTTP resource to a file

inspect

call_args Get function call arguments as a single dict

iterable

sliding_window Iterate using a sliding window
partition Split iterable into partitions
is_sorted Get whether iterable is sorted ascendingly
flatten Flatten shallowly zero or more times

logging

configure Configure root logger to log INFO to stderr and DEBUG to log file.
set_level Temporarily change log level of logger

multi_dict

MultiDict A multi-dict view of a {hashable => {hashable}} dict.

observable

Set Observable set

path

assert_equals Assert 2 files are equal
assert_mode Assert last 3 octal mode digits match given mode exactly
chmod Change file mode bits
hash Hash file or directory
read Get file contents
remove Remove file or directory (recursively), unless it’s missing
write Create or overwrite file with contents

pymysql

patch Patch bugs and add encoders for other data types to pymysql

series

assert_equals Assert 2 series are equal
equals Get whether 2 series are equal
invert Swap index with values of series
split Split values

set

merge_by_overlap Of a list of sets, merge those that overlap, in place.

sqlalchemy

log_sql Temporarily log SQL statements
pretty_sql Pretty format sql

test

assert_text_contains Assert long string contains given string
assert_text_equals Assert long strings are equal
assert_matches
assert_search_matches
temp_dir_cwd pytest fixture that sets current working directory to a temporary directory