Skip to content

Commit

Permalink
fix change in run methods in graphviz so dtreeviz works in 0.17 and 0…
Browse files Browse the repository at this point in the history
….18 graphviz. bump version to 1.3.2
  • Loading branch information
parrt committed Nov 10, 2021
1 parent 4952596 commit 90031de
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions dtreeviz/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dtreeviz/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
__version__ = '1.3'
__version__ = '1.3.2'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 90031de

Please sign in to comment.