anypytools.tools

Created on Sun Sep 7 13:25:38 2014.

@author: Morten

class anypytools.tools.AMSVersion(major: int, minor: int, patch: int, build: int)[source]
class anypytools.tools.AnyPyProcessOutput(*args, **kwargs)[source]

Subclassed OrderedDict which supports partial key access.

to_dataframe(index_var: str | None = 'auto', interp_var=None, interp_val=None, interp_method='cubic')[source]

Convert the output to a pandas dataframe.

Parameters:

index_var: str

Name of the variable to use as axis 0 in the dataframe. If “auto” is given the system will look for variables ending with “Ouput.Abcsissa.t”. If ‘None’ no index variable is used an only a single row is returned in the dataframe.

interp_var: str

Name of the variable on which the data is interpolating/resampled.

interp_val: np.ndarray

Values to use when re-interpolating/resampling the data.

interp_method: str

Method to use when re-interpolating/resampling the data. Defaults to ‘cubic’.

Returns:

df: pandas.DataFrame

Dataframe with the output data.

class anypytools.tools.AnyPyProcessOutputList(*args)[source]

List like class to wrap the output of model simulations.

The class behaves as a normal list but provide extra function to easily access data.

filter(function)[source]

Filter elements for whichfunction returns true.

insert(item, v)[source]

S.insert(index, value) – insert value before index

to_dataframe(index_var='auto', **kwargs)[source]

Return output of all simuations as a concatenated pandas dataframe.

Parameters:

index_var: str

Name of the variable to use as axis 0 in the dataframe. If not given system will look for variables ending with “Ouput.Abcsissa.t”

interp_var: str

Name of the variable on which the data is interpolating/resampled.

interp_val: np.ndarray

Values to use when re-interpolating/resampling the data.

interp_method: str

Method to use when re-interpolating/resampling the data. Defaults to ‘cubic’.

Returns:

pandas.DataFrame

tolist()[source]

Return as native python types (list of dicts).

anypytools.tools.anybodycon_version(anybodyconpath=None)[source]

Return the AnyBodyCon version.

anypytools.tools.array2anyscript(arr)[source]

Format a numpy array as an anyscript variable.

anypytools.tools.case_preserving_replace(string, old, new)[source]

Replace string while preserving the case

anypytools.tools.correct_dump_prefix(raw, idx)[source]

Find the correct prefix to use in the output

anypytools.tools.find_ammr_path(folder=None)[source]

Return the root AMMR path if possible .

The function will walk up a directory tree looking for a ammr_verion.any file to parse.

anypytools.tools.get_ammr_version(folder=None)[source]

Return the AMMR version if possible.

The function will walk up a directory tree looking for a ammr_verion.any file to parse.

anypytools.tools.get_anybodycon_path()str | None[source]

Return the path to default AnyBody console application. If AnyBodyCon.exe is on path it will take precedence over the registry lookup.

anypytools.tools.get_bm_constants(ammr_path=None, ammr_version=2)[source]

Return the BM_CONSTANT mapping.

It will try to locate the mapping in the AMMR: Body/AAUHuman/Documentation/bm_constants.py

If that fails it will use the ammr_version specification to select a value.

anypytools.tools.get_git_branch_info()[source]

Return the branch name for git repository.

anypytools.tools.get_ncpu()[source]

Return the number of CPUs in the computer.

anypytools.tools.getsubdirs(toppath, search_string='.')[source]

Find all directories below a given top path.

Args:

toppath: top directory when searching for sub directories search_string: Limit to directories matching the this regular expression

Returns:

List of directories

anypytools.tools.make_hash(o)[source]

Make a hash from a dictionary, list, tuple or set.

Create the hash to any sublevel that contains only other hashable types (including any lists, tuples, sets, and dictionaries). http://stackoverflow.com/questions/5884066/hashing-a-python-dictionary

anypytools.tools.parse_anybodycon_output(raw, errors_to_ignore=None, warnings_to_include=None, fatal_warnings=False)[source]

Parse the output log file from AnyBodyConsole to for data, errors and warnings. If fatal_warnins is True, then warnings are also added to the error list.

anypytools.tools.replace_bm_constants(d, bm_constants=None)[source]

Replace BM constants with value represenation.

anypytools.tools.silentremove(filename)[source]

Remove a file ignoring cases where the file does not exits.

anypytools.tools.walk_up(bottom)[source]

Mimic os.walk, but walk ‘up’ instead of down the directory tree.

anypytools.tools.winepath(path, opts=None)[source]

Wrapper for the winepath commandline tool

anypytools.tools.wraptext(elem, initial_indent='', subsequent_indent=None)[source]

Wraps text to fit the terminal window.