-
-
Notifications
You must be signed in to change notification settings - Fork 488
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
Pass number of variables to var #22813
Comments
comment:1
if we parse the arg by the length we get the desired behavior:
does it have some other undesired effects? with the current set of tests in |
comment:2
Problem: |
comment:3
IIRC |
comment:5
Added the numeric 2nd argument, following @tscrim's recommendation. Let me suggest to add functionality for handling more than one variable. Note that the behavior below is a replica of SymPy's symbols constructor, check
and
What are your thoughts? New commits:
|
Commit: |
comment:6
There is, of course, the danger that this could overwrite someone's already-defined variables - say, if
though of course that can happen anyway, this is just more silent about it. Perhaps a check to see whether any of the variables about to be produced is already defined? Though we don't currently do that and the same danger exists... this is just more implicit, which isn't very Pythonic. None of this should be construed as not supporting the goal of this ticket, I'm just raising questions. |
comment:7
I would expect |
comment:8
fair enough about naming conventions or handy constructions. as far as i'm concerned, this ticket is ready for peer-review! |
comment:9
Replying to @kcrisman:
I think that's one of the reasons why this doesn't belong in the top-level
or perhaps even
but you'd probably want to bind the result to a single symbol, say
where you need to use In other words, generating indexed symbolic variables is probably not suitable for injection at all. |
comment:10
Replying to @nbruin:
OK, it makes sense. Moreover it also answers my previous question if there is a technical reason why I guess this is wontfix? |
comment:11
Perhaps what we want is the output of |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:13
Replying to @tscrim:
Good, i've uploaded an attempt to implement it. Feedback welcome. The behavior is now:
BTW this is related to #11576, a summary follows. There are pointers to use cases where this notation is useful. There are also many technical hints explaining that one would prefer to exploit Ginac's indexed expressions. There are patches, the last one with a doctests failure reported in sage 5.10. As far as i can see, a random user would still need, currently, the convoluted |
comment:14
Instead of checking for a string and assuming it's a number otherwise, I'd rather do it the other way around: check for a number with I also dislike the |
comment:15
Hi, Replying to @jdemeyer:
do you mean
this was intended for the case with those changes, the
|
comment:16
Replying to @mforets:
I'm pretty sure he rather meant
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:18
Replying to @nbruin:
ok. for the updated version with:
critics/corrections welcome |
comment:19
Style in python prefers imports on top (see PEP-8). There are reasons to deviate, and reasons not to. The answer at Most imports in functions in sage are to avoid expensive imports on startup and to avoid some circular import problems with |
comment:20
I'm -1 on this injection and the place where this change happens. First the place:
Next the kind of injection. With Hence: generating variable sequences is fine, but the "right" injection behaviour here is even less clear than in a simple First put it in SR.var and see what usage arises. Perhaps practical experience shows how (if at all) injection should work. |
comment:21
Replying to @nbruin:
ok! i'm ready to write the code for SR.var (new ticket). do you mind creating it? (i don't know if doing that right now is ok or on the contrary it is too soon to take that decision..) for the full discussion, true, now i see that you want to avoid |
comment:23
Is this is invalid/wontfix? Who does that? Thanks. |
comment:24
You would set the milestone to invald/wontfix, but I am not sure that is what we want to do at this point. #22909 is a different issue and having this would be useful. I think there is still some discussion to be had as I feel the injection issue is no worse than the current situation. I think we should come to a bit more of a consensus before rendering this ticket invalid. |
comment:25
Replying to @tscrim:
That's fine. If a new discussion takes place, it would be nice if it kicks off with a summary of the several threads on this topic that exist in sage-devel, sage-support and ask.sage (plus those in a couple of old tickets). I don't plan to do this, at least not at the moment. |
comment:26
This is fixed by #22909 (albeit requesting using the ==> marking as duplicate and requesting review in order to solve... |
comment:27
As you can see from the discussion, at least Travis thought this wasn't 100% resolved, since this ticket is now about injection into the global namespace of the Of course, we could also close this as undesirable or something not to work on now but rather if it comes up again. Marcelo and Nils seemed to agree with me that maybe that wasn't bad. See if Travis responds (he's usually pretty aware of relevant ticket changes he's cc:ed on) otherwise I this we can indeed close this, though as wontfix rather than a dup. |
comment:28
Replying to @kcrisman:
The current behavior seems OK :
Users can always do Furthermore, we have so far just a trick to define a bunch of symbolic variables easily, but no mathematical properties associated with this bunch. We could want to do something like Such an addition would be extremely tempting, however, if we could create "symbolic variables of a fixed type", which do not exist currently in Sage (e. g. there is no way to create a polynomial with, say, rational coefficients designated by names rather than values...).
As far as I know, this the same closure |
comment:29
I wouldn't say the current behaviour is "OK", but it's a fact that we already have that:
so it's already injecting the (individual) variables. As I explained above, I expect that this is one of 3 outcomes:
so +1 on closing as duplicate/wontfix |
comment:30
I agree with Nils that the behavior needs to be better specified, which means there needs to be better documentation. So I am okay with closing this as duplicate, but we might want to consider update the documentation of Which, getting towards that later argument, I see Nils point about binding. I typically want the tuple and utilize that because I will later on iterate over the variables. So I might lean towards that behavior rather than injecting the individual variables. However, I can see a lot of cases where I would instead just use the individual variables, which I feel would be more in line with a less programming-friendly user. There is some advantage to the current behavior that you can have the best of both worlds with |
comment:31
Okay. Then let's close this one, and Travis can you open a new ticket that describes exactly what you are thinking of? I don't have a horse in this race other than making sure everything is meta-documented on Trac :-) |
comment:32
We can just refer to this ticket for now until we have a more concrete proposal. I am also stretched a little too thin right now to put much effort into this. |
Changed commit from |
Changed branch from u/mforets/pass_number_of_variables_to_var to none |
Reviewer: Travis Scrimshaw |
Extend the functionality of
var
by allowing to specify the number of variables:This ticket is a follow-up of #22809. It is related to #11576.
CC: @nbruin @kcrisman @tscrim
Component: symbolics
Keywords: symbolic, vector
Reviewer: Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/22813
The text was updated successfully, but these errors were encountered: