Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging #187

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions thicket/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# SPDX-License-Identifier: MIT

from collections import OrderedDict
import logging
import warnings

from hatchet import GraphFrame
Expand Down Expand Up @@ -37,6 +38,8 @@ def _unify(thickets, inplace=False, disable_tqdm=False):
(list): list of Thicket objects
"""

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
_thickets = thickets
if not inplace:
_thickets = [th.deepcopy() for th in thickets]
Expand All @@ -45,6 +48,7 @@ def _unify(thickets, inplace=False, disable_tqdm=False):
union_graph = _thickets[0].graph
old_to_new = {}
for i in range(len(_thickets) - 1):
logger.debug(f"Unifying {i} and {i + 1}")
new_dict = {}
union_graph = union_graph.union(_thickets[i + 1].graph, new_dict)
# Set all graphs to the union graph
Expand All @@ -58,11 +62,13 @@ def _unify(thickets, inplace=False, disable_tqdm=False):
for old_id, cur_node in old_to_new.items():
cur_id = id(cur_node)
if cur_id in new_dict:
logger.debug(f"\tReplacing merged_dict[{old_id}]: ({cur_node} {cur_id} -> {cur_id}) with ({new_dict[cur_id]} {id(new_dict[cur_id])})")
merged_dict[old_id] = new_dict[cur_id]
seen_keys.add(cur_id)
# Add pairs that are left from new_dict into old_to_new
for cur_id, new_node in new_dict.items():
if cur_id not in seen_keys:
logger.debug(f"\tDidn't see {cur_id} in old_to_new, adding merged_dict[{cur_id}] = ({new_node} {id(new_node)})")
merged_dict[cur_id] = new_node
old_to_new = merged_dict
# Update the nodes in the dataframe
Expand Down
Loading