浏览代码

Fix the --devs shape edge case

Fixes #320

Signed-off-by: Vadim Markovtsev <vadim@sourced.tech>
Vadim Markovtsev 5 年之前
父节点
当前提交
0a0292b1d8
共有 4 个文件被更改,包括 11 次插入4 次删除
  1. 8 1
      python/labours/modes/devs.py
  2. 1 1
      python/requirements.in
  3. 1 1
      python/requirements.txt
  4. 1 1
      python/setup.py

+ 8 - 1
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
 
 

+ 1 - 1
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

+ 1 - 1
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
 

+ 1 - 1
python/setup.py

@@ -22,7 +22,7 @@ setup(
     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",