Repository: dask/dask

Issue:
blocksize option to read_csv doesn't accept floats
The read_csv docstring presents floats as supported:
```
2.  In some cases it can break up large files as follows:

    >>> df = dd.read_csv('largefile.csv', blocksize=25e6)  # 25MB chunks  # doctest: +SKIP
```

but on Python 3 at least you get an error:
```
  File "/home/antoine/miniconda3/envs/cfmdemo/lib/python3.6/site-packages/dask/bytes/core.py", line 166, in read_bytes
    off = list(range(0, size, blocksize))
TypeError: 'float' object cannot be interpreted as an integer
```


Discussion:

Resolving patch:
diff --git a/dask/bytes/core.py b/dask/bytes/core.py
--- a/dask/bytes/core.py
+++ b/dask/bytes/core.py
@@ -12,7 +12,7 @@
 from ..compatibility import PY2, unicode
 from ..base import tokenize, normalize_token
 from ..delayed import delayed
-from ..utils import import_required, ensure_bytes, ensure_unicode
+from ..utils import import_required, ensure_bytes, ensure_unicode, is_integer
 
 
 def write_block_to_file(data, lazy_file):
@@ -138,6 +138,11 @@ def read_bytes(urlpath, delimiter=None, not_zero=False, blocksize=2**27,
     if len(paths) == 0:
         raise IOError("%s resolved to no files" % urlpath)
 
+    if blocksize is not None:
+        if not is_integer(blocksize):
+            raise TypeError("blocksize must be an integer")
+        blocksize = int(blocksize)
+
     blocks, lengths, machines = fs.get_block_locations(paths)
     if blocks:
         offsets = blocks
diff --git a/dask/utils.py b/dask/utils.py
--- a/dask/utils.py
+++ b/dask/utils.py
@@ -11,12 +11,13 @@
 from collections import Iterator
 from contextlib import contextmanager
 from importlib import import_module
+from numbers import Integral
 from threading import Lock
 import multiprocessing as mp
 import uuid
 from weakref import WeakValueDictionary
 
-from .compatibility import long, getargspec, PY3, unicode, urlsplit
+from .compatibility import getargspec, PY3, unicode, urlsplit
 from .core import get_deps
 from .context import _globals
 from .optimize import key_split    # noqa: F401
@@ -285,15 +286,7 @@ def is_integer(i):
     >>> is_integer('abc')
     False
     """
-    import numpy as np
-    if isinstance(i, (int, long)):
-        return True
-    if isinstance(i, float):
-        return (i).is_integer()
-    if issubclass(type(i), np.integer):
-        return i
-    else:
-        return False
+    return isinstance(i, Integral) or (isinstance(i, float) and i.is_integer())
 
 
 ONE_ARITY_BUILTINS = set([abs, all, any, bool, bytearray, bytes, callable, chr,


Test patch:
diff --git a/dask/bytes/tests/test_local.py b/dask/bytes/tests/test_local.py
--- a/dask/bytes/tests/test_local.py
+++ b/dask/bytes/tests/test_local.py
@@ -62,6 +62,18 @@ def test_read_bytes_blocksize_none():
         assert sum(map(len, values)) == len(files)
 
 
+def test_read_bytes_blocksize_float():
+    with filetexts(files, mode='b'):
+        sample, vals = read_bytes('.test.account*', blocksize=5.0)
+        results = compute(*concat(vals))
+        ourlines = b"".join(results).split(b'\n')
+        testlines = b"".join(files.values()).split(b'\n')
+        assert set(ourlines) == set(testlines)
+
+        with pytest.raises(TypeError):
+            read_bytes('.test.account*', blocksize=5.5)
+
+
 def test_with_urls():
     with filetexts(files, mode='b'):
         # OS-independent file:// URI with glob *