Closed moorepants closed 6 years ago
Heads up, my main focus right now is the release, so I may be slow in fixing the things for my notebooks.
is the llvm printer available to show?
The LLVM printer is a bit weird. It doesn't actually create a string. Rather, it creates an LLVM jit callable directly from llvmlite
objects. The theanocode printer is similar actually.
it is unfortunate we don't really have a python printer
Agree. It wouldn't be hard to start doing a cleanup of lambdify moving the translations into the printers. Worth doing for the release?
a simple exercise would be to list a bunch of mathematical expressions in the mardown cell and ask them to try printing them with different languages
Good idea.
there are other interesting things to show here to like piecewise printing, indexed types that will print to loops, printing matrices, assignment, and different printer options
I'll add those. Also Piecewise is a good thing to show in the intro notebook.
custom functions
What do you mean here?
labmdify needs some explanation on the first use. the name is confusing and i don't think anyone will know what it is doing. it would be worth spend some time explaining what lambdify does with simple examples here, then you can let them try to use lambdify to convert the ODE rhs to a numerical function as an exercise. explain why it is called lambdify and show a simple lambda function.
Yes, I was just thinking this. It isn't even clear that lambdify is code generation. Honestly, I think it's worth explaining exactly how lambdify works. The better you understand exactly what it does, the better you can utilize it.
what about a vectorized operation for the example cython intro code. this would essentially show them what ufuncify does behind the scenes. this would be a function more like:
ufuncify is a bit more complicated than this (it specifically fits the ufunc API, which lets it get broadcasting).
i suggest we leave these out or have them as special extra topics, as they are outside the original scope of the proposal
100% agree on symengine, which is still early work anyway. But for numba, I think we should show that you can wrap lambdify
in numba.jit
to make it faster. It's literally just two extra cells, and it could just be a section at the bottom of an existing notebook. There's no need to have a whole separate notebook for it.
codegen and autowrap don't work with array inputs, would be nice if they did
Let's not use autowrap for anything ever. As far as I'm concerned, autowrap
should be deprecated in favor of ufuncify
. The only reason you might ever want to use it is if you know you never care about vectorization, you only care about Python's float
(no numpy data types), and want to get rid of a little bit of Python overhead. Neither of those conditions are really worth it in my view, and they definitely don't make it worth showing in the tutorial.
general
Intro to sympy
init_printing
does? My students have been confused about why things display in the notebook in different ways. Maybe show the string, pretty, and latex printing based on a single input?Code printers
25 chemical kinetics intro
32 chemical kinetics
# %load ../scipy2017codegen/symbolic_constr.py
should be hidden, not sure there is any reason for students to read this code, or is this an exercise? if so, see the previous pointnumba/symengine
the harder way
the easy hard way
or have this as an exercise, i.e. have them create their own vectorized function
~/miniconda3/envs/codegen17/lib/python3.6/site-packages/scipy2017codegen/chem.py in load_large_ode() 32 file_path = os.path.join(os.path.dirname(file), 'data', 33 'radiolysis_300_Gy_s.json') ---> 34 with open(file_path) as f: 35 ode_def_dict = json.load(f) 36 eqs, states = mk_exprs_symbs(ode_def_dict['reactions'],
FileNotFoundError: [Errno 2] No such file or directory: '/home/moorepants/miniconda3/envs/codegen17/lib/python3.6/site-packages/scipy2017codegen/data/radiolysis_300_Gy_s.json'