PDSim.misc package¶
Subpackages¶
Submodules¶
PDSim.misc.datatypes module¶
- class PDSim.misc.datatypes.AnnotatedValue(str key, value, str annotation, str units)¶
Bases:
objectAn 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:
- class PDSim.misc.datatypes.Collector¶
Bases:
objectThe 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
- class PDSim.misc.datatypes.arraym(data=None)¶
Bases:
objectA 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 dofrom __future__ import divisionin your header- N¶
The number of entries in this arraym 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 (
arrayminstance) – 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:
listSee 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.hdf5 module¶
- class PDSim.misc.hdf5.HDF5Writer[source]¶
Bases:
objectThis 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.
PDSim.misc.polymath_sample module¶
PDSim.misc.scipylike module¶
- class PDSim.misc.scipylike.Spline¶
Bases:
objectA 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 allNonevalues- Parameters:
f (function) –
Must have a signature of the form:
(x0,*args) --> array
that returns an array-like object the same shape as
x0J0 (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.stl_utilities module¶
- PDSim.misc.stl_utilities.get_map_sd(map[string, double] m, string s) double¶