helpers
Functions
function
camel(name: str) → strParameters
name: str
function
check32() → tuple[(bool, str, str)]function
cleanName(name: str) → strParameters
name: str
function
collectFormats(config: dict[(str, str)]) → tuple[(dict[(str, tuple[(str, str, tuple[(tuple[(tuple[(str, ...)], str)], ...)])])], list[str])]Parameters
config: dict[(str, str)]
function
console(msg: Any = (), error: bool = False, newline: bool = True, file: Any = None) → NoneParameters
msg: Any= ()error: bool= Falsenewline: bool= Truefile: Any= None
function
deepSize(o: Any, handlers: dict[(type, Callable[([Any], Any)])] = {'cls': 'ExprDict', 'keys': [], 'values': []}, verbose: bool = False, seen: set[int] | None = None) → intReturns the approximate memory footprint an object and all of its contents.
Returns the approximate memory footprint an object and all of its contents.
Automatically finds the contents of the following builtin containers and
their subclasses:
`tuple`, `list`, `deque`, `dict`, `set` and `frozenset`.
To search other containers, add handlers to iterate over their contents:
```
handlers = {SomeContainerClass: iter,
OtherContainerClass: OtherContainerClass.get_elements}
```
Parameters
o: Anyhandlers: dict[(type, Callable[([Any], Any)])]verbose: bool= Falseseen: set[int] | None= None
function
fitemize(value: Any) → list[str]Parameters
value: Any
function
flattenToSet(features: str | list[Any] | tuple[(Any, ...)]) → set[str]Parameters
features: str | list[Any] | tuple[(Any, ...)]
function
formatMeta(featureMeta: dict[(str, dict[(str, str)])]) → dict[(str, dict[(str, str)])]Reorder meta data.
Reorder meta data.
Parameters
----------
meta: dict
Dictionary of meta data: keyed by feature, valued by a dict
of metadata in the form of key values
Returns
-------
dict
A copy of the dict but with the values for metadata keys
`desc` and `eg` merged under a new key `description`,
and the keys `desc` and `eg` deleted.
Parameters
featureMeta: dict[(str, dict[(str, str)])]
function
getAllRealFeatures(api: Any) → set[str]Get all configuration features and all loaded node and edge features.
Get all configuration features and all loaded node and edge features.
Except `omap@v-w` features.
When we take volumes or collections from works,
we need to pass these features on.
This will exclude the computed features and the node / edge features
that are not loaded by default.
Parameters
api: Any
function
htmlEsc(val: Any, math: bool = False) → strEscape certain HTML characters by HTML entities.
Escape certain HTML characters by HTML entities.
To prevent them to be interpreted as HTML
in cases where you need them literally.
Parameters
----------
val: string
The input value
math: boolean, optional False
Whether retain TeX notation.
If True, `$` is not escaped, if False, it is not escaped.
Parameters
val: Anymath: bool= False
function
isClean(name: str | None) → boolParameters
name: str | None
function
isInt(val: Any) → boolParameters
val: Any
function
itemize(string: str | None, sep: str | None = None) → list[str]Parameters
string: str | Nonesep: str | None= None
function
makeExamples(nodeList: list[int] | tuple[(int, ...)]) → strParameters
nodeList: list[int] | tuple[(int, ...)]
function
makeIndex(data: dict[(int, int)]) → dict[(int, set[int])]Parameters
data: dict[(int, int)]
function
makeInverse(data: dict[(int, list[int] | set[int])]) → dict[(int, set[int])]Parameters
data: dict[(int, list[int] | set[int])]
function
makeInverseVal(data: dict[(int, dict[(int, Any)])]) → dict[(int, dict[(int, Any)])]Parameters
data: dict[(int, dict[(int, Any)])]
function
mathEsc(val: Any) → strEscape dollar signs to `<span>$</span>`.
Escape dollar signs to `<span>$</span>`.
To prevent them from being interpreted as math in a Jupyter notebook
in cases where you need them literally.
Parameters
val: Any
function
mdEsc(val: Any, math: bool = False) → strEscape certain markdown characters.
Escape certain markdown characters.
Parameters
----------
val: string
The input value
math: boolean, optional False
Whether retain TeX notation.
If True, `$` is not escaped, if False, it is not escaped.
Parameters
val: Anymath: bool= False
function
mdhtmlEsc(val: Any, math: bool = False) → strEscape certain Markdown characters by HTML entities or span elements.
Escape certain Markdown characters by HTML entities or span elements.
To prevent them to be interpreted as Markdown
in cases where you need them literally.
Parameters
----------
val: string
The input value
math: boolean, optional False
Whether retain TeX notation.
If True, `$` is not escaped, if False, it is not escaped.
Parameters
val: Anymath: bool= False
function
mergeDict(source: dict[(str, Any)], overrides: dict[(str, Any)]) → NoneMerge overrides into a source dictionary recursively.
Merge overrides into a source dictionary recursively.
Parameters
----------
source: dict
The source dictionary, which will be modified by the overrides.
overrides: dict
The overrides, itself a dictionary.
Parameters
source: dict[(str, Any)]overrides: dict[(str, Any)]
function
mergeDictOfSets(d1: dict[(Any, set[Any])], d2: dict[(Any, set[Any])]) → NoneParameters
d1: dict[(Any, set[Any])]d2: dict[(Any, set[Any])]
function
nbytes(by: int | float) → strParameters
by: int | float
function
pandasEsc(x: Any) → strEscapes the character that will be used as the `pandas` quote char.
Escapes the character that will be used as the `pandas` quote char.
The escaping is realized by prepending a special char the quote char.
Also: all tab characters will be replaced by single spaces.
Parameters
x: Any
function
project(iterableOfTuples: set[tuple[(Any, ...)]] | list[tuple[(Any, ...)]], maxDimension: int) → set[Any] | set[tuple[(Any, ...)]]Parameters
iterableOfTuples: set[tuple[(Any, ...)]] | list[tuple[(Any, ...)]]maxDimension: int
function
rangesFromList(nodeList: list[int]) → Generator[(tuple[(int, int)], None, None)]Parameters
nodeList: list[int]
function
rangesFromSet(nodeSet: set[int]) → Generator[(tuple[(int, int)], None, None)]Parameters
nodeSet: set[int]
function
readCfg(folder: str, file: str, label: str, verbose: int = 0, kwargs: Any = {}) → tuple[(bool, AttrDict | dict[(str, Any)] | None)]Parameters
folder: strfile: strlabel: strverbose: int= 0kwargs: Any= {}
function
run(cmdline: str, workDir: str | None = None) → tuple[(bool, int, str, str)]Runs a shell command and returns all relevant info.
Runs a shell command and returns all relevant info.
The function runs a command-line in a shell, and returns
whether the command was successful, and also what the output was, separately for
standard error and standard output.
Parameters
----------
cmdline: string
The command-line to execute.
workDir: string, optional None
The working directory where the command should be executed.
If `None` the current directory is used.
Parameters
cmdline: strworkDir: str | None= None
function
safe_rank_key(Crank: Any) → Callable[([int], int)]Create a sort key function that safely handles out-of-bounds nodes.
Create a sort key function that safely handles out-of-bounds nodes.
Parameters
----------
Crank : array-like
The canonical rank array (0-indexed, so node n has rank Crank[n-1])
Returns
-------
Callable[[int], int]
A function that returns the rank for a node, or a large value for
out-of-bounds nodes (so they sort to the end).
Parameters
Crank: Any
function
setFromSpec(spec: str) → set[int]Parameters
spec: str
function
setFromStr(x: str | None) → set[str]Parameters
x: str | None
function
setFromValue(x: Any, asInt: bool = False) → set[Any]Parameters
x: AnyasInt: bool= False
function
specFromRanges(ranges: list[tuple[(int, int)]] | Generator[(tuple[(int, int)], None, None)]) → strParameters
ranges: list[tuple[(int, int)]] | Generator[(tuple[(int, int)], None, None)]
function
specFromRangesLogical(ranges: list[tuple[(int, int)]] | Generator[(tuple[(int, int)], None, None)]) → list[int | list[int]]Parameters
ranges: list[tuple[(int, int)]] | Generator[(tuple[(int, int)], None, None)]
function
tfFromValue(val: str | int) → str | NoneParameters
val: str | int
function
tsvEsc(x: Any) → strEscapes a double quote for strings to be included in TSV data.
Escapes a double quote for strings to be included in TSV data.
Only `"` and `'` at the beginning of the string are escaped.
The escaping is realized by putting a backslash at the beginning.
Parameters
x: Any
function
utcnow() → dtfunction
valueFromTf(tf: str) → strParameters
tf: str
function
var(envVar: str) → str | NoneRetrieves the value of an environment variable.
Retrieves the value of an environment variable.
Parameters
----------
envVar: string
The name of the environment variable.
Returns
-------
string or void
The value of the environment variable if it exists, otherwise `None`.
Parameters
envVar: str
function
versionSort(x: str) → tuple[(tuple[(int, str, str)], ...)]Parameters
x: str
function
wrapMessages(messages: str | list[str | tuple[(bool, bool, str)]]) → tuple[(bool, str)]Parameters
messages: str | list[str | tuple[(bool, bool, str)]]
function
xmlEsc(val: Any) → strEscape certain HTML characters by XML entities.
Escape certain HTML characters by XML entities.
To prevent them to be interpreted as XML
in cases where you need them literally.
Parameters
val: Any