mcocdawc / chemcoord

A python module for manipulating cartesian and internal coordinates.
GNU Lesser General Public License v3.0
72 stars 19 forks source link

Old numba version Zmat.give_cartesian() bug #17

Closed sgill2 closed 7 years ago

sgill2 commented 7 years ago

When I was running the following code (in both python 2.7 and 3.5):

import chemcoord as cc
a = cc.Cartesian.read_xyz('some.xyz')
amat = a.give_zmat()
b = amat.give_cartesian()

I got the following (abbreviated) error traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/chemcoord/internal_coordinates/_zmat_class_give_cartesian.py", line 74, in give_cartesian
    positions[row] = _jit_calculate_position(refs, zmat_values, row)
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/numba/dispatcher.py", line 277, in _compile_for_args
    return self.compile(tuple(real_args))
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/numba/dispatcher.py", line 495, in compile
    cres = self._compiler.compile(args, return_type)
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/numba/dispatcher.py", line 76, in compile
    flags=flags, locals=self.locals)
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 696, in compile_extra
    return pipeline.compile_extra(func)
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 369, in compile_extra
    return self.compile_bytecode(bc, func_attr=self.func_attr)
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 378, in compile_bytecode
    return self._compile_bytecode()
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 662, in _compile_bytecode
    res = pm.run(self.status)
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 257, in run
    raise patched_exception
numba.errors.UntypedAttributeError: Caused By:
Traceback (most recent call last):
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 249, in run
    stage()
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 466, in stage_nopython_frontend
    self.locals)
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 807, in type_inference_stage
    infer.propagate()
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/numba/typeinfer.py", line 613, in propagate
    raise errors[0]
UntypedAttributeError: Caused By:
Traceback (most recent call last):
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 249, in run
    stage()
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 466, in stage_nopython_frontend
    self.locals)
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/numba/compiler.py", line 807, in type_inference_stage
    infer.propagate()
  File "/Users/samgill/anaconda/lib/python2.7/site-packages/numba/typeinfer.py", line 613, in propagate
    raise errors[0]
UntypedAttributeError: Unknown attribute "norm" of type Module(<module 'numpy.linalg' from '/Users/samgill/anaconda/lib/python2.7/site-packages/numpy/linalg/__init__.pyc'>)
File "../../../anaconda/lib/python2.7/site-packages/chemcoord/utilities/algebra_utilities.py", line 34

Failed at nopython (nopython frontend)
Unknown attribute "norm" of type Module(<module 'numpy.linalg' from '/Users/samgill/anaconda/lib/python2.7/site-packages/numpy/linalg/__init__.pyc'>)
File "../../../anaconda/lib/python2.7/site-packages/chemcoord/utilities/algebra_utilities.py", line 34

This suggested that it had something to do with numba. In Python3 when I updated my numba package (from 0.26.0 to 0.33.0) this error went away. However in Python2.7 I couldn't update to numba 0.33.0 with conda due to a conflict in requirements:

UnsatisfiableError: The following specifications were found to be in conflict:
  - chaco -> enable -> numpy 1.9*
  - numba 0.33.0* -> llvmlite 0.18.*
Use "conda info <package>" to see the dependencies for each package.

By removing the chaco and enable packages to remove this conflict I was able to update to the latest version of numba and this error went away.

I'm mostly mentioning this because I saw that in your tests test_back_forth.py your latest commit said that there was a Python2.7 bug. After doing the above fix I ran test_back_forth.py in Python2.7 without it spitting out errors; I don't know if that's the same bug you've been seeing though.

sgill2 commented 7 years ago

It might be helpful to post any bugs you encounter and enhancements as issues so that

  1. Other people using your code can be aware of potential bugs (as well as helping yourself keep track of them) and other changes.
  2. Other people can potentially help contribute towards those issues.

And as an aside, I haven't had a chance to try out all the changes you've put in recently but I'm looking forward to trying the revamped package out when I find the time :)

mcocdawc commented 7 years ago

Thank you very much for your detailed reports. And you are definitely right, I have to get into the good habit of writing more issues myself. (Did not expect interest that early) ;) On the other hand I won't force myself to write bug reports for bugs in sidebranches and this specific bug was introduced (and solved) in a sidebranch which was lateron merged into master. (Besides the bug was small and unrelated to your detected one)

It seems as if I have to specify some minimum version for numba, and have to figure out which one.

If you have some running scripts with defined expected output, you would help this project a lot, if you include them in the tests directory. The infrastructure for tests is there, but the test cases are missing. (https://docs.pytest.org/en/latest/) I will write an enhancement request issue for it tomorrow