Re: [sympy] lambdify list of arguments converted silently, why not throw a warning?

2020-07-17 Thread roberto franceschini
FYI https://github.com/sympy/sympy/pull/19792 On Fri, Jul 17, 2020 at 3:27 PM roberto franceschini < franceschini.robe...@gmail.com> wrote: > Thanks, I think this is why lambdify should not accept anything that > hasn't a fixed ordering - this part of lambdify was coded too lighthearted > in my

Re: [sympy] lambdify list of arguments converted silently, why not throw a warning?

2020-07-17 Thread roberto franceschini
Thanks, I think this is why lambdify should not accept anything that hasn't a fixed ordering - this part of lambdify was coded too lighthearted in my opinion. So I am working on a pull request but I would like to have some discussion on what to do to make lambdify better in this sense. At this

Re: [sympy] lambdify list of arguments converted silently, why not throw a warning?

2020-07-17 Thread Jared Claypoole
Hi Roberto, It looks like you're expecting python sets to do something they're not intended to do. From the docs , "A set object is an unordered collection". Of course when you iterate over all the elements they have

Re: [sympy] lambdify list of arguments converted silently, why not throw a warning?

2020-07-16 Thread Roberto
I am starting to wonder why python is so loose on this. I say "python" because the issue appears for enumerate as well. How can I enumerate a set? Still I am allowed to enumerate a set without receiving any warning. Look at this for instance set(["a","b"])==set(["b","a"])

Re: [sympy] lambdify list of arguments converted silently, why not throw a warning?

2020-07-10 Thread roberto franceschini
Sure, the output of free_symbols can be easily massaged with sorted. This is how I am working now. However the issue remains that a set is silently converted into a list with no guarantee of preserving the order. Working on a pull request... On Fri, Jul 10, 2020, 20:49 Aaron Meurer wrote: > If

Re: [sympy] lambdify list of arguments converted silently, why not throw a warning?

2020-07-10 Thread roberto franceschini
Not sure at all why you say so. Adding extra output to the function is excess baggage in my opinion. Indeed free_symbols is a great idea from the sympy developers. I understand why technically one wants to give it as a set, because after all the names are truly meant to be unique. What we need

Re: [sympy] lambdify list of arguments converted silently, why not throw a warning?

2020-07-10 Thread Aaron Meurer
If you use the free symbols as arguments, the question is, what order should they be in? As you noted, they could go in any order. It is also not hard to do this manually. For example, lambdify(sorted(expr.free_symbols, key=str), expr) will sort the symbols in alphabetical order. Another option

Re: [sympy] lambdify list of arguments converted silently, why not throw a warning?

2020-07-10 Thread Oscar Benjamin
Hi Roberto, If you have something like expr = some_function(args) where some_function creates new symbols (not found in args) then ideally some_function should also return what the newly created symbols are or some other object that can tell you them: expr, syms = some_function(args) I

Re: [sympy] lambdify list of arguments converted silently, why not throw a warning?

2020-07-10 Thread roberto franceschini
The situation is the one in which I get a sympy expression out of a function that ends in `return my_polynomial_inRn` and now I want to pass this to another function (e.g. to make plots or whatever) without having to know the names of the symbols involved, which is exactly what free_symbols does

Re: [sympy] lambdify list of arguments converted silently, why not throw a warning?

2020-07-10 Thread Oscar Benjamin
Hi Roberto, I already answered this on SO: https://stackoverflow.com/questions/62798213/keep-the-order-of-parameters-fixed-in-sympy-lambdify-from-free-symbols/62800716?noredirect=1#comment111075099_62800716 If you are using symarray to generate the symbols then you can get the list of symbols

Re: [sympy] lambdify list of arguments converted silently, why not throw a warning?

2020-07-10 Thread roberto franceschini
Hello, I have opened an issue for the input of lambdify. If you want to disallow sets as inputs I think it is fair. However, It would be nice to have that free_symbol can be given directly as input for lambdify, is that possible? should I use something else than free_symbols for this purpose? On

Re: [sympy] lambdify list of arguments converted silently, why not throw a warning?

2020-07-09 Thread Aaron Meurer
Can you open an issue in the issue tracker for this? I agree that sets should not be allowed. Aaron Meurer On Thu, Jul 9, 2020 at 3:08 AM Roberto wrote: > > I have seen that lambdify wants a list for the arguments to be treated as > symbols. This list can be also give as a python set, e.g.

Re: [sympy] lambdify list of arguments converted silently, why not throw a warning?

2020-07-09 Thread Davide Sandona'
You can wrap lambdify into a new function: def get_lambda(expr, modules="numpy", **kwargs): from sympy.utilities.iterables import ordered signature = list(ordered(expr.free_symbols)) return signature, lambdify(signature, expr, modules=modules, **kwargs) With it, the argument are

[sympy] lambdify list of arguments converted silently, why not throw a warning?

2020-07-09 Thread Roberto
I have seen that lambdify wants a list for the arguments to be treated as symbols. This list can be also give as a python set, e.g. {x,y,z }, which is exactly what would be returned by a .free_symbol property. If lambdify is feed a set like that of the output of .free_symbol it may change their