Package numpy :: Package core :: Module records
[hide private]
[frames] | no frames]

Module records

source code

Classes [hide private]
  format_parser
  recarray
  record
Functions [hide private]
 
array(obj, dtype=None, shape=None, offset=0, strides=None, formats=None, names=None, titles=None, aligned=False, byteorder=None, copy=False)
Construct a record array from a wide-variety of objects.
source code
 
find_duplicate(list)
Find duplication in a list, return a list of duplicated elements
source code
 
fromarrays(arrayList, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=False, byteorder=None)
create a record array from a (flat) list of arrays
source code
 
fromfile(fd, dtype=None, shape=None, offset=0, formats=None, names=None, titles=None, aligned=False, byteorder=None)
Create an array from binary file data
source code
 
fromrecords(recList, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=False, byteorder=None)
create a recarray from a list of records in text form The data in the same field can be heterogeneous, they will be promoted to the highest data type.
source code
 
fromstring(datastring, dtype=None, shape=None, offset=0, formats=None, names=None, titles=None, aligned=False, byteorder=None)
create a (read-only) record array from binary data contained in a string
source code
 
get_remaining_size(fd) source code
Variables [hide private]
  _byteorderconv = {'<': '<', '=': '=', '>': '>', 'B': '>', 'I':...
  _typestr = {<type 'numpy.int64'>: 'i8', <type 'numpy.int16'>: ...
  numfmt = {0: <type 'numpy.bool_'>, 1: <type 'numpy.int8'>, 2: ...
Function Details [hide private]

fromarrays(arrayList, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=False, byteorder=None)

source code 
create a record array from a (flat) list of arrays
>>> x1=N.array([1,2,3,4])
>>> x2=N.array(['a','dd','xyz','12'])
>>> x3=N.array([1.1,2,3,4])
>>> r = fromarrays([x1,x2,x3],names='a,b,c')
>>> print r[1]
(2, 'dd', 2.0)
>>> x1[1]=34
>>> r.a
array([1, 2, 3, 4])

fromfile(fd, dtype=None, shape=None, offset=0, formats=None, names=None, titles=None, aligned=False, byteorder=None)

source code 

Create an array from binary file data

If file is a string then that file is opened, else it is assumed to be a file object.
>>> from tempfile import TemporaryFile
>>> a = N.empty(10,dtype='f8,i4,a5')
>>> a[5] = (0.5,10,'abcde')
>>>
>>> fd=TemporaryFile()
>>> a = a.newbyteorder('<')
>>> a.tofile(fd)
>>>
>>> fd.seek(0)
>>> r=fromfile(fd, formats='f8,i4,a5', shape=10, byteorder='<')
>>> print r[5]
(0.5, 10, 'abcde')
>>> r.shape
(10,)

fromrecords(recList, dtype=None, shape=None, formats=None, names=None, titles=None, aligned=False, byteorder=None)

source code 
create a recarray from a list of records in text form

    The data in the same field can be heterogeneous, they will be promoted
    to the highest data type.  This method is intended for creating
    smaller record arrays.  If used to create large array without formats
    defined

    r=fromrecords([(2,3.,'abc')]*100000)

    it can be slow.

    If formats is None, then this will auto-detect formats. Use list of
    tuples rather than list of lists for faster processing.

>>> r=fromrecords([(456,'dbe',1.2),(2,'de',1.3)],names='col1,col2,col3')
>>> print r[0]
(456, 'dbe', 1.2)
>>> r.col1
array([456,   2])
>>> r.col2
chararray(['dbe', 'de'],
      dtype='|S3')
>>> import cPickle
>>> print cPickle.loads(cPickle.dumps(r))
[(456, 'dbe', 1.2) (2, 'de', 1.3)]


Variables Details [hide private]

_byteorderconv

Value:
{'<': '<',
 '=': '=',
 '>': '>',
 'B': '>',
 'I': '|',
 'L': '<',
 'N': '=',
 'S': 's',
...

_typestr

Value:
{<type 'numpy.int64'>: 'i8', <type 'numpy.int16'>: 'i2', <type 'numpy.\
float32'>: 'f4', <type 'numpy.bool_'>: 'b1', <type 'numpy.uint8'>: 'u1\
', <type 'numpy.object_'>: 'O4', <type 'numpy.float64'>: 'f8', <type '\
numpy.uint16'>: 'u2', <type 'numpy.string_'>: 'S', <type 'numpy.int8'>\
: 'i1', <type 'numpy.float96'>: 'f12', <type 'numpy.unicode_'>: 'U', <\
type 'numpy.uint32'>: 'u4', <type 'numpy.complex192'>: 'c24', <type 'n\
umpy.int32'>: 'i4', <type 'numpy.complex64'>: 'c8', <type 'numpy.uint3\
2'>: 'u4', <type 'numpy.int32'>: 'i4', <type 'numpy.complex128'>: 'c16\
...

numfmt

Value:
{0: <type 'numpy.bool_'>,
 1: <type 'numpy.int8'>,
 2: <type 'numpy.uint8'>,
 3: <type 'numpy.int16'>,
 4: <type 'numpy.uint16'>,
 5: <type 'numpy.int32'>,
 6: <type 'numpy.uint32'>,
 7: <type 'numpy.int32'>,
...