Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grid3D broken by numpy 1.10 #475

Closed
guyer opened this issue Nov 24, 2015 · 3 comments
Closed

Grid3D broken by numpy 1.10 #475

guyer opened this issue Nov 24, 2015 · 3 comments
Assignees
Milestone

Comments

@guyer
Copy link
Member

guyer commented Nov 24, 2015

As of numpy 1.10, any uses of Grid3D fail, e.g.

======================================================================
FAIL: _test (fipy.meshes.uniformGrid3D.UniformGrid3D)
Doctest: fipy.meshes.uniformGrid3D.UniformGrid3D._test
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/guyer/anaconda/envs/py2_7_debug/lib/python2.7/doctest.py", line 2226, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for fipy.meshes.uniformGrid3D.UniformGrid3D._test
  File "/Users/guyer/Documents/research/FiPy/fipy/fipy/meshes/uniformGrid3D.py", line 541, in _test

----------------------------------------------------------------------
File "/Users/guyer/Documents/research/FiPy/fipy/fipy/meshes/uniformGrid3D.py", line 667, in fipy.meshes.uniformGrid3D.UniformGrid3D._test
Failed example:
    print numerix.allclose(faceToCellDistanceRatios, mesh._faceToCellDistanceRatio, atol = 1e-10, rtol = 1e-10) # doctest: +PROCESSOR_0
Exception raised:
    Traceback (most recent call last):
      File "/Users/guyer/anaconda/envs/py2_7_debug/lib/python2.7/doctest.py", line 1315, in __run
        compileflags, 1) in test.globs
      File "<doctest fipy.meshes.uniformGrid3D.UniformGrid3D._test[49]>", line 1, in <module>
        print numerix.allclose(faceToCellDistanceRatios, mesh._faceToCellDistanceRatio, atol = 1e-10, rtol = 1e-10) # doctest: +PROCESSOR_0
      File "/Users/guyer/Documents/research/FiPy/fipy/fipy/meshes/uniformGrid3D.py", line 278, in _faceToCellDistanceRatio
        numerix.ravel(YZdis.swapaxes(0,2))), axis=1)
    IndexError: axis 1 out of bounds [0, 1)

The issue is that numerix.ravel returns a 1D array and so axis=1 is nonsensical in _faceToCellDistanceRatio. It looks like this was always wrong (going back to at least 2011), but numpy tolerated it until now.

Probably safe to just remove the axis=1 argument, but need to test.

@guyer guyer self-assigned this Nov 24, 2015
@guyer guyer added this to the 3.1 milestone Nov 24, 2015
guyer added a commit that referenced this issue Nov 25, 2015
This never should have worked, but numpy 1.10 actually checks.
Also provide some documentation for what `_faceToCellDistanceRatio` is and
why it's scalar.

Addresses #475
pkgw added a commit to pkgw/fipy that referenced this issue Dec 9, 2015
…() calls

As far as I can tell, there were several codepaths in the UniformGrid3D class
that seemed not to have been tested since they didn't work at all; in
particular, the _cellToCellIDs map was broken. This commit fixes that (I hope)
and a couple of more invalid `axis=n` keywords to `numerix.concatenate()`.
Unfortunately I have not put together test cases for these problems, so I'm
not completely sure that the "fixed" _cellToCellIDs is always correct.

See issue usnistgov#470, issue usnistgov#475, and issue usnistgov#477.
guyer pushed a commit that referenced this issue Dec 27, 2015
…() calls

As far as I can tell, there were several codepaths in the UniformGrid3D class
that seemed not to have been tested since they didn't work at all; in
particular, the _cellToCellIDs map was broken. This commit fixes that (I hope)
and a couple of more invalid `axis=n` keywords to `numerix.concatenate()`.
Unfortunately I have not put together test cases for these problems, so I'm
not completely sure that the "fixed" _cellToCellIDs is always correct.

See issue #470, issue #475, and issue #477.
@guyer
Copy link
Member Author

guyer commented Dec 27, 2015

Fixed by #478 / 33d033d

@DarioPanada
Copy link

This seems to still be an issue on clean pip installations, tentatively fixed by removing axis=1 parameter on line 279, uniformGrid3D.py

@DarioPanada
Copy link

For anybody reading in 2018, the issue is actually solved in the development branch (not by me, just to be clear) but not in the version you get when installing via pip. You will have to clone from git, checkout development and build with python setup.py install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants