git_revision issues with scipy/numpy/matplotlib

2012-07-06 Thread Stephen Webb
I installed py27-numpy / scipy / matplotlib using macports, and it ran without 
failing.

When I run Python I get the following error:

$>> which python

/Library/Frameworks/Python.framework/Versions/2.7/bin/python

$>> python

Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/__init__.py",
 line 128, in 
from version import git_revision as __git_revision__
ImportError: cannot import name git_revision

I get the same error for all three packages. Is this a MacPorts issue or a 
different issue?

I am running OS X 10.6 with the Intel Core i5 architecture. At one point I 
thought this was a 64-bit versus 32-bit issue, viz.:

>>> import platform
>>> platform.architecture()
('64bit', '')

but I would have thought the MacPorts install would have resolved that.

Any help would be appreciated.

Thanks!

-s
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: git_revision issues with scipy/numpy/matplotlib

2012-07-07 Thread Stephen Webb
I think the easiest thing to do would be to remove the python.org Python 
entirely, kill it from the path (which I've already done), and install directly 
a MacPorts version of Python.

Any caveats or warnings about getting rid of the /Library/Frameworks/Python 
directory?

On Jul 7, 2012, at Jul 7 8:40 AM, Hans Mulder wrote:

> On 7/07/12 14:09:56, Ousmane Wilane wrote:
>>> "H" == Hans Mulder  writes:
>> 
>>H> Or you can explicitly type the full path of the python you want.
>> 
>>H> Or you can define aliases, for example:
>> 
>>H> alias apple_python=/usr/bin/python alias
>>H> macport_python=/opt/local/bin/python
>> 
>>H> lfpv=/Library/Frameworks/Python.framework/Versions alias
>>H> python_org_python=$lfpv/2.7/bin/python
>> 
>> 
>> Or alternatively use `port select --set' to make one of the MacPort version 
>> the
>> default:
>> 
>> imac:~ wilane$ port select --list python
>> Available versions for python:
>>  none
>>  python25-apple
>>  python26
>>  python26-apple
>>  python27 (active)
>>  python27-apple
>>  python32
> 
> That would work if the OP had /opt/local/bin early in his searcht path.
> However, the OP has installed Python27 from python.org, and that has
> prepended /Library/Frameworks/Python.framework/Versions/2.7/bin to
> his PATH, overriding anything he does with "port select".
> 
> He could, of course, change his PATH and move /opt/local/bin to the
> front and then use "port select".
> 
> -- HansM
> -- 
> http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Strange set of errors

2007-08-03 Thread Stephen Webb
Greetings all,

I've recently begun using Python to do scientific computation, and I wrote
the following script to find approximate eigenvalues for a semi-infinite
matrix:


from pylab import *
from numpy import *
from scipy import *

def bandstructure(N,s):

b = s/4.0

jmax = 10 + N**2

spectrum1 = [0]*2*N
spectrum2 = [0]*2*N
spectrum3 = [0]*2*N


for k in arange(1, 2*N+1, 1):

A = zeros( (jmax,jmax) )

i = 0
while i <= jmax-1:
if i <= jmax-2:
A[i,i+1] = b
A[i+1,i] = b
A[i,i] = ((k + 2.0*i*N)/N)**2
i = i+1
else:
A[i,i] = ((k + 2.0*i*N)/N)**2
i = i+1

#This portion of the code builds a matrix twice as large to check
against

B = zeros( (2*jmax,2*jmax) )

i = 0
while i <= 2*jmax-1:
if i <= 2*jmax-2:
B[i,i+1] = b
B[i+1,i] = b
B[i,i] = ((k + 2.0*i*N)/N)**2
i = i+1
else:
B[i,i] = ((k + 2.0*i*N)/N)**2
i = i+1

x = linalg.eigvals(A)
y = linalg.eigvals(B)

j = 1
while j<=3:
if abs(y[j]-x[j]) <= 10.0**(-5):
j = j + 1
else:
print 'jmax not large enough to obtain accurate results'

spectrum1[k-1] = x[0] + 0.5*s
spectrum2[k-1] = x[1] + 0.5*s
spectrum3[k-1] = x[2] + 0.5*s

plot (k, spectrum1, k, spectrum2, k, spectrum3)

xlabel('k (energy level)')
ylabel('E/E_r')
title('Finite Size Band Structure, N = %d, s = %f' % (N, s))
grid(true)


When I run this script, I get the following message, which I can't figure
out:

Traceback (most recent call last):
  File "", line 1, in 
  File "bandstruc.py", line 61, in bandstructure
plot (k, spectrum1, k, spectrum2, k, spectrum3)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/pylab.py",
line 2028, in plot
ret =  gca().plot(*args, **kwargs)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.py",
line 2535, in plot
for line in self._get_lines(*args, **kwargs):
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.py",
line 437, in _grab_next_args
for seg in self._plot_2_args(remaining[:2], **kwargs):
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.py",
line 337, in _plot_2_args
x, y, multicol = self._xy_from_xy(x, y)
  File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/axes.py",
line 266, in _xy_from_xy
nrx, ncx = x.shape
ValueError: need more than 0 values to unpack

Also, I've been having trouble with the plot function in matplotlib. For
example, I enter the following in the terminal:

>>> from pylab import *
>>> plot([1,2,3])
[]

I'm reasonably sure that the issue in the first big error message is just an
indexing error on my part, but I have no idea what the second thing means.
Every time I run the plot([1,2,3]) I get a different ending number that
seems to vary randomly.

Could anybody please help me out with these problems?

Thanks,

Stephen
-- 
http://mail.python.org/mailman/listinfo/python-list