Compare commits
	
		
			No commits in common. "numpy" and "master" have entirely different histories.
		
	
	
		
	
		
| @ -27,7 +27,6 @@ from . import exceptions, tags, types | ||||
| from datetime import datetime | ||||
| import math | ||||
| import struct | ||||
| import numpy | ||||
| 
 | ||||
| __all__ = [ | ||||
|     'Record', | ||||
| @ -77,7 +76,7 @@ def _parse_int2(data): | ||||
|     data_len = len(data) | ||||
|     if not data_len or (data_len % 2): | ||||
|         raise exceptions.IncorrectDataSize('INT2') | ||||
|     return numpy.frombuffer(data, dtype='>i2', count=data_len // 2) | ||||
|     return struct.unpack('>%dh' % (data_len//2), data) | ||||
| 
 | ||||
| def _parse_int4(data): | ||||
|     """ | ||||
| @ -97,7 +96,7 @@ def _parse_int4(data): | ||||
|     data_len = len(data) | ||||
|     if not data_len or (data_len % 4): | ||||
|         raise exceptions.IncorrectDataSize('INT4') | ||||
|     return numpy.frombuffer(data, dtype='>i4', count=data_len // 4) | ||||
|     return struct.unpack('>%dl' % (data_len//4), data) | ||||
| 
 | ||||
| def _int_to_real(num): | ||||
|     """ | ||||
| @ -209,7 +208,7 @@ def _pack_int2(data): | ||||
|         6 | ||||
|     """ | ||||
|     size = len(data) | ||||
|     return numpy.array(data).astype('>i2').tobytes() | ||||
|     return struct.pack('>{0}h'.format(size), *data) | ||||
| 
 | ||||
| def _pack_int4(data): | ||||
|     """ | ||||
| @ -224,7 +223,7 @@ def _pack_int4(data): | ||||
|         12 | ||||
|     """ | ||||
|     size = len(data) | ||||
|     return numpy.array(data).astype('>i4').tobytes() | ||||
|     return struct.pack('>{0}l'.format(size), *data) | ||||
| 
 | ||||
| def _real_to_int(fnum): | ||||
|     """ | ||||
| @ -345,7 +344,12 @@ class Record(object): | ||||
|         if data is not None: | ||||
|             self.data = data | ||||
|         elif points is not None: | ||||
|             self.data = numpy.ravel(points) | ||||
|             new_data = [] | ||||
|             # TODO make it faster | ||||
|             for point in points: | ||||
|                 new_data.append(point[0]) | ||||
|                 new_data.append(point[1]) | ||||
|             self.data = new_data | ||||
|         elif times is not None: | ||||
|             mod_time = times[0] | ||||
|             acc_time = times[1] | ||||
| @ -499,7 +503,7 @@ class Record(object): | ||||
|         data_size = len(self.data) | ||||
|         if not data_size or (data_size % 2): | ||||
|             raise exceptions.DataSizeError(self.tag) | ||||
|         return numpy.array(self.data).reshape(-1, 2) | ||||
|         return [(self.data[i], self.data[i+1]) for i in range(0, data_size, 2)] | ||||
| 
 | ||||
|     @property | ||||
|     def times(self): | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user