QDpy
Loading...
Searching...
No Matches
utils.py File Reference

Domain checks, collection helpers, and optional JIT support. More...

Go to the source code of this file.

Namespaces

namespace  qdpy

Functions

bool qdpy.utils.is_iterable (Any obj)
 UTILS ########### {{{1.
bool qdpy.utils.in_bounds (Any val, Any domain)
Tuple[Any,...] qdpy.utils.tuplify (Union[Any, Sequence[Any]] item)
 qdpy.utils.argsort (a, **kwargs)
Sequence[Any] qdpy.utils.flatten_seq_of_seq (Sequence[Sequence[Any]] seq)
Generator[Any, None, None] qdpy.utils.generator_flattened_seq_of_seq (Sequence[Sequence[Any]] seq)
 qdpy.utils.catch (func, handle=lambda e:None, *args, **kwargs)
 qdpy.utils.insert_dict (d, key, val, idx=0, bool in_place=True)
 qdpy.utils._dummyJit (*args, **kwargs)
 NUMBA ########### {{{1.

Detailed Description

Domain checks, collection helpers, and optional JIT support.

Definition in file utils.py.

Function Documentation

◆ _dummyJit()

qdpy.utils._dummyJit ( * args,
** kwargs )
protected

NUMBA ########### {{{1.

Dummy version of jit decorator, does nothing

Definition at line 122 of file utils.py.

◆ argsort()

qdpy.utils.argsort ( a,
** kwargs )
Return indexes ordered by the values they address.

Definition at line 75 of file utils.py.

◆ catch()

qdpy.utils.catch ( func,
handle = lambda e: None,
* args,
** kwargs )
Safeguard function evaluation against exceptions. Useful when calling function inside a list-comprehension.

Definition at line 92 of file utils.py.

◆ flatten_seq_of_seq()

Sequence[Any] qdpy.utils.flatten_seq_of_seq ( Sequence[Sequence[Any]] seq)
Materialise elements from nested sequences in encounter order.

Definition at line 80 of file utils.py.

◆ generator_flattened_seq_of_seq()

Generator[Any, None, None] qdpy.utils.generator_flattened_seq_of_seq ( Sequence[Sequence[Any]] seq)
Yield nested elements in encounter order without an intermediate list.

Definition at line 86 of file utils.py.

◆ in_bounds()

bool qdpy.utils.in_bounds ( Any val,
Any domain )
Check whether a scalar or vector falls inside inclusive bounds.

A vector may use one shared interval or one interval per coordinate.
Coordinate-specific bounds must have the same length as the vector.
A NaN comparison fails the bounds check.

Definition at line 38 of file utils.py.

◆ insert_dict()

qdpy.utils.insert_dict ( d,
key,
val,
idx = 0,
bool in_place = True )
Insert a new key at an index in mapping order, with an option to update the supplied mapping.

Definition at line 100 of file utils.py.

◆ is_iterable()

bool qdpy.utils.is_iterable ( Any obj)

UTILS ########### {{{1.

Return if ``obj`` is iterable or not.

Definition at line 33 of file utils.py.

◆ tuplify()

Tuple[Any, ...] qdpy.utils.tuplify ( Union[Any, Sequence[Any]] item)
Convert a sequence to a tuple, or wrap a single value in a one-item tuple.

Definition at line 67 of file utils.py.