« first day (1985 days earlier)      last day (2963 days later) » 

11:31 PM
yup.
And bafflingly so, the answer got another upvote.
 
Hey guys
I have a question for experts in python with cython and sympy if you don't mind
I wish someone would have a few minutes to help
 
@MartijnPieters this misguided accepted answer goes clearly against my hypothesis that rep is self-generating after a while;)
now it has 2 upvotes, just like your unaccepted answer
 
So my question is: Is it possible to use lambdify() with cython?
 
Hi!
 
I have a code that works perfectly, but when I compile it with cython it doesn't work anymore
 
11:35 PM
can you specify "doesn't work anymore"?
 
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/sympy/core/cache.py", line 93, in wrapper
    retval = cfunc(*args, **kwargs)
  File "/usr/lib/python3.4/functools.py", line 444, in wrapper
    key = make_key(args, kwds, typed)
  File "/usr/lib/python3.4/functools.py", line 368, in _make_key
    return _HashedSeq(key)
  File "/usr/lib/python3.4/functools.py", line 337, in __init__
    self.hashvalue = hash(tup)
TypeError: unhashable type: 'list'

During handling of the above exception, another exception occurred:
 
I know sympy, but I've never seen cython
 
Are you familiar with lambdify?
 
yup
 
I have a code that uses it. Cython is supposed to create c-code that to compile stuff and make them fast
 
11:36 PM
yeah, that's roughly all I know about cython:)
 
@TheQuantumPhysicist: so where did the list value come from?
 
but you'll need more than that for this, I'm afraid
 
but then when I run the compiled program, it complains that the variable is not there
@MartijnPieters I'm sorry, what list?
 
> TypeError: unhashable type: 'list'
probably this one ^
 
The exception is a little longer.
The CodeGenArgumentListError exception is perhaps a result of the first? Not sure.
 
11:38 PM
Is it OK if I paste the function that does the job? This will make the discussion much easier
 
Use a pastebin, and post the link here.
 
so what's in
> File "PlotScript.py", line 505, in PlotScript.CreateMagneticFieldsList
 
It's not that long
it's like 20 lines
 
Still, it'll be more readable. gist.github.com or dpaste.de
 
So the reason I'm lambdifying this is that I want to evaluate this function for a list
 
11:39 PM
which line corresponds to line 505 in your original?
 
lam_f = ufuncify(DSList,expression)
 
@TheQuantumPhysicist the lambdified version should also be faster then evaling, at least from what I usually see in matlab (not a very strong argument, I know)
 
Of course! it's way faster!
 
and why is it ufuncify?
 
But it doesn't work with Cython
I was playing around
 
11:40 PM
due to cython?
 
but the original was lambdify, it's commented
 
and did it throw the same error?
 
I'll check now again to make sure
Because it was handled with an exception
1 sec please
 
sure
 
This is the new error:
Traceback (most recent call last):
  File "PlotScript.py", line 1076, in init PlotScript (PlotScript.c:29372)
    plotData(args.datadir,lastTimeAvailable,args.length,args.outdir,args.tmpfolder,datasetsToPlotString)
  File "PlotScript.py", line 718, in PlotScript.plotData (PlotScript.c:18011)
    fdata = CreateMagneticFieldsList(all_data,feqStr,all_symbols)
  File "PlotScript.py", line 503, in PlotScript.CreateMagneticFieldsList (PlotScript.c:13648)
    lam_f = lambdify(tuple(DSList),expression,modules='numpy')
So this is for lambdify
 
11:43 PM
so, is that "modules='numpy'" but not odd?
nevermind
I got confused with the doc
 
Well, this is supposed to be even faster according to the manual:
http://docs.sympy.org/dev/modules/numeric-computation.html
 
I couldn't find the keyword name
and I thought that it was weird
whereas only I was being weird:)
 
so I presume DSList is indeed an iterable of Symbols?
 
Yes
Which is at that point only 1 parameter, MagneticFields
"MagneticFields"
 
11:46 PM
is equationStringWithoutUnits what you think it is?
it's not empty or anything, right?
 
Yes, I can see it
"MagneticFields*2857"
 
yeah that doesn't seem problematic
so does it even work with python, and breaks with cython?
 
Yep!
I use it on my website with Python
This website uses this script, now it's very slow because I'm not using cython anymore
 
is your cython up-to-date? I've found some similar issues on github, solved in Aug 2014
I mean this one
 
Yep! I just upgraded it with pip yesterday
 
11:50 PM
 
Well I have Debian Jessie
I'm sorry, forgive my ignorance
how can I know the required cython version?
 
I'm trying to figure it out:D
 
:)
sudo pip3 install cython --upgrade
Requirement already up-to-date: cython in /usr/local/lib/python3.4/dist-packages
Cleaning up...
This is what pip says
 
but pip should be fairly up-to-date, right?
 
I guess so!
 
11:54 PM
it's odd that I can't seem to find directly related issues
 
Yep
That's why I'm asking here
 
still it's odd that it seems to work without cython
you're out of luck by the way, since I'm quite noobish in python
the gurus are all asleep
you'd make more use of me with the quantum part;)
 
:-(
hehe ^_^
You're a physicist?
 
have you considered asking a question about this on SO?
@TheQuantumPhysicist yup
 
I don't know what to ask on SO!
It's quite a weird situation
 
11:55 PM
well, you should strip down your problem
 
and see you guys asked me many things because it's kind of an unbelievable problem
Yep, that's the ugly part!
 
create a simple skeleton of your issue, your simple function and a call to lambdify
 
One of the reasons why I wasn't encouraged enough to ask on SO
 
you can already see if the issue persists -- if it doesn't, there's an actual bug somewhere
 
I'll do that!
Thanks for trying to help, though :)
 
11:56 PM
most debugging questions with proper MCVE's should be solved before asking
no prob:)
if you have an MCVE, you could still try asking here first
 
it's easier to debug if the fluff is gone away
Minimal Complete Verifiable Example
 
the complete but bare minimum needed to reproduce a problem
 
Sure! I'll create that now
 
11:57 PM
good luck:)
 
I'll be around for a while, so keep me updated
 
I'll paste the link here ;)
 
thanks
 

« first day (1985 days earlier)      last day (2963 days later) »