From 1bb0b605d9a254e99c78a7b98bfea938bca95e7b Mon Sep 17 00:00:00 2001 From: Nate Parsons <4307001+thehomebrewnerd@users.noreply.github.com> Date: Wed, 1 May 2024 17:07:22 -0500 Subject: [PATCH] Move flatten_list util function into feature_discovery (#2702) * move util func * update release notes * remove dask restriction * update release notes --- docs/source/release_notes.rst | 1 + featuretools/feature_discovery/feature_discovery.py | 3 +-- featuretools/feature_discovery/utils.py | 4 ++++ featuretools/tests/testing_utils/generate_fake_dataframe.py | 6 ++---- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/source/release_notes.rst b/docs/source/release_notes.rst index ddaf5aecc6..8370fa29e4 100644 --- a/docs/source/release_notes.rst +++ b/docs/source/release_notes.rst @@ -7,6 +7,7 @@ Future Release ============== * Enhancements * Fixes + * Move ``flatten_list`` util function into ``feature_discovery`` module to fix import bug (:pr:`2702`) * Changes * Temporarily restrict Dask version (:pr:`2694`) * Remove support for creating ``EntitySets`` from Dask or Pyspark dataframes (:pr:`2705`) diff --git a/featuretools/feature_discovery/feature_discovery.py b/featuretools/feature_discovery/feature_discovery.py index 36826b056c..46fb575c1e 100644 --- a/featuretools/feature_discovery/feature_discovery.py +++ b/featuretools/feature_discovery/feature_discovery.py @@ -9,9 +9,8 @@ from featuretools.feature_discovery.FeatureCollection import FeatureCollection from featuretools.feature_discovery.LiteFeature import LiteFeature -from featuretools.feature_discovery.utils import column_schema_to_keys +from featuretools.feature_discovery.utils import column_schema_to_keys, flatten_list from featuretools.primitives.base.primitive_base import PrimitiveBase -from featuretools.tests.testing_utils.generate_fake_dataframe import flatten_list def _index_column_set(column_set: List[ColumnSchema]) -> List[Tuple[str, int]]: diff --git a/featuretools/feature_discovery/utils.py b/featuretools/feature_discovery/utils.py index 01d942e596..ed334c29c2 100644 --- a/featuretools/feature_discovery/utils.py +++ b/featuretools/feature_discovery/utils.py @@ -75,3 +75,7 @@ def get_primitive_return_type(primitive: PrimitiveBase) -> ColumnSchema: if isinstance(return_type, list): return_type = return_type[0] return return_type + + +def flatten_list(nested_list): + return [item for sublist in nested_list for item in sublist] diff --git a/featuretools/tests/testing_utils/generate_fake_dataframe.py b/featuretools/tests/testing_utils/generate_fake_dataframe.py index 5b39ecf6d7..96112a515c 100644 --- a/featuretools/tests/testing_utils/generate_fake_dataframe.py +++ b/featuretools/tests/testing_utils/generate_fake_dataframe.py @@ -5,6 +5,8 @@ import woodwork.type_sys.type_system as ww_type_system from woodwork import logical_types +from featuretools.feature_discovery.utils import flatten_list + logical_type_mapping = { logical_types.Boolean.__name__: [True, False], logical_types.BooleanNullable.__name__: [True, False, pd.NA], @@ -31,10 +33,6 @@ } -def flatten_list(nested_list): - return [item for sublist in nested_list for item in sublist] - - def generate_fake_dataframe( col_defs=[("f_1", "Numeric"), ("f_2", "Datetime", "time_index")], n_rows=10,