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

Bug with numpy 1.7.0 #373

Closed
guyer opened this issue Sep 19, 2014 · 3 comments
Closed

Bug with numpy 1.7.0 #373

guyer opened this issue Sep 19, 2014 · 3 comments

Comments

@guyer
Copy link
Member

guyer commented Sep 19, 2014

As reported [http://thread.gmane.org/gmane.comp.python.fipy/2963 on the list]:

I think I found a bug with numpy 1.7.0 and Fipy (latest git).
The best example is the circle diffusion problem in which I can't
initialize the viewer. I try to debug the problem and is seems to be
related to numpy.take for which indices should be integers. It
complains to cast from float64 to int64 !

The best workaround I found is to tweak the tools/numerix.py and
modifiy the following lines :

596: taken = a.take(indices.astype('int64'), axis=axis)   
601: taken = MA.take(a,MA.filled(indices,0).astype('int64'),axis=axis) 
620: taken = NUMERIX.take(a, indices.astype('int64'),axis=axis)
622: taken = MA.take(a, indices.astype('int64'),axis=axis)

I used Gentoo and all the python package are on the edge :
dev-python/numpy-1.7.0
dev-python/matplotlib-1.2.0-r2
sci-libs/scipy-0.11.0-r1

I hope it will help !!!

Imported from trac ticket #539, created by guyer on 03-18-2013 at 11:32, last modified: 03-20-2013 at 15:51

@guyer
Copy link
Member Author

guyer commented Sep 19, 2014

The issue is because of fipy/meshes/gmshMesh.py@28de7a8107fb#L859. If maxVerts-len(v) is zero, then concatenation is with an empty list, but NumPy 1.7 apparently casts each of the concatenates to an array before concatenating them. Compare:

>>> import numpy as np
>>> np.__version__
'1.7.0'
>>> np.concatenate(([1, 2, 3], []))
array([ 1.,  2.,  3.])

with

>>> import numpy as np
>>> np.__version__
'1.6.1'
>>> np.concatenate(([1, 2, 3], []))
array([1, 2, 3])

The solution is to manually cast the (possibly empty) list of [-1] to an array of int before concatenation.

Trac comment by guyer on 03-19-2013 at 10:38

@guyer
Copy link
Member Author

guyer commented Sep 19, 2014

Pull request

The following changes since commit 8c51478a3e8c30618b3a96c132612a46735c7548:

  Merge branch 'ticket496-FIPY_DISPLAY_MATRIX_is_broken' into develop (2013-02-11 12:18:26 -0500)

are available in the git repository at:


  ssh://git@code.matforge.org/nist/fipy.git ticket539

for you to fetch changes up to 9ae4801ab0d2f314a7b51dafcc155eb142da0b2d:

  Fix for issue #373 (2013-03-19 10:40:29 -0400)

----------------------------------------------------------------
Jonathan Guyer (1):
Fix for issue #373

 fipy/meshes/gmshMesh.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Trac comment by guyer on 03-19-2013 at 13:16

@wd15
Copy link
Contributor

wd15 commented Sep 19, 2014

Tests pass on Buildbot and in a virtualenv with numpy 1.7. Merged back to develop with [0c8a5a6/fipy].

Trac comment by wd15 on 03-20-2013 at 12:59

@guyer guyer closed this as completed Sep 19, 2014
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

3 participants