Hi Volker,

The problem is that you are using sympy.numbers.Zero. There is no
sympy.numbers module. Rather there is a sympy.core.numbers module
which is where Zero is defined. In SymPy 1.5 the main
sympy/__init__.py used to do
    from .core import *
which resulted in the sympy.core.numbers module being imported into
the __init__.py as numbers which then made it accessible as
sympy.numbers. This was unintentional and was a result of sympy
internally using import * without consistently using __all__.

In sympy 1.6 this is fixed and the old modules that were accidentally
imported are still there but give a deprecation warning if you try to
use them. They will be removed in future though so sympy.numbers.Zero
will end up giving an error.

There are several ways to get Zero. To get it from the module where it
is defined you can use sympy.core.numbers.Zero or
    from sympy.core.numbers import Zero
However in general users are encouraged not to depend on exactly which
module sympy objects are defined in except where the documentation
advises importing in a particular way. The intended way to get Zero
is:

from sympy import S
Zero = S.Zero  # Or just use S.Zero wherever you would use Zero

Another way is just Integer(0) or S(0) because any sympy zero Integer
will return S.Zero.

The S object gives access to a number of sympy objects like S.pi,
S.One, S.NaN etc. You can also use it as a shorthand for sympify as in
S(1)/3 which gives a sympy Rational rather than a python float as 1/3
would.
https://docs.sympy.org/latest/modules/core.html#s


Oscar

On Fri, 3 Jul 2020 at 15:53, Volker Weißmann
<volker.weissmann...@gmail.com> wrote:
>
> Hello,
>
> I have library that is organized as follows:
>
> mymod/__init__.py:
> from .base import *
>
> mymod/base.py:
> import sympy
> from .modA import *
> from .modB import *
>
> mymod/modA.py:
> from .base import *
> var = sympy.numbers.Zero
>
> mymod/modB.py:
> from .base import *
> # other code
>
>
> When I run python -c "import mymod", I get the warning:
>
>> /home/volker/.local/lib/python3.8/site-packages/sympy/__init__.py:672: 
>> SymPyDeprecationWarning:
>>
>> importing sympy.core.numbers with 'from sympy import *' has been
>> deprecated since SymPy 1.6. Use import sympy.core.numbers instead. See
>> https://github.com/sympy/sympy/issues/18245 for more info.
>>
>>   self.Warn(
>
>
> Should I be worried?  Should I change my import scheme?
>
> --
> 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 sympy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/147c76c5-f166-434e-8c08-2bb2072b530co%40googlegroups.com.

-- 
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 sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxT2VoVVGMwbzvxGKhsDtL7Ueegw8-cP28wDTde%2BMu8jmw%40mail.gmail.com.

Reply via email to