Skip to content

Commit

Permalink
Refactor executable check in plot module
Browse files Browse the repository at this point in the history
Replaced the use of `find_executable` with `which` for checking the availability of 'dvipng' in the `set_latex` function.
  • Loading branch information
cuihantao committed Jan 5, 2025
1 parent 6b53d8b commit 183dee1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions andes/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np

from andes.core.var import BaseVar
from andes.shared import find_executable, mpl, plt
from andes.shared import which, mpl, plt
from andes.utils.paths import get_dot_andes_path # NOQA

logger = logging.getLogger(__name__)
Expand All @@ -27,7 +27,7 @@ def set_latex():
True for LaTeX on, False for off
"""

if find_executable('dvipng'):
if which('dvipng'):
mpl.rc('text', usetex=True)

no_warn_file = os.path.join(get_dot_andes_path(), '.no_warn_latex')
Expand Down
5 changes: 1 addition & 4 deletions andes/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import coloredlogs # NOQA
import numpy as np # NOQA
import psutil
from shutil import which # NOQA
from kvxopt import printing # NOQA
from kvxopt import (div, klu, matrix, mul, sparse, spdiag, spmatrix, # NOQA
umfpack)
Expand Down Expand Up @@ -73,7 +74,3 @@
odeint = LazyImport('from scipy.integrate import odeint')

Oct2PyError = LazyImport('from oct2py import Oct2PyError')


# --- Shared functions ---
find_executable = LazyImport('from distutils.spawn import find_executable')

0 comments on commit 183dee1

Please sign in to comment.