PDSim.misc package

Subpackages

Submodules

PDSim.misc.datatypes module

class PDSim.misc.datatypes.AnnotatedValue(str key, value, str annotation, str units)

Bases: object

An annotated value is a structured datatype that is used to hold a python object and provide information about the item in a strongly structured way

annotation

str

Type:

annotation

key

str

Type:

key

units

str

Type:

units

value

object

Type:

value

class PDSim.misc.datatypes.Collector

Bases: object

The collector class is a thin wrapper around a list with compact semantics for adding values:

C  = Collector()
C << 1
C << 3

And the values can be obtained as a numpy array by:

C.v()

Or as a list from the attribute:

C.vec
v(self, int ndmin=2)

Get a numpy array of the Collector values

Internally, the call looks like:

return np.array(self.vec, ndmin = ndmin)
Parameters:
  • ndmin – Minimum number of axes

  • int – Minimum number of axes

vec

list

The list that contains the values

Type:

vec

class PDSim.misc.datatypes.arraym(data=None)

Bases: object

A thin wrapper around a low-level c-array with pythonic semantics

Implements the element-wise operators +,-,/,* between arraym instances and other iterables and constants

Note: The only divide operator implemented is the truediv operator of python 3.x . To get the / operator to work in python 2.x, you need to do from __future__ import division in your header

N

The number of entries in this arraym instance

all_finite(self) bool

Return True if all entries in the array are valid (not NAN, INF, etc.)

copy(self) arraym

Return a copy of the instance

dealloc(self)

Clean up the memory we allocated. Not generally needed to be called, python will do the cleanup automatically

extend(self, arraym array2)

Extend this arraym instance with another arraym instance

Parameters:

array2 (arraym instance) – The arraym to be appended to this arraym instance

fill(self, double fillval)

Fill the array with the given value

get_index(self, int i) double

Get the value at the given index

Parameters:

i (int) – The index in the array

set_index(self, int i, double val)

Set the value at the given index

Parameters:

i (int) – The index in the array

set_size(self, int N)

Set the size of the internal array, initialized to zeros

PDSim.misc.datatypes.empty_arraym(int N) arraym

A convenience function to return an arraym with the given size initialized to zero

Parameters:

N (int) – Size of the arraym to return initialized to zero

class PDSim.misc.datatypes.listm(iterable=(), /)

Bases: list

See http://docs.cython.org/src/userguide/special_methods.html

copy(self)

Return a copy of the listm instance

PDSim.misc.datatypes.rebuildListm(d)

PDSim.misc.error_bar module

PDSim.misc.error_bar.error_ascii_bar(val, tol, N=50, min_p=-5, max_p=2)[source]

PDSim.misc.hdf5 module

class PDSim.misc.hdf5.HDF5Writer[source]

Bases: object

This class contains the logic for writing a nested structure to a file. The structure to be written could include dictionaries, lists, numpy arrays, classes, and combinations thereof. The recursive writer function will walk through the tree, writing all the elements into the HDF5 file in the same general structure as was laid out in the object passed.

Some small modifications are needed - for instance, lists are written in a slighltly different manner. Otherwise, the structure should be pretty much exactly the same.

prune(fName, keys)[source]

Prune datasets and groups that are nested below the keys requested

write_to_file(struct, fName)[source]

Write the structure to the file given by fName

class PDSim.misc.hdf5.StubClass(d)[source]

Bases: object

PDSim.misc.polymath_sample module

PDSim.misc.scipylike module

class PDSim.misc.scipylike.Spline

Bases: object

A python wrapper around the Spline interpolator class from Devin Lane: http://shiftedbits.org/2011/01/30/cubic-spline-interpolation/

interpolate
PDSim.misc.scipylike.splev(signatures, args, kwargs, defaults, _fused_sigindex={})

A C++/python equivalent of the scipy function scipy.interpolate.splev

PDSim.misc.scipylike.splrep(vector[double] x, vector[double] y, k=3, s=0) Spline

A C++/python equivalent of the scipy function scipy.interpolate.splrep

PDSim.misc.scipylike.trapz(ndarray y, ndarray x)

Do a trapezoidal integration of the array y with respect to x

Parameters:
  • x (numpy array (1-D, float type))

  • y (numpy array (1-D, float type))

PDSim.misc.solvers module

PDSim.misc.solvers.Broyden(f, x0, dx=1e-05, args=(), kwargs={}, ytol=1e-05, Nfd=1, J0=None, w=1.0, wJ=1.0, itermax=10, JustOneStep=False)[source]

Broyden’s method

If f returns None, then the computation is stopped, and a list the size of x0 is returned with all None values

Parameters:
  • f (function) –

    Must have a signature of the form:

    (x0,*args) --> array
    

    that returns an array-like object the same shape as x0

  • J0 (ndarray) – A square matrix that contains a first guess for the Jacobian

  • x0 (array-like) – Initial values for the solver

  • args (tuple) – Positional arguments to pass to the objective function

  • kwargs (dictionary) – Keyword arguments to pass to the objective function

  • ytol (float) – The allowed root-sum-square-error

  • itermax (int) – maximum number of iterations allowed

  • Nfd (int) – The number of finite difference steps to be used at the beginning

  • w (float) – relaxation factor

  • wJ (float) – relaxation factor for updating of Jacobian matrix

  • JustOneStep (boolean) – If True, stop after one step

PDSim.misc.solvers.MultiDimNewtRaph(f, x0, dx=1e-06, args=(), ytol=1e-05, w=1.0, JustOneStep=False)[source]

A Newton-Raphson solver where the Jacobian is always re-evaluated rather than re-using the information as in the fsolve method of scipy.optimize

PDSim.misc.solvers.newton(f, x0, dx=0.0001, args=(), kwargs={}, tol=1e-08, ytol=1e-08)[source]

PDSim.misc.stl_utilities module

PDSim.misc.stl_utilities.get_map_sd(map[string, double] m, string s) double
PDSim.misc.stl_utilities.is_in_vector(string a, vector[string] v) bool

Module contents