Skip to content
Snippets Groups Projects
Commit d46ff930 authored by Matt Wala's avatar Matt Wala
Browse files

Pull magic string out.

parent d9073204
Branches
Tags
1 merge request!26Initial SymEngine integration.
Pipeline #
...@@ -47,21 +47,23 @@ def _find_symbolic_backend(): ...@@ -47,21 +47,23 @@ def _find_symbolic_backend():
symengine_found = False symengine_found = False
ALLOWED_BACKENDS = ("sympy", "symengine") # noqa ALLOWED_BACKENDS = ("sympy", "symengine") # noqa
BACKEND_ENV_VAR = "SUMPY_FORCE_SYMBOLIC_BACKEND" # noqa
import os import os
backend = os.environ.get("SUMPY_FORCE_SYMBOLIC_BACKEND") backend = os.environ.get(BACKEND_ENV_VAR)
if backend is not None: if backend is not None:
if backend not in ALLOWED_BACKENDS: if backend not in ALLOWED_BACKENDS:
raise RuntimeError( raise RuntimeError(
"SUMPY_FORCE_SYMBOLIC_BACKEND value is unrecognized: '%s' " "%s value is unrecognized: '%s' "
"(allowed values are %s)" % ( "(allowed values are %s)" % (
BACKEND_ENV_VAR,
backend, backend,
", ".join("'%s'" % val for val in ALLOWED_BACKENDS))) ", ".join("'%s'" % val for val in ALLOWED_BACKENDS)))
if backend == "symengine" and not symengine_found: if backend == "symengine" and not symengine_found:
from warnings import warn from warnings import warn
warn("SUMPY_FORCE_SYMBOLIC_BACKEND=symengine was specified, but " warn("%s=symengine was specified, but could not find symengine. "
"could not find symengine. Using sympy.", RuntimeWarning) "Using sympy." % BACKEND_ENV_VAR, RuntimeWarning)
USE_SYMENGINE = backend == "symengine" and symengine_found USE_SYMENGINE = backend == "symengine" and symengine_found
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment