Skip to content

TST: GH10837 remove test_ujson.py reliance on dict iteration order #10853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 19, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions pandas/io/tests/test_json/test_ujson.py
Original file line number Diff line number Diff line change
Expand Up @@ -1131,22 +1131,20 @@ def testArrayNumpyLabelled(self):
self.assertTrue(output[1] is None)
self.assertTrue((np.array([u('a')]) == output[2]).all())

# py3 is non-determinstic on the ordering......
if not compat.PY3:
input = [{'a': 42, 'b':31}, {'a': 24, 'c': 99}, {'a': 2.4, 'b': 78}]
output = ujson.loads(ujson.dumps(input), numpy=True, labelled=True)
expectedvals = np.array([42, 31, 24, 99, 2.4, 78], dtype=int).reshape((3,2))
self.assertTrue((expectedvals == output[0]).all())
self.assertTrue(output[1] is None)
self.assertTrue((np.array([u('a'), 'b']) == output[2]).all())


input = {1: {'a': 42, 'b':31}, 2: {'a': 24, 'c': 99}, 3: {'a': 2.4, 'b': 78}}
output = ujson.loads(ujson.dumps(input), numpy=True, labelled=True)
expectedvals = np.array([42, 31, 24, 99, 2.4, 78], dtype=int).reshape((3,2))
self.assertTrue((expectedvals == output[0]).all())
self.assertTrue((np.array(['1','2','3']) == output[1]).all())
self.assertTrue((np.array(['a', 'b']) == output[2]).all())
# Write out the dump explicitly so there is no dependency on iteration order GH10837
input_dumps = '[{"a": 42, "b":31}, {"a": 24, "c": 99}, {"a": 2.4, "b": 78}]'
output = ujson.loads(input_dumps, numpy=True, labelled=True)
expectedvals = np.array([42, 31, 24, 99, 2.4, 78], dtype=int).reshape((3, 2))
self.assertTrue((expectedvals == output[0]).all())
self.assertTrue(output[1] is None)
self.assertTrue((np.array([u('a'), 'b']) == output[2]).all())

input_dumps = '{"1": {"a": 42, "b":31}, "2": {"a": 24, "c": 99}, "3": {"a": 2.4, "b": 78}}'
output = ujson.loads(input_dumps, numpy=True, labelled=True)
expectedvals = np.array([42, 31, 24, 99, 2.4, 78], dtype=int).reshape((3, 2))
self.assertTrue((expectedvals == output[0]).all())
self.assertTrue((np.array(['1', '2', '3']) == output[1]).all())
self.assertTrue((np.array(['a', 'b']) == output[2]).all())


class PandasJSONTests(TestCase):
Expand Down