|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 | from __future__ import absolute_import, print_function, division |
| 3 | +import itertools |
3 | 4 |
|
4 | 5 |
|
5 | | -_lzma = None |
| 6 | +import nose |
| 7 | +import numpy as np |
| 8 | + |
6 | 9 | try: |
7 | | - import lzma as _lzma |
| 10 | + from numcodecs.lzma import LZMA, _lzma |
8 | 11 | except ImportError: # pragma: no cover |
9 | | - try: |
10 | | - from backports import lzma as _lzma |
11 | | - except ImportError: |
12 | | - pass |
13 | | - |
14 | | - |
15 | | -if _lzma: |
16 | | - |
17 | | - import itertools |
18 | | - import numpy as np |
19 | | - from numcodecs.lzma import LZMA |
20 | | - from numcodecs.tests.common import check_encode_decode, check_config, \ |
21 | | - check_repr |
22 | | - |
23 | | - codecs = [ |
24 | | - LZMA(), |
25 | | - LZMA(preset=1), |
26 | | - LZMA(preset=5), |
27 | | - LZMA(preset=9), |
28 | | - LZMA(format=_lzma.FORMAT_RAW, |
29 | | - filters=[dict(id=_lzma.FILTER_LZMA2, preset=1)]) |
30 | | - ] |
31 | | - |
32 | | - # mix of dtypes: integer, float, bool, string |
33 | | - # mix of shapes: 1D, 2D, 3D |
34 | | - # mix of orders: C, F |
35 | | - arrays = [ |
36 | | - np.arange(1000, dtype='i4'), |
37 | | - np.linspace(1000, 1001, 1000, dtype='f8'), |
38 | | - np.random.normal(loc=1000, scale=1, size=(100, 10)), |
39 | | - np.random.randint(0, 2, size=1000, dtype=bool).reshape(100, 10, |
40 | | - order='F'), |
41 | | - np.random.choice([b'a', b'bb', b'ccc'], size=1000).reshape(10, 10, 10) |
42 | | - ] |
43 | | - |
44 | | - def test_encode_decode(): |
45 | | - for arr, codec in itertools.product(arrays, codecs): |
46 | | - check_encode_decode(arr, codec) |
47 | | - |
48 | | - def test_config(): |
49 | | - codec = LZMA(preset=1, format=_lzma.FORMAT_XZ, |
50 | | - check=_lzma.CHECK_NONE, filters=None) |
51 | | - check_config(codec) |
52 | | - |
53 | | - def test_repr(): |
54 | | - check_repr('LZMA(format=1, check=0, preset=1, filters=None)') |
| 12 | + raise nose.SkipTest("LZMA not available") |
| 13 | + |
| 14 | +from numcodecs.tests.common import check_encode_decode, check_config, check_repr |
| 15 | + |
| 16 | + |
| 17 | +codecs = [ |
| 18 | + LZMA(), |
| 19 | + LZMA(preset=1), |
| 20 | + LZMA(preset=5), |
| 21 | + LZMA(preset=9), |
| 22 | + LZMA(format=_lzma.FORMAT_RAW, filters=[dict(id=_lzma.FILTER_LZMA2, preset=1)]) |
| 23 | +] |
| 24 | + |
| 25 | + |
| 26 | +# mix of dtypes: integer, float, bool, string |
| 27 | +# mix of shapes: 1D, 2D, 3D |
| 28 | +# mix of orders: C, F |
| 29 | +arrays = [ |
| 30 | + np.arange(1000, dtype='i4'), |
| 31 | + np.linspace(1000, 1001, 1000, dtype='f8'), |
| 32 | + np.random.normal(loc=1000, scale=1, size=(100, 10)), |
| 33 | + np.random.randint(0, 2, size=1000, dtype=bool).reshape(100, 10, order='F'), |
| 34 | + np.random.choice([b'a', b'bb', b'ccc'], size=1000).reshape(10, 10, 10) |
| 35 | +] |
| 36 | + |
| 37 | + |
| 38 | +def test_encode_decode(): |
| 39 | + for arr, codec in itertools.product(arrays, codecs): |
| 40 | + check_encode_decode(arr, codec) |
| 41 | + |
| 42 | + |
| 43 | +def test_config(): |
| 44 | + codec = LZMA(preset=1, format=_lzma.FORMAT_XZ, check=_lzma.CHECK_NONE, filters=None) |
| 45 | + check_config(codec) |
| 46 | + |
| 47 | + |
| 48 | +def test_repr(): |
| 49 | + check_repr('LZMA(format=1, check=0, preset=1, filters=None)') |
0 commit comments