General utilities

Common routines for Colossus modules.

Module contents

printLine() Print a line to the console.
getHomeDir() Finds the home directory on this system.
getCodeDir() Returns the path to this code file.
isArray(var) Tests whether a variable is iterable or not.
getArray(var) Convert a variable to a numpy array, whether it already is one or not.

Module reference

utils.utilities.printLine()

Print a line to the console.

utils.utilities.parseVersionString(version_str)

Parse a version string into numbers.

There are more official functions to parse version numbers that use regular expressions and can handle more formats according to PEP 440. Since Colossus versions are always composed of three numbers and no letters, we implement a comparison manually to avoid needing to include non-standard libraries.

Parameters:
version_str: str

The version string to be converted.

Returns:
nums: array_like

A list of the three version numbers.

utils.utilities.versionIsOlder(v1, v2)

Compare two version strings.

Parameters:
v1: str

A version string.

v2: str

A second version string.

Returns:
is_older: bool

True if v2 is older than v1, False otherwise.

utils.utilities.getHomeDir()

Finds the home directory on this system.

Returns:
path : string

The home directory, or None if home cannot be found.

utils.utilities.getCodeDir()

Returns the path to this code file.

Returns:
path: string

The code directory.

utils.utilities.isArray(var)

Tests whether a variable is iterable or not.

Parameters:
var: array_like

Variable to be tested.

Returns:
is_array: boolean

Whether var is a numpy array or not.

utils.utilities.getArray(var)

Convert a variable to a numpy array, whether it already is one or not.

Parameters:
var: array_like

Variable to be converted to an array.

Returns:
var_ret: numpy array

A numpy array with one or more entries.

is_array: boolean

Whether var is a numpy array or not.