|
36 | 36 |
|
37 | 37 | register_codec(BZ2)
|
38 | 38 |
|
39 |
| -with suppress(ImportError): |
40 |
| - from numcodecs.lzma import LZMA |
| 39 | +from numcodecs.lzma import LZMA |
41 | 40 |
|
42 |
| - register_codec(LZMA) |
| 41 | +register_codec(LZMA) |
43 | 42 |
|
44 |
| -with suppress(ImportError): |
45 |
| - from numcodecs import blosc |
46 |
| - from numcodecs.blosc import Blosc |
47 |
| - |
48 |
| - register_codec(Blosc) |
49 |
| - # initialize blosc |
50 |
| - try: |
51 |
| - ncores = multiprocessing.cpu_count() |
52 |
| - except OSError: # pragma: no cover |
53 |
| - ncores = 1 |
54 |
| - blosc.init() |
55 |
| - blosc.set_nthreads(min(8, ncores)) |
56 |
| - atexit.register(blosc.destroy) |
| 43 | +from numcodecs import blosc |
| 44 | +from numcodecs.blosc import Blosc |
57 | 45 |
|
58 |
| -with suppress(ImportError): |
59 |
| - from numcodecs import zstd as zstd |
60 |
| - from numcodecs.zstd import Zstd |
| 46 | +register_codec(Blosc) |
| 47 | +# initialize blosc |
| 48 | +try: |
| 49 | + ncores = multiprocessing.cpu_count() |
| 50 | +except OSError: # pragma: no cover |
| 51 | + ncores = 1 |
| 52 | +blosc.init() |
| 53 | +blosc.set_nthreads(min(8, ncores)) |
| 54 | +atexit.register(blosc.destroy) |
61 | 55 |
|
62 |
| - register_codec(Zstd) |
| 56 | +from numcodecs import zstd as zstd |
| 57 | +from numcodecs.zstd import Zstd |
63 | 58 |
|
64 |
| -with suppress(ImportError): |
65 |
| - from numcodecs import lz4 as lz4 |
66 |
| - from numcodecs.lz4 import LZ4 |
| 59 | +register_codec(Zstd) |
67 | 60 |
|
68 |
| - register_codec(LZ4) |
| 61 | +from numcodecs import lz4 as lz4 |
| 62 | +from numcodecs.lz4 import LZ4 |
69 | 63 |
|
70 |
| -with suppress(ImportError): |
71 |
| - from numcodecs.zfpy import ZFPY |
72 |
| - |
73 |
| - register_codec(ZFPY) |
| 64 | +register_codec(LZ4) |
74 | 65 |
|
75 | 66 | from numcodecs.astype import AsType
|
76 | 67 |
|
|
112 | 103 |
|
113 | 104 | register_codec(BitRound)
|
114 | 105 |
|
115 |
| -with suppress(ImportError): |
116 |
| - from numcodecs.msgpacks import MsgPack |
117 |
| - |
118 |
| - register_codec(MsgPack) |
119 |
| - |
120 | 106 | from numcodecs.checksum32 import CRC32, Adler32, JenkinsLookup3
|
121 | 107 |
|
122 | 108 | register_codec(CRC32)
|
123 | 109 | register_codec(Adler32)
|
124 | 110 | register_codec(JenkinsLookup3)
|
125 | 111 |
|
126 |
| -with suppress(ImportError): |
127 |
| - from numcodecs.checksum32 import CRC32C |
128 |
| - |
129 |
| - register_codec(CRC32C) |
130 |
| - |
131 | 112 | from numcodecs.json import JSON
|
132 | 113 |
|
133 | 114 | register_codec(JSON)
|
134 | 115 |
|
135 |
| -with suppress(ImportError): |
136 |
| - from numcodecs import vlen as vlen |
137 |
| - from numcodecs.vlen import VLenArray, VLenBytes, VLenUTF8 |
| 116 | +from numcodecs import vlen as vlen |
| 117 | +from numcodecs.vlen import VLenArray, VLenBytes, VLenUTF8 |
138 | 118 |
|
139 |
| - register_codec(VLenUTF8) |
140 |
| - register_codec(VLenBytes) |
141 |
| - register_codec(VLenArray) |
| 119 | +register_codec(VLenUTF8) |
| 120 | +register_codec(VLenBytes) |
| 121 | +register_codec(VLenArray) |
142 | 122 |
|
143 | 123 | from numcodecs.fletcher32 import Fletcher32
|
144 | 124 |
|
145 | 125 | register_codec(Fletcher32)
|
146 | 126 |
|
147 |
| -from numcodecs.pcodec import PCodec |
| 127 | +# Optional depenedencies |
| 128 | +with suppress(ImportError): |
| 129 | + from numcodecs.zfpy import ZFPY |
| 130 | + |
| 131 | + register_codec(ZFPY) |
| 132 | + |
| 133 | +with suppress(ImportError): |
| 134 | + from numcodecs.msgpacks import MsgPack |
| 135 | + |
| 136 | + register_codec(MsgPack) |
| 137 | + |
| 138 | +with suppress(ImportError): |
| 139 | + from numcodecs.checksum32 import CRC32C |
| 140 | + |
| 141 | + register_codec(CRC32C) |
| 142 | + |
| 143 | +with suppress(ImportError): |
| 144 | + from numcodecs.pcodec import PCodec |
148 | 145 |
|
149 |
| -register_codec(PCodec) |
| 146 | + register_codec(PCodec) |
0 commit comments