Re: run code error with numpy and scipy

2016-06-10 Thread meInvent bbird
On Thursday, June 9, 2016 at 9:52:43 PM UTC+8, MRAB wrote:
> On 2016-06-09 07:02, meInvent bbird wrote:
> > when i run code in window has an error not a valid win32 dll
> >
> > then i install scipy first in this site, then install numpy-mkl
> > all python 2.7 and win32
> >
> > http://www.lfd.uci.edu/~gohlke/pythonlibs/
> >
> > then i run code below, got error , and captured screen in this link
> >
> > https://drive.google.com/file/d/0Bxs_ao6uuBDUQXROd2VqSURGa00/view?usp=sharing
> >
> [snip]
> You're entering it at the interactive Python prompt.
> 
> When it sees the blank line, it thinks you've finished entering the 
> function, so it complains when the next line is indented. (Things are 
> slightly different when working interactively than when running from a 
> file.)
> 
> You should put the code into a file and then run that.

thank you i will try it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: run code error with numpy and scipy

2016-06-09 Thread MRAB

On 2016-06-09 07:02, meInvent bbird wrote:

when i run code in window has an error not a valid win32 dll

then i install scipy first in this site, then install numpy-mkl
all python 2.7 and win32

http://www.lfd.uci.edu/~gohlke/pythonlibs/

then i run code below, got error , and captured screen in this link

https://drive.google.com/file/d/0Bxs_ao6uuBDUQXROd2VqSURGa00/view?usp=sharing


[snip]
You're entering it at the interactive Python prompt.

When it sees the blank line, it thinks you've finished entering the 
function, so it complains when the next line is indented. (Things are 
slightly different when working interactively than when running from a 
file.)


You should put the code into a file and then run that.

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


Re: run code error with numpy and scipy

2016-06-09 Thread Ben Finney
meInvent bbird  writes:

> when i run code in window has an error not a valid win32 dll

Simplify the example, to diagnose it. What is the *simplest* example
code that shows the problem?

In other words, remove statements from the example until the problem no
longer happens. Then add back *one* statement to make it happen, and
present that example.

-- 
 \ “I have had a perfectly wonderful evening, but this wasn't it.” |
  `\ —Groucho Marx |
_o__)  |
Ben Finney

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


run code error with numpy and scipy

2016-06-09 Thread meInvent bbird
when i run code in window has an error not a valid win32 dll

then i install scipy first in this site, then install numpy-mkl
all python 2.7 and win32

http://www.lfd.uci.edu/~gohlke/pythonlibs/

then i run code below, got error , and captured screen in this link

https://drive.google.com/file/d/0Bxs_ao6uuBDUQXROd2VqSURGa00/view?usp=sharing

import numpy as np
from scipy.sparse.linalg import svds
from functools import partial
from scipy.sparse import csr_matrix

def emsvd(Y, k=None, tol=1E-3, maxiter=None):
 if k is None:
  svdmethod = partial(np.linalg.svd, full_matrices=False)
 else:
  svdmethod = partial(svds, k=k)
 if maxiter is None:
  maxiter = np.inf

 muhat = np.nanmean(Y, axis=0, keepdims=1)
 valid = np.isfinite(Y)
 Y_hat = np.where(valid, Y, muhat)

 halt = False
 ii = 1
 v_prev = 0

 while not halt:
  U, s, Vt = svdmethod(Y_hat - muhat)
  Y_hat[~valid] = (U.dot(np.diag(s)).dot(Vt) + muhat)[~valid]
  muhat = Y_hat.mean(axis=0, keepdims=1)
  v = s.sum()
  if ii >= maxiter or ((v - v_prev) / v_prev) < tol:
   halt = True
   ii += 1
   v_prev = v
 return Y_hat, muhat, U, s, Vt


A = csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]])
emsvd(A)

np.nanmean(A, axis=0, keepdims=1)
-- 
https://mail.python.org/mailman/listinfo/python-list