From d1cb929bbdaeabfaee64e8e31a03600dd329ec83 Mon Sep 17 00:00:00 2001
From: Blaise Li <blaise.li__git@nsup.org>
Date: Mon, 12 Dec 2022 12:30:23 +0100
Subject: [PATCH] Try to fix detection of clustering diffs.

---
 libcodonusage/__init__.py      |  2 +-
 libcodonusage/libcodonusage.py | 10 +++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libcodonusage/__init__.py b/libcodonusage/__init__.py
index a79d9a5..1254cf9 100644
--- a/libcodonusage/__init__.py
+++ b/libcodonusage/__init__.py
@@ -1,6 +1,6 @@
 __copyright__ = "Copyright (C) 2022 Blaise Li"
 __licence__ = "GNU GPLv3"
-__version__ = "0.26"
+__version__ = "0.27"
 from .libcodonusage import (
     aa2colour,
     aa_usage,
diff --git a/libcodonusage/libcodonusage.py b/libcodonusage/libcodonusage.py
index 3bb2a5e..9e60d26 100644
--- a/libcodonusage/libcodonusage.py
+++ b/libcodonusage/libcodonusage.py
@@ -21,7 +21,8 @@ from pathlib import Path
 # python3 -m pip install cytoolz
 from cytoolz import concat, groupby, unique
 # To render mardown in a Jupyter notebook on gitlab
-from IPython.core.display import display, HTML
+from IPython.display import display
+from IPython.core.display import HTML
 # python3 -m pip install markdown
 from markdown import markdown
 # Basic plotting library for Python
@@ -67,6 +68,7 @@ fmt_metadata = {
         "Title": "Distribution of standardized codon usages biases (by aa), by chromosome"}
 }
 
+
 def render_md(md_str):
     """
     Render a markdown string *md_str* in a Jupyter notebook.
@@ -112,7 +114,7 @@ nuc2colour = dict(zip(nuc_alphabet, nuc_colours))
 def load_counts_table(
         table_path, index_col="old_locus_tag", index_unique=True):
     """
-    Load a table or pre-computed codon counts at *table_path*.
+    Load a table of pre-computed codon counts at *table_path*.
 
     The lines correspond to genes.
     Besides the columns containing the counts for each codon,
@@ -933,7 +935,9 @@ def compare_clusterings(
         for (clust_1, clust_2) in combinations(cluster_names, 2):
             # assert crosstabs[aa][clust_1][clust_2] == 0
             try:
-                if crosstabs[aa][clust_1][clust_2] != 0:
+                # if crosstabs[aa][clust_1][clust_2] != 0:
+                if (crosstabs[aa][clust_1][clust_2] != 0) \
+                        or (crosstabs[aa][clust_2][clust_1] != 0):
                     same_clusters = False
             except KeyError:
                 # At least one cluster is absent.
-- 
GitLab