def _write_nab_file(self,fd,values,formats,names,masktype=None): bfh = BinaryFileHeader(formats=formats,names=names,masktype=masktype) fd.write(bfh.make_header()+'\n') if not len(values): return try: tmpdata = narec.array(values,formats=formats,names=names) except MemoryError: log.warning('got MemoryError, trying alternate write method') tmpdata = None # TANYA: The only error that numpy.core.records.array raises is ValueError; commenting out the below... #except self.BufferError: # log.info('reached memmap limit on system, using alternate write method') # tmpdata = None if tmpdata is not None: tmpdata.tofile(fd) del tmpdata return # write using small groups to conserve memory total = len(values[0]) grpsize = max(1,min(1024*1024,total/16)) for i in range(0,total,grpsize): valslice = [arr[i:i+grpsize] for arr in values] tmpdata = narec.array(valslice,formats=formats,names=names) tmpdata.tofile(fd) del tmpdata
def to_array(records: Iterator[Purchase]) -> recarray: return rec.array(list(records), dtype=dtype([('report', unicode(8)), ('date', date64), ('report_date', date64), ('seller', uint8), ('arrangement', uint8), ('basis', uint8), ('head_count', uint32), ('avg_price', float32), ('low_price', float32), ('high_price', float32)]))
def to_array(records: Iterator[Sales]) -> recarray: return rec.array(list(records), dtype=dtype([ ('report', unicode(8)), ('date', date64), ('report_date', date64), ('type', uint8), ('description', unicode(64)), ('weight', uint32), ('avg_price', float32), ('low_price', float32), ('high_price', float32) ]))
def to_array(records: Iterator[Cutout]) -> recarray: return rec.array(list(records), dtype=dtype([('report', unicode(8)), ('date', date64), ('report_date', date64), ('primal_loads', float32), ('trimming_loads', float32), ('carcass_price', float32), ('loin_price', float32), ('butt_price', float32), ('picnic_price', float32), ('rib_price', float32), ('ham_price', float32), ('belly_price', float32)]))
def columnsOfType(self, columnames, rows=None, colTypes=None): if colTypes == None: return self.columns(columnames, rows) dataSubset = self.columns(columnames, rows) dataCols = [] dtypeInput = [] for i in range(len(columnames)): colName = columnames[i] colType = colTypes[colName] dataCols.append(dataSubset.data[:,i].astype(colType)) dataSubset.data = rec.array(dataCols) return dataSubset
def to_array(records: Iterator[Slaughter]) -> recarray: return rec.array(list(records), dtype=dtype([('report', unicode(8)), ('date', date64), ('report_date', date64), ('seller', uint8), ('arrangement', uint8), ('basis', uint8), ('head_count', uint32), ('base_price', float32), ('net_price', float32), ('low_price', float32), ('high_price', float32), ('live_weight', float32), ('carcass_weight', float32), ('sort_loss', float32), ('backfat', float32), ('loin_depth', float32), ('loineye_area', float32), ('lean_percent', float32)]))
from statsmodels.tools.testing import Holder var_results = Holder() var_results.comment = 'VAR test data converted from vars_results.npz' var_results.causality = array([ (9.317172089406967e-08,), (0.5183914225971917,), (4.8960835385969403e-14,)], dtype=[('causedby', 'float')]) var_results.name = 'var_results' var_results.orthirf = array({ 'realgdp': rec.array([ (0.007557357219752236, 0.003948403413668315, 0.02972434157321242), (0.0015408726821578582, 0.0010664916255201816, 0.00923575489996933), (0.0015874964105555918, 0.0010551760558416706, 0.006102514196485799), (0.0007262051539604352, 0.0005562787500837443, 0.003199064883156089), (0.0005537000868358786, 0.0003520396722562061, 0.0024372344590635623), (0.0003079984190444812, 0.00021674897409108682, .0013369479853037147)], dtype=[('realgdp', 'float'), ('realcons', 'float'), ('realinv', 'float')]), 'realinv': rec.array([ (.0, 0.0, 0.020741992721114832), (.0006890376065674764, .0005338724781743238, 0.004676882806534488), (.00017134455810606506, .000682084896451223, -0.0005205835547221123), (.0005217378718553543, .00030179909990059973, 0.0026650577026759623), (.00034979575853114173, .00022249591743758265, 0.0015804716569096742), (.00017738402507880077, .00013384975583249413, 0.0007585745605878197)], dtype=[('realgdp', 'float'), ('realcons', 'float'), ('realinv', 'float')]), 'realcons': rec.array([
var_results = Holder() var_results.comment = 'VAR test data converted from vars_results.npz' var_results.causality = array([ (9.317172089406967e-08,), (0.5183914225971917,), (4.8960835385969403e-14,)], dtype=[('causedby', 'float')]) var_results.name = 'var_results' var_results.orthirf = array({ 'realgdp': rec.array([ (0.007557357219752236, 0.003948403413668315, 0.02972434157321242), (0.0015408726821578582, 0.0010664916255201816, 0.00923575489996933), (0.0015874964105555918, 0.0010551760558416706, 0.006102514196485799), (0.0007262051539604352, 0.0005562787500837443, 0.003199064883156089), (0.0005537000868358786, 0.0003520396722562061, 0.0024372344590635623), (0.0003079984190444812, 0.00021674897409108682, .0013369479853037147)], dtype=[('realgdp', 'float'), ('realcons', 'float'), ('realinv', 'float')]), 'realinv': rec.array([ (.0, 0.0, 0.020741992721114832), (.0006890376065674764, .0005338724781743238, 0.004676882806534488), (.00017134455810606506, .000682084896451223, -0.0005205835547221123), (.0005217378718553543, .00030179909990059973, 0.0026650577026759623), (.00034979575853114173, .00022249591743758265, 0.0015804716569096742), (.00017738402507880077, .00013384975583249413, 0.0007585745605878197)], dtype=[('realgdp', 'float'), ('realcons', 'float'), ('realinv', 'float')]), 'realcons': rec.array([