Go ahead and create an issue for it.  If you can push the changes up to github, 
that would also make things easier.

On May 15, 2010, at 3:34 PM, Harold E. wrote:

> I made a lot of progress and I think the code is almost finished, but
> I have some troubles and need some reviews, to be sure that the
> implementation goes on the right way. Should I open an issue to show
> the code I made until yet?
> 
> I have some problems to simplify expression:
>>>> a = Symbol('a')
>>>> T = 3.155815e7*s
>>>> M = 1.988435e30*kg
>>>> aa = solve(T**2/a**3 - 4*pi**2 / G / M, a)
>>>> res = aa[1].evalf()
>>>> res
> 149598206033.591*kg**-1/3*kg**1/3*m*s**-2/3*s**2/3
>>>> res.args
> (149598206033.591, kg**-1/3, kg**1/3, m, s**-2/3, s**2/3)
>>>> type(res)
> <class 'sympy.core.mul.Mul'>

This is strange.  How do you have the units implemented?  Are they Symbols, or 
something else?  Does it cancel if you do res = Mul(*res.args)?

Aaron Meurer
> 
> Harold
> 
> On 26 avr, 12:00, Harold Erbin <[email protected]> wrote:
>> H Ondrej,
>> 
>> Le dimanche 25 avril 2010 à 16:10 -0700, Ondrej Certik a écrit :
>> 
>> 
>> 
>>> Hi Harold,
>> 
>>> On Sun, Apr 25, 2010 at 3:52 AM, Harold E. <[email protected]> wrote:
>>>> Hi,
>> 
>>>> I saw that a new modules for physics began to be implemented, and the
>>>> part which interested me was on the physicalunits: for a project I
>>>> tried to write my own classes, inspired by those in ScientificPython,
>>>> but evidently it was not compatible with sympy, and so I thought and
>>>> tried to inspired from the classes in sympycore, without successes.
>>>> But yet, with a better understanding of sympy, I read the recent
>>>> implementation and had few questions and observations: the actual way
>>>> is useful to make symbolic computations withunits, but it is
>>>> convenient when we want to work withunits, e.g. to convert a quantity
>>>> in one unit into another, or to take into account the dimension of
>>>> units.
>>>> So I was wondering me if it was not possible to merge actual and
>>>> ScientificPython approaches. For my project I tried several ways, the
>>>> latest was to create classes for the dimension (a tuple), the unit
>>>> symbol (like actual unit) and for the unit; the latest having a
>>>> symbol, a factor and a dimension — something like that (I still search
>>>> the best way to arrange).
>> 
>>> Is this how ScientificPython does it?
>> 
>>> http://dirac.cnrs-orleans.fr/ScientificPython/ScientificPythonManual/...
>> 
>> Yes, ScientificPython has two classes: one which handlesunitsand
>> another for quantities. The Unit class has some properties like a
>> dimension: e.g. for the meter has [1,0,0,0,0,0,0,0,0] and the joule
>> [2,1,-2,0,0,0,0,0,0], and so on. They have also a factor (1 for meter,
>> 1000 for km…) and of course a name. They can also have an offset (to
>> symbolize degree Celsius for example). A quantity has a value and an
>> unit.
>> Several methods tests ifunitsare compatible, converts them into
>> another… When operations are made betweenunits, a new unit is created
>> from dimensions and factors.
>> 
>>> Ourunitsare very simple, see sympy/physics/units.py, so anything
>>> more advanced is welcomed. If you get something working, let us know
>>> and we can review the code and merge it in, or help you improve it.
>> 
>>> Ondrej
>> 
>> I will try to make something good to submit it to you.
>> 
>> The first approach I had was to directly make operations when twounits
>> where together, but it gave strange comportment (even if, written on
>> paper its more logic, it's not convenient for computing use, I think)
>> like>>> m + m
>> m
>>>>> 1*m + 1*m
>> 
>> 2*m
>> so I try another way.
>> 
>> I created a class Unit which have almost the same attributs as those in
>> ScientificPython, but also a base symbol (like m for all distances),
>> which is used when computations are made. It will have the methods to
>> convertunits. This class does not inherit from another class, but the
>> class for the symbol is the same as those defined in the actualunits.py
>> from sympy. I made also a short class for the Dimension.
>> The main problems after is how transform an object like Mul, Add…
>> (passed in argument) into a Quantity (I did not already read the
>> documentation for that), which have methods to change itsunits…
>> 
>> How can I show you the code? Should I create a new issue on tracker and
>> attach the code?
>> 
>> I had a problem with the code in sympy/physics/units.py (0.6.7 version
>> or svn): when I use the class Unit like it is defined, it works fine:>>> m = 
>> Unit('meter', 'm')
>>>>> m
>> 
>> m
>> but if I rename it into UnitSymbol, I have:>>> m = UnitSymbol('meter', 'm')
>>>>> m
>> 
>> UnitSymbol()
>> 
>> Do you know how I can fit that? I try to search into the code, but I did
>> not see anything which can help me.
>> 
>> Harold
>> 
>> --
>> 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 
>> athttp://groups.google.com/group/sympy?hl=en.
> 
> -- 
> 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.
> 

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