vnmabus / dcor

Distance correlation and related E-statistics in Python
https://dcor.readthedocs.io
MIT License
144 stars 26 forks source link

error in import dcor #19

Closed sanghoonkim0918 closed 4 years ago

sanghoonkim0918 commented 4 years ago

Hello,

I installed the Python dcor package, and I got the following error whenever I tried to import dcor.

Traceback (most recent call last): File "", line 1, in File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/dcor/init.py", line 14, in from . import independence # noqa File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/dcor/independence.py", line 13, in from ._dcor import u_distance_correlation_sqr File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/dcor/_dcor.py", line 27, in from ._fast_dcov_avl import _distance_covariance_sqr_avl_generic File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/dcor/_fast_dcov_avl.py", line 89, in _generate_partial_sum_2d(compiled=True)) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/decorators.py", line 200, in wrapper disp.compile(sig) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/compiler_lock.py", line 32, in _acquire_compile_lock return func(*args, *kwargs) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/dispatcher.py", line 768, in compile cres = self._compiler.compile(args, return_type) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/dispatcher.py", line 81, in compile raise retval File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/dispatcher.py", line 91, in _compile_cached retval = self._compile_core(args, return_type) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/dispatcher.py", line 109, in _compile_core pipeline_class=self.pipeline_class) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/compiler.py", line 551, in compile_extra return pipeline.compile_extra(func) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/compiler.py", line 331, in compile_extra return self._compile_bytecode() File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/compiler.py", line 393, in _compile_bytecode return self._compile_core() File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/compiler.py", line 373, in _compile_core raise e File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/compiler.py", line 364, in _compile_core pm.run(self.state) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/compiler_machinery.py", line 347, in run raise patched_exception File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/compiler_machinery.py", line 338, in run self._runPass(idx, pass_inst, state) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/compiler_lock.py", line 32, in _acquire_compile_lock return func(args, **kwargs) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/compiler_machinery.py", line 302, in _runPass mutated |= check(pss.run_pass, internal_state) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/compiler_machinery.py", line 275, in check mangled = func(compiler_state) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/typed_passes.py", line 95, in run_pass raise_errors=self._raise_errors) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/typed_passes.py", line 66, in type_inference_stage infer.build_constraint() File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/typeinfer.py", line 938, in build_constraint self.constrain_statement(inst) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/typeinfer.py", line 1274, in constrain_statement self.typeof_assign(inst) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/typeinfer.py", line 1345, in typeof_assign self.typeof_global(inst, inst.target, value) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/typeinfer.py", line 1444, in typeof_global typ = self.resolve_value_type(inst, gvar.value) File "/Users/sanghoonkim/anaconda3/lib/python3.7/site-packages/numba/typeinfer.py", line 1366, in resolve_value_type raise TypingError(msg, loc=inst.loc) numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend) Untyped global name '_dyad_update': cannot determine Numba type of <class 'function'>

File "anaconda3/lib/python3.7/site-packages/dcor/_fast_dcov_avl.py", line 70: def _partial_sum_2d(x, y, c, ix, iy, sx_c, sy_c, c_sum, l_max,

    dyad_update = _dyad_update_compiled if compiled else _dyad_update
    ^
vnmabus commented 4 years ago

Ok, this must be related with the changes in the most recent version of the package.

What version of Numba are you using?

sanghoonkim0918 commented 4 years ago

Thanks for a quick reply! I am currently using Numba 0.48.0.

vnmabus commented 4 years ago

Can you try using version 0.51? I have this version installed and it does not give me problems, so maybe something does not work in older versions.

vnmabus commented 4 years ago

Ok, this error seems to exist only in numba versions prior to 0.49. This is probably because in version 0.49 branch pruning was implemented (https://github.com/numba/numba/pull/4798), which removes the offending code in this case.

In order to also improve import times, and eliminate the warning of non cacheable closures, numba versions above 0.51 are required, as they implement https://github.com/numba/numba/pull/6097. Thus, I will bump the required numba version to 0.51.

Thank you for reporting this, and please confirm that upgrading the numba version fixed your issue!

sanghoonkim0918 commented 4 years ago

I am sorry for the late response. I checked both 0.49 and 0.50 don't work, so I upgraded numba to the 0.51 version. Now dcor works well without any problem. The dcor package is amazing by the way. Thanks so much for helping me fix the error and providing such a fantastic package!

vnmabus commented 4 years ago

This should be solved in recent versions.