Re: [sage-support] Numpy Troubles

2011-02-14 Thread D. S. McNeil
I think it's neither Sage nor numpy that's at fault, it's a weird
interaction (Sage 4.6.1):

sage: import numpy
sage: numpy.binary_repr(17)
''
sage: numpy.binary_repr(int(17))
'10001'

and I think it's rooted in this fact:

sage: hex(17)
'11'
sage: hex(int(17))
'0x11'

That is, Sage capital-I Integers deliberately don't have the '0x'
prepended, and the numpy.binary_repr routine has lines

ostr = hex(num)
[..]
bin = ''.join([_lkup[ch] for ch in ostr[2:]])

which fail if the prefix isn't there.


Doug

-- 
Department of Earth Sciences
University of Hong Kong

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Numpy Troubles

2011-02-14 Thread Graham Enos
Hi everyone,

I've run into some unexpected behavior with Numpy on Sage 4.6 (running
on Mac OS X 10.6.6). Specifically in the binary_repr function, I get
empty strings. For instance:

$ sage
--
| Sage Version 4.6, Release Date: 2010-10-30 |
| Type notebook() for the GUI, and license() for information.|
--
sage [1]: import numpy as np
sage [2]: np.version.version
'1.3.0'
sage [3]: np.binary_repr(17)
''
sage [4]: np.binary_repr(42)
''
sage [5]: np.binary_repr(3)
''

Whereas in my other Python installation (EPD), things work fine:

$ python
Enthought Python Distribution -- www.enthought.com
Version: 7.0-1 (32-bit)

Python 2.7.1 |EPD 7.0-1 (32-bit)| (r271:86832, Dec  3 2010, 15:41:32)
[GCC 4.0.1 (Apple Inc. build 5488)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.version.version
'1.5.1'
>>> np.binary_repr(17)
'10001'
>>> np.binary_repr(42)
'101010'
>>> np.binary_repr(3)
'11'

Is this an issue with the version of NumPy installed in Sage?

Best,
Graham

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org