From 5372134ea2d22c90fff4b5830464a8f2c9932407 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Tue, 2 Oct 2018 11:35:07 -0500 Subject: [PATCH] fixed move --- pandas/tests/extension/decimal/__init__.py | 2 +- pandas/tests/extension/decimal/array.py | 5 +++++ pandas/tests/extension/decimal/test_decimal.py | 7 +------ pandas/tests/extension/json/array.py | 9 +++++++++ pandas/tests/extension/json/test_json.py | 11 +---------- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pandas/tests/extension/decimal/__init__.py b/pandas/tests/extension/decimal/__init__.py index 6bdfa0e05e0a0..c37aad0af8407 100644 --- a/pandas/tests/extension/decimal/__init__.py +++ b/pandas/tests/extension/decimal/__init__.py @@ -1,4 +1,4 @@ -from .array import DecimalArray, DecimalDtype +from .array import DecimalArray, DecimalDtype, to_decimal, make_data __all__ = ['DecimalArray', 'DecimalDtype', 'to_decimal', 'make_data'] diff --git a/pandas/tests/extension/decimal/array.py b/pandas/tests/extension/decimal/array.py index f324cc2e0f345..79e1a692f744a 100644 --- a/pandas/tests/extension/decimal/array.py +++ b/pandas/tests/extension/decimal/array.py @@ -1,5 +1,6 @@ import decimal import numbers +import random import sys import numpy as np @@ -142,5 +143,9 @@ def to_decimal(values, context=None): return DecimalArray([decimal.Decimal(x) for x in values], context=context) +def make_data(): + return [decimal.Decimal(random.random()) for _ in range(100)] + + DecimalArray._add_arithmetic_ops() DecimalArray._add_comparison_ops() diff --git a/pandas/tests/extension/decimal/test_decimal.py b/pandas/tests/extension/decimal/test_decimal.py index 024f758943649..64872eba6f8f0 100644 --- a/pandas/tests/extension/decimal/test_decimal.py +++ b/pandas/tests/extension/decimal/test_decimal.py @@ -1,7 +1,6 @@ import operator import decimal -import random import numpy as np import pandas as pd import pandas.util.testing as tm @@ -9,11 +8,7 @@ from pandas.tests.extension import base -from .array import DecimalDtype, DecimalArray - - -def make_data(): - return [decimal.Decimal(random.random()) for _ in range(100)] +from .array import DecimalDtype, DecimalArray, make_data @pytest.fixture diff --git a/pandas/tests/extension/json/array.py b/pandas/tests/extension/json/array.py index 6ce0d63eb63ec..87876d84bef99 100644 --- a/pandas/tests/extension/json/array.py +++ b/pandas/tests/extension/json/array.py @@ -13,6 +13,8 @@ import collections import itertools import numbers +import random +import string import sys import numpy as np @@ -179,3 +181,10 @@ def _values_for_argsort(self): # cast them to an (N, P) array, instead of an (N,) array of tuples. frozen = [()] + [tuple(x.items()) for x in self] return np.array(frozen, dtype=object)[1:] + + +def make_data(): + # TODO: Use a regular dict. See _NDFrameIndexer._setitem_with_indexer + return [collections.UserDict([ + (random.choice(string.ascii_letters), random.randint(0, 100)) + for _ in range(random.randint(0, 10))]) for _ in range(100)] diff --git a/pandas/tests/extension/json/test_json.py b/pandas/tests/extension/json/test_json.py index 0126d771caf7f..b30ff02c4fa9a 100644 --- a/pandas/tests/extension/json/test_json.py +++ b/pandas/tests/extension/json/test_json.py @@ -1,7 +1,5 @@ import operator import collections -import random -import string import pytest @@ -10,18 +8,11 @@ from pandas.compat import PY2, PY36 from pandas.tests.extension import base -from .array import JSONArray, JSONDtype +from .array import JSONArray, JSONDtype, make_data pytestmark = pytest.mark.skipif(PY2, reason="Py2 doesn't have a UserDict") -def make_data(): - # TODO: Use a regular dict. See _NDFrameIndexer._setitem_with_indexer - return [collections.UserDict([ - (random.choice(string.ascii_letters), random.randint(0, 100)) - for _ in range(random.randint(0, 10))]) for _ in range(100)] - - @pytest.fixture def dtype(): return JSONDtype()