Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: numpy support? #3

Closed
jankoslavic opened this issue Aug 20, 2017 · 2 comments
Closed

ENH: numpy support? #3

jankoslavic opened this issue Aug 20, 2017 · 2 comments

Comments

@jankoslavic
Copy link

jankoslavic commented Aug 20, 2017

This is a great magic!!

I wonder why this code is not working:

   %%heat 
   def gauss(A, b):
       Ab = np.column_stack((A, b))
       for p, pivot_vrsta in enumerate(Ab[:-1]):
       for vrsta in Ab[p + 1:]:
            if pivot_vrsta[p]:
                vrsta[p:] = vrsta[p:] - pivot_vrsta[p:] * vrsta[p] / pivot_vrsta[p]
            else:
                raise Exception('Division with 0.')
        return Ab

   import numpy as np
   n = 40
   gauss(np.random.random((n, n)),np.random.random(n))
@csurfer
Copy link
Owner

csurfer commented Aug 22, 2017

@jankoslavic: I ran the same code with probably some indentation fixes and it ran without a glitch for me. The code I ran was:

%%heat
def gauss(A, b):
    Ab = np.column_stack((A, b))
    for p, pivot_vrsta in enumerate(Ab[:-1]):
        for vrsta in Ab[p + 1:]:
            if pivot_vrsta[p]:
                vrsta[p:] = vrsta[p:] - pivot_vrsta[p:] * vrsta[p] / pivot_vrsta[p]
            else:
                raise Exception('Division with 0.')
            return Ab

    import numpy as np
    n = 40
    gauss(np.random.random((n, n)),np.random.random(n))

I suspect something wrong with your setup. One easy way to verify is to create a virtualenv and install py-heat-magic within it. Then run the above. As the magic internally installs all the dependency needed for the above code, it will run and you might get a better idea as to what might be going wrong otherwise.

@jankoslavic
Copy link
Author

jankoslavic commented Aug 22, 2017

@csurfer I have updated conda update conda and then conda update --all and now everything works as it should. Thank you for your effort. Great package!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants