def test_recarray_from_repr(self):
a = np.array([(1,'ABC'), (2, "DEF")],
dtype=[('foo', int), ('bar', 'S4')])
recordarr = np.rec.array(a)
recarr = a.view(np.recarray)
recordview = a.view(np.dtype((np.record, a.dtype)))
recordarr_r = eval("numpy." + repr(recordarr), {'numpy': np})
recarr_r = eval("numpy." + repr(recarr), {'numpy': np})
recordview_r = eval("numpy." + repr(recordview), {'numpy': np})
assert_equal(type(recordarr_r), np.recarray)
assert_equal(recordarr_r.dtype.type, np.record)
assert_equal(recordarr, recordarr_r)
assert_equal(type(recarr_r), np.recarray)
assert_equal(recarr_r.dtype.type, np.record)
assert_equal(recarr, recarr_r)
assert_equal(type(recordview_r), np.ndarray)
assert_equal(recordview.dtype.type, np.record)
assert_equal(recordview, recordview_r)
python类recarray()的实例源码
def get_signal_data(self, ep, ch):
"""
Return a numpy array containing all samples of a
signal, acquired on an Elphy analog channel, formatted
as a list of (time, value) tuples.
"""
#get data from the file
y_data = self.load_encoded_data(ep, ch)
x_data = np.arange(0, len(y_data))
#create a recarray
data = np.recarray(len(y_data), dtype=[('x', b_float), ('y', b_float)])
#put in the recarray the scaled data
x_factors = self.x_scale_factors(ep, ch)
y_factors = self.y_scale_factors(ep, ch)
data['x'] = x_factors.scale(x_data)
data['y'] = y_factors.scale(y_data)
return data
def get_tag_data(self, ep, tag_ch):
"""
Return a numpy array containing all samples of a
signal, acquired on an Elphy tag channel, formatted
as a list of (time, value) tuples.
"""
#get data from the file
y_data = self.load_encoded_tags(ep, tag_ch)
x_data = np.arange(0, len(y_data))
#create a recarray
data = np.recarray(len(y_data), dtype=[('x', b_float), ('y', b_int)])
#put in the recarray the scaled data
factors = self.x_tag_scale_factors(ep)
data['x'] = factors.scale(x_data)
data['y'] = y_data
return data
def get_signal_data(self, ep, ch):
"""
Return a numpy array containing all samples of a
signal, acquired on an Elphy analog channel, formatted
as a list of (time, value) tuples.
"""
#get data from the file
y_data = self.load_encoded_data(ep, ch)
x_data = np.arange(0, len(y_data))
#create a recarray
data = np.recarray(len(y_data), dtype=[('x', b_float), ('y', b_float)])
#put in the recarray the scaled data
x_factors = self.x_scale_factors(ep, ch)
y_factors = self.y_scale_factors(ep, ch)
data['x'] = x_factors.scale(x_data)
data['y'] = y_factors.scale(y_data)
return data
def test_recfromtxt(self):
#
data = TextIO('A,B\n0,1\n2,3')
kwargs = dict(delimiter=",", missing_values="N/A", names=True)
test = np.recfromtxt(data, **kwargs)
control = np.array([(0, 1), (2, 3)],
dtype=[('A', np.int), ('B', np.int)])
self.assertTrue(isinstance(test, np.recarray))
assert_equal(test, control)
#
data = TextIO('A,B\n0,1\n2,N/A')
test = np.recfromtxt(data, dtype=None, usemask=True, **kwargs)
control = ma.array([(0, 1), (2, -1)],
mask=[(False, False), (False, True)],
dtype=[('A', np.int), ('B', np.int)])
assert_equal(test, control)
assert_equal(test.mask, control.mask)
assert_equal(test.A, [0, 2])
scalar_vectorize.py 文件源码
项目:instacart-basket-prediction
作者: colinmorris
项目源码
文件源码
阅读 80
收藏 0
点赞 0
评论 0
def accumulate_user_vectors(users, max_prods, product_lookup, max_users, testmode):
BUFFER_SIZE = float('inf') # XXX: see what mem usage looks like before over-engineering
vec_accumulator = []
nusers = 0
for user in users:
vecs = get_user_vectors(user, max_prods, product_lookup, testmode)
vec_accumulator.append(vecs)
nusers += 1
if max_users and nusers >= max_users:
break
if nusers % 10000 == 0:
print "{}... ".format(nusers)
print "Accumulated vectors for {} users".format(len(vec_accumulator))
concatted = np.concatenate(vec_accumulator)
final_arr = concatted.view(np.recarray)
return final_arr
def test_recarray_from_repr(self):
a = np.array([(1,'ABC'), (2, "DEF")],
dtype=[('foo', int), ('bar', 'S4')])
recordarr = np.rec.array(a)
recarr = a.view(np.recarray)
recordview = a.view(np.dtype((np.record, a.dtype)))
recordarr_r = eval("numpy." + repr(recordarr), {'numpy': np})
recarr_r = eval("numpy." + repr(recarr), {'numpy': np})
recordview_r = eval("numpy." + repr(recordview), {'numpy': np})
assert_equal(type(recordarr_r), np.recarray)
assert_equal(recordarr_r.dtype.type, np.record)
assert_equal(recordarr, recordarr_r)
assert_equal(type(recarr_r), np.recarray)
assert_equal(recarr_r.dtype.type, np.record)
assert_equal(recarr, recarr_r)
assert_equal(type(recordview_r), np.ndarray)
assert_equal(recordview.dtype.type, np.record)
assert_equal(recordview, recordview_r)
def test_recfromtxt(self):
#
data = TextIO('A,B\n0,1\n2,3')
kwargs = dict(delimiter=",", missing_values="N/A", names=True)
test = np.recfromtxt(data, **kwargs)
control = np.array([(0, 1), (2, 3)],
dtype=[('A', np.int), ('B', np.int)])
self.assertTrue(isinstance(test, np.recarray))
assert_equal(test, control)
#
data = TextIO('A,B\n0,1\n2,N/A')
test = np.recfromtxt(data, dtype=None, usemask=True, **kwargs)
control = ma.array([(0, 1), (2, -1)],
mask=[(False, False), (False, True)],
dtype=[('A', np.int), ('B', np.int)])
assert_equal(test, control)
assert_equal(test.mask, control.mask)
assert_equal(test.A, [0, 2])
test_records.py 文件源码
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda
作者: SignalMedia
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def test_recarray_from_repr(self):
a = np.array([(1,'ABC'), (2, "DEF")],
dtype=[('foo', int), ('bar', 'S4')])
recordarr = np.rec.array(a)
recarr = a.view(np.recarray)
recordview = a.view(np.dtype((np.record, a.dtype)))
recordarr_r = eval("numpy." + repr(recordarr), {'numpy': np})
recarr_r = eval("numpy." + repr(recarr), {'numpy': np})
recordview_r = eval("numpy." + repr(recordview), {'numpy': np})
assert_equal(type(recordarr_r), np.recarray)
assert_equal(recordarr_r.dtype.type, np.record)
assert_equal(recordarr, recordarr_r)
assert_equal(type(recarr_r), np.recarray)
assert_equal(recarr_r.dtype.type, np.record)
assert_equal(recarr, recarr_r)
assert_equal(type(recordview_r), np.ndarray)
assert_equal(recordview.dtype.type, np.record)
assert_equal(recordview, recordview_r)
def _join(files):
from .io import load_locs, save_locs
from os.path import splitext
from numpy import append
import numpy as np
locs, info = load_locs(files[0])
join_info = {'Generated by': 'Picasso Join',
'Files': [files[0]]}
for path in files[1:]:
locs_, info_ = load_locs(path)
locs = append(locs, locs_)
join_info['Files'].append(path)
base, ext = splitext(files[0])
info.append(join_info)
locs.sort(kind='mergesort', order='frame')
locs = locs.view(np.recarray)
save_locs(base + '_join.hdf5', locs, info)
def groupprops(locs, callback=None):
try:
locs = locs[locs.dark != -1]
except AttributeError:
pass
group_ids = _np.unique(locs.group)
n = len(group_ids)
n_cols = len(locs.dtype)
names = ['group', 'n_events'] + list(_itertools.chain(*[(_ + '_mean', _ + '_std') for _ in locs.dtype.names]))
formats = ['i4', 'i4'] + 2 * n_cols * ['f4']
groups = _np.recarray(n, formats=formats, names=names)
if callback is not None:
callback(0)
for i, group_id in enumerate(_tqdm(group_ids, desc='Calculating group statistics', unit='Groups')):
group_locs = locs[locs.group == group_id]
groups['group'][i] = group_id
groups['n_events'][i] = len(group_locs)
for name in locs.dtype.names:
groups[name + '_mean'][i] = _np.mean(group_locs[name])
groups[name + '_std'][i] = _np.std(group_locs[name])
if callback is not None:
callback(i+1)
return groups
def test_recarray_from_repr(self):
a = np.array([(1,'ABC'), (2, "DEF")],
dtype=[('foo', int), ('bar', 'S4')])
recordarr = np.rec.array(a)
recarr = a.view(np.recarray)
recordview = a.view(np.dtype((np.record, a.dtype)))
recordarr_r = eval("numpy." + repr(recordarr), {'numpy': np})
recarr_r = eval("numpy." + repr(recarr), {'numpy': np})
recordview_r = eval("numpy." + repr(recordview), {'numpy': np})
assert_equal(type(recordarr_r), np.recarray)
assert_equal(recordarr_r.dtype.type, np.record)
assert_equal(recordarr, recordarr_r)
assert_equal(type(recarr_r), np.recarray)
assert_equal(recarr_r.dtype.type, np.record)
assert_equal(recarr, recarr_r)
assert_equal(type(recordview_r), np.ndarray)
assert_equal(recordview.dtype.type, np.record)
assert_equal(recordview, recordview_r)
def test_recfromtxt(self):
#
data = TextIO('A,B\n0,1\n2,3')
kwargs = dict(delimiter=",", missing_values="N/A", names=True)
test = np.recfromtxt(data, **kwargs)
control = np.array([(0, 1), (2, 3)],
dtype=[('A', np.int), ('B', np.int)])
self.assertTrue(isinstance(test, np.recarray))
assert_equal(test, control)
#
data = TextIO('A,B\n0,1\n2,N/A')
test = np.recfromtxt(data, dtype=None, usemask=True, **kwargs)
control = ma.array([(0, 1), (2, -1)],
mask=[(False, False), (False, True)],
dtype=[('A', np.int), ('B', np.int)])
assert_equal(test, control)
assert_equal(test.mask, control.mask)
assert_equal(test.A, [0, 2])
def convert(self, other):
"""Convert a :class:`numpy.recarray` to a :class:`numpy.recarray` with additional fields, filling the additional fields with 0.
:param other: The :class:`numpy.recarray` to be converted.
:type other: :class:`numpy.recarray`"""
a = self(np.zeros(self._nfields))
if npv < (1,13,0):
a[other.dtype.names] = other
elif npv < (1,14,0):
with warnings.catch_warnings():
warnings.simplefilter('ignore', FutureWarning)
a[:] = other
else:
for field_name in self._fields:
a[field_name] = other[field_name]
return a
def test_recarray_from_repr(self):
a = np.array([(1,'ABC'), (2, "DEF")],
dtype=[('foo', int), ('bar', 'S4')])
recordarr = np.rec.array(a)
recarr = a.view(np.recarray)
recordview = a.view(np.dtype((np.record, a.dtype)))
recordarr_r = eval("numpy." + repr(recordarr), {'numpy': np})
recarr_r = eval("numpy." + repr(recarr), {'numpy': np})
recordview_r = eval("numpy." + repr(recordview), {'numpy': np})
assert_equal(type(recordarr_r), np.recarray)
assert_equal(recordarr_r.dtype.type, np.record)
assert_equal(recordarr, recordarr_r)
assert_equal(type(recarr_r), np.recarray)
assert_equal(recarr_r.dtype.type, np.record)
assert_equal(recarr, recarr_r)
assert_equal(type(recordview_r), np.ndarray)
assert_equal(recordview.dtype.type, np.record)
assert_equal(recordview, recordview_r)
def test_recfromtxt(self):
#
data = TextIO('A,B\n0,1\n2,3')
kwargs = dict(delimiter=",", missing_values="N/A", names=True)
test = np.recfromtxt(data, **kwargs)
control = np.array([(0, 1), (2, 3)],
dtype=[('A', np.int), ('B', np.int)])
self.assertTrue(isinstance(test, np.recarray))
assert_equal(test, control)
#
data = TextIO('A,B\n0,1\n2,N/A')
test = np.recfromtxt(data, dtype=None, usemask=True, **kwargs)
control = ma.array([(0, 1), (2, -1)],
mask=[(False, False), (False, True)],
dtype=[('A', np.int), ('B', np.int)])
assert_equal(test, control)
assert_equal(test.mask, control.mask)
assert_equal(test.A, [0, 2])
def writeCandidates(self,filename=None):
if filename is None: filename = self.candfile
threshold = self.config['search']['cand_threshold']
select = (self.assocs['CUT']==0)
select &= (self.assocs['TS']>threshold)
#select &= (self.assocs['ASSOC2']=='')
self.candidates = self.assocs[select]
# ADW: View as a recarray or selection doesn't work.
# Why? I don't know, and I'm slightly terrified...
hdu = pyfits.new_table(self.candidates.view(np.recarray))
logger.info("Writing %s..."%filename)
hdu.writeto(filename,clobber=True)
# DEPRECATED: ADW 2017-09-15
## Dump to txt file
#if which('fdump'):
# txtfile = filename.replace('.fits','.txt')
# columns = ['NAME','TS','GLON','GLAT','DISTANCE','MASS']
# cmd = 'fdump %(infile)s %(outfile)s columns="%(columns)s" rows="-" prhead="no" showcol="yes" clobber="yes" pagewidth="256" fldsep=" " showrow="no"'%(dict(infile=filename,outfile=txtfile,columns=','.join(columns)))
# print cmd
# subprocess.call(cmd,shell=True)
def test_recarray_from_repr(self):
a = np.array([(1,'ABC'), (2, "DEF")],
dtype=[('foo', int), ('bar', 'S4')])
recordarr = np.rec.array(a)
recarr = a.view(np.recarray)
recordview = a.view(np.dtype((np.record, a.dtype)))
recordarr_r = eval("numpy." + repr(recordarr), {'numpy': np})
recarr_r = eval("numpy." + repr(recarr), {'numpy': np})
recordview_r = eval("numpy." + repr(recordview), {'numpy': np})
assert_equal(type(recordarr_r), np.recarray)
assert_equal(recordarr_r.dtype.type, np.record)
assert_equal(recordarr, recordarr_r)
assert_equal(type(recarr_r), np.recarray)
assert_equal(recarr_r.dtype.type, np.record)
assert_equal(recarr, recarr_r)
assert_equal(type(recordview_r), np.ndarray)
assert_equal(recordview.dtype.type, np.record)
assert_equal(recordview, recordview_r)
def test_recfromtxt(self):
#
data = TextIO('A,B\n0,1\n2,3')
kwargs = dict(delimiter=",", missing_values="N/A", names=True)
test = np.recfromtxt(data, **kwargs)
control = np.array([(0, 1), (2, 3)],
dtype=[('A', np.int), ('B', np.int)])
self.assertTrue(isinstance(test, np.recarray))
assert_equal(test, control)
#
data = TextIO('A,B\n0,1\n2,N/A')
test = np.recfromtxt(data, dtype=None, usemask=True, **kwargs)
control = ma.array([(0, 1), (2, -1)],
mask=[(False, False), (False, True)],
dtype=[('A', np.int), ('B', np.int)])
assert_equal(test, control)
assert_equal(test.mask, control.mask)
assert_equal(test.A, [0, 2])
def transform(self, posts):
features = np.recarray(shape=(len(posts),),
dtype=[('subject', object), ('body', object)])
for i, text in enumerate(posts):
headers, _, bod = text.partition('\n\n')
bod = strip_newsgroup_footer(bod)
bod = strip_newsgroup_quoting(bod)
features['body'][i] = bod
prefix = 'Subject:'
sub = ''
for line in headers.split('\n'):
if line.startswith(prefix):
sub = line[len(prefix):]
break
features['subject'][i] = sub
return features
def test_recarray_from_repr(self):
a = np.array([(1,'ABC'), (2, "DEF")],
dtype=[('foo', int), ('bar', 'S4')])
recordarr = np.rec.array(a)
recarr = a.view(np.recarray)
recordview = a.view(np.dtype((np.record, a.dtype)))
recordarr_r = eval("numpy." + repr(recordarr), {'numpy': np})
recarr_r = eval("numpy." + repr(recarr), {'numpy': np})
recordview_r = eval("numpy." + repr(recordview), {'numpy': np})
assert_equal(type(recordarr_r), np.recarray)
assert_equal(recordarr_r.dtype.type, np.record)
assert_equal(recordarr, recordarr_r)
assert_equal(type(recarr_r), np.recarray)
assert_equal(recarr_r.dtype.type, np.record)
assert_equal(recarr, recarr_r)
assert_equal(type(recordview_r), np.ndarray)
assert_equal(recordview.dtype.type, np.record)
assert_equal(recordview, recordview_r)
def test_recfromtxt(self):
#
data = TextIO('A,B\n0,1\n2,3')
kwargs = dict(delimiter=",", missing_values="N/A", names=True)
test = np.recfromtxt(data, **kwargs)
control = np.array([(0, 1), (2, 3)],
dtype=[('A', np.int), ('B', np.int)])
self.assertTrue(isinstance(test, np.recarray))
assert_equal(test, control)
#
data = TextIO('A,B\n0,1\n2,N/A')
test = np.recfromtxt(data, dtype=None, usemask=True, **kwargs)
control = ma.array([(0, 1), (2, -1)],
mask=[(False, False), (False, True)],
dtype=[('A', np.int), ('B', np.int)])
assert_equal(test, control)
assert_equal(test.mask, control.mask)
assert_equal(test.A, [0, 2])
def merge_table(self,name):
"""Merge an existing table in the database with the __self__ table.
n = a.merge_table(<name>)
Executes as 'INSERT INTO __self__ SELECT * FROM <name>'.
However, this method is probably used less often than the simpler merge(recarray).
:Arguments:
name name of the table in the database (must be compatible with __self__)
:Returns:
n number of inserted rows
"""
l_before = len(self)
SQL = """INSERT OR ABORT INTO __self__ SELECT * FROM %s""" % name
self.sql(SQL)
l_after = len(self)
return l_after - l_before
def extract_roi(self, top_left, size, is_normalize=False):
"""Extract Region of Interest
Does not modify instance data
Generates a set of td_events which fall into a rectangular region of interest with
top left corner at 'top_left' and size 'size'
top_left: [x: int, y: int]
size: [width, height]
is_normalize: bool. If True, x and y values will be normalized to the cropped region
"""
min_x = top_left[0]
min_y = top_left[1]
max_x = size[0] + min_x
max_y = size[1] + min_y
extracted_data = self.data[(self.data.x >= min_x) & (self.data.x < max_x) & (self.data.y >= min_y) & (self.data.y < max_y)]
if is_normalize:
self.width = size[0]
self.height = size[1]
extracted_data = np.copy(extracted_data)
extracted_data = extracted_data.view(np.recarray)
extracted_data.x -= min_x
extracted_data.y -= min_y
return extracted_data
def parse_csv(csv_reader):
previous_date = None
data = []
dtype = [('dt', 'int64'), ('sid', '|S14'), ('open', float),
('high', float), ('low', float), ('close', float),
('volume', int)]
for line in csv_reader:
row = process_line(line)
current_date = line["dt"][:10].replace("-", "")
if previous_date and previous_date != current_date:
rows = np.array(data, dtype=dtype).view(np.recarray)
yield current_date, rows
data = []
data.append(row)
previous_date = current_date
def _compute_asset_lifetimes(self):
"""
Compute and cache a recarry of asset lifetimes.
"""
equities_cols = self.equities.c
buf = np.array(
tuple(
sa.select((
equities_cols.sid,
equities_cols.start_date,
equities_cols.end_date,
)).execute(),
), dtype='<f8', # use doubles so we get NaNs
)
lifetimes = np.recarray(
buf=buf,
shape=(len(buf),),
dtype=[
('sid', '<f8'),
('start', '<f8'),
('end', '<f8')
],
)
start = lifetimes.start
end = lifetimes.end
start[np.isnan(start)] = 0 # convert missing starts to 0
end[np.isnan(end)] = np.iinfo(int).max # convert missing end to INTMAX
# Cast the results back down to int.
return lifetimes.astype([
('sid', '<i8'),
('start', '<i8'),
('end', '<i8'),
])
def get_tag_data(self, episode, tag_channel):
#memorise some useful properties
block = self.episode_block(episode)
sample_size = self.sample_size(episode, tag_channel)
sample_symbol = self.sample_symbol(episode, tag_channel)
#create a bit mask to define which
#sample to keep from the file
channel_mask = self.create_channel_mask(episode)
bit_mask = self.create_bit_mask(channel_mask, 1)
#get bytes from the file
data_block = self.data_blocks[episode - 1]
n_bytes = data_block.size
self.file.seek(data_block.start)
databytes = np.frombuffer(self.file.read(n_bytes), '<i1')
#detect which bits keep to recompose the tag
ep_mask = np.ones(n_bytes, dtype=int)
np.putmask(ep_mask, ep_mask, bit_mask)
to_keep = np.where(ep_mask > 0)[0]
raw = databytes.take(to_keep)
raw = raw.reshape([len(raw) / sample_size, sample_size])
#create a recarray containing data
dt = np.dtype(numpy_map[sample_symbol])
dt.newbyteorder('<')
tag_mask = 0b01 if (tag_channel == 1) else 0b10
y_data = np.frombuffer(raw, dt) & tag_mask
x_data = np.arange(0, len(y_data)) * block.dX + block.X0
data = np.recarray(len(y_data), dtype=[('x', b_float), ('y', b_int)])
data['x'] = x_data
data['y'] = y_data
return data
def get_tag_data(self, episode, tag_channel):
#memorise some useful properties
block = self.episode_block(episode)
sample_size = self.sample_size(episode, tag_channel)
sample_symbol = self.sample_symbol(episode, tag_channel)
#create a bit mask to define which
#sample to keep from the file
channel_mask = self.create_channel_mask(episode)
bit_mask = self.create_bit_mask(channel_mask, 1)
#get bytes from the file
data_block = self.data_blocks[episode - 1]
n_bytes = data_block.size
self.file.seek(data_block.start)
databytes = np.frombuffer(self.file.read(n_bytes), '<i1')
#detect which bits keep to recompose the tag
ep_mask = np.ones(n_bytes, dtype=int)
np.putmask(ep_mask, ep_mask, bit_mask)
to_keep = np.where(ep_mask > 0)[0]
raw = databytes.take(to_keep)
raw = raw.reshape([len(raw) / sample_size, sample_size])
#create a recarray containing data
dt = np.dtype(numpy_map[sample_symbol])
dt.newbyteorder('<')
tag_mask = 0b01 if (tag_channel == 1) else 0b10
y_data = np.frombuffer(raw, dt) & tag_mask
x_data = np.arange(0, len(y_data)) * block.dX + block.X0
data = np.recarray(len(y_data), dtype=[('x', b_float), ('y', b_int)])
data['x'] = x_data
data['y'] = y_data
return data
def readVcf(inFile, logDebug):
log.info("reading the VCF file")
## We read only one sample from the VCF file
if logDebug:
vcf = allel.read_vcf(inFile, samples = [0], fields = '*')
else:
sys.stderr = StringIO.StringIO()
vcf = allel.read_vcf(inFile, samples = [0], fields = '*')
#vcf = vcfnp.variants(inFile, cache=False).view(np.recarray)
#vcfD = vcfnp.calldata_2d(inFile, cache=False).view(np.recarray)
sys.stderr = sys.__stderr__
(snpCHR, snpsREQ) = parseChrName(vcf['variants/CHROM'])
try:
snpGT = allel.GenotypeArray(vcf['calldata/GT']).to_gt()[snpsREQ, 0]
except AttributeError:
die("input VCF file doesnt have required GT field")
snpsREQ = snpsREQ[np.where(snpGT != './.')[0]]
snpGT = allel.GenotypeArray(vcf['calldata/GT']).to_gt()[snpsREQ, 0]
if 'calldata/PL' in sorted(vcf.keys()):
snpWEI = np.copy(vcf['calldata/PL'][snpsREQ, 0]).astype('float')
snpWEI = snpWEI/(-10)
snpWEI = np.exp(snpWEI)
else:
snpBinary = parseGT(snpGT)
snpWEI = np.ones((len(snpsREQ), 3)) ## for homo and het
snpWEI[np.where(snpBinary != 0),0] = 0
snpWEI[np.where(snpBinary != 1),2] = 0
snpWEI[np.where(snpBinary != 2),1] = 0
snpCHR = snpCHR[snpsREQ]
DPmean = np.mean(vcf['calldata/DP'][snpsREQ,0])
snpPOS = np.array(vcf['variants/POS'][snpsREQ])
return (DPmean, snpCHR, snpPOS, snpGT, snpWEI)
def test_endian_recarray(self,level=rlevel):
# Ticket #2185
dt = np.dtype([
('head', '>u4'),
('data', '>u4', 2),
])
buf = np.recarray(1, dtype=dt)
buf[0]['head'] = 1
buf[0]['data'][:] = [1, 1]
h = buf[0]['head']
d = buf[0]['data'][0]
buf[0]['head'] = h
buf[0]['data'][0] = d
assert_(buf[0]['head'] == 1)