[Numpy-discussion] a question about freeze on numpy 1.7.0

2013-02-24 Thread Gelin Yan
Hi All

 When I used numpy 1.7.0 with cx_freeze 4.3.1 on windows, I quickly
found out even a simple import numpy may lead to program failed with
following exception:

AttributeError: 'module' object has no attribute 'sys'

After a poking around some codes I noticed /numpy/core/__init__.py has a
line 'del sys' at the bottom. After I commented this line, and repacked the
whole program, It ran fine.
I also noticed this 'del sys' didn't exist on numpy 1.6.2

I am curious why this 'del sys' should be here and whether it is safe to
omit it. Thanks.

Regards

gelin yan
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Calling scipy blas from cython is extremely slow

2013-02-24 Thread Pauli Virtanen
23.02.2013 20:31, Sergio Callegari kirjoitti:
 Partially fixed.
 
 I was messing the row, column order.  For some reason this was working in some
 case. Now I've fixed it and it *always* works.
 
 However, it is still slower than the cblas
 
 cblas - 0.69 sec
 scipy blas - 0.74 sec

The possible explanations are that either the routine called is
different in the two cases, or, the benchmark if somehow faulty.

-- 
Pauli Virtanen

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] a question about freeze on numpy 1.7.0

2013-02-24 Thread Ondřej Čertík
Hi Gelin,

On Sun, Feb 24, 2013 at 12:08 AM, Gelin Yan dynami...@gmail.com wrote:
 Hi All

  When I used numpy 1.7.0 with cx_freeze 4.3.1 on windows, I quickly
 found out even a simple import numpy may lead to program failed with
 following exception:

 AttributeError: 'module' object has no attribute 'sys'

 After a poking around some codes I noticed /numpy/core/__init__.py has a
 line 'del sys' at the bottom. After I commented this line, and repacked the
 whole program, It ran fine.
 I also noticed this 'del sys' didn't exist on numpy 1.6.2

 I am curious why this 'del sys' should be here and whether it is safe to
 omit it. Thanks.

The del sys line was introduced in the commit:

https://github.com/numpy/numpy/commit/4c0576fe9947ef2af8351405e0990cebd83ccbb6

and it seems to me that it is needed so that the numpy.core namespace is not
cluttered by it.

Can you post the full stacktrace of your program (and preferably some
instructions
how to reproduce the problem)? It should become clear where the problem is.

Thanks,
Ondrej
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] a question about freeze on numpy 1.7.0

2013-02-24 Thread Benjamin Root
On Sun, Feb 24, 2013 at 8:16 PM, Ondřej Čertík ondrej.cer...@gmail.comwrote:

 Hi Gelin,

 On Sun, Feb 24, 2013 at 12:08 AM, Gelin Yan dynami...@gmail.com wrote:
  Hi All
 
   When I used numpy 1.7.0 with cx_freeze 4.3.1 on windows, I quickly
  found out even a simple import numpy may lead to program failed with
  following exception:
 
  AttributeError: 'module' object has no attribute 'sys'
 
  After a poking around some codes I noticed /numpy/core/__init__.py has a
  line 'del sys' at the bottom. After I commented this line, and repacked
 the
  whole program, It ran fine.
  I also noticed this 'del sys' didn't exist on numpy 1.6.2
 
  I am curious why this 'del sys' should be here and whether it is safe to
  omit it. Thanks.

 The del sys line was introduced in the commit:


 https://github.com/numpy/numpy/commit/4c0576fe9947ef2af8351405e0990cebd83ccbb6

 and it seems to me that it is needed so that the numpy.core namespace is
 not
 cluttered by it.

 Can you post the full stacktrace of your program (and preferably some
 instructions
 how to reproduce the problem)? It should become clear where the problem is.

 Thanks,
 Ondrej


I have run into issues with doing del sys before, but usually with
respect to my pythonrc file.  Because the import of sys has already
happened, python won't let you import the module again in the same
namespace (in my case, the runtime environment).  I don't know how the
frozen binaries work, but maybe something along those lines is happening?

Ben Root
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] [EXTERNAL] swig interface file (numpy.i) warning

2013-02-24 Thread Bill Spotz
I wanted to take a stab at updating numpy.i to not use deprecated NumPy C/API 
code.  Nothing in the git logs indicates this has already been done. I added

 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION

to numpy.i right before it includes numpy/arrayobject.h.  The built-in tests 
for numpy.i should be sufficient to ferret out all of the deprecated calls.  
When I try to make the tests, the compiler tells me that it has included

 npy_deprecated_api.h

and I get a compiler error when it includes old_defines.h, telling me that it 
is deprecated.  Shouldn't my #define prevent this from happening?  I'm 
confused.  Any guidance would be appreciated.

Thanks,
Bill

On Oct 9, 2012, at 9:18 PM, Tom Krauss wrote:

 This code reproduces the error - I think it is small enough for email.  
 (large) numpy.i not included, let me know if you want that too.  Makefile 
 will need to be tailored to your environment.  
 If it's more convenient, or you have trouble reproducing, I can create a 
 branch on github - let me know. 
 
 On Tue, Oct 9, 2012 at 1:47 PM, Tom Krauss thomas.p.kra...@gmail.com wrote:
 I can't attach the exact code but would be happy to provide something simple 
 that has the same issue.  I'll post something here when I can get to it.
 - Tom
 
 
 On Tue, Oct 9, 2012 at 10:52 AM, Bill Spotz wfsp...@sandia.gov wrote:
 Tom, Charles,
 
 If you discuss this further, be sure to CC me.
 
 -Bill Spotz
 
 On Oct 9, 2012, at 8:50 AM, Charles R Harris wrote:
 
 Hi Tom,
 
 On Tue, Oct 9, 2012 at 8:30 AM, Tom Krauss thomas.p.kra...@gmail.com wrote:
 Hi,
 
 I've been happy to use numpy.i for generating SWIG interfaces to C++.
 
 For a while, I've noticed this warning while compiling:
 /Users/tkrauss/projects/dev_env/lib/python2.7/site-packages/numpy-1.8.0.dev_f2f0ac0_20120725-py2.7-macosx-10.8-x86_64.egg/numpy/core/include/numpy/npy_deprecated_api.h:11:2:
  warning: #warning Using deprecated NumPy API, disable it by #defining 
 NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
 
 and today tried to get rid of the warning.
 
 So, in numpy.i, I followed the warning's advice.  I added the # def here:
 
 %{
 #ifndef SWIG_FILE_WITH_INIT
 #  define NO_IMPORT_ARRAY
 #endif
 #include stdio.h
 #define NPY_NO_DEPRECATED_API  NPY_1_7_API_VERSION
 #include numpy/arrayobject.h
 %}
 
 SWIG was happy, but when compiling the C++ wrapper, there were many warnings 
 followed by many errors.  The warnings were for redefinition of NPY_MIN_BYTE 
 and similar.  The errors were for all kinds of stuff, excerpt here:
 native_wrap.cpp:3632: error: ‘PyArray_NOTYPE’ was not declared in this scope
 native_wrap.cpp:3633: error: cannot convert ‘PyObject*’ to ‘const 
 PyArrayObject*’ for argument ‘1’ to ‘int PyArray_TYPE(const PyArrayObject*)’
 native_wrap.cpp: At global scope:
 native_wrap.cpp:3877: error: ‘intp’ has not been declared
 native_wrap.cpp: In function ‘int require_fortran(PyArrayObject*)’:
 native_wrap.cpp:3929: error: ‘struct tagPyArrayObject’ has no member named 
 ‘nd’
 native_wrap.cpp:3933: error: ‘struct tagPyArrayObject’ has no member named 
 ‘flags’
 native_wrap.cpp:3933: error: ‘FARRAY’ was not declared in this scope
 native_wrap.cpp:20411: error: ‘struct tagPyArrayObject’ has no member named 
 ‘data’
 
 It looks like there is a new C API for numpy, and the version of numpy.i 
 that I have doesn't use it.
 
 Is there a new version of numpy.i available (or in development) that works 
 with the new API?  Short term it will just get rid of a warning but I am 
 interested in a good long term solution in case I need to upgrade numpy.
 
 
 In the long term we would like to hide the ndarray internals, essentially 
 making them private. There are still some incomplete areas, f2py and, 
 apparently, numpy.i. Your feedback here is quite helpful and if you have 
 some time we can try to get this straightened out. Could you attach the code 
 you are trying to interface? If you have a github account you could also set 
 up a branch where we could work on this.
 
 Chuck
 ___
 NumPy-Discussion mailing list
 NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion
 
 ** Bill Spotz  **
 ** Sandia National Laboratories  Voice: (505)845-0170  **
 ** P.O. Box 5800 Fax:   (505)284-0154  **
 ** Albuquerque, NM 87185-0370Email: wfsp...@sandia.gov **
 
 
 ___
 NumPy-Discussion mailing list
 NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion
 
 
 example.tar.gz___
 NumPy-Discussion mailing list
 NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion

** Bill Spotz  **
** Sandia National Laboratories  Voice: (505)845-0170  **
** P.O. Box 5800 Fax:   (505)284-0154  **
** Albuquerque, NM 87185-0370

Re: [Numpy-discussion] a question about freeze on numpy 1.7.0

2013-02-24 Thread Gelin Yan
On Mon, Feb 25, 2013 at 9:16 AM, Ondřej Čertík ondrej.cer...@gmail.comwrote:

 Hi Gelin,

 On Sun, Feb 24, 2013 at 12:08 AM, Gelin Yan dynami...@gmail.com wrote:
  Hi All
 
   When I used numpy 1.7.0 with cx_freeze 4.3.1 on windows, I quickly
  found out even a simple import numpy may lead to program failed with
  following exception:
 
  AttributeError: 'module' object has no attribute 'sys'
 
  After a poking around some codes I noticed /numpy/core/__init__.py has a
  line 'del sys' at the bottom. After I commented this line, and repacked
 the
  whole program, It ran fine.
  I also noticed this 'del sys' didn't exist on numpy 1.6.2
 
  I am curious why this 'del sys' should be here and whether it is safe to
  omit it. Thanks.

 The del sys line was introduced in the commit:


 https://github.com/numpy/numpy/commit/4c0576fe9947ef2af8351405e0990cebd83ccbb6

 and it seems to me that it is needed so that the numpy.core namespace is
 not
 cluttered by it.

 Can you post the full stacktrace of your program (and preferably some
 instructions
 how to reproduce the problem)? It should become clear where the problem is.

 Thanks,
 Ondrej
 ___
 NumPy-Discussion mailing list
 NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion


Hi Ondrej

I attached two files here for demonstration. you need cx_freeze to
build a standalone executable file. simply running python setup.py build
and try to run the executable file you may see this exception. This example
works with numpy 1.6.2. Thanks.

Regards

gelin yan


numpytest.py
Description: Binary data


setup.py
Description: Binary data
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] a question about freeze on numpy 1.7.0

2013-02-24 Thread Bradley M. Froehle
I can reproduce with NumPy 1.7.0, but I'm not convinced the bug lies within
NumPy.

The exception is not being raised on the `del sys` line.  Rather it is
being raised in numpy.__init__:

  File
/home/bfroehle/.local/lib/python2.7/site-packages/cx_Freeze/initscripts/Console.py,
line 27, in module
exec code in m.__dict__
  File numpytest.py, line 1, in module
import numpy
  File
/home/bfroehle/.local/lib/python2.7/site-packages/numpy/__init__.py, line
147, in module
from core import *
AttributeError: 'module' object has no attribute 'sys'

This is because, somehow, `'sys' in numpy.core.__all__` returns True in the
cx_Freeze context but False in the regular Python context.

-Brad


On Sun, Feb 24, 2013 at 10:49 PM, Gelin Yan dynami...@gmail.com wrote:



 On Mon, Feb 25, 2013 at 9:16 AM, Ondřej Čertík ondrej.cer...@gmail.comwrote:

 Hi Gelin,

 On Sun, Feb 24, 2013 at 12:08 AM, Gelin Yan dynami...@gmail.com wrote:
  Hi All
 
   When I used numpy 1.7.0 with cx_freeze 4.3.1 on windows, I quickly
  found out even a simple import numpy may lead to program failed with
  following exception:
 
  AttributeError: 'module' object has no attribute 'sys'
 
  After a poking around some codes I noticed /numpy/core/__init__.py has a
  line 'del sys' at the bottom. After I commented this line, and repacked
 the
  whole program, It ran fine.
  I also noticed this 'del sys' didn't exist on numpy 1.6.2
 
  I am curious why this 'del sys' should be here and whether it is safe to
  omit it. Thanks.

 The del sys line was introduced in the commit:


 https://github.com/numpy/numpy/commit/4c0576fe9947ef2af8351405e0990cebd83ccbb6

 and it seems to me that it is needed so that the numpy.core namespace is
 not
 cluttered by it.

 Can you post the full stacktrace of your program (and preferably some
 instructions
 how to reproduce the problem)? It should become clear where the problem
 is.

 Thanks,
 Ondrej
 ___
 NumPy-Discussion mailing list
 NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion


 Hi Ondrej

 I attached two files here for demonstration. you need cx_freeze to
 build a standalone executable file. simply running python setup.py build
 and try to run the executable file you may see this exception. This
 example works with numpy 1.6.2. Thanks.

 Regards

 gelin yan


 ___
 NumPy-Discussion mailing list
 NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion


___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion