As a test for the unit system module, I have written some codes using the 
solve method, since Units (and other objects defined in the module) are 
supposed to behave as normal sympy objects.
But when I call solve, it tries to create an intermediate Unit object where 
one of the argument is Dummy, so it returns an error since this argument 
should be a Unit or a Dimension object [2]. I tried to understand how solve 
is working, but I don't get it. Here is the full traceback
File 
"/mnt/data/Documents/Projets/Programmation/sympy/doc/src/modules/physics/unitsystems/examples.rst"
, line 76, in examples.rst
Failed example:
    Tr = solve(T**2/venus_a**3 - 4*pi**2 / mks["G"] / solar_mass, T)[1]
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python2.7/doctest.py", line 1289, in __run
        compileflags, 1) in test.globs
      File "<doctest examples.rst[25]>", line 1, in <module>
        Tr = solve(T**2/venus_a**3 - 4*pi**2 / mks["G"] / solar_mass, T)[1]
      File "sympy/solvers/solvers.py", line 893, in solve
        f[i] = nsimplify(fi, rational=True)
      File "sympy/simplify/simplify.py", line 3830, in nsimplify
        return _real_to_rational(expr, tolerance)
      File "sympy/simplify/simplify.py", line 3785, in _real_to_rational
        return p.subs(reps, simultaneous=True)
      File "sympy/core/basic.py", line 941, in subs
        rv = rv._subs(old, d, **kwargs)
      File "sympy/core/cache.py", line 93, in wrapper
        r = func(*args, **kw_args)
      File "sympy/core/basic.py", line 1063, in _subs
        rv = fallback(self, old, new)
      File "sympy/core/basic.py", line 1035, in fallback
        arg = arg._subs(old, new, **hints)
      File "sympy/core/cache.py", line 93, in wrapper
        r = func(*args, **kw_args)
      File "sympy/core/basic.py", line 1063, in _subs
        rv = fallback(self, old, new)
      File "sympy/core/basic.py", line 1035, in fallback
        arg = arg._subs(old, new, **hints)
      File "sympy/core/cache.py", line 93, in wrapper
        r = func(*args, **kw_args)
      File "sympy/core/basic.py", line 1063, in _subs
        rv = fallback(self, old, new)
      File "sympy/core/basic.py", line 1035, in fallback
        arg = arg._subs(old, new, **hints)
      File "sympy/core/cache.py", line 93, in wrapper
        r = func(*args, **kw_args)
      File "sympy/core/basic.py", line 1063, in _subs
        rv = fallback(self, old, new)
      File "sympy/core/basic.py", line 1040, in fallback
        rv = self.func(*args)
      File "sympy/physics/unitsystems/units.py", line 72, in __new__
        "instance; found %s" % type(dim))
    TypeError: 'dim' object should be Unit or Dimension instance; found <
class 'sympy.core.symbol.Dummy'>

When I wrote the test (commit 05ddf1aeac22eb1f01c9db1c7ab61d6ee8cc955b), 
this was working since I just copied-pasted the results I was seeing on 
IPython. One of the main thing which change since this moment is that Unit 
inherits from Expr instead of AtomicExpr. I tried to go back to the 
mentioned commit, but now I get a recursive call...

This is the only remaining bug in the proposed pull request [3]. You can 
find the branch there [4].

Do you have some ideas? if not, maybe we should give up (temporarily) the 
use of Units in equations, etc. (since we can still do it with abstract 
symbol and then replace).

[1] 
https://github.com/melsophos/sympy/blob/units/doc/src/modules/physics/unitsystems/examples.rst
[2] 
https://github.com/melsophos/sympy/blob/units/sympy/physics/unitsystems/units.py
[3] https://github.com/sympy/sympy/pull/2628
[4] https://github.com/melsophos/sympy/tree/units

Best,

Harold

-- 
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 http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/96a1e62d-95d6-4dd7-8c1d-f1cb9400d438%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to