On Aug 6, 3:35 pm, "Aaron S. Meurer" <[email protected]> wrote:
> Yes, you should avoid using the names I, E, S, N, C, or O (uppercase
> only) for Symbols because they are predefined by SymPy.
> Seehttp://docs.sympy.org/gotchas.html#id2
>
> By the way, you can use the mnemonic COSINE to remember these.
>
True, but this does seem like a bug as unlike redefining this
variables and getting strange behaviour I am using a method that is
not protecting these names for its own local use (I shouldn't need to
worry about how the internal code for .subs works when I pass it
arguments)
This even breaks local names spaces, unlike:
>>> import sympy
>>> N = 3
>>> sympy.N(N)
3.00000000
which works fine, if I do
>>> (1 + x).subs(dict(N=3))
things break, so the behaviour is non local and a different issue than
the name spacing problems described in the gotcha's.
Gabriel
> Aaron Meurer
> On Aug 6, 2009, at 1:02 PM, Gabriel wrote:
>
>
>
> > Yes I was just coming to post. This is an error in sympy if you use
> > the variable name 'N'
>
> > so do this:
>
> > (1 + x).subs(dict(x=1, y=2, N=3))
>
> > which complains about N being a function, so I imagine the fix is to
> > import the N function in the subs namespace with an underscore...
> > maybe this is already fixed. I am using 0.6.4
>
> > Gabriel
>
> > On Aug 6, 2:24 pm, Ondrej Certik <[email protected]> wrote:
> >> On Thu, Aug 6, 2009 at 12:09 PM, Gabriel<[email protected]>
> >> wrote:
>
> >>> I would like to do substitution for a set of symbols into an
> >>> expression where not all the symbols may be defined.
>
> >>> something like
>
> >>> (1 + x).subs(dict(x=1, y=2))
>
> >>> which raises a cryptic error since y is not in the expression. (the
> >>> problem this is for is that I am making a jacobian then substituting
> >>> in the equilibrium values, but I don't want to check all n**2
> >>> entries
> >>> to see which symbols have dropped out).
>
> >>> Any tips, pointers?
>
> >> Could you please post the full script? Your line works for me:
>
> >> In [1]: (1 + x).subs(dict(x=1, y=2))
> >> Out[1]: 2
>
> >> Ondrej
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---