Skip to content

Commit 3c3d851

Browse files
committed
refactor: vals -> keys
1 parent 257e096 commit 3c3d851

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

sugar/_io/tab/xsv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ def _read_fts_xsv(f, ftype=None, **kw):
8989
return FeatureList.frompandas(df, ftype=ftype)
9090

9191

92-
def _write_fts_xsv(fts: FeatureList, f, vals='type start stop strand', dtype=None, index=False, **kw):
92+
def _write_fts_xsv(fts: FeatureList, f, keys='type start stop strand', dtype=None, index=False, **kw):
9393
try:
94-
df = fts.topandas(vals, dtype=dtype)
94+
df = fts.topandas(keys, dtype=dtype)
9595
except ImportError:
9696
raise ImportError('TSV/CSV writer depends on pandas module')
9797
return df.to_csv(f, index=index, **kw)

sugar/core/fts.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,11 @@ def tofmtstr(self, fmt, **kw):
567567
"""
568568
return self.write(None, fmt)
569569

570-
def tolists(self, vals='type start stop strand'):
570+
def tolists(self, keys='type start stop strand'):
571571
"""
572572
Return a generator yielding a list for each feature
573573
574-
:param vals: Parameters from the metadata or location to return,
574+
:param keys: Parameters from the metadata or location to return,
575575
``'len'`` is also allowed,
576576
might be a string or tuple, defaults to ``'type start stop strand'``
577577
@@ -586,24 +586,24 @@ def tolists(self, vals='type start stop strand'):
586586
cDNA_match 103944892 - 7136
587587
cDNA_match 107859806 - 2392
588588
"""
589-
if isinstance(vals, str):
590-
vals = vals.split()
589+
if isinstance(keys, str):
590+
keys = keys.split()
591591
for ft in self:
592592
yield [
593-
ft.loc.strand if v == 'strand' else
594-
ft.loc.defect if v == 'defect' else
595-
ft.locs.range[0] if v == 'start' else
596-
ft.locs.range[1] if v == 'stop' else
597-
len(ft) if v == 'len' else
598-
ft.meta.get(v)
599-
for v in vals
593+
ft.loc.strand if k == 'strand' else
594+
ft.loc.defect if k == 'defect' else
595+
ft.locs.range[0] if k == 'start' else
596+
ft.locs.range[1] if k == 'stop' else
597+
len(ft) if k == 'len' else
598+
ft.meta.get(k)
599+
for k in keys
600600
]
601601

602-
def topandas(self, vals='type start stop strand', **kw):
602+
def topandas(self, keys='type start stop strand', **kw):
603603
"""
604604
Return a `pandas.DataFrame` of the features
605605
606-
:param vals: Parameters from the metadata or location to return,
606+
:param keys: Parameters from the metadata or location to return,
607607
``'len'`` is also allowed,
608608
might be a string or tuple, defaults to ``'type start stop strand'``
609609
@@ -620,10 +620,10 @@ def topandas(self, vals='type start stop strand', **kw):
620620
3 cDNA_match 107859806 107862198 -
621621
"""
622622
import pandas
623-
if isinstance(vals, str):
624-
vals = vals.split()
625-
kw.setdefault('columns', vals)
626-
return pandas.DataFrame(self.tolists(vals=vals), **kw)
623+
if isinstance(keys, str):
624+
keys = keys.split()
625+
kw.setdefault('columns', keys)
626+
return pandas.DataFrame(self.tolists(keys=keys), **kw)
627627

628628

629629
def get(self, type):

sugar/tests/test_io_tab_xsv.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ def test_csv():
2525
def test_xsv_edgecases():
2626
pytest.importorskip('pandas')
2727
fts = read_fts()
28-
out = fts.write(None, 'csv', sep=' ', vals='type start len strand defect')
28+
out = fts.write(None, 'csv', sep=' ', keys='type start len strand defect')
2929
fts2 = read_fts(io.StringIO(out), sep=None, engine='python')
3030
fts3 = read_fts('!data/fts_example.tsv')
3131
assert fts2 == fts3
32-
out = fts.write(None, 'csv', sep='|', vals='type stop len strand defect')
32+
out = fts.write(None, 'csv', sep='|', keys='type stop len strand defect')
3333
fts2 = read_fts(io.StringIO(out), sep='|')
3434
assert fts2 == fts3

0 commit comments

Comments
 (0)