Type Checkers

This module defines functions for type, value, and/or attribute checking.

checkCoords(coords, csets=False, natoms=None, dtype=(<type 'float'>, <type 'numpy.float32'>), name='coords')[source]

Return True if shape, dimensionality, and data type of coords array are as expected.

Parameters:
  • coords – coordinate array
  • csets – whether multiple coordinate sets (i.e. .ndim in (2, 3)) are allowed, default is False
  • natoms – number of atoms, if None number of atoms is not checked
  • dtype – allowed data type(s), default is (float, numpy.float32), if None data type is not checked
  • name – name of the coordinate argument
Raises :

TypeError when coords is not an instance of numpy.ndarray

Raises :

ValueError when wrong shape, dimensionality, or data type is encountered

checkWeights(weights, natoms, ncsets=None, dtype=<type 'float'>)[source]

Return weights if it has correct shape ([ncsets, ]natoms, 1). after its shape and data type is corrected. otherwise raise an exception. All items of weights must be greater than zero.

checkTypes(args, **types)[source]

Return True if types of all args match those given in types.

Raises :TypeError when type of an argument is not one of allowed types
def incr(n, i):
    '''Return sum of *n* and *i*.'''

    checkTypes(locals(), n=(float, int), i=(float, int))
    return n + i
Read the Docs v: v1.5
Versions
latest
v1.5
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.