tBuLi / symfit

Symbolic Fitting; fitting as it should be.
http://symfit.readthedocs.org
MIT License
233 stars 17 forks source link

Exposing sympy API #299

Open Jhsmit opened 4 years ago

Jhsmit commented 4 years ago

In api.py the sympy API is exposed by:

# Expose the sympy API
from sympy import *

This has the consequence that:

import symfit
print(symfit.core)
>>> <module 'sympy.core.core' from 'C:\\Users\\jhs\\Miniconda3\\lib\\site-packages\\sympy\\core\\core.py'>

What? symfit.core is not sympy.core.core? Its probably not a problem but it caused me a lot of confusion since you can't import anymore like this:

import symfit.core.argument as arg
ImportError: cannot import name 'argument' from 'sympy.core.core' (C:\Users\jhs\Miniconda3\lib\site-packages\sympy\core\core.py)

Maybe we can only import the useful stuff from sympy instead of importing *?

tBuLi commented 4 years ago

Yeah you're probably right about this. The original reason for doing this is that there is probably a lot of useful stuff in sympy that people want to have access to, and it's a changing list over time. Is there a smart way to get both proper paths and a maintenance free way of exposing sympy?

Jhsmit commented 4 years ago

Yes I understand the reasoning and I frequently use exp from sympy.

this issue is related to: https://github.com/sympy/sympy/issues/12115 where they had a similar issue of imports from sympy.core.core and this seems to be fixed on diofant (which is a fork of sympy) by restructuring and removing core.py

The only fix I can think of is manually importing what could be useful. But if you look in sympy's init its a long list.