bucky.util

Submodule containing various types of utility functions.

Submodules

Package Contents

Classes

TqdmLoggingHandler

Logging handler that is friendly with tqdm.

dotdict

dot.notation access to dictionary attributes.

Functions

_banner()

A banner for the CLI.

bin_age_csv(filename, out_filename)

Group ages in the Census csv to match the bins used by Prem et al.

estimate_IFR(age)

Estimate the best fit IFR for a given age.

remove_chars(seq)

Remove all non digit characters from a string, but cleanly passthrough non strs.

class bucky.util.TqdmLoggingHandler(level=logging.NOTSET)[source]

Bases: logging.Handler

Logging handler that is friendly with tqdm.

See: https://stackoverflow.com/questions/38543506/change-logging-print-function-to-tqdm-write-so-logging-doesnt-interfere-wit

emit(self, record)[source]

Emit message.

class bucky.util.dotdict[source]

Bases: dict

dot.notation access to dictionary attributes.

__delattr__[source]
__getattr__[source]
__setattr__[source]
__deepcopy__(self, memo=None)[source]

Return a deepcopy of the dict.

bucky.util._banner()[source]

A banner for the CLI.

bucky.util.bin_age_csv(filename, out_filename)[source]

Group ages in the Census csv to match the bins used by Prem et al.

Parameters
  • filename (str) – Location of Census CSV

  • out_filename (str) – Output filename for binned data

bucky.util.estimate_IFR(age)[source]

Estimate the best fit IFR for a given age.

See https://www.medrxiv.org/content/10.1101/2020.07.23.20160895v4.full.pdf for the fit

Parameters

age (numpy.ndarray or cupy.ndarray if using CuPy) – Array of ages to calculate IFR for

Returns

ifr – The calculated best fit IFR

Return type

numpy.ndarray or cupy.ndarray if using CuPy

bucky.util.remove_chars(seq)[source]

Remove all non digit characters from a string, but cleanly passthrough non strs.

Parameters

seq (Any) – Strings will be modified, any other type is directly returned

Returns

The original sequence, minus non-digit characters if input was a string

Return type

Any