Skip to content

Commit 988c417

Browse files
committed
style: replace deprecated delim_whitespace with sep
* Previously a FutureWarning was coming up in pytest that 'delim_whitespace' keyword in pd.read_table is deprecated, need to use sep='\s+' instead. * Deprecated in v2.2.0, see pandas-dev/pandas#55569 and https://pandas.pydata.org/docs/whatsnew/v2.2.0.html#other-deprecations for more info
1 parent b082369 commit 988c417

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/threads_arg/utils.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,19 @@ def interpolate_map(map_gz, pgen):
5454
Reading in map file (format has columns [chrom, SNP, cM-pos, bp])
5555
"""
5656
if (map_gz[:-3] == ".gz") :
57-
maps = pd.read_table(map_gz, header=None, compression='gzip', delim_whitespace=True)
57+
maps = pd.read_table(map_gz, header=None, compression='gzip', sep="\\s+")
5858
else:
59-
maps = pd.read_table(map_gz, header=None, delim_whitespace=True)
59+
maps = pd.read_table(map_gz, header=None, sep="\\s+")
6060
cm_pos_map = maps[2].values.astype(np.float64)
6161
phys_pos_map = maps[3].values.astype(np.float64)
6262
pvar = pgen.replace("pgen", "pvar")
6363
bim = pgen.replace("pgen", "bim")
6464

6565
physical_positions = None
6666
if os.path.isfile(bim):
67-
physical_positions = np.array(pd.read_table(bim, delim_whitespace=True, header=None, comment='#')[3]).astype(np.float64)
67+
physical_positions = np.array(pd.read_table(bim, sep="\\s+", header=None, comment='#')[3]).astype(np.float64)
6868
elif os.path.isfile(pvar):
69-
physical_positions = np.array(pd.read_table(pvar, delim_whitespace=True, header=None, comment='#')[1]).astype(np.float64)
69+
physical_positions = np.array(pd.read_table(pvar, sep="\\s+", header=None, comment='#')[1]).astype(np.float64)
7070
else:
7171
raise RuntimeError(f"Can't find {bim} or {pvar}")
7272

@@ -87,10 +87,10 @@ def get_map_from_bim(pgen, rho):
8787
cm_out = None
8888
physical_positions = None
8989
if os.path.isfile(bim):
90-
physical_positions = np.array(pd.read_table(bim, delim_whitespace=True, header=None, comment='#')[3]).astype(int)
90+
physical_positions = np.array(pd.read_table(bim, sep="\\s+", header=None, comment='#')[3]).astype(int)
9191
cm_out = rho * 100 * physical_positions
9292
elif os.path.isfile(pvar):
93-
physical_positions = np.array(pd.read_table(pvar, delim_whitespace=True, header=None, comment='#')[1]).astype(int)
93+
physical_positions = np.array(pd.read_table(pvar, sep="\\s+", header=None, comment='#')[1]).astype(int)
9494
cm_out = rho * 100 * physical_positions
9595
else:
9696
raise RuntimeError(f"Can't find {bim} or {pvar}")
@@ -101,5 +101,5 @@ def get_map_from_bim(pgen, rho):
101101
return cm_out, physical_positions
102102

103103
def parse_demography(demography):
104-
d = pd.read_table(demography, delim_whitespace=True, header=None)
104+
d = pd.read_table(demography, sep="\\s+", header=None)
105105
return list(d[0]), list(d[1])

0 commit comments

Comments
 (0)