pantea.utils package#

Submodules#

pantea.utils.attribute module#

pantea.utils.attribute.asarray(data, dtype=None)[source]#

An utility function to cast input data (scalar, array, etc) to Array type with predefined dtype.

Parameters
  • value (Any) – input data

  • dtype (Optional[Dtype], optional) – casted dtype. Default dtype will be used otherwise.

Returns

casted input

Return type

Array

pantea.utils.attribute.set_as_attribute(obj, items, prefix='', postfix='')[source]#

An utility function to set a dictionary of items as the input object attributes.

Parameters
  • obj (Any) – instance

  • items (Dict[str, Any]) – dictionary of attributes

  • prefix (str, optional) – _description_, defaults to “”

  • postfix (str, optional) – _description_, defaults to “”

Return type

None

pantea.utils.batch module#

pantea.utils.batch.create_batch(array, batch_size)[source]#

Create baches of the input array.

Parameters
  • array (Array) – input array

  • batch_size (int) – desired batch size

Yield

a batch of input array

Return type

Generator[Array, None, None]

pantea.utils.compare module#

pantea.utils.compare.compare(structure1, structure2, errors='RMSEpa', return_difference=False)[source]#

Compare the force and total energy values between two input structures and returning the desired errors metrics.

Parameters
  • structure1 (Structure) – first structure

  • structure2 (Structure) – second structure

  • error – a list of error metrics including RMSE, RMSEpa, MSE, and MSEpa. Defaults to [RMSEpa]

  • return_difference (bool) – whether return energy and force array differences or not, defaults to False

Return type

Dict[str, ArrayImpl]

Returns

a dictionary of error metrics.

pantea.utils.profiler module#

class pantea.utils.profiler.Profiler(name='Profiler', sort_by='cumtime')[source]#

Bases: object

An implementation of a basic profiler for debugging.

How to use it:
  1. add profile() as a decorator before each targeted method

  2. use context manager to collect stats from the region of interest

get_dataframe()[source]#

Return a dataframe representation of profiler statistics.

Return type

DataFrame

static profile(func)[source]#
Return type

Callable

class pantea.utils.profiler.Timer(name='Timer')[source]#

Bases: object

A class to measure elapsed time.

pantea.utils.profiler.timer(func)[source]#

A decorator to measure elapsed time when calling a function.

pantea.utils.tokenize module#

pantea.utils.tokenize.tokenize(line, comment=None)[source]#

An utility function to read the input line as a keyword and list of tokens.

Return type

Tuple[Optional[str], List[str]]

Module contents#

class pantea.utils.Profiler(name='Profiler', sort_by='cumtime')[source]#

Bases: object

An implementation of a basic profiler for debugging.

How to use it:
  1. add profile() as a decorator before each targeted method

  2. use context manager to collect stats from the region of interest

get_dataframe()[source]#

Return a dataframe representation of profiler statistics.

Return type

DataFrame

static profile(func)[source]#
Return type

Callable