Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit a7fe8a5

Browse files
committed
Fix call to map
1 parent ca49588 commit a7fe8a5

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

root_pandas/readwrite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def read_root(paths, key=None, columns=None, ignore=None, chunksize=None, where=
137137
ignore = [ignore]
138138
ignored = get_matching_variables(branches, ignore, fail=False)
139139
ignored = list(itertools.chain.from_iterable(list(map(expand_braces, ignored))))
140-
if any(map(lambda x: x.startswith('__index__', ignored))):
140+
if any(map(lambda x: x.startswith('__index__'), ignored)):
141141
raise ValueError('__index__* branch is being ignored!')
142142
for var in ignored:
143143
all_vars.remove(var)

tests/test.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ def test_read_write():
3434
df = read_root('tmp.root', columns=['x'])
3535
os.remove('tmp.root')
3636

37+
def test_ignore_columns():
38+
df = pd.DataFrame({'x': [1,2,3], 'y1': [2,3,4], 'y2': [3,4,5]})
39+
df.to_root('tmp.root')
40+
41+
df = read_root('tmp.root', ignore=['y1'])
42+
assert(df.columns[0] == 'x' and df.columns[1] == 'y2')
43+
44+
df = read_root('tmp.root', ignore=['y*'])
45+
assert(df.columns == ['x'])
46+
47+
# Test interaction with columns kwarg
48+
df = read_root('tmp.root', columns=['y*'], ignore=['*1'])
49+
assert(df.columns == ['y2'])
50+
51+
os.remove('tmp.root')
52+
3753

3854
def test_persistent_index():
3955
df = pd.DataFrame({'index': [42, 0, 1], 'x': [1,2,3]})

0 commit comments

Comments
 (0)