Skip to content

Commit

Permalink
Move flatten_list util function into feature_discovery (#2702)
Browse files Browse the repository at this point in the history
* move util func

* update release notes

* remove dask restriction

* update release notes
  • Loading branch information
thehomebrewnerd authored May 1, 2024
1 parent 95f490b commit 1bb0b60
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/source/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
3 changes: 1 addition & 2 deletions featuretools/feature_discovery/feature_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand Down
4 changes: 4 additions & 0 deletions featuretools/feature_discovery/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
6 changes: 2 additions & 4 deletions featuretools/tests/testing_utils/generate_fake_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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,
Expand Down

0 comments on commit 1bb0b60

Please sign in to comment.