Re: [Numpy-discussion] python 2.4 incompatibility in numpy.lookfor in numpy 1.2.0rc2

2008-09-24 Thread Pauli Virtanen
Hi,

Tue, 23 Sep 2008 15:48:22 -0700, joep wrote:
 A possible solution would be in
 
 http://bazaar.launchpad.net/~pauli-virtanen/scipy/pydocweb/revision/386
 
 It seems to be possible to be used in the same way when  iter_modules is
 not available.
 The usage in ``_lookfor_generate_cache`` in lib/utils.py looks almost
 exactly the same
 as in the above revision

Yes, sorry about this; obviously lookfor wasn't tested with Python2.4. 
I'll commit and backport a fix for this today, if that's OK.

-- 
Pauli Virtanen

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] python 2.4 incompatibility in numpy.lookfor in numpy 1.2.0rc2

2008-09-24 Thread Pauli Virtanen
Wed, 24 Sep 2008 11:18:43 +, Pauli Virtanen wrote:
 Tue, 23 Sep 2008 15:48:22 -0700, joep wrote:
 A possible solution would be in
 
 http://bazaar.launchpad.net/~pauli-virtanen/scipy/pydocweb/revision/386
 
 It seems to be possible to be used in the same way when  iter_modules
 is not available.
 The usage in ``_lookfor_generate_cache`` in lib/utils.py looks almost
 exactly the same
 as in the above revision
 
 Yes, sorry about this; obviously lookfor wasn't tested with Python2.4.
 I'll commit and backport a fix for this today, if that's OK.

In trunk now, r5862.

-- 
Pauli Virtanen

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] python 2.4 incompatibility in numpy.lookfor in numpy 1.2.0rc2

2008-09-23 Thread joep
Hi,
I was trying to use lookfor on python 2.4 and got an exception with
np.lookfor because of a missing method in pkgutil that was added in
python 2.5.

see the following session

 np.lookfor('range')
Traceback (most recent call last):
  File pyshell#55, line 1, in ?
np.lookfor('range')
  File C:\Programs\Python24\Lib\site-packages\numpy\lib\utils.py,
line 556, in lookfor
cache = _lookfor_generate_cache(module, import_modules,
regenerate)
  File C:\Programs\Python24\Lib\site-packages\numpy\lib\utils.py,
line 687, in _lookfor_generate_cache
for m in pkgutil.iter_modules(item.__path__):
AttributeError: 'module' object has no attribute 'iter_modules'

 import pkgutil
 dir(pkgutil)
['__builtins__', '__doc__', '__file__', '__name__', 'extend_path',
'os', 'sys']
 pkgutil.__file__
'C:\\Programs\\Python24\\lib\\pkgutil.pyc'
 np.version.version
'1.2.0rc2'

Josef
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] python 2.4 incompatibility in numpy.lookfor in numpy 1.2.0rc2

2008-09-23 Thread Robert Kern
On Tue, Sep 23, 2008 at 15:18, joep [EMAIL PROTECTED] wrote:
 Hi,
 I was trying to use lookfor on python 2.4 and got an exception with
 np.lookfor because of a missing method in pkgutil that was added in
 python 2.5.

Hmmm. Unfortunately, that's an intrinsic part of the lookfor()
functionality. We could just bring in all of pkgutil.py. Or we remove
lookfor(). Or we document it as working with Python 2.5 only.

-- 
Robert Kern

I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth.
 -- Umberto Eco
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] python 2.4 incompatibility in numpy.lookfor in numpy 1.2.0rc2

2008-09-23 Thread Jarrod Millman
On Tue, Sep 23, 2008 at 1:35 PM, Robert Kern [EMAIL PROTECTED] wrote:
 On Tue, Sep 23, 2008 at 15:18, joep [EMAIL PROTECTED] wrote:
 Hi,
 I was trying to use lookfor on python 2.4 and got an exception with
 np.lookfor because of a missing method in pkgutil that was added in
 python 2.5.

 Hmmm. Unfortunately, that's an intrinsic part of the lookfor()
 functionality. We could just bring in all of pkgutil.py. Or we remove
 lookfor(). Or we document it as working with Python 2.5 only.

For 1.2.0, let's add a note to the docstring stating it currently
works for 2.5 and make it raise a more informative exception.

lookfor is in 1.1.x as well.

-- 
Jarrod Millman
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] python 2.4 incompatibility in numpy.lookfor in numpy 1.2.0rc2

2008-09-23 Thread joep
A possible solution would be in

http://bazaar.launchpad.net/~pauli-virtanen/scipy/pydocweb/revision/386

It seems to be possible to be used in the same way when  iter_modules
is not available.
The usage in ``_lookfor_generate_cache`` in lib/utils.py looks almost
exactly the same
as in the above revision

Josef

On Sep 23, 4:55 pm, Jarrod Millman [EMAIL PROTECTED] wrote:
 On Tue, Sep 23, 2008 at 1:35 PM, Robert Kern [EMAIL PROTECTED] wrote:
  On Tue, Sep 23, 2008 at 15:18, joep [EMAIL PROTECTED] wrote:
  Hi,
  I was trying to use lookfor on python 2.4 and got an exception with
  np.lookfor because of a missing method in pkgutil that was added in
  python 2.5.

  Hmmm. Unfortunately, that's an intrinsic part of the lookfor()
  functionality. We could just bring in all of pkgutil.py. Or we remove
  lookfor(). Or we document it as working with Python 2.5 only.

 For 1.2.0, let's add a note to the docstring stating it currently
 works for 2.5 and make it raise a more informative exception.

 lookfor is in 1.1.x as well.

 --
 Jarrod Millman
 Computational Infrastructure for Research Labs
 10 Giannini Hall, UC Berkeley
 phone: 510.643.4014http://cirl.berkeley.edu/
 ___
 Numpy-discussion mailing list
 [EMAIL PROTECTED]://projects.scipy.org/mailman/listinfo/numpy-discussion
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] python 2.4 incompatibility in numpy.lookfor in numpy 1.2.0rc2

2008-09-23 Thread joep
On Sep 23, 6:48 pm, joep [EMAIL PROTECTED] wrote:
 A possible solution would be in

 http://bazaar.launchpad.net/~pauli-virtanen/scipy/pydocweb/revision/386

 It seems to be possible to be used in the same way when  iter_modules
 is not available.
 The usage in ``_lookfor_generate_cache`` in lib/utils.py looks almost
 exactly the same
 as in the above revision

 Josef


this works for me and leaves the module unchanged if iter_modules is
available
python 2.4 compatible version is copied from
 http://bazaar.launchpad.net/~pauli-virtanen/scipy/pydocweb/revision/386
with adjustment for variable names, and it works under python 2.4
windowsXP

in Python24\Lib\site-packages\numpy\lib\utils.py
def _lookfor_generate_cache

starting at line 685
   # import sub-packages
   if import_modules and hasattr(item, '__path__'):
if hasattr(pkgutil,'iter_modules'):  #
line added
for m in pkgutil.iter_modules(item.__path__):
if _all is not None and m[1] not in _all:
continue
try:
__import__(%s.%s % (name, m[1]))
except ImportError:
continue
else:# else branch
added
for pth in item.__path__:
for mod_path in os.listdir(pth):
init_py = os.path.join(pth, mod_path,
'__init__.py')
if not os.path.isfile(init_py): continue
nm = %s.%s % (name, mod_path)
try:
__import__(nm)
except:
print  sys.stderr, Failed to import
module %s % nm
pass


example:
C:\Josef\easyeclipseworkspace\sandbox\playground\numpyscipy
\teststatsipython
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)]
Type copyright, credits or license for more information.

IPython 0.9.1 -- An enhanced Interactive Python.
? - Introduction and overview of IPython's features.
%quickref - Quick reference.
help  - Python's own help system.
object?   - Details about 'object'. ?object also works, ?? prints
more.

In [1]: import numpy as np

In [2]: np.lookfor('norm')
Search results for 'norm'
-
numpy.frexp
y1,y2 = frexp(x)
numpy.linalg.norm
Matrix or vector norm.
numpy.ma.cov
Estimates the covariance matrix.
numpy.random.normal
Draw random samples from a normal (Gaussian) distribution.
numpy.linalg.qr
Compute QR decomposition of a matrix.
...
In [14]: np.version.version
Out[14]: '1.2.0rc2'

also tested with IDLE
same result as with Python 2.5

Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on win32
Type copyright, credits or license() for more information.


Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface.  This connection is not visible on any external
interface and no data is sent to or received from the Internet.


IDLE 1.2.2   No Subprocess 

 import numpy as np
 np.version.version
'1.2.0rc2'
 np.lookfor('norm')
Search results for 'norm'
-
numpy.frexp
y1,y2 = frexp(x)
numpy.linalg.norm
Matrix or vector norm.
numpy.ma.cov
Estimates the covariance matrix.
numpy.random.normal
Draw random samples from a normal (Gaussian) distribution.
numpy.linalg.qr
Compute QR decomposition of a matrix.

are there any tests for lookfor?
Josef
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion