On Wed, Jun 22, 2011 at 12:09 AM, Aaron Meurer <[email protected]> wrote:
> So far, I've coded up an import_module function, that wraps the try,
> except ImportError logic into a single unified function.  It has
> support for checking the module version and the Python version and
> returning None if they are too old, even if the module is installed,
> and it also supports raising warnings when the module cannot be used.
> You can see the code at
> https://github.com/asmeurer/sympy/tree/external.
>
> I've yet to apply this everywhere in SymPy (I will do it tomorrow).  I
> still need to decide if it will be good enough to use
> import_module('numpy', min_python_version=(2, 6)) everywhere in the
> quantum module, or if I should centralize numpy importing in that
> module even further.
>
> But it should a *lot* less code, i.e., instead of
>
> import sys
> import warnings
>
> try:
>    if sys.version_info < (2, 6):
>        warnings.warn("Python version too old to use numpy")
>        raise ImportError
>    import numpy
> except ImportError:
>    <do numpy not supported stuff>
>
> in every single quantum file that uses numpy (including the tests), we
> would just have
>
> from sympy.external import import_module
> numpy = import_module('numpy', min_python_version=(2, 6))
> if not numpy:
>    <do numpy not supported stuff>
>
> Aaron Meurer
>
> On Mon, Jun 20, 2011 at 6:11 PM, Aaron Meurer <[email protected]> wrote:
>> It should at least be in a separate file for the quantum code.  I
>> didn't consider to make one file for it for all of SymPy. I'm waiting
>> to see what Brian Granger thinks, since he knows the most about the
>> quantum module.

So numpy is optionally imported in the quantum module, and sympy fails
to import with a particular version of numpy and python2.5?

If it's just a test failure on a particular combination of
numpy/python and it's not easy for us to fix currently, I would just
document it in the release notes and release.

Ondrej

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