本文整理汇总了Python中mvpa2.datasets.base.Dataset.fa['z']方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.fa['z']方法的具体用法?Python Dataset.fa['z']怎么用?Python Dataset.fa['z']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mvpa2.datasets.base.Dataset
的用法示例。
在下文中一共展示了Dataset.fa['z']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unique_stack
# 需要导入模块: from mvpa2.datasets.base import Dataset [as 别名]
# 或者: from mvpa2.datasets.base.Dataset import fa['z'] [as 别名]
def test_unique_stack():
data = Dataset(np.reshape(np.arange(24), (4, 6)),
sa=dict(x=[0, 1, 0, 1]),
fa=dict(y=[x for x in 'abccba']))
sa_stack = stack_by_unique_sample_attribute(data, 'x')
assert_equal(sa_stack.shape, (2, 12))
assert_array_equal(sa_stack.fa.x, [0] * 6 + [1] * 6)
assert_array_equal(sa_stack.fa.y, [x for x in 'abccbaabccba'])
fa_stack = stack_by_unique_feature_attribute(data, 'y')
assert_equal(fa_stack.shape, (12, 2))
assert_array_equal(fa_stack.sa.x, [0, 1] * 6)
assert_array_equal(fa_stack.sa.y, [y for y in 'aaaabbbbcccc'])
#assert_array_equal(fa_stack.fa.y,[''])
# check values match the fa or sa
for i in xrange(4):
for j in xrange(6):
d = data[i, j]
for k, other in enumerate((sa_stack, fa_stack)):
msk = other.samples == d.samples
ii, jj = np.nonzero(msk) # find matching indices in other
o = other[ii, jj]
coll = [o.fa, o.sa][k]
assert_equal(coll.x, d.sa.x)
assert_equal(coll.y, d.fa.y)
ystacker = lambda y: lambda x: stack_by_unique_feature_attribute(x, y)
assert_raises(KeyError, ystacker('z'), data)
data.fa['z'] = [z for z in '123451']
assert_raises(ValueError, ystacker('z'), data)