Miscellaneous

class featomic.FeatomicError(message, status=None)

Exceptions thrown for all errors in featomic.

message

str, error message for this exception

status

Optional[int], status code for this exception

featomic.set_logging_callback(function)

Call function on every log event.

The callback functions should take two arguments: an integer value representing the log level and a string containing the log message. The function return value is ignored.

featomic.log.default_logging_callback(level, message)

Redirect message to the logging module.

class featomic.Profiler

Profiler recording execution time of featomic functions.

Featomic uses the time_graph to collect timing information on the calculations. The Profiler class can be used as a context manager to access to this functionality.

The profiling code collects the total time spent inside the most important functions, as well as the function call graph (which function called which other function).

import featomic

with featomic.Profiler() as profiler:
    # run some calculations
    ...

print(profiler.as_short_table())
as_json()

Get current profiling data formatted as JSON.

as_table()

Get current profiling data formatted as a table.

as_short_table()

Get current profiling data formatted as a table, using short functions names.

featomic.convert_hypers(origin, representation=None, hypers=None)

Convert hyper-parameters from other software into the format used by featomic.

Parameters:
  • origin

    which software do the hyper-parameters come from? Valid values are:

    • "rascaline" for old rascaline format;

  • representation

    which representation are these hyper for? The meaning depend on the origin:

    • for origin="rascaline", this is the name of the calculator class;

  • hypers

    the hyper parameter to convert. The type depend on the origin:

    • for origin="rascaline", this should be a dictionary;

Returns:

A string containing the code corresponding to the requested representation and hypers

featomic.utils.hypers_to_json(hypers_dict: Dict[str, Any])

Convert from class version of featomic hyper-parameters to the JSON version.

The class version would contain something like {"cutoff": Cutoff(radius=3.4)}, which this function transforms into {"cutoff": {"radius": 3.4", "smoothing": {"type": "Step"}}}.