Skip to content

Commit

Permalink
Doctest fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbourbeau committed Nov 22, 2019
1 parent 6054dc4 commit 801a260
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ install:
- source activate test-environment
- conda install pytest locket numpy toolz pandas blosc pyzmq -c conda-forge

# Install dask
# Install partd
- python setup.py install

script:
- py.test partd --verbose
- if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then py.test partd --doctest-modules --verbose; else py.test partd --verbose; fi

notifications:
email: false
8 changes: 4 additions & 4 deletions partd/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ def serialize_dtype(dt):
""" Serialize dtype to bytes
>>> serialize_dtype(np.dtype('i4'))
'<i4'
b'<i4'
>>> serialize_dtype(np.dtype('M8[us]'))
'<M8[us]'
b'<M8[us]'
"""
return dt.str.encode()


def parse_dtype(s):
""" Parse text as numpy dtype
>>> parse_dtype('i4')
>>> parse_dtype(b'i4')
dtype('int32')
>>> parse_dtype("[('a', 'i4')]")
>>> parse_dtype(b"[('a', 'i4')]")
dtype([('a', '<i4')])
"""
if s.startswith(b'['):
Expand Down
2 changes: 1 addition & 1 deletion partd/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def partition_all(n, bytes):
The final block holds the remainder and so may not be of equal size
>>> list(partition_all(2, b'Hello'))
['He', 'll', 'o']
[b'He', b'll', b'o']
See Also:
toolz.partition_all
Expand Down
12 changes: 6 additions & 6 deletions partd/zmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ def serialize_key(key):
"""
>>> serialize_key('x')
'x'
b'x'
>>> serialize_key(('a', 'b', 1))
'a-|-b-|-1'
b'a-|-b-|-1'
"""
if isinstance(key, tuple):
return tuple_sep.join(map(serialize_key, key))
Expand All @@ -228,10 +228,10 @@ def serialize_key(key):
def deserialize_key(text):
"""
>>> deserialize_key('x')
'x'
>>> deserialize_key('a-|-b-|-1')
('a', 'b', '1')
>>> deserialize_key(b'x')
b'x'
>>> deserialize_key(b'a-|-b-|-1')
(b'a', b'b', b'1')
"""
if tuple_sep in text:
return tuple(text.split(tuple_sep))
Expand Down

0 comments on commit 801a260

Please sign in to comment.