|
5 | 5 | from nose.tools import * |
6 | 6 | from numpy.testing import * |
7 | 7 | from numpy.testing.utils import * |
| 8 | +from numpy.testing.decorators import skipif as skip_if |
8 | 9 |
|
9 | 10 | import numpy as np |
10 | 11 | import quantities as pq |
@@ -157,37 +158,34 @@ def test_rounding(): |
157 | 158 | ) |
158 | 159 |
|
159 | 160 | #test rint |
160 | | - a = [-4.1, -3.6, -2.5, 0.1, 2.5, 3.1, 3.9] * pq.dimensionless |
| 161 | + a = [-4.1, -3.6, -2.5, 0.1, 2.5, 3.1, 3.9] * pq.m |
161 | 162 | assert_array_almost_equal( |
162 | 163 | np.rint(a), |
163 | | - [-4., -4., -2., 0., 2., 3., 4.] |
| 164 | + [-4., -4., -2., 0., 2., 3., 4.]*pq.m |
164 | 165 | ) |
165 | | - assert_raises(ValueError, np.rint, 3.3*pq.m) |
166 | | - |
167 | | - # test fix |
168 | | -# TODO: uncomment once np.fix behaves itself |
169 | | -# assert_array_equal(np.fix(3.14 * pq.degF), 3.0 * pq.degF) |
170 | | -# assert_array_equal(np.fix(3.0 * pq.degF), 3.0 * pq.degF) |
171 | | -# assert_array_equal( |
172 | | -# np.fix([2.1, 2.9, -2.1, -2.9] * pq.degF), |
173 | | -# [2., 2., -2., -2.] * pq.degF |
174 | | -# ) |
175 | 166 |
|
176 | 167 | # test floor |
177 | | - a = [-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0] * pq.dimensionless |
| 168 | + a = [-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0] * pq.m |
178 | 169 | assert_array_almost_equal( |
179 | 170 | np.floor(a), |
180 | | - [-2., -2., -1., 0., 1., 1., 2.] * pq.dimensionless |
| 171 | + [-2., -2., -1., 0., 1., 1., 2.] * pq.m |
181 | 172 | ) |
182 | | - assert_raises(ValueError, np.floor, 3.3*pq.m) |
183 | 173 |
|
184 | 174 | # test ceil |
185 | | - a = [-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0] * pq.dimensionless |
| 175 | + a = [-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0] * pq.m |
186 | 176 | assert_array_almost_equal( |
187 | 177 | np.ceil(a), |
188 | | - [-1., -1., -0., 1., 2., 2., 2.] * pq.dimensionless |
| 178 | + [-1., -1., -0., 1., 2., 2., 2.] * pq.m |
| 179 | + ) |
| 180 | + |
| 181 | +@skip_if(np.__version__[:3] < '1.4') |
| 182 | +def test_fix(): |
| 183 | + assert_array_equal(np.fix(3.14 * pq.degF), 3.0 * pq.degF) |
| 184 | + assert_array_equal(np.fix(3.0 * pq.degF), 3.0 * pq.degF) |
| 185 | + assert_array_equal( |
| 186 | + np.fix([2.1, 2.9, -2.1, -2.9] * pq.degF), |
| 187 | + [2., 2., -2., -2.] * pq.degF |
189 | 188 | ) |
190 | | - assert_raises(ValueError, np.ceil, 3.3*pq.m) |
191 | 189 |
|
192 | 190 |
|
193 | 191 | def test_exponents_and_logarithms(): |
|
0 commit comments