Here are the examples of the python api numpy.recarray taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
33 Examples
3
View Complete Implementation : utils.py
Copyright MIT License
Author : adswa
Copyright MIT License
Author : adswa
def mk_fix_vector(length=5):
"""creates a random length x 3 fixation vector in form of a record array"""
fix = np.recarray((0,), dtype=[('start_x', '<f8'), ('start_y', '<f8'),
('duration', '<f8')])
for i in range(0, length):
fixation = np.array((np.random.uniform(1, 720),
np.random.uniform(1, 720),
np.random.uniform(0.01, 5)),
dtype=[('start_x', float),
('start_y', float),
('duration', float)])
fix = np.append(fix, fixation)
return fix
3
View Complete Implementation : model.py
Copyright MIT License
Author : arkottke
Copyright MIT License
Author : arkottke
def load_data_file(name, skip_header=None) -> np.recarray:
"""Load a data file.
Returns
-------
data : :clast:`numpy.recarray`
data values
"""
fname = os.path.join(os.path.dirname(__file__), 'data', name)
return np.recfromcsv(
fname, skip_header=skip_header, case_sensitive=True).view(np.recarray)
3
View Complete Implementation : test_data.py
Copyright MIT License
Author : birforce
Copyright MIT License
Author : birforce
@clastmethod
def setup_clast(cls):
super(TestRecarrays, cls).setup_clast()
cls.endog = np.random.random(9).view([('y_1',
'f8')]).view(np.recarray)
exog = np.random.random(9*3).view([('const', 'f8'),('x_1', 'f8'),
('x_2', 'f8')]).view(np.recarray)
exog['const'] = 1
cls.exog = exog
cls.data = sm_data.handle_data(cls.endog, cls.exog)
cls.xnames = ['const', 'x_1', 'x_2']
cls.ynames = 'y_1'
3
View Complete Implementation : test_data.py
Copyright MIT License
Author : birforce
Copyright MIT License
Author : birforce
@clastmethod
def setup_clast(cls):
super(TestStructarrays, cls).setup_clast()
cls.endog = np.random.random(9).view([('y_1',
'f8')]).view(np.recarray)
exog = np.random.random(9*3).view([('const', 'f8'),('x_1', 'f8'),
('x_2', 'f8')]).view(np.recarray)
exog['const'] = 1
cls.exog = exog
cls.data = sm_data.handle_data(cls.endog, cls.exog)
cls.xnames = ['const', 'x_1', 'x_2']
cls.ynames = 'y_1'
3
View Complete Implementation : data.py
Copyright MIT License
Author : birforce
Copyright MIT License
Author : birforce
def load():
"""
Load the data and return a Dataset clast instance.
Returns
-------
Dataset instance:
See DATASET_PROPOSAL.txt for more information.
"""
data = _get_data()
names = data.columns.tolist()
dtype = lzip(names, ['a45', 'a3', 'a40', 'a14'] + ['<f8'] * 54)
data = lmap(tuple, data.values.tolist())
dataset = du.Dataset(data=np.array(data, dtype=dtype).view(np.recarray), names=names)
return dataset
3
View Complete Implementation : test_data.py
Copyright MIT License
Author : birforce
Copyright MIT License
Author : birforce
@nose.tools.nottest
@pytest.mark.parametrize('dataset_name', datasets)
def test_dataset(dataset_name):
dataset = importlib.import_module('statsmodels.datasets.' + dataset_name)
data = dataset.load()
astert isinstance(data, Dataset)
astert isinstance(data.data, np.recarray)
df_data = dataset.load_pandas()
astert isinstance(df_data, Dataset)
astert isinstance(df_data.data, pd.DataFrame)
3
View Complete Implementation : test_tools.py
Copyright MIT License
Author : birforce
Copyright MIT License
Author : birforce
def test_recarray1d(self):
instr = self.structdes['instrument'].view(np.recarray)
dum = tools.categorical(instr)
test_dum = np.column_stack(([dum[_] for _ in dum.dtype.names[-5:]]))
astert_array_equal(test_dum, self.dummy)
astert_equal(len(dum.dtype.names), 6)
3
View Complete Implementation : test_tools.py
Copyright MIT License
Author : birforce
Copyright MIT License
Author : birforce
def test_recarray1d_drop(self):
instr = self.structdes['instrument'].view(np.recarray)
dum = tools.categorical(instr, drop=True)
test_dum = np.column_stack(([dum[_] for _ in dum.dtype.names]))
astert_array_equal(test_dum, self.dummy)
astert_equal(len(dum.dtype.names), 5)
3
View Complete Implementation : test_tools.py
Copyright MIT License
Author : birforce
Copyright MIT License
Author : birforce
def test_recarray1d(self):
instr = self.structdes['str_instr'].view(np.recarray)
dum = tools.categorical(instr)
test_dum = np.column_stack(([dum[_] for _ in dum.dtype.names[-5:]]))
astert_array_equal(test_dum, self.dummy)
astert_equal(len(dum.dtype.names), 6)
3
View Complete Implementation : test_tools.py
Copyright MIT License
Author : birforce
Copyright MIT License
Author : birforce
def test_recarray1d_drop(self):
instr = self.structdes['str_instr'].view(np.recarray)
dum = tools.categorical(instr, drop=True)
test_dum = np.column_stack(([dum[_] for _ in dum.dtype.names]))
astert_array_equal(test_dum, self.dummy)
astert_equal(len(dum.dtype.names), 5)