Skip to content

Commit

Permalink
Remove deps on the matplotlib
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Feb 21, 2023
1 parent ca1af5c commit a0bfdd9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 40 deletions.
14 changes: 3 additions & 11 deletions diofant/external/importtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def import_module(module, min_module_version=None, min_python_version=None,
warn_not_installed=False, warn_old_version=True,
module_version_attr='__version__',
module_version_attr_call_args=None,
import__kwargs={}, catch=()):
import__kwargs={}):
"""
Import and return a module if it is installed.
Expand Down Expand Up @@ -46,9 +46,7 @@ def import_module(module, min_module_version=None, min_python_version=None,
example, to import a submodule A.B, you must pass a nonempty fromlist option
to __import__.
This catches ImportError to determine if the module is not installed. To
catch additional errors, pass them as a tuple to the catch keyword
argument.
This catches ImportError to determine if the module is not installed.
Examples
========
Expand All @@ -73,15 +71,9 @@ def import_module(module, min_module_version=None, min_python_version=None,
To import a submodule, you must pass a nonempty fromlist to
__import__(). The values do not matter.
>>> p3 = import_module('mpl_toolkits.mplot3d',
>>> p3 = import_module('scipy.optimize',
... import__kwargs={'fromlist': ['something']})
matplotlib.pyplot can raise RuntimeError when the display cannot be opened
>>> matplotlib = import_module('matplotlib',
... import__kwargs={'fromlist': ['pyplot']},
... catch=(RuntimeError,))
See Also
========
Expand Down
28 changes: 0 additions & 28 deletions diofant/tests/external/test_importtools.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import collections

import pytest

from diofant.core.compatibility import HAS_GMPY
Expand All @@ -8,32 +6,6 @@

__all__ = ()

# fixes issue that arose in addressing issue sympy/sympy#6533


def test_no_stdlib_collections():
# Make sure we get the right collections when it is not part of a
# larger list.

matplotlib = import_module('matplotlib',
import__kwargs={'fromlist': ['cm', 'collections']},
min_module_version='1.1.0', catch=(RuntimeError,))
if matplotlib:
assert collections != matplotlib.collections

matplotlib = import_module('matplotlib',
import__kwargs={'fromlist': ['collections']},
min_module_version='1.1.0', catch=(RuntimeError,))
if matplotlib:
assert collections != matplotlib.collections

# Make sure we get the right collections with no catch.
matplotlib = import_module('matplotlib',
import__kwargs={'fromlist': ['cm', 'collections']},
min_module_version='1.1.0')
if matplotlib:
assert collections != matplotlib.collections


def test_interface():
with pytest.warns(UserWarning) as warn:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ gmpy = ['gmpy2>=2.1.0']
interactive = ['ipykernel']
docs = ['sphinx>=4', 'sphinxcontrib-bibtex>=2.1', 'sphinxcontrib-autoprogram',
'sphinx-rtd-theme>=1']
tests = ['pytest>=6', 'hypothesis', 'pytest-timeout', 'pexpect', 'matplotlib']
tests = ['pytest>=6', 'hypothesis', 'pytest-timeout', 'pexpect']
develop = ['diofant[tests]', 'flake518>=1.5', 'flake8-docstrings>=1.3',
'pep8-naming', 'flake8-comprehensions', 'flake8-isort>=4.1',
'flake8-quotes>=3', 'flake8-sfs', 'pytest-xdist>=1.22',
Expand Down

0 comments on commit a0bfdd9

Please sign in to comment.