Module utils

Source
Expand description

Module containing miscellaneous utility functions.

Constants§

NESTED_STRUCT_ERR
Error message for when user attempts to set value in a nested struct.

Functions§

add_from
Returns a new array with a constant added starting at xs[i] to the end. Values prior to xs[i] are unchanged.
arrmax
return max of arr
arrmin
return min of arr
clear_cache
Deletes FASTSim data directory, clearing its contents. If subpath is provided, will only delete the subdirectory pointed to by the subpath, rather than deleting the whole data directory. If the subpath is an empty string, deletes the entire FASTSim directory. USE WITH CAUTION, as this function deletes ALL objects stored in the FASTSim data directory or provided subdirectory.
create_project_subdir
Creates/gets an OS-specific data directory and returns the path.
diff
download_file_from_url
Assumes the parent directory exists. Assumes file doesn’t exist (i.e., newly created) or that it will be truncated if it does.
first_eq
Return first index of arr equal to cut
first_grtr
Return first index of arr greater than cut
get_index_permutations
Generate all permutations of indices for a given N-dimensional array shape
interpolate
interpolation algorithm from http://www.cplusplus.com/forum/general/216928/ Arguments: x : value at which to interpolate
interpolate_vectors
interpolation algorithm from http://www.cplusplus.com/forum/general/216928/ Arguments: x : value at which to interpolate
max
return max of 2 f64
min
return min of 2 f64
multilinear
Multilinear interpolation function, accepting any dimensionality N.
ndarrallzeros
return true if the array is all zeros
ndarrcumsum
return cumsum of arr
ndarrunique
return the unique values of the array
path_to_cache
Returns the path to the OS-specific data directory, if it exists.
tire_code_to_radius
Calculate tire radius (in meters) from an ISO metric tire code
url_to_cache
takes an object from a url and saves it in the FASTSim data directory in a rust_objects folder WARNING: if there is a file already in the data subdirectory with the same name, it will be replaced by the new file to save to a folder other than rust_objects, define constant CACHE_FOLDER to be the desired folder name