#\input texinfo """ Unified place for determining if external dependencies are installed or not. You should import all external modules using the import_module() function. For example >>> from sympy.external import import_module >>> numpy = import_module('numpy') If the resulting library is not installed, or if the installed version is less than a given minimum version, the function will return None. Otherwise, it will return the library. See the docstring of import_module() for more information. """ from sympy.external.importtools import import_module
from sympy.external.importtools import import_module disabled = False # if pyglet.gl fails to import, e.g. opengl is missing, we disable the tests pyglet_gl = import_module("pyglet.gl", catch=(OSError, )) pyglet_window = import_module("pyglet.window", catch=(OSError, )) if not pyglet_gl or not pyglet_window: disabled = True from sympy import symbols, sin, cos, log x, y, z = symbols('x, y, z') def test_import(): from sympy.plotting.pygletplot import PygletPlot def test_plot_2d(): from sympy.plotting.pygletplot import PygletPlot p = PygletPlot(x, [x, -5, 5, 4], visible=False) p.wait_for_calculations() def test_plot_2d_discontinuous(): from sympy.plotting.pygletplot import PygletPlot p = PygletPlot(1 / x, [x, -1, 1, 2], visible=False) p.wait_for_calculations() def test_plot_3d():
from sympy.external.importtools import import_module disabled = False # if pyglet.gl fails to import, e.g. opengl is missing, we disable the tests pyglet_gl = import_module("pyglet.gl", catch=(OSError,)) pyglet_window = import_module("pyglet.window", catch=(OSError,)) if not pyglet_gl or not pyglet_window: disabled = True from sympy import symbols, sin, cos x, y, z = symbols('x, y, z') def test_import(): from sympy.plotting.pygletplot import PygletPlot def test_plot_2d(): from sympy.plotting.pygletplot import PygletPlot p = PygletPlot(x, [x, -5, 5, 4], visible=False) p.wait_for_calculations() def test_plot_2d_discontinuous(): from sympy.plotting.pygletplot import PygletPlot p = PygletPlot(1/x, [x, -1, 1, 2], visible=False) p.wait_for_calculations()
def satisfiable(expr, algorithm=None, all_models=False): """ Check satisfiability of a propositional sentence. Returns a model when it succeeds. Returns {true: true} for trivially true expressions. On setting all_models to True, if given expr is satisfiable then returns a generator of models. However, if expr is unsatisfiable then returns a generator containing the single element False. Examples ======== >>> from sympy.abc import A, B >>> from sympy.logic.inference import satisfiable >>> satisfiable(A & ~B) {A: True, B: False} >>> satisfiable(A & ~A) False >>> satisfiable(True) {True: True} >>> next(satisfiable(A & ~A, all_models=True)) False >>> models = satisfiable((A >> B) & B, all_models=True) >>> next(models) {A: False, B: True} >>> next(models) {A: True, B: True} >>> def use_models(models): ... for model in models: ... if model: ... # Do something with the model. ... print(model) ... else: ... # Given expr is unsatisfiable. ... print("UNSAT") >>> use_models(satisfiable(A >> ~A, all_models=True)) {A: False} >>> use_models(satisfiable(A ^ A, all_models=True)) UNSAT """ if algorithm is None or algorithm == "pycosat": pycosat = import_module('pycosat') if pycosat is not None: algorithm = "pycosat" else: if algorithm == "pycosat": raise ImportError("pycosat module is not present") # Silently fall back to dpll2 if pycosat # is not installed algorithm = "dpll2" if algorithm == "dpll": from sympy.logic.algorithms.dpll import dpll_satisfiable return dpll_satisfiable(expr) elif algorithm == "dpll2": from sympy.logic.algorithms.dpll2 import dpll_satisfiable return dpll_satisfiable(expr, all_models) elif algorithm == "pycosat": from sympy.logic.algorithms.pycosat_wrapper import pycosat_satisfiable return pycosat_satisfiable(expr, all_models) raise NotImplementedError
""" Unified place for determining if external dependencies are installed or not. You should import all external modules using the import_module() function. For example >>> from sympy.external import import_module >>> numpy = import_module('numpy') If the resulting library is not installed, or if the installed version is less than a given minimum version, the function will return None. Otherwise, it will return the library. See the docstring of import_module() for more information. """ from sympy.external.importtools import import_module