Skip to content

Commit d658c8e

Browse files
committed
Merge 'zarr-developers/master' into 'funkey/master'
2 parents eb154f0 + d23853b commit d658c8e

File tree

13 files changed

+69
-43
lines changed

13 files changed

+69
-43
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
TODO:
44
* [ ] Unit tests and/or doctests in docstrings
5-
* [ ] ``tox -e py36`` passes locally
5+
* [ ] ``tox -e py37`` passes locally
66
* [ ] ``tox -e py27`` passes locally
77
* [ ] Docstrings and API docs for any new/modified user-facing classes and functions
88
* [ ] Changes documented in docs/release.rst

.travis.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ addons:
1111
packages:
1212
- liblzma-dev
1313

14-
python:
15-
- 2.7
16-
- 3.5
17-
- 3.6
14+
matrix:
15+
include:
16+
- python: 2.7
17+
- python: 3.5
18+
- python: 3.6
19+
- python: 3.7
20+
dist: xenial
21+
sudo: true
1822

1923
install:
2024
- pip install -U tox-travis coveralls pip setuptools wheel

appveyor.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ environment:
3131
- PYTHON: "C:\\Python36-x64"
3232
PYTHON_VERSION: "3.6"
3333

34+
- PYTHON: "C:\\Python37"
35+
PYTHON_VERSION: "3.7"
36+
37+
- PYTHON: "C:\\Python37-x64"
38+
PYTHON_VERSION: "3.7"
39+
3440
install:
3541
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
3642
- git submodule update --init --recursive

docs/contributing.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ you have cloned the NumCodecs source code and your current working directory is
9090
the repository, you can do something like the following::
9191

9292
$ mkdir -p ~/pyenv/numcodecs-dev
93-
$ virtualenv --no-site-packages --python=/usr/bin/python3.6 ~/pyenv/numcodecs-dev
93+
$ virtualenv --no-site-packages --python=/usr/bin/python3.7 ~/pyenv/numcodecs-dev
9494
$ source ~/pyenv/numcodecs-dev/bin/activate
9595
$ pip install -r requirements_dev.txt
9696
$ python setup.py build_ext --inplace
@@ -145,11 +145,11 @@ To also run the doctests within docstrings, run::
145145
Tests can be run under different Python versions using tox. E.g. (assuming you have the
146146
corresponding Python interpreters installed on your system)::
147147

148-
$ tox -e py27,py35,py36
148+
$ tox -e py27,py35,py36,py37
149149

150-
NumCodecs currently supports Python 2.7 and Python 3.5-3.6, so the above command must
151-
succeed before code can be accepted into the main code base. Note that only the py36
152-
tox environment runs the doctests, i.e., doctests only need to succeed under Python 3.6.
150+
NumCodecs currently supports Python 2.7 and Python 3.5-3.7, so the above command must
151+
succeed before code can be accepted into the main code base. Note that only the py37
152+
tox environment runs the doctests, i.e., doctests only need to succeed under Python 3.7.
153153

154154
All tests are automatically run via Travis (Linux) and AppVeyor (Windows) continuous
155155
integration services for every pull request. Tests must pass under both services before
@@ -164,14 +164,14 @@ Conformance can be checked by running::
164164

165165
$ flake8 --max-line-length=100 numcodecs
166166

167-
This is automatically run when invoking ``tox -e py36``.
167+
This is automatically run when invoking ``tox -e py37``.
168168

169169
Test coverage
170170
~~~~~~~~~~~~~
171171

172172
NumCodecs maintains 100% test coverage under the latest Python stable release (currently
173-
Python 3.6). Both unit tests and docstring doctests are included when computing
174-
coverage. Running ``tox -e py36`` will automatically run the test suite with coverage
173+
Python 3.7). Both unit tests and docstring doctests are included when computing
174+
coverage. Running ``tox -e py37`` will automatically run the test suite with coverage
175175
and produce a coverage report. This should be 100% before code can be accepted into the
176176
main code base.
177177

@@ -185,7 +185,7 @@ Documentation
185185
Docstrings for user-facing classes and functions should follow the `numpydoc
186186
<https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt>`_ standard,
187187
including sections for Parameters and Examples. All examples will be run as doctests
188-
under Python 3.6.
188+
under Python 3.7.
189189

190190
NumCodecs uses Sphinx for documentation, hosted on readthedocs.org. Documentation is
191191
written in the RestructuredText markup language (.rst files) in the ``docs`` folder.

docs/release.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ Release notes
1818
* Updated the msgpack dependency (by :user:`Jerome Kelleher <jeromekelleher>`;
1919
:issue:`74`, :issue:`75`).
2020

21+
* Allow :class:`Blosc` compressor to run on systems where locks are not present (by
22+
:user:`Marcus Kinsella <mckinsel>`, :issue:`83`; and :user:`Tom White <tomwhite>`,
23+
:issue:`93`).
24+
2125
* Drop Python 3.4 (by :user:`John Kirkham <jakirkham>`; :issue:`89`).
2226

27+
* Add Python 3.7 (by :user:`John Kirkham <jakirkham>`; :issue:`92`).
28+
2329
* Add codec :class:`numcodecs.gzip.GZip` to replace ``gzip`` alias for ``zlib``,
2430
which was incorrect (by :user:`Jan Funke <funkey>`; :issue:`87`).
2531

@@ -58,7 +64,7 @@ Release notes
5864

5965
* Add support for encoding None values in VLen... codecs (:issue:`59`).
6066

61-
67+
6268
.. _release_0.5.1:
6369

6470
0.5.1

numcodecs/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
from numcodecs.blosc import Blosc
4747
register_codec(Blosc)
4848
# initialize blosc
49-
ncores = multiprocessing.cpu_count()
49+
try:
50+
ncores = multiprocessing.cpu_count()
51+
except OSError:
52+
ncores = 1
5053
blosc.init()
5154
blosc.set_nthreads(min(8, ncores))
5255
atexit.register(blosc.destroy)

numcodecs/blosc.pyx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ AUTOSHUFFLE = -1
7676
AUTOBLOCKS = 0
7777

7878
# synchronization
79-
mutex = multiprocessing.Lock()
80-
79+
try:
80+
mutex = multiprocessing.Lock()
81+
except OSError:
82+
mutex = None
8183

8284
# store ID of process that first loads the module, so we can detect a fork later
8385
_importer_pid = os.getpid()
@@ -405,6 +407,10 @@ def _get_use_threads():
405407
global use_threads
406408
proc = multiprocessing.current_process()
407409

410+
# check if locks are available, and if not no threads
411+
if not mutex:
412+
return False
413+
408414
# check for fork
409415
if proc.pid != _importer_pid:
410416
# If this module has been imported in the parent process, and the current process

numcodecs/fixedscaleoffset.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,33 @@ class FixedScaleOffset(Codec):
3838
>>> import numpy as np
3939
>>> x = np.linspace(1000, 1001, 10, dtype='f8')
4040
>>> x
41-
array([ 1000. , 1000.11111111, 1000.22222222, 1000.33333333,
42-
1000.44444444, 1000.55555556, 1000.66666667, 1000.77777778,
43-
1000.88888889, 1001. ])
41+
array([1000. , 1000.11111111, 1000.22222222, 1000.33333333,
42+
1000.44444444, 1000.55555556, 1000.66666667, 1000.77777778,
43+
1000.88888889, 1001. ])
4444
>>> codec = numcodecs.FixedScaleOffset(offset=1000, scale=10, dtype='f8', astype='u1')
4545
>>> y1 = codec.encode(x)
4646
>>> y1
4747
array([ 0, 1, 2, 3, 4, 6, 7, 8, 9, 10], dtype=uint8)
4848
>>> z1 = codec.decode(y1)
4949
>>> z1
50-
array([ 1000. , 1000.1, 1000.2, 1000.3, 1000.4, 1000.6, 1000.7,
51-
1000.8, 1000.9, 1001. ])
50+
array([1000. , 1000.1, 1000.2, 1000.3, 1000.4, 1000.6, 1000.7,
51+
1000.8, 1000.9, 1001. ])
5252
>>> codec = numcodecs.FixedScaleOffset(offset=1000, scale=10**2, dtype='f8', astype='u1')
5353
>>> y2 = codec.encode(x)
5454
>>> y2
55-
array([ 0, 11, 22, 33, 44, 56, 67, 78, 89, 100], dtype=uint8)
55+
array([ 0, 11, 22, 33, 44, 56, 67, 78, 89, 100], dtype=uint8)
5656
>>> z2 = codec.decode(y2)
5757
>>> z2
58-
array([ 1000. , 1000.11, 1000.22, 1000.33, 1000.44, 1000.56,
59-
1000.67, 1000.78, 1000.89, 1001. ])
58+
array([1000. , 1000.11, 1000.22, 1000.33, 1000.44, 1000.56,
59+
1000.67, 1000.78, 1000.89, 1001. ])
6060
>>> codec = numcodecs.FixedScaleOffset(offset=1000, scale=10**3, dtype='f8', astype='u2')
6161
>>> y3 = codec.encode(x)
6262
>>> y3
63-
array([ 0, 111, 222, 333, 444, 556, 667, 778, 889, 1000], dtype=uint16)
63+
array([ 0, 111, 222, 333, 444, 556, 667, 778, 889, 1000], dtype=uint16)
6464
>>> z3 = codec.decode(y3)
6565
>>> z3
66-
array([ 1000. , 1000.111, 1000.222, 1000.333, 1000.444, 1000.556,
67-
1000.667, 1000.778, 1000.889, 1001. ])
66+
array([1000. , 1000.111, 1000.222, 1000.333, 1000.444, 1000.556,
67+
1000.667, 1000.778, 1000.889, 1001. ])
6868
6969
See Also
7070
--------

numcodecs/packbits.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class PackBits(Codec):
2323
array([ 4, 144], dtype=uint8)
2424
>>> z = codec.decode(y)
2525
>>> z
26-
array([ True, False, False, True], dtype=bool)
26+
array([ True, False, False, True])
2727
2828
Notes
2929
-----

numcodecs/quantize.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ class Quantize(Codec):
2828
>>> import numpy as np
2929
>>> x = np.linspace(0, 1, 10, dtype='f8')
3030
>>> x
31-
array([ 0. , 0.11111111, 0.22222222, 0.33333333, 0.44444444,
32-
0.55555556, 0.66666667, 0.77777778, 0.88888889, 1. ])
31+
array([0. , 0.11111111, 0.22222222, 0.33333333, 0.44444444,
32+
0.55555556, 0.66666667, 0.77777778, 0.88888889, 1. ])
3333
>>> codec = numcodecs.Quantize(digits=1, dtype='f8')
3434
>>> codec.encode(x)
35-
array([ 0. , 0.125 , 0.25 , 0.3125, 0.4375, 0.5625, 0.6875,
36-
0.75 , 0.875 , 1. ])
35+
array([0. , 0.125 , 0.25 , 0.3125, 0.4375, 0.5625, 0.6875,
36+
0.75 , 0.875 , 1. ])
3737
>>> codec = numcodecs.Quantize(digits=2, dtype='f8')
3838
>>> codec.encode(x)
39-
array([ 0. , 0.109375 , 0.21875 , 0.3359375, 0.4453125,
40-
0.5546875, 0.6640625, 0.78125 , 0.890625 , 1. ])
39+
array([0. , 0.109375 , 0.21875 , 0.3359375, 0.4453125,
40+
0.5546875, 0.6640625, 0.78125 , 0.890625 , 1. ])
4141
>>> codec = numcodecs.Quantize(digits=3, dtype='f8')
4242
>>> codec.encode(x)
43-
array([ 0. , 0.11132812, 0.22265625, 0.33300781, 0.44433594,
44-
0.55566406, 0.66699219, 0.77734375, 0.88867188, 1. ])
43+
array([0. , 0.11132812, 0.22265625, 0.33300781, 0.44433594,
44+
0.55566406, 0.66699219, 0.77734375, 0.88867188, 1. ])
4545
4646
See Also
4747
--------

0 commit comments

Comments
 (0)