Skip to content

Commit c776133

Browse files
committed
Unskip most JSON tests
1 parent d5e8198 commit c776133

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

pandas/tests/extension/json/array.py

+11
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ def __getitem__(self, item):
4444
return self._constructor_from_sequence([
4545
x for x, m in zip(self, item) if m
4646
])
47+
elif isinstance(item, collections.Iterable):
48+
# fancy indexing
49+
return type(self)([self.data[i] for i in item])
4750
else:
51+
# slice
4852
return type(self)(self.data[item])
4953

5054
def __setitem__(self, key, value):
@@ -104,6 +108,13 @@ def _concat_same_type(cls, to_concat):
104108
data = list(itertools.chain.from_iterable([x.data for x in to_concat]))
105109
return cls(data)
106110

111+
def _values_for_argsort(self):
112+
# Disable NumPy's shape inference by including an empty tuple...
113+
# If all the elemnts of self are the same size P, NumPy will
114+
# cast them to an (N, P) array, instead of an (N,) array of tuples.
115+
frozen = [()] + list(tuple(x.items()) for x in self)
116+
return np.array(frozen, dtype=object)[1:]
117+
107118

108119
def make_data():
109120
# TODO: Use a regular dict. See _NDFrameIndexer._setitem_with_indexer

pandas/tests/extension/json/test_json.py

+6-19
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def data_for_sorting():
3636

3737
@pytest.fixture
3838
def data_missing_for_sorting():
39-
return JSONArray([{'b': 1}, {}, {'c': 4}])
39+
return JSONArray([{'b': 1}, {}, {'a': 4}])
4040

4141

4242
@pytest.fixture
@@ -80,28 +80,15 @@ def test_fillna_frame(self):
8080

8181

8282
class TestMethods(base.BaseMethodsTests):
83-
@pytest.mark.skip(reason="Unhashable")
84-
def test_value_counts(self, all_data, dropna):
85-
pass
83+
unhashable = pytest.mark.skip(reason="Unhashable")
8684

87-
@pytest.mark.skip(reason="Dictionaries are not orderable.")
88-
def test_argsort(self):
89-
pass
90-
91-
@pytest.mark.skip(reason="Dictionaries are not orderable.")
92-
def test_argsort_missing(self):
93-
pass
94-
95-
@pytest.mark.skip(reason="Dictionaries are not orderable.")
96-
def test_sort_values(self):
97-
pass
98-
99-
@pytest.mark.skip(reason="Dictionaries are not orderable.")
100-
def test_sort_values_missing(self):
85+
@unhashable
86+
def test_value_counts(self, all_data, dropna):
10187
pass
10288

103-
@pytest.mark.skip(reason="Dictionaries are not orderable.")
89+
@unhashable
10490
def test_sort_values_frame(self):
91+
# TODO (EA.factorize): see if _values_for_factorize allows this.
10592
pass
10693

10794

0 commit comments

Comments
 (0)