fix bug where linker was not deepcopied
@@ -84,21 +84,22 @@ def cumulative_comparisons_generated_by_blocking_rules(
unique_id_column_name=None,
):
+ linker = deepcopy(linker)
+
settings_obj = get_link_type_settings_obj(
linker=linker,
link_type=link_type,
unique_id_column_name=unique_id_column_name,
)
linker._settings_obj_ = settings_obj
+
# Deepcopy our original linker so we can safely adjust our settings.
# This is particularly important to ensure we don't overwrite our
# original blocking rules.
- copied_linker = deepcopy(linker)
+
if blocking_rules:
brs_as_objs = settings_obj._brs_as_objs(blocking_rules)
- copied_linker._settings_obj_._blocking_rules_to_generate_predictions = (
- brs_as_objs
- )
+ linker._settings_obj_._blocking_rules_to_generate_predictions = brs_as_objs
# Calculate the Cartesian Product
if len(linker._input_tables_dict) == 1:
@@ -123,10 +124,10 @@ def cumulative_comparisons_generated_by_blocking_rules(
# Calculate the total number of rows generated by each blocking rule
linker._initialise_df_concat_with_tf(materialise=False)
- sql = block_using_rules_sql(copied_linker)
+ sql = block_using_rules_sql(linker)
linker._enqueue_sql(sql, "__splink__df_blocked_data")
- brs_as_objs = copied_linker._settings_obj_._blocking_rules_to_generate_predictions
+ brs_as_objs = linker._settings_obj_._blocking_rules_to_generate_predictions
group_by = (
"group by match_key order by cast(match_key as int) desc"
if len(brs_as_objs) > 1
@@ -137,6 +138,7 @@ def cumulative_comparisons_generated_by_blocking_rules(
select count(*) as row_count
from __splink__df_blocked_data
{group_by}
+
"""
linker._enqueue_sql(sql, "__splink__df_count_cumulative_blocks")
cumulative_blocking_rule_count = linker._execute_sql_pipeline()
