Closed radkoff closed 1 year ago
Hi, thanks for this project. I've ran into some strange compilation errors using a certain combination of numpy calls.
This input file:
import numpy as np def bar(): rand = np.random.random((10, 20)) return [1,2,3] #pythran export foo() def foo(): return np.median(bar())
Causes the following compilation errors (output is from using -v)
-v
/var/folders/l5/210k0yvw8xj04j001s6yhlr00000gq/T/tmpfp7w9ly4.cpp:42:24: error: no matching function for call to object of type '(anonymous namespace)::pythonic::numpy::functor::median' typedef decltype(std::declval<__type0>()(std::declval<__type2>())) __type3; ^~~~~~~~~~~~~~~~~~~~~~~ /Users/evan/miniforge3/envs/project/lib/python3.9/site-packages/pythran/pythonic/include/numpy/median.hpp:31:3: note: candidate template ignored: substitution failure [with Types = <(anonymous namespace)::pythonic::types::list<long>>]: no matching function for call to 'median' DEFINE_FUNCTOR(pythonic::numpy, median); ^ ~~~~~~~~ /Users/evan/miniforge3/envs/project/lib/python3.9/site-packages/pythran/pythonic/include/utils/functor.hpp:28:31: note: expanded from macro 'DEFINE_FUNCTOR' #define DEFINE_FUNCTOR(ns, f) DEFINE_FUNCTOR_2(f, ns::f) ^ ~~ /Users/evan/miniforge3/envs/project/lib/python3.9/site-packages/pythran/pythonic/include/utils/functor.hpp:14:12: note: expanded from macro 'DEFINE_FUNCTOR_2' auto operator()(Types && ... types) const \ ^ /var/folders/l5/210k0yvw8xj04j001s6yhlr00000gq/T/tmpfp7w9ly4.cpp:62:12: error: no matching function for call to object of type 'pythonic::numpy::functor::median' return pythonic::numpy::functor::median{}(bar()()); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/evan/miniforge3/envs/project/lib/python3.9/site-packages/pythran/pythonic/include/numpy/median.hpp:31:3: note: candidate template ignored: substitution failure [with Types = <(anonymous namespace)::pythonic::types::list<long>>]: no matching function for call to 'median' DEFINE_FUNCTOR(pythonic::numpy, median); ^ ~~~~~~~~ /Users/evan/miniforge3/envs/project/lib/python3.9/site-packages/pythran/pythonic/include/utils/functor.hpp:28:31: note: expanded from macro 'DEFINE_FUNCTOR' #define DEFINE_FUNCTOR(ns, f) DEFINE_FUNCTOR_2(f, ns::f) ^ ~~ /Users/evan/miniforge3/envs/project/lib/python3.9/site-packages/pythran/pythonic/include/utils/functor.hpp:14:12: note: expanded from macro 'DEFINE_FUNCTOR_2' auto operator()(Types && ... types) const \ ^ 1 warning and 2 errors generated. WARNING: Compilation error, trying hard to find its origin... WARNING: Nope, I'm going to flood you with C++ errors! CRITICAL: Cover me Jack. Jack? Jaaaaack!!!! E: error: Command "clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/evan/miniforge3/envs/project/include -arch arm64 -I/Users/evan/miniforge3/envs/project/include -fPIC -O2 -isystem /Users/evan/miniforge3/envs/project/include -arch arm64 -DENABLE_PYTHON_MODULE -D__PYTHRAN__=3 -DPYTHRAN_BLAS_OPENBLAS -I/usr/local/opt/openblas/include -I/Users/evan/miniforge3/envs/project/lib/python3.9/site-packages/pythran -I/Users/evan/miniforge3/envs/project/lib/python3.9/site-packages/numpy/core/include -I/Users/evan/miniforge3/envs/project/include/python3.9 -c /var/folders/l5/210k0yvw8xj04j001s6yhlr00000gq/T/tmpfp7w9ly4.cpp -o /var/folders/l5/210k0yvw8xj04j001s6yhlr00000gq/T/tmpgfjieuw6/var/folders/l5/210k0yvw8xj04j001s6yhlr00000gq/T/tmpfp7w9ly4.o -std=c++11 -fno-math-errno -Wno-unused-function" failed with exit status 1
Interestingly removing the np.random.random((10, 20)) makes the problem go away, and changing from np.median to np.mean also makes it work.
np.random.random((10, 20))
np.median
np.mean
I'm using pythran==0.12.1 with Python 3.9.13 on an M1 mac.
pythran==0.12.1
Python 3.9.13
Thanks for reporting! #2083 should do the trick.
Thanks for the quick fix, that worked!
Hi, thanks for this project. I've ran into some strange compilation errors using a certain combination of numpy calls.
This input file:
Causes the following compilation errors (output is from using
-v
)Interestingly removing the
np.random.random((10, 20))
makes the problem go away, and changing fromnp.median
tonp.mean
also makes it work.I'm using
pythran==0.12.1
withPython 3.9.13
on an M1 mac.