coords.Coords.fromstring#
- classmethod Coords.fromstring(s, sep=' ', ndim=3, count=-1)#
Create a
Coordsobject with data from a string.This uses
numpy.fromstring()to read coordinates from a string and creates a Coords object from them.Parameters#
- s: str
A string containing a single sequence of float numbers separated by whitespace and a possible separator string.
- sep: str
The separator used between the coordinates. If not a space, all extra whitespace is ignored.
- ndim: int,
Number of coordinates per point. Should be 1, 2 or 3 (default). If 1, resp. 2, the coordinate string only holds x, resp. x,y values.
- count: int, optional
Total number of coordinates to read. This should be a multiple of ndim. The default is to read all the coordinates in the string.
Returns#
- Coords
A Coords object with the coordinates read from the string.
Raises#
- ValueError
If count was provided and the string does not contain that exact number of coordinates.
Notes#
For writing the coordinates to a string,
numpy.tostring()can be used.Examples#
>>> Coords.fromstring('4 0 0 3 1 2 6 5 7') Coords([[4., 0., 0.], [3., 1., 2.], [6., 5., 7.]]) >>> Coords.fromstring('1 2 3 4 5 6',ndim=2) Coords([[1., 2., 0.], [3., 4., 0.], [5., 6., 0.]])