Skip to content

Commit 50eb561

Browse files
committed
BUG: fix for GH pandas-dev#2694 (natural naming issue on __contains__)
1 parent bcda1c6 commit 50eb561

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

RELEASE.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ pandas 0.10.1
6666
- handle correctly ``Term`` passed types (e.g. ``index<1000``, when index
6767
is ``Int64``), (closes GH512_)
6868
- handle Timestamp correctly in data_columns (closes GH2637_)
69+
- contains correctly matches on non-natural names
6970
- Fix DataFrame.info bug with UTF8-encoded columns. (GH2576_)
7071
- Fix DatetimeIndex handling of FixedOffset tz (GH2604_)
7172
- More robust detection of being in IPython session for wide DataFrame
@@ -98,6 +99,7 @@ pandas 0.10.1
9899
.. _GH2625: https://github.com/pydata/pandas/issues/2625
99100
.. _GH2643: https://github.com/pydata/pandas/issues/2643
100101
.. _GH2637: https://github.com/pydata/pandas/issues/2637
102+
.. _GH2694: https://github.com/pydata/pandas/issues/2694
101103

102104
pandas 0.10.0
103105
=============

pandas/io/pytables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def __contains__(self, key):
220220
node = self.get_node(key)
221221
if node is not None:
222222
name = node._v_pathname
223-
return re.search(key, name) is not None
223+
if name == key or name[1:] == key: return True
224224
return False
225225

226226
def __len__(self):

pandas/io/tests/test_pytables.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ def test_contains(self):
111111
self.assert_('/foo/b' not in self.store)
112112
self.assert_('bar' not in self.store)
113113

114+
# GH 2694
115+
warnings.filterwarnings('ignore', category=tables.NaturalNameWarning)
116+
self.store['node())'] = tm.makeDataFrame()
117+
self.assert_('node())' in self.store)
118+
warnings.filterwarnings('always', category=tables.NaturalNameWarning)
119+
114120
def test_versioning(self):
115121
self.store['a'] = tm.makeTimeSeries()
116122
self.store['b'] = tm.makeDataFrame()

0 commit comments

Comments
 (0)