From 90031de435247632b75292e862e9697bb06479ca Mon Sep 17 00:00:00 2001 From: parrt Date: Wed, 10 Nov 2021 14:50:53 -0800 Subject: [PATCH] fix change in run methods in graphviz so dtreeviz works in 0.17 and 0.18 graphviz. bump version to 1.3.2 --- dtreeviz/trees.py | 9 ++++++--- dtreeviz/version.py | 2 +- setup.py | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) 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(),