#12834: Modify subs so that it can accept multiple equations just like subs_expr
-------------------------------------+-------------------------------------
       Reporter:  JoalHeagney        |        Owner:  AlexGhitza
           Type:  enhancement        |       Status:  needs_info
       Priority:  minor              |    Milestone:  sage-6.4
      Component:  algebra            |   Resolution:
       Keywords:  subs algebra       |    Merged in:
  solving                            |    Reviewers:
        Authors:  Michael Orlitzky   |  Work issues:
Report Upstream:  N/A                |       Commit:
         Branch:  public/12384       |  045eebfd67858405c6665acfa1eea5f22ca7fc6f
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by mjo):

 @Vincent: Most of your changes look fine to me, thanks for picking this up
 again. I have a few comments:

 1. When making multiple duplicate substitutions, all of the errors are no
 longer reported. This used to work like,

 {{{
 sage: d1 = {'a': 1, 'b': 2}
 sage: d2 = {'b': 1, 'a': 2}
 sage: _subs_safe_merge(d1, d2)
 ValueError: Duplicate substitutions given: a, b
 }}}

 showing that both `a` and `b` had duplicate substitituons. Now it only
 shows the error for `a`:

 {{{
 ValueError: duplicate substitutions a->1 and a->2
 }}}

 The test "We should report all such conflicts..." was intended to show
 that =)

 2. I like the fact that you show the whole substitution in the error, e.g.
 `ValueError: duplicate substitutions a->b and a->c`, but I think the arrow
 notation is confusing. I can't tell at a glance whether `a` or `b` is the
 variable. In some programming languages, the arrow is used to mean "take
 the value of `a` and put that into `b`." In other contexts, you could
 think of it as "take `a` and make it become `b`", which is actually the
 reverse substitution.[[BR]][[BR]]Above, you can deduce which is which (if
 you think for a minute), but you can also wind up with `ValueError:
 duplicate substitutions x->y and x->y` where it's totally
 ambiguous.[[BR]][[BR]]Is there some other notation that people generally
 agree on? Maybe the colon-equals, which defines the thing on the left to
 be equal to the thing on the right? For example, `x := 3` would mean that
 `x` is being defined to be `3`; i.e. `3` is substituted for `x`. It's a
 slight abuse of notation, but we can think of `:=` as "make the thing on
 the left equal the thing on the right from now on." That's basically what
 a substitution is.

 3. My "And finally, a list containing one of everything" test was meant to
 show that we can handle all three types (symbolic equality, a dict, and
 another list) at the same time. You noticed that I forgot tuples
 (thanks!), but can we do them all at the same time? For example,[[BR]]
 {{{
 sage: w, x, y, z = SR.var('w, x, y, z')
 sage: _subs_make_dict([w == 1, {x: 1}, [y == 1], (z == 1,)])
 {w: 1, y: 1, x: 1, z: 1}
 }}}
 4. I agree that we can deprecate the other substitution methods
 `subs_expr` and `substitute_expression`.

 That's it, thanks again for taking the time to work on this.

--
Ticket URL: <http://trac.sagemath.org/ticket/12834#comment:16>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to