Skip to content

Commit

Permalink
[#137] Add type hints to LinkStepExplode._explode() and ._expand()
Browse files Browse the repository at this point in the history
  • Loading branch information
riley-harper committed Jun 5, 2024
1 parent bd69a9e commit e7e6225
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions hlink/linking/matching/link_step_explode.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
# in this project's top-level directory, and also on-line at:
# https://github.com/ipums/hlink

from typing import Any

from pyspark.sql import Column, DataFrame
from pyspark.sql.functions import array, explode, col

import hlink.linking.core.comparison as comparison_core
from . import _helpers as matching_helpers

from hlink.linking.link_step import LinkStep


Expand Down Expand Up @@ -64,7 +66,15 @@ def _run(self):
),
)

def _explode(self, df, comparisons, comparison_features, blocking, id_column, is_a):
def _explode(
self,
df: DataFrame,
comparisons: dict[str, Any],
comparison_features: list[dict[str, Any]],
blocking: list[dict[str, Any]],
id_column: str,
is_a: bool,
) -> DataFrame:
# comp_feature_names, dist_features_to_run, feature_columns = comparison_core.get_feature_specs_from_comp(
# comparisons, comparison_features
# )
Expand Down Expand Up @@ -159,7 +169,7 @@ def _explode(self, df, comparisons, comparison_features, blocking, id_column, is
exploded_df = exploded_df.select(explode_selects)
return exploded_df

def _expand(self, column_name, expand_length):
def _expand(self, column_name: str, expand_length: int) -> Column:
return array(
[
col(column_name).cast("int") + i
Expand Down

0 comments on commit e7e6225

Please sign in to comment.