Skip to content

Commit f6bd26e

Browse files
committed
Rename materialize_tree to materialize_table
1 parent a832458 commit f6bd26e

4 files changed

Lines changed: 16 additions & 13 deletions

File tree

syndiffix/clustering/common.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def __repr__(self) -> str:
2424

2525

2626
# Owner, Stitch columns, Derived columns
27+
# The total set of columns is Stitch+Derived.
2728
DerivedCluster = tuple[StitchOwner, list[ColumnId], list[ColumnId]]
2829

2930

@@ -35,6 +36,8 @@ class Clusters:
3536

3637
TreeMaterializer = Callable[[Forest, list[ColumnId]], tuple[list[MicrodataRow], Combination]]
3738

39+
TableMaterializer = Callable[[Forest, list[ColumnId]], tuple[list[MicrodataRow], Combination]]
40+
3841

3942
def microdata_row_to_row(microdata_row: MicrodataRow) -> Row:
4043
return tuple(value[MICRODATA_SYN_VALUE] for value in microdata_row)

syndiffix/clustering/stitching.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,15 +360,15 @@ def _do_patch(
360360

361361

362362
def _stitch(
363-
materialize_tree: TreeMaterializer,
363+
materialize_table: TableMaterializer,
364364
forest: Forest,
365365
metadata: StitchingMetadata,
366366
left: tuple[list[MicrodataRow], Combination],
367367
derived_cluster: DerivedCluster,
368368
) -> tuple[list[MicrodataRow], Combination]:
369369
(_, stitch_columns, derived_columns) = derived_cluster
370370

371-
right = materialize_tree(forest, stitch_columns + derived_columns)
371+
right = materialize_table(forest, stitch_columns + derived_columns)
372372

373373
if len(stitch_columns) == 0:
374374
return _do_patch(forest.unsafe_rng, left, right)
@@ -377,12 +377,12 @@ def _stitch(
377377

378378

379379
def build_table(
380-
materialize_tree: TreeMaterializer, forest: Forest, metadata: StitchingMetadata, clusters: Clusters
380+
materialize_table: TableMaterializer, forest: Forest, metadata: StitchingMetadata, clusters: Clusters
381381
) -> tuple[list[Row], Combination]:
382-
acc = materialize_tree(forest, clusters.initial_cluster)
382+
acc = materialize_table(forest, clusters.initial_cluster)
383383

384384
for derived_cluster in clusters.derived_clusters:
385-
acc = _stitch(materialize_tree, forest, metadata, acc, derived_cluster)
385+
acc = _stitch(materialize_table, forest, metadata, acc, derived_cluster)
386386

387387
rows, columns = acc
388388
return [microdata_row_to_row(row) for row in rows], columns

syndiffix/synthesizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def __init__(
119119
converter.analyze_tree(self.forest.get_tree((ColumnId(col_id),)))
120120

121121
def sample(self) -> pd.DataFrame:
122-
def materialize_tree(forest: Forest, columns: list[ColumnId]) -> tuple[list[MicrodataRow], Combination]:
122+
def materialize_table(forest: Forest, columns: list[ColumnId]) -> tuple[list[MicrodataRow], Combination]:
123123
combination = tuple(sorted(columns))
124124
tree = forest.get_tree(combination)
125125
buckets = harvest(tree, self.forest.derive_unsafe_rng())
@@ -134,7 +134,7 @@ def materialize_tree(forest: Forest, columns: list[ColumnId]) -> tuple[list[Micr
134134
)
135135

136136
rows, root_combination = build_table(
137-
materialize_tree,
137+
materialize_table,
138138
self.forest,
139139
StitchingMetadata(self.column_is_integral, self.entropy_1dim),
140140
self.clusters,

tests/clustering/test_stitching.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_stitching() -> None:
3535
(ColumnId(2), ColumnId(3)): _build_rows(col_c_right, col_d),
3636
}
3737

38-
def materialize_tree(_forest: Forest, columns: list[ColumnId]) -> tuple[list[MicrodataRow], Combination]:
38+
def materialize_table(_forest: Forest, columns: list[ColumnId]) -> tuple[list[MicrodataRow], Combination]:
3939
combination = tuple(sorted(columns))
4040
return (microtables[combination], combination)
4141

@@ -47,7 +47,7 @@ def materialize_tree(_forest: Forest, columns: list[ColumnId]) -> tuple[list[Mic
4747
],
4848
)
4949

50-
rows, combination = build_table(materialize_tree, forest, _dummy_metadata(4), clusters)
50+
rows, combination = build_table(materialize_table, forest, _dummy_metadata(4), clusters)
5151

5252
assert combination == (0, 1, 2, 3)
5353
assert rows == [
@@ -67,7 +67,7 @@ def materialize_tree(_forest: Forest, columns: list[ColumnId]) -> tuple[list[Mic
6767
def test_empty_microtables() -> None:
6868
forest = load_forest("dummy.csv")
6969

70-
def materialize_tree(_forest: Forest, columns: list[ColumnId]) -> tuple[list[MicrodataRow], Combination]:
70+
def materialize_table(_forest: Forest, columns: list[ColumnId]) -> tuple[list[MicrodataRow], Combination]:
7171
combination = tuple(sorted(columns))
7272
return ([], combination)
7373

@@ -78,7 +78,7 @@ def materialize_tree(_forest: Forest, columns: list[ColumnId]) -> tuple[list[Mic
7878
],
7979
)
8080

81-
rows, combination = build_table(materialize_tree, forest, _dummy_metadata(3), clusters)
81+
rows, combination = build_table(materialize_table, forest, _dummy_metadata(3), clusters)
8282

8383
assert combination == (0, 1, 2)
8484
assert rows == []
@@ -98,7 +98,7 @@ def test_patching() -> None:
9898
(ColumnId(3),): _build_rows(col_d),
9999
}
100100

101-
def materialize_tree(_forest: Forest, columns: list[ColumnId]) -> tuple[list[MicrodataRow], Combination]:
101+
def materialize_table(_forest: Forest, columns: list[ColumnId]) -> tuple[list[MicrodataRow], Combination]:
102102
combination = tuple(sorted(columns))
103103
return (microtables[combination], combination)
104104

@@ -110,7 +110,7 @@ def materialize_tree(_forest: Forest, columns: list[ColumnId]) -> tuple[list[Mic
110110
],
111111
)
112112

113-
rows, combination = build_table(materialize_tree, forest, _dummy_metadata(4), clusters)
113+
rows, combination = build_table(materialize_table, forest, _dummy_metadata(4), clusters)
114114

115115
assert combination == (0, 1, 2, 3)
116116
assert rows == [

0 commit comments

Comments
 (0)