Skip to content

Commit

Permalink
Merge pull request #4482 from cpcloud/set-construct
Browse files Browse the repository at this point in the history
BUG: raise on frozenset construction by Series
  • Loading branch information
cpcloud committed Aug 8, 2013
2 parents 515074a + e78cae7 commit 5a2daa4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions doc/source/release.rst
Expand Up @@ -133,6 +133,8 @@ pandas 0.13
(:issue:`4016`)
- Fixed Panel assignment with a transposed frame (:issue:`3830`)
- Raise on set indexing with a Panel and a Panel as a value which needs alignment (:issue:`3777`)
- frozenset objects now raise in the ``Series`` constructor (:issue:`4482`,
:issue:`4480`)

pandas 0.12
===========
Expand Down
5 changes: 3 additions & 2 deletions pandas/core/series.py
Expand Up @@ -467,8 +467,9 @@ def __new__(cls, data=None, index=None, dtype=None, name=None,
data = [data.get(i, nan) for i in index]
elif isinstance(data, types.GeneratorType):
data = list(data)
elif isinstance(data, set):
raise TypeError('Set value is unordered')
elif isinstance(data, (set, frozenset)):
raise TypeError("{0!r} type is unordered"
"".format(data.__class__.__name__))

if dtype is not None:
dtype = np.dtype(dtype)
Expand Down
11 changes: 8 additions & 3 deletions pandas/io/tests/test_pytables.py
Expand Up @@ -2418,9 +2418,14 @@ def test_string_select(self):
expected = df[df.x == 'none']
assert_frame_equal(result,expected)

result = store.select('df',Term('x!=none'))
expected = df[df.x != 'none']
assert_frame_equal(result,expected)
try:
result = store.select('df',Term('x!=none'))
expected = df[df.x != 'none']
assert_frame_equal(result,expected)
except Exception as detail:
print("[{0}]".format(detail))
print(store)
print(expected)

df2 = df.copy()
df2.loc[df2.x=='','x'] = np.nan
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/test_series.py
Expand Up @@ -544,7 +544,8 @@ def test_constructor_tuple_of_tuples(self):

def test_constructor_set(self):
values = set([1, 2, 3, 4, 5])

self.assertRaises(TypeError, Series, values)
values = frozenset(values)
self.assertRaises(TypeError, Series, values)

def test_fromDict(self):
Expand Down

0 comments on commit 5a2daa4

Please sign in to comment.