Skip to content

Commit

Permalink
Hotfix for change in get_handle in pandas 1.2.0 (#239)
Browse files Browse the repository at this point in the history
* Update cload.py

* Fix get_handle handling
  • Loading branch information
nvictus committed Feb 3, 2021
1 parent 84b0d51 commit 9850bd4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cooler/cli/cload.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
TabixAggregator, HDF5Aggregator, PairixAggregator,
)

_pandas_major_version = int(pd.__version__.split('.')[0])
if _pandas_major_version > 0:
_pandas_version = pd.__version__.split('.')
if int(_pandas_version[0]) > 0:
from pandas.io.common import get_handle


Expand Down Expand Up @@ -542,13 +542,18 @@ def pairs(bins, pairs_path, cool_path, metadata, assembly, chunksize,
if pairs_path == '-':
f_in = sys.stdin
_, f_in = get_header(f_in)
elif _pandas_major_version > 0:
f_in = get_handle(pairs_path, mode='r', compression='infer')[0]
elif int(_pandas_version[0]) > 0:
if int(_pandas_version[1]) < 2:
f_in = get_handle(pairs_path, mode='r', compression='infer')[0]
else:
f_in = get_handle(pairs_path, mode='r', compression='infer').handle

_, f_in = get_header(f_in)
else:
f_in = pairs_path
kwargs['comment'] = '#'


reader = pd.read_csv(
f_in,
sep='\t',
Expand Down

0 comments on commit 9850bd4

Please sign in to comment.