sambuca_core.utility

Sambuca_Core utility code module

Collections

Operating system-specific utility functions.

sambuca_core.utility.collections.merge_dictionary(target, new_items)[source]

Merges a dictionary into the master set, warning when a duplicate name is detected. Keys from new_items that are already present in target will generate warnings without modifying target.

And yes, I know there are builtin methods to merge dictionaries (update), but I wanted finer control over handling for existing keys.

Parameters:
  • target (dictionary) – The destination dictionary.
  • new_items (dictionary) – The dictionary of new items to merge.
Returns:

target, with all unique items merged from new items.

Return type:

dict

sambuca_core.utility.collections.pairwise(iterable)[source]

s -> (s0,s1), (s1,s2), (s2, s3), …

Numpy

Numpy-specific utility functions.

sambuca_core.utility.numpy.strictly_decreasing(x)[source]

Tests if a 1D vector is strictly decreasing, where x[i+1] < x[i] for i in [0 .. len(x)].

Parameters:x (array-like) – The vector to test.
Returns:True if x is strictly decreasing; false otherwise.
Return type:bool
sambuca_core.utility.numpy.strictly_increasing(x)[source]

Tests if a 1D vector is strictly increasing, where x[i+1] > x[i] for i in [0 .. len(x)].

Parameters:x (array-like) – The vector to test.
Returns:True if x is strictly increasing; false otherwise.
Return type:bool

OS

Operating system-specific utility functions.

sambuca_core.utility.os.list_files(directory, extensions=None)[source]

Get a list of files in a directory, filtered by an optional list of extensions.

Parameters:
  • directory (str) – The directory to list.
  • extensions (list) – Optional list of file extensions.
Returns:

The list of matching file info objects.

Return type:

list