fixed move · pandas-dev/pandas@5372134 (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Commit 5372134

File tree

5 files changed

lines changed

5 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1 -from .array import DecimalArray, DecimalDtype
1 +from .array import DecimalArray, DecimalDtype, to_decimal, make_data
2 2
3 3
4 4 __all__ = ['DecimalArray', 'DecimalDtype', 'to_decimal', 'make_data']
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
1 1 import decimal
2 2 import numbers
3 +import random
3 4 import sys
4 5
5 6 import numpy as np
@@ -142,5 +143,9 @@ def to_decimal(values, context=None):
142 143 return DecimalArray([decimal.Decimal(x) for x in values], context=context)
143 144
144 145
146 +def make_data():
147 +return [decimal.Decimal(random.random()) for _ in range(100)]
148 +
149 +
145 150 DecimalArray._add_arithmetic_ops()
146 151 DecimalArray._add_comparison_ops()
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
1 1 import operator
2 2 import decimal
3 3
4 -import random
5 4 import numpy as np
6 5 import pandas as pd
7 6 import pandas.util.testing as tm
8 7 import pytest
9 8
10 9 from pandas.tests.extension import base
11 10
12 -from .array import DecimalDtype, DecimalArray
13 -
14 -
15 -def make_data():
16 -return [decimal.Decimal(random.random()) for _ in range(100)]
11 +from .array import DecimalDtype, DecimalArray, make_data
17 12
18 13
19 14 @pytest.fixture
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@
13 13 import collections
14 14 import itertools
15 15 import numbers
16 +import random
17 +import string
16 18 import sys
17 19
18 20 import numpy as np
@@ -179,3 +181,10 @@ def _values_for_argsort(self):
179 181 # cast them to an (N, P) array, instead of an (N,) array of tuples.
180 182 frozen = [()] + [tuple(x.items()) for x in self]
181 183 return np.array(frozen, dtype=object)[1:]
184 +
185 +
186 +def make_data():
187 +# TODO: Use a regular dict. See _NDFrameIndexer._setitem_with_indexer
188 +return [collections.UserDict([
189 + (random.choice(string.ascii_letters), random.randint(0, 100))
190 +for _ in range(random.randint(0, 10))]) for _ in range(100)]
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
1 1 import operator
2 2 import collections
3 -import random
4 -import string
5 3
6 4 import pytest
7 5
@@ -10,18 +8,11 @@
10 8 from pandas.compat import PY2, PY36
11 9 from pandas.tests.extension import base
12 10
13 -from .array import JSONArray, JSONDtype
11 +from .array import JSONArray, JSONDtype, make_data
14 12
15 13 pytestmark = pytest.mark.skipif(PY2, reason="Py2 doesn't have a UserDict")
16 14
17 15
18 -def make_data():
19 -# TODO: Use a regular dict. See _NDFrameIndexer._setitem_with_indexer
20 -return [collections.UserDict([
21 - (random.choice(string.ascii_letters), random.randint(0, 100))
22 -for _ in range(random.randint(0, 10))]) for _ in range(100)]
23 -
24 -
25 16 @pytest.fixture
26 17 def dtype():
27 18 return JSONDtype()