holoviz / spatialpandas

Pandas extension arrays for spatial/geometric operations
BSD 2-Clause "Simplified" License
308 stars 24 forks source link

Tests in `test_parquet` failing with `TypeError: argument of type 'PosixPath' is not iterable` #42

Closed brl0 closed 4 years ago

brl0 commented 4 years ago

Multiple tests in test_parquet are failing with the same error message, and example of which is below:

``` ____________________________________________________________ test_parquet ____________________________________________________________ tmp_path = PosixPath('/tmp/pytest-of-blarsen/pytest-0/test_parquet0') @given( > gp_point=st_point_array(min_size=1, geoseries=True), gp_multipoint=st_multipoint_array(min_size=1, geoseries=True), gp_multiline=st_multiline_array(min_size=1, geoseries=True), ) @hyp_settings def test_parquet(gp_point, gp_multipoint, gp_multiline, tmp_path): tests/test_parquet.py:24: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_parquet.py:43: in test_parquet df_read = read_parquet(path, columns=['point', 'multipoint', 'multiline', 'a']) spatialpandas/io/parquet.py:103: in read_parquet filesystem = validate_coerce_filesystem(path, filesystem) spatialpandas/io/utils.py:19: in validate_coerce_filesystem return fsspec.open(path).fs ../../miniconda3/envs/default/lib/python3.7/site-packages/fsspec/core.py:378: in open **kwargs ../../miniconda3/envs/default/lib/python3.7/site-packages/fsspec/core.py:222: in open_files chain = _un_chain(urlpath, kwargs) ../../miniconda3/envs/default/lib/python3.7/site-packages/fsspec/core.py:269: in _un_chain bits = [_un_chain(p, kwargs) for p in path] ../../miniconda3/envs/default/lib/python3.7/site-packages/fsspec/core.py:269: in bits = [_un_chain(p, kwargs) for p in path] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ path = PosixPath('/tmp/pytest-of-blarsen/pytest-0/test_parquet0/df.parq'), kwargs = {} def _un_chain(path, kwargs): if isinstance(path, (tuple, list)): bits = [_un_chain(p, kwargs) for p in path] out = [] for pbit in zip(*bits): paths, protocols, kwargs = zip(*pbit) if len(set(protocols)) > 1: raise ValueError("Protocol mismatch in URL chain") if len(set(paths)) == 1: paths = paths[0] else: paths = list(paths) out.append([paths, protocols[0], kwargs[0]]) return out x = re.compile(".*[^a-z]+.*") # test for non protocol-like single word bits = ( [p if "://" in p or x.match(p) else p + "://" for p in path.split("::")] > if "::" in path else [path] ) E TypeError: argument of type 'PosixPath' is not iterable ../../miniconda3/envs/default/lib/python3.7/site-packages/fsspec/core.py:284: TypeError ```

It appears that fsspec does not support Path objects. A simple fix would be to cast the Path object to str before passing to the function being tested.

brl0 commented 4 years ago

Fixed in #37.