|
37 | 37 |
|
38 | 38 | register_codec(BZ2) |
39 | 39 |
|
40 | | -with suppress(ImportError): |
41 | | - from numcodecs.lzma import LZMA |
| 40 | +from numcodecs.lzma import LZMA |
42 | 41 |
|
43 | | - register_codec(LZMA) |
| 42 | +register_codec(LZMA) |
44 | 43 |
|
45 | | -with suppress(ImportError): |
46 | | - from numcodecs import blosc |
47 | | - from numcodecs.blosc import Blosc |
48 | | - |
49 | | - register_codec(Blosc) |
50 | | - # initialize blosc |
51 | | - try: |
52 | | - ncores = multiprocessing.cpu_count() |
53 | | - except OSError: # pragma: no cover |
54 | | - ncores = 1 |
55 | | - blosc.init() |
56 | | - blosc.set_nthreads(min(8, ncores)) |
57 | | - atexit.register(blosc.destroy) |
| 44 | +from numcodecs import blosc |
| 45 | +from numcodecs.blosc import Blosc |
58 | 46 |
|
59 | | -with suppress(ImportError): |
60 | | - from numcodecs import zstd |
61 | | - from numcodecs.zstd import Zstd |
| 47 | +register_codec(Blosc) |
| 48 | +# initialize blosc |
| 49 | +try: |
| 50 | + ncores = multiprocessing.cpu_count() |
| 51 | +except OSError: # pragma: no cover |
| 52 | + ncores = 1 |
| 53 | +blosc.init() |
| 54 | +blosc.set_nthreads(min(8, ncores)) |
| 55 | +atexit.register(blosc.destroy) |
62 | 56 |
|
63 | | - register_codec(Zstd) |
| 57 | +from numcodecs import zstd |
| 58 | +from numcodecs.zstd import Zstd |
64 | 59 |
|
65 | | -with suppress(ImportError): |
66 | | - from numcodecs import lz4 |
67 | | - from numcodecs.lz4 import LZ4 |
| 60 | +register_codec(Zstd) |
68 | 61 |
|
69 | | - register_codec(LZ4) |
| 62 | +from numcodecs import lz4 |
| 63 | +from numcodecs.lz4 import LZ4 |
70 | 64 |
|
| 65 | +register_codec(LZ4) |
| 66 | + |
| 67 | +# zfpy is an optional external dependency |
71 | 68 | with suppress(ImportError): |
72 | 69 | from numcodecs.zfpy import ZFPY |
73 | 70 |
|
|
113 | 110 |
|
114 | 111 | register_codec(BitRound) |
115 | 112 |
|
| 113 | +# msgpack is an optional external dependency |
116 | 114 | with suppress(ImportError): |
117 | 115 | from numcodecs.msgpacks import MsgPack |
118 | 116 |
|
|
128 | 126 |
|
129 | 127 | register_codec(JSON) |
130 | 128 |
|
131 | | -with suppress(ImportError): |
132 | | - from numcodecs import vlen |
133 | | - from numcodecs.vlen import VLenUTF8, VLenBytes, VLenArray |
| 129 | +from numcodecs import vlen |
| 130 | +from numcodecs.vlen import VLenUTF8, VLenBytes, VLenArray |
134 | 131 |
|
135 | | - register_codec(VLenUTF8) |
136 | | - register_codec(VLenBytes) |
137 | | - register_codec(VLenArray) |
| 132 | +register_codec(VLenUTF8) |
| 133 | +register_codec(VLenBytes) |
| 134 | +register_codec(VLenArray) |
138 | 135 |
|
139 | 136 | from numcodecs.fletcher32 import Fletcher32 |
140 | 137 |
|
141 | 138 | register_codec(Fletcher32) |
142 | 139 |
|
143 | | -from numcodecs.pcodec import PCodec |
| 140 | +# pcodec is an optional external dependency |
| 141 | +with suppress(ImportError): |
| 142 | + from numcodecs.pcodec import PCodec |
144 | 143 |
|
145 | | -register_codec(PCodec) |
| 144 | + register_codec(PCodec) |
0 commit comments