I believe the sympy.physics.unitsystems module is capable of doing this. http://docs.sympy.org/latest/modules/physics/unitsystems/index.html
Aaron Meurer On Thu, Mar 2, 2017 at 4:56 AM, <[email protected]> wrote: > I wonder whether it is currently (or will soon be) possible to specify which > physical dimension (or unit) a symbol has and have sympy check that these > are compatible when, say, adding symbols or expressions, and compute the > resulting dimension (or unit) when, say, multiplying symbols or expressions? > > I imagine something like > > >>>> x = Symbol("x", dimension=length/time) >>>> y = Symbol("y", dimension=time) >>>> x + y > DimensionError: incompatible dimensions cannot be added >>>> (x * y).dimension > length > > > I know that sympy has now units, but it seems they are only used in > numerical computations, not in symbolic ones, am I right? > > If the imagined functionality is not present or planned to be added soon, > how would you advise me to add it for my project by subclassing? Would it be > sufficient to subclass sympy.Expr or would I have to subclass Add, Mul, etc. > as well? > > Thanks, Jobst > > -- > You received this message because you are subscribed to the Google Groups > "sympy" 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 https://groups.google.com/group/sympy. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/1ce09588-af7d-4781-9ce9-cac5cf858086%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "sympy" 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 https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6KQvAf9ZiiYrcg29jEAQnpTWsbwqZy0QBcO9%3Dp_7%3D_ysA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
