From 0a0292b1d845aefdfe77b319df91fcdb521c9fb9 Mon Sep 17 00:00:00 2001 From: Vadim Markovtsev Date: Wed, 6 Nov 2019 23:17:56 +0100 Subject: [PATCH] Fix the --devs shape edge case Fixes #320 Signed-off-by: Vadim Markovtsev --- python/labours/modes/devs.py | 9 ++++++++- python/requirements.in | 2 +- python/requirements.txt | 2 +- python/setup.py | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/python/labours/modes/devs.py b/python/labours/modes/devs.py index b74f253e..f969f895 100644 --- a/python/labours/modes/devs.py +++ b/python/labours/modes/devs.py @@ -64,6 +64,10 @@ def show_devs( prop_cycle = pyplot.rcParams["axes.prop_cycle"] colors = prop_cycle.by_key()["color"] fig, axes = pyplot.subplots(final.shape[0], 1) + try: + axes = tuple(axes) + except TypeError: + axes = axes, backgrounds = ( ("#C4FFDB", "#FFD0CD") if args.background == "white" else ("#05401C", "#40110E") ) @@ -227,7 +231,10 @@ def hdbscan_cluster_routed_series( [0] + [dists[route[i], route[i + 1]] for i in range(len(route) - 1)] ) ) - clusters = HDBSCAN(min_cluster_size=2).fit_predict(opt_dist_chain[:, numpy.newaxis]) + if len(route) < 2: + clusters = numpy.zeros(len(route), dtype=int) + else: + clusters = HDBSCAN(min_cluster_size=2).fit_predict(opt_dist_chain[:, numpy.newaxis]) return clusters diff --git a/python/requirements.in b/python/requirements.in index a1b651fc..be8d36b2 100644 --- a/python/requirements.in +++ b/python/requirements.in @@ -6,7 +6,7 @@ scipy>=0.19.0,<1.2.2 protobuf>=3.5.0,<4.0 munch>=2.0,<3.0 hdbscan>=0.8.0,<2.0 -seriate>=1.0,<2.0 +seriate>=1.1.2,<2.0 fastdtw>=0.3.2,<2.0 python-dateutil>=2.6.0,<3.0 lifelines>=0.20.0,<2.0 diff --git a/python/requirements.txt b/python/requirements.txt index bfe8172a..3419bbe0 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -27,7 +27,7 @@ pytz==2019.2 # via pandas pyyaml==3.13 scikit-learn==0.21.3 # via hdbscan scipy==1.2.1 -seriate==1.1.0 +seriate==1.1.2 six==1.12.0 # via cycler, munch, ortools, packaging, protobuf, python-dateutil tqdm==4.36.1 diff --git a/python/setup.py b/python/setup.py index da21cc6f..da691dcd 100644 --- a/python/setup.py +++ b/python/setup.py @@ -22,7 +22,7 @@ description="Python companion for github.com/src-d/hercules to visualize the results.", long_description=long_description, long_description_content_type="text/markdown", - version="10.5.1", + version="10.5.2", license="Apache-2.0", author="source{d}", author_email="machine-learning@sourced.tech",