skuschel / postpic

The open-source particle-in-cell post-processor.
GNU General Public License v3.0
67 stars 27 forks source link

Failing tests on numpy 1.11.0/scipy 0.17.0 #104

Closed Ablinne closed 7 years ago

Ablinne commented 7 years ago
=====  running next command =====
$ python3 -m nose
......................................./usr/lib/python3/dist-packages/numpy/lib/function_base.py:1492: RuntimeWarning: invalid value encountered in true_divide
  out /= dx[i]
/usr/lib/python3/dist-packages/numpy/lib/function_base.py:1492: RuntimeWarning: divide by zero encountered in true_divide
  out /= dx[i]
FF.........................
======================================================================
FAIL: test_map_coordinates (test.test_datahandling.TestField)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/raid/home/albn/src/postpic/test/test_datahandling.py", line 318, in test_map_coordinates
    self.assertTrue(np.isclose(a, b, rtol=0.01))
AssertionError: False is not true
-------------------- >> begin captured stdout << ---------------------
5.7 nan

--------------------- >> end captured stdout << ----------------------

======================================================================
FAIL: test_map_coordinates_2 (test.test_datahandling.TestField)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/raid/home/albn/src/postpic/test/test_datahandling.py", line 348, in test_map_coordinates_2
    self.assertTrue(np.all(np.isclose(a, b, rtol=0.001, atol=0.001)))
AssertionError: False is not true
-------------------- >> begin captured stdout << ---------------------
(1, 89) 0.353105764672 3.95336192755e-05 1.99955221129
(20, 45) -0.999370733428 -0.000391863869052 0.999478750858

--------------------- >> end captured stdout << ----------------------

----------------------------------------------------------------------
Ran 66 tests in 3.261s

FAILED (failures=2)

Happens in both, python2.7 and python3.5.

Ablinne commented 7 years ago

The problem is in pp.helper.approx_jacobian...

Ablinne commented 7 years ago

This is due to using the varargs argument of np.gradient to supply the grid. This is a new feature of numpy 1.13. Unfortunately this feature is not completely trivial to implement, see https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.gradient.html. In most cases, when the grid is equidistant, a fallback to the constant grid spacing varargs of older numpy should be sufficient. In other cases maybe raise NotImplemented.