本文整理汇总了Python中thunder.images.readers.fromlist函数的典型用法代码示例。如果您正苦于以下问题:Python fromlist函数的具体用法?Python fromlist怎么用?Python fromlist使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fromlist函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_binary
def test_to_binary(tmpdir, eng):
a = [arange(8, dtype='int16').reshape((4, 2)), arange(8, 16, dtype='int16').reshape((4, 2))]
fromlist(a, engine=eng).tobinary(os.path.join(str(tmpdir), 'binary'), prefix='image')
files = [os.path.basename(f) for f in glob.glob(str(tmpdir) + '/binary/image*')]
assert sorted(files) == ['image-00000.bin', 'image-00001.bin']
with open(str(tmpdir) + '/binary/conf.json', 'r') as f:
conf = json.load(f)
assert conf['shape'] == [4, 2]
assert conf['dtype'] == 'int16'
示例2: test_nanmax
def test_nanmax(eng):
original = arange(24).reshape((2, 3, 4)).astype(float64)
data = fromlist(list(original), engine=eng)
assert allclose(data.nanmax().shape, (1, 3, 4))
assert allclose(data.nanmax().toarray(), original.max(axis=0))
original[0, 2, 3] = nan
original[1, 0, 2] = nan
original[1, 2, 2] = nan
data = fromlist(list(original), engine=eng)
assert allclose(data.nanmax().shape, (1, 3, 4))
assert allclose(data.nanmax().toarray(), nanmax(original, axis=0))
示例3: test_map
def test_map(eng):
a = arange(8).reshape((4, 2))
data = fromlist([a, a], engine=eng)
map1 = data.toblocks((4, 2)).map(lambda x: 1.0 * x, dtype=float64).toimages()
map2 = data.toblocks((4, 2)).map(lambda x: 1.0 * x).toimages()
assert map1.dtype == float64
assert map2.dtype == float64
示例4: test_count
def test_count(eng):
a = arange(8).reshape((2, 4))
data = fromlist([a], engine=eng)
assert data.toblocks((1, 1)).count() == 8
assert data.toblocks((1, 2)).count() == 4
assert data.toblocks((2, 2)).count() == 2
assert data.toblocks((2, 4)).count() == 1
示例5: test_conversion_series_3d
def test_conversion_series_3d(eng):
if eng is None:
return
a = arange(24).reshape((2, 3, 4))
data = fromlist([a], engine=eng)
vals = data.toblocks((2, 3, 4)).toseries().toarray()
assert allclose(vals, a)
示例6: test_series_roundtrip_simple
def test_series_roundtrip_simple(eng):
if eng is None:
return
a = arange(8).reshape((4, 2))
data = fromlist([a, a], engine=eng)
vals = data.toseries().toimages()
assert allclose(vals.toarray(), data.toarray())
示例7: test_median_filter_3d_empty
def test_median_filter_3d_empty(eng):
data = fromlist([arange(24).reshape((2, 3, 4))], engine=eng)
test1 = data.median_filter([2, 2, 0])[:, :, :, 0].squeeze().toarray()
test2 = data[:, :, :, 0].squeeze().median_filter([2, 2]).toarray()
assert test1.shape == (2, 3)
assert test2.shape == (2, 3)
assert allclose(test1, test2)
示例8: test_squeeze
def test_squeeze(eng):
data = fromlist([array([[1, 5], [1, 5]]), array([[1, 10], [1, 10]])], engine=eng)
assert data.shape == (2, 2, 2)
assert data[:, :, 0].shape == (2, 2, 1)
assert data[:, 0, 0].shape == (2, 1, 1)
assert data[:, :, 0].squeeze().shape == (2, 2)
assert data[:, 0, 0].squeeze().shape == (2, 1)
示例9: test_map_generic
def test_map_generic(eng):
a = arange(3*4).reshape((3, 4))
data = fromlist([a, a], engine=eng)
b = asarray(data.toblocks((2, 2)).map_generic(lambda x: [0, 1]))
assert b.shape == (2, 2)
assert b.dtype == object
truth = [v == [0, 1] for v in b.flatten()]
assert all(truth)
示例10: test_local_mode
def test_local_mode(eng):
a = arange(64).reshape((8, 8))
data = fromlist([a, a])
if data.mode == 'local':
blocks = data.toblocks((4, 4))
assert allclose(blocks.values, data.values)
assert blocks.count() == 1
assert blocks.blockshape == (2, 8, 8)
示例11: test_shape
def test_shape(eng):
if eng is None:
return
data = fromlist([ones((30, 30)) for _ in range(0, 3)], engine=eng)
blocks = data.toblocks((10, 10))
values = [v for k, v in blocks.tordd().collect()]
assert blocks.blockshape == (3, 10, 10)
assert all([v.shape == (3, 10, 10) for v in values])
示例12: test_conversion
def test_conversion(eng):
if eng is None:
return
a = arange(8).reshape((4, 2))
data = fromlist([a, a], engine=eng)
vals = data.toblocks((2, 2)).tordd().sortByKey().values().collect()
truth = [array([a[0:2, 0:2], a[0:2, 0:2]]), array([a[2:4, 0:2], a[2:4, 0:2]])]
assert allclose(vals, truth)
示例13: test_full
def test_full(eng):
if eng is None:
return
a = arange(8).reshape((4, 2))
data = fromlist([a, a], engine=eng)
vals = data.toblocks((4, 2)).tordd().values().collect()
truth = [a, a]
assert allclose(vals, truth)
示例14: test_labels
def test_labels(eng):
x = arange(10).reshape(10, 1, 1)
data = fromlist(x, labels=range(10), engine=eng)
assert allclose(data.filter(lambda x: x[0, 0]%2==0).labels, array([0, 2, 4, 6, 8]))
assert allclose(data[4:6].labels, array([4, 5]))
assert allclose(data[5].labels, array([5]))
assert allclose(data[[0, 3, 8]].labels, array([0, 3, 8]))
示例15: test_blocksize
def test_blocksize(eng):
a = arange(100*100, dtype='int16').reshape((100, 100))
data = fromlist(10*[a], engine=eng)
blocks = data.toblocks((5, 5))
assert blocks.blockshape == (10, 5, 5)
blocks = data.toblocks('1')
assert blocks.blockshape == (10, 5, 100)