diff --git a/dtreeviz/trees.py b/dtreeviz/trees.py index 71a99672..dea344de 100644 --- a/dtreeviz/trees.py +++ b/dtreeviz/trees.py @@ -10,7 +10,7 @@ import matplotlib.patches as patches import matplotlib.pyplot as plt from colour import Color, rgb2hex -from graphviz.backend import run, view +import graphviz from sklearn import tree from typing import Mapping, List, Tuple from numbers import Number @@ -45,7 +45,7 @@ def svg(self): def view(self): svgfilename = self.save_svg() - view(svgfilename) + graphviz.backend.view(svgfilename) def save_svg(self): """Saves the current object as SVG file in the tmp directory and returns the filename""" @@ -76,7 +76,10 @@ def save(self, filename): # Gen .svg file from .dot but output .svg has image refs to other files cmd = ["dot", f"-T{format}", "-o", filename, dotfilename] # print(' '.join(cmd)) - run(cmd, capture_output=True, check=True, quiet=False) + if graphviz.__version__ <= '0.17': + graphviz.backend.run(cmd, capture_output=True, check=True, quiet=False) + else: + graphviz.backend.execute.run_check(cmd, capture_output=True, check=True, quiet=False) if filename.endswith(".svg"): # now merge in referenced SVG images to make all-in-one file diff --git a/dtreeviz/version.py b/dtreeviz/version.py index 1e182c38..80fdc1a8 100644 --- a/dtreeviz/version.py +++ b/dtreeviz/version.py @@ -21,4 +21,4 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -__version__ = '1.3' \ No newline at end of file +__version__ = '1.3.2' \ No newline at end of file diff --git a/setup.py b/setup.py index c0e40966..dbc4452f 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name='dtreeviz', - version='1.3.1', + version='1.3.2', url='https://github.com/parrt/dtreeviz', license='MIT', packages=find_packages(),