Skip to content

Commit

Permalink
Use left-stitched instead of patched columns for target clusters (#139)
Browse files Browse the repository at this point in the history
* Update solver.py

* Update test_solver.py to match changes

* ran black, isort, etc.

* Update .gitignore

* Delete my_debugger.py

* better variable name
  • Loading branch information
yoid2000 authored Aug 2, 2024
1 parent 4dcdbfa commit 9258648
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 76 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ __pycache__/
*.log

# Ignore vscode workspace virtual environment
/venv/
/venv/
/tests/my_debugger.py
6 changes: 3 additions & 3 deletions syndiffix/clustering/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ def new_cluster() -> MutableCluster:
derived_clusters = [(StitchOwner.SHARED, [main_column], list(cluster.columns)) for cluster in clusters[1:]]

ml_columns = [main_column] + main_features
patch_columns: list[DerivedCluster] = (
non_feature_columns: list[DerivedCluster] = (
[]
if drop_non_features
else [(StitchOwner.SHARED, [], [ColumnId(c)]) for c in range(num_columns) if c not in ml_columns]
else [(StitchOwner.LEFT, [main_column], [ColumnId(c)]) for c in range(num_columns) if c not in ml_columns]
)

return Clusters(initial_cluster=initial_cluster, derived_clusters=derived_clusters + patch_columns)
return Clusters(initial_cluster=initial_cluster, derived_clusters=derived_clusters + non_feature_columns)
8 changes: 5 additions & 3 deletions syndiffix/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,11 @@ def _create_child_leaf(self, child_index: int, initial_row: RowId) -> Leaf:

# Set child's subnodes to the matching-interval children of the parent's subnodes.
subnodes = tuple(
subnode.children.get(Branch._remove_dimension_from_index(dim_index, child_index))
if isinstance(subnode, Branch)
else None
(
subnode.children.get(Branch._remove_dimension_from_index(dim_index, child_index))
if isinstance(subnode, Branch)
else None
)
for dim_index, subnode in enumerate(self.subnodes)
)

Expand Down
4 changes: 2 additions & 2 deletions tests/clustering/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def test_solve_with_features() -> None:
assert clusters_patches.derived_clusters == [
(StitchOwner.SHARED, [Col(0)], [Col(3), Col(4)]),
(StitchOwner.SHARED, [Col(0)], [Col(5)]),
(StitchOwner.SHARED, [], [Col(6)]),
(StitchOwner.SHARED, [], [Col(7)]),
(StitchOwner.LEFT, [Col(0)], [Col(6)]),
(StitchOwner.LEFT, [Col(0)], [Col(7)]),
]

clusters_no_patches = solver.solve_with_features(
Expand Down
67 changes: 0 additions & 67 deletions tests/my_debugger.py

This file was deleted.

0 comments on commit 9258648

Please sign in to comment.