Skip to content

Commit 3aee98d

Browse files
committed
Merge pull request #6990 from jreback/less_precise
TST: fix checking for less_precise in floats
2 parents 5824637 + 1dd7750 commit 3aee98d

File tree

5 files changed

+28
-18
lines changed

5 files changed

+28
-18
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ language: python
33
env:
44
global:
55
# scatterci API key
6-
- secure: "Bx5umgo6WjuGY+5XFa004xjCiX/vq0CyMZ/ETzcs7EIBI1BE/0fIDXOoWhoxbY9HPfdPGlDnDgB9nGqr5wArO2s+BavyKBWg6osZ3dmkfuJPMOWeyCa92EeP+sfKw8e5HSU5MizW9e319wHWOF/xkzdHR7T67Qd5erhv91x4DnQ="
6+
#- secure: "Bx5umgo6WjuGY+5XFa004xjCiX/vq0CyMZ/ETzcs7EIBI1BE/0fIDXOoWhoxbY9HPfdPGlDnDgB9nGqr5wArO2s+BavyKBWg6osZ3dmkfuJPMOWeyCa92EeP+sfKw8e5HSU5MizW9e319wHWOF/xkzdHR7T67Qd5erhv91x4DnQ="
77
# ironcache API key
88
- secure: "e4eEFn9nDQc3Xa5BWYkzfX37jaWVq89XidVX+rcCNEr5OlOImvveeXnF1IzbRXznH4Sv0YsLwUd8RGUWOmyCvkONq/VJeqCHWtTMyfaCIdqSyhIP9Odz8r9ahch+Y0XFepBey92AJHmlnTh+2GjCDgIiqq4fzglojnp56Vg1ojA="
99
- secure: "CjmYmY5qEu3KrvMtel6zWFEtMq8ORBeS1S1odJHnjQpbwT1KY2YFZRVlLphfyDQXSz6svKUdeRrCNp65baBzs3DQNA8lIuXGIBYFeJxqVGtYAZZs6+TzBPfJJK798sGOj5RshrOJkFG2rdlWNuTq/XphI0JOrN3nPUkRrdQRpAw="
@@ -51,13 +51,15 @@ matrix:
5151
- JOB_NAME: "27_numpy_master"
5252
- JOB_TAG=_NUMPY_DEV_master
5353
- NUMPY_BUILD=master
54+
- PANDAS_TESTING_MODE="numpy_deprecate"
5455
allow_failures:
5556
- python: 2.7
5657
env:
5758
- NOSE_ARGS="not slow and not network and not disabled"
5859
- JOB_NAME: "27_numpy_master"
5960
- JOB_TAG=_NUMPY_DEV_master
6061
- NUMPY_BUILD=master
62+
- PANDAS_TESTING_MODE="numpy_deprecate"
6163

6264
# allow importing from site-packages,
6365
# so apt-get python-x works for system pythons

ci/after_script.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

3-
wget https://raw.github.com/y-p/ScatterCI-CLI/master/scatter_cli.py
4-
chmod u+x scatter_cli.py
3+
#wget https://raw.github.com/y-p/ScatterCI-CLI/master/scatter_cli.py
4+
#chmod u+x scatter_cli.py
55

66
pip install -I requests==2.1.0
77
echo "${TRAVIS_PYTHON_VERSION:0:4}"
@@ -12,7 +12,6 @@ fi
1212
# ScatterCI accepts a build log, but currently does nothing with it.
1313
echo '' > /tmp/build.log
1414

15-
# These should be in the environment, but not in source control
1615
# nore exposed in the build logs
1716
#export SCATTERCI_ACCESS_KEY=
1817
#export SCATTERCI_HOST=
@@ -22,6 +21,6 @@ ci/print_versions.py -j /tmp/env.json
2221

2322
# nose ran using "--with-xunit --xunit-file nosetest.xml" and generated /tmp/nosetest.xml
2423
# Will timeout if server not available, and should not fail the build
25-
python scatter_cli.py --xunit-file /tmp/nosetests.xml --log-file /tmp/build.log --env-file /tmp/env.json --build-name "$JOB_NAME" --succeed
24+
#python scatter_cli.py --xunit-file /tmp/nosetests.xml --log-file /tmp/build.log --env-file /tmp/env.json --build-name "$JOB_NAME" --succeed
2625

2726
true # never fail because bad things happened here

ci/script.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ fi
1616
"$TRAVIS_BUILD_DIR"/ci/build_docs.sh 2>&1 > /tmp/doc.log &
1717
# doc build log will be shown after tests
1818

19-
# export the testing mode
20-
if [ -n "$NUMPY_BUILD" ]; then
21-
22-
export PANDAS_TESTING_MODE="numpy_deprecate"
23-
24-
fi
25-
2619
echo nosetests --exe -w /tmp -A "$NOSE_ARGS" pandas --with-xunit --xunit-file=/tmp/nosetests.xml
2720
nosetests --exe -w /tmp -A "$NOSE_ARGS" pandas --with-xunit --xunit-file=/tmp/nosetests.xml
2821

pandas/src/testing.pyx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,7 @@ cpdef assert_almost_equal(a, b, bint check_less_precise=False):
118118

119119
# deal with differing dtypes
120120
if check_less_precise:
121-
dtype_a = np.dtype(type(a))
122-
dtype_b = np.dtype(type(b))
123-
if dtype_a.kind == 'f' and dtype_b == 'f':
124-
decimal = 3
121+
decimal = 3
125122

126123
if np.isinf(a):
127124
assert np.isinf(b), "First object is inf, second isn't"
@@ -132,11 +129,11 @@ cpdef assert_almost_equal(a, b, bint check_less_precise=False):
132129
if abs(fa) < 1e-5:
133130
if not decimal_almost_equal(fa, fb, decimal):
134131
assert False, (
135-
'(very low values) expected %.5f but got %.5f' % (b, a)
132+
'(very low values) expected %.5f but got %.5f, with decimal %d' % (fb, fa, decimal)
136133
)
137134
else:
138135
if not decimal_almost_equal(1, fb / fa, decimal):
139-
assert False, 'expected %.5f but got %.5f' % (b, a)
136+
assert False, 'expected %.5f but got %.5f, with decimal %d' % (fb, fa, decimal)
140137

141138
else:
142139
assert a == b, "%r != %r" % (a, b)

pandas/tests/test_testing.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,25 @@ def test_not_equal(self):
154154
# ATM meta data is not checked in assert_series_equal
155155
# self._assert_not_equal(Series(range(3)),Series(range(3),name='foo'),check_names=True)
156156

157+
def test_less_precise(self):
158+
s1 = Series([0.12345],dtype='float64')
159+
s2 = Series([0.12346],dtype='float64')
160+
161+
self.assertRaises(AssertionError, assert_series_equal, s1, s2)
162+
self._assert_equal(s1,s2,check_less_precise=True)
163+
164+
s1 = Series([0.12345],dtype='float32')
165+
s2 = Series([0.12346],dtype='float32')
166+
167+
self.assertRaises(AssertionError, assert_series_equal, s1, s2)
168+
self._assert_equal(s1,s2,check_less_precise=True)
169+
170+
# even less than less precise
171+
s1 = Series([0.1235],dtype='float32')
172+
s2 = Series([0.1236],dtype='float32')
173+
174+
self.assertRaises(AssertionError, assert_series_equal, s1, s2)
175+
self.assertRaises(AssertionError, assert_series_equal, s1, s2, True)
157176

158177
class TestRNGContext(unittest.TestCase):
159178

0 commit comments

Comments
 (0)