TransportMaps.Misc

Module Contents

Classes

cached

cached_tuple

DataStorageObject

state_loader

Loader of state provided to functions

Functions

cmdinput(instr[, default])

read_and_cast_input(field_name, cast_type[, current_value])

deprecate(name, version, msg)

setLogLevel(level)

Set the log level for all existing and new objects related to the TransportMaps module

counted(f)

required_kwargs(*keys)

generate_total_order_midxs(max_order_list)

Generate a total order multi-index

no_cost_function(*args, **kwargs)

total_time_cost_function(ncalls, nevals, teval[, ...])

get_sub_cache(cache, *args)

taylor_test(x, dx, f[, gf, hf, ahf, h, fungrad, ...])

Test the gradient and Hessian of a function using the Taylor test.

argsort(seq)

Attributes

LOG_LEVEL

logger

TransportMaps.Misc.cmdinput(instr, default='')[source]
TransportMaps.Misc.read_and_cast_input(field_name, cast_type, current_value=None)[source]
TransportMaps.Misc.LOG_LEVEL[source]
TransportMaps.Misc.logger[source]
TransportMaps.Misc.deprecate(name, version, msg)[source]
TransportMaps.Misc.setLogLevel(level)[source]

Set the log level for all existing and new objects related to the TransportMaps module

Parameters:

level (int) – logging level

TransportMaps.Misc.counted(f)[source]
TransportMaps.Misc.required_kwargs(*keys)[source]
TransportMaps.Misc.generate_total_order_midxs(max_order_list)[source]

Generate a total order multi-index

Given the list of maximums \({\bf m}\), the returned set of multi-index \(I\) is such that \(\sum_j^d {\bf_i}_j <= max {\bf m}\) and \({\bf i}_j <= {\bf m}_j\).

TransportMaps.Misc.no_cost_function(*args, **kwargs)[source]
TransportMaps.Misc.total_time_cost_function(ncalls, nevals, teval, ncalls_x_solve=None, new_nx=None)[source]
class TransportMaps.Misc.cached(sub_cache_list=[], caching=True)[source]

Bases: object

__call__(f)[source]
class TransportMaps.Misc.cached_tuple(commands=[], sub_cache_list=[], caching=True)[source]

Bases: object

__call__(f)[source]
TransportMaps.Misc.get_sub_cache(cache, *args)[source]
TransportMaps.Misc.taylor_test(x, dx, f, gf=None, hf=None, ahf=None, h=0.0001, fungrad=False, caching=False, args={})[source]

Test the gradient and Hessian of a function using the Taylor test.

Using a Taylor expansion around \({\bf x}\), we have

\[f({\bf x}+h \delta{\bf x}) = f({\bf x}) + h (\nabla f({\bf x}))^\top \delta{\bf x} + \frac{h^2}{2} (\delta{\bf x})^\top \nabla^2 f({\bf x}) \delta{\bf x} + \mathcal{O}(h^3)\]

Therefore

\[\vert f({\bf x}+h \delta{\bf x}) - f({\bf x}) - h (\nabla f({\bf x}))^\top \delta{\bf x} \vert = \mathcal{O}(h^2)\]

and

\[\vert f({\bf x}+h \delta{\bf x}) - f({\bf x}) - h (\nabla f({\bf x}))^\top \delta{\bf x} - \frac{h^2}{2} (\delta{\bf x})^\top \nabla^2 f({\bf x}) \delta{\bf x} \vert = \mathcal{O}(h^3)\]
Parameters:
  • x (ndarray [\(m,d_x\)]) – evaluation points \({\bf x}\)

  • dx (ndarray [\(m,d_x\)]) – perturbation direction \(\delta{\bf x}\)

  • f (function) – function \({\bf x} \mapsto f({\bf x})\). If fungrad==True, then f is the mapping \({\bf x} \mapsto (\nabla f({\bf x}), f({\bf x}))\).

  • gf (function) – gradient function \({\bf x} \mapsto \nabla f({\bf x})\)

  • hf (function) – Hessian function \({\bf x} \mapsto \nabla^2 f({\bf x})\)

  • ahf (function) – action of the Hessian function \({\bf x},\delta{\bf x} \mapsto (\nabla f({\bf x}))^\top \delta{\bf x}\)

  • h (float) – perturbation step

  • fungrad (bool) – whether f returns also the gradient or not.

  • caching (bool) – whether to pass a cache dictionary to the functions.

  • args (dict) – arguments to be passed to functions

TransportMaps.Misc.argsort(seq)[source]
class TransportMaps.Misc.DataStorageObject[source]

Bases: object

class TransportMaps.Misc.state_loader(keys=None)[source]

Bases: object

Loader of state provided to functions

__call__(f)[source]