These are general utility functions that depend only on the numpy array model. All pyformex modules needing numpy should import everything from this module.
f) |
f,approx=floor) |
arg) |
arg) |
arg) |
A,B,axis=-1) |
The default axis is the last.
A,axis=-1) |
The default axis is the last.
A,axis=-1) |
The default axis is the last.
A,B,axis=-1) |
The default axis is the last.
v,n=2) |
Default is the quadratic norm (vector length) n == 1 returns the sum n <= 0 returns the max absolute value
p,mi,ma) |
values,target,rtol=1.e-5,atol=1.e-8) |
values is a float array, target is a float value. values and target should be broadcastable to the same shape.
The return value is a boolean array with shape of values flagging where the values are close to target. Two values a and b are considered close if | a - b | < atol + rtol * | b |
) |
axis) |
Use normalize() to get a unit vector in a general direction.
angle,axis=None) |
The angle is specified in degrees. If axis==None (default), a 2x2 rotation matrix is returned. Else, axis should specifying the rotation axis in a 3D world. It is either one of 0,1,2, specifying a global axis, or a vector with 3 components specifying an axis through the origin. In either case a 3x3 rotation matrix is returned. Note that: rotationMatrix(angle,[1,0,0]) == rotationMatrix(angle,0) rotationMatrix(angle,[0,1,0]) == rotationMatrix(angle,1) rotationMatrix(angle,[0,0,1]) == rotationMatrix(angle,2) but the latter functions calls are more efficient. The result is returned as an array.
v,n=3) |
Return either a 3x3(default) or 4x4(if n==4) rotation matrix.
a,size,axis=-1,fill=0) |
a,axis=-1) |
a,shape=None,kind=None,allow=None) |
The input a is anything that can e converted into a numpy array. Either shape and or kind can be specified. The dimensions where shape contains a -1 value are not checked. The number of dimensions should match, though. If kind does not match, but is included in allow, conversion to the requested type is attempted. Returns the array if valid. Else, an error is raised.
a,size=None,kind=None,allow=None) |
Either size and or kind can be specified. If kind does not match, but is included in allow, conversion to the requested type is attempted. Returns the array if valid. Else, an error is raised.
nrs,nmin=0,nmax=None,error=None) |
nrs is an integer array with any shape. All integers should be unique and in the range(nmin,nmax). Beware: this means that nmin <= i < nmax ! Default nmax is unlimited. Set nmin to None to error is the value to return if the tests are not passed. By default, a ValueError is raised. On success, None is returned