On Mon, Jun 22, 2009 at 2:45 PM, Bryan Bishop<[email protected]> wrote:
>
> On Mon, Jun 22, 2009 at 3:35 PM, Ondrej Certik <[email protected]> wrote:
>> On Mon, Jun 22, 2009 at 2:15 PM, Bryan Bishop <[email protected]> wrote:
>>> Attached (new revision from my sandbox git repository). Any ideas on
>>> how to go about getting these tests to pass? Maybe there's some
>>> architecture changes that need to be made?
>>
>> The tests you wrote are all pretty simple, e.g. integrating a constant
>> function and such. If this is all you want, it could be implemented by
>> enhancing the integrate() function to handle units (I am not much
>> convinced that is the way to go though).
>
> That's true, I only had a few integrations in there. I don't think
> that captures the essence of what I am trying to convey though. I
> would like this to work not only with integrate(), but also diff(),
> limit(), pow(), factorial(), etc. etc. In other words,
> across-the-board integration (which has something to do with the class
> architecture). I guess I was lazy though 8-) because I didn't write
> unit tests for every possible situation in sympy where units should be
> handled correctly.
>
>> But how would you like to work with this:
>>
>> # i(t) = I_p * sin(2 * pi * f * t)
>> # di(t)/dt = 2 * pi * f * I_p * cos(2 * pi * f * t)
>>
>> do you want "t" to be a symbol, or something that also holds units?
>> The same question about I_p and f.
>
> er, great question. Those were really just notes for my later usage.
> In the case of i(t), that was current as a function of time. So in
> that case, I guess i(t) is really saying i(t) is a function equivalent
> to (the given expression). I don't know how to do functions in sympy
> yet. So, I think if sympy's Function() implemented units as well, then
> all would be well (er, right?).
>
>> And you then want sympy to automatically handle i(t) and di(t)/dt?
>
> I am not sure.
>
>> Yes, that would be cool to figure out how to do it. First I'd like to
>> understand more how you want to work with it exactly.
>
> Mainly so that I can use symbolic expressions and have variables with
> units that are taken care of throughout the manipulations that the
> expressions call for. That's all, I guess.

I see, I think it makes sense. If there is a sympy expression with
symbols and those symbols have units, sympy should be able to
automatically figure out the units of the result.

so I can imagine something like:

>>> from sympy.physics import units
>>> var("s t")
>>> derive_units(s*t, {s: units.m, t: units.s})
m*s
>>> derive_units(s.diff(t), {s: units.m, t: units.s})
m/s

Is that what you want?

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to