diff --git a/notebooks/Basics_of_lineageTree.ipynb b/notebooks/Basics_of_lineageTree.ipynb index e48806b3..943228c4 100644 --- a/notebooks/Basics_of_lineageTree.ipynb +++ b/notebooks/Basics_of_lineageTree.ipynb @@ -131,11 +131,11 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "# lT.plot_nodes(list(lT.roots)[3])" + "# lT.plot_nodes(list(lT.roots)[3]) # noqa: ERA001\n" ] }, { @@ -556,7 +556,7 @@ "source": [ "selected_root = list(lT.roots)[0]\n", "lT.get_subtree_nodes(selected_root) # returns all the nodes spawned by a node\n", - "lT.all_chains # returns a list of lists that contains each chain of the dataset\n", + "lT.all_chains # returns a list of lists that contains each chain of the dataset # noqa: B018\n", "lT.get_all_chains_of_subtree(\n", " selected_root\n", ") # returns a list of lists that contains each chain of the subtree of a node" @@ -568,8 +568,8 @@ "metadata": {}, "outputs": [], "source": [ - "lT.nodes # all the nodes present on the lT object\n", - "lT.roots # all the roots of the object\n", + "lT.nodes # all the nodes present on the lT object # noqa: B018\n", + "lT.roots # all the roots of the object # noqa: B018\n", "lT.successor # dictionary that connects an id to a list of successors, can be used to find all edges." ] }, diff --git a/notebooks/Easy_clustermaps.ipynb b/notebooks/Easy_clustermaps.ipynb index ec2bf603..dccd0ade 100644 --- a/notebooks/Easy_clustermaps.ipynb +++ b/notebooks/Easy_clustermaps.ipynb @@ -46,8 +46,8 @@ "\n", "try:\n", " import seaborn as sns\n", - "except:\n", - " !pip install seaborn\n", + "except ModuleNotFoundError:\n", + " %pip install seaborn\n", "finally:\n", " from itertools import combinations\n", "\n", @@ -77,7 +77,7 @@ "\n", "### Or load a manager###\n", "\n", - "# lTm = lineageTreeManager.load(\"path_to/Manager.ltM\")" + "# lTm = lineageTreeManager.load(\"path_to/Manager.ltM\") # noqa: ERA001" ] }, { @@ -195,7 +195,7 @@ "outputs": [], "source": [ "comparison = {}\n", - "for i, (n1, n2) in enumerate(combs):\n", + "for n1, n2 in combs:\n", " comparison[n1, n2] = lTm.cross_lineage_edit_distance(\n", " names[n1][1],\n", " names[n1][0],\n", @@ -247,8 +247,8 @@ "source": [ "g = sns.clustermap(\n", " hierarchy,\n", - " xticklabels=[label for label in labels], # labels,\n", - " yticklabels=[label for label in labels],\n", + " xticklabels=list(labels),\n", + " yticklabels=list(labels),\n", " cmap=\"viridis\",\n", " row_linkage=linkage_data,\n", " col_linkage=linkage_data,\n", diff --git a/src/LineageTree/lineageTree.py b/src/LineageTree/lineageTree.py index 82cb1f33..01a3d264 100644 --- a/src/LineageTree/lineageTree.py +++ b/src/LineageTree/lineageTree.py @@ -3497,7 +3497,7 @@ def __init__( f"Attribute `starting_time` was a `{type(starting_time)}`, has been casted as an `int`.", stacklevel=2, ) - self._time = {node: starting_time for node in self.roots} + self._time = dict.fromkeys(self.roots, starting_time) queue = list(self.roots) for node in queue: for succ in self._successor[node]: diff --git a/src/LineageTree/loaders.py b/src/LineageTree/loaders.py index 79e6ad7e..027da08d 100644 --- a/src/LineageTree/loaders.py +++ b/src/LineageTree/loaders.py @@ -393,7 +393,7 @@ def read_from_binary(fname: str, name: None | str = None) -> lineageTree: ) ) ) - is_root = {c: True for c in tmp} + is_root = dict.fromkeys(tmp, True) done = True while ( i < len(number_sequence) and not done @@ -635,7 +635,7 @@ def read_from_txt_for_celegans_BAO( ids = list(range(unique_id, unique_id + len(lc))) successor.update({ids[i]: [ids[i + 1]] for i in range(len(ids) - 1)}) properties["expression"].update(dict(zip(ids, lc, strict=True))) - properties["_labels"].update({id_: c for id_ in ids}) + properties["_labels"].update(dict.fromkeys(ids, c)) to_link[c] = (unique_id, unique_id + len(lc) - 1) unique_id += len(lc) diff --git a/src/LineageTree/test/test_lineageTree.py b/src/LineageTree/test/test_lineageTree.py index eaafea81..a8f201bc 100644 --- a/src/LineageTree/test/test_lineageTree.py +++ b/src/LineageTree/test/test_lineageTree.py @@ -2,6 +2,7 @@ import numpy as np import pytest + from LineageTree import ( lineageTree, lineageTreeManager,