Skip to content

Commit

Permalink
Add metadata to dt equality check (#449)
Browse files Browse the repository at this point in the history
* Add metadata to dt equality check

* Add release note
  • Loading branch information
tamargrey committed Dec 11, 2020
1 parent 82e18a1 commit 8f3c6cc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/source/release_notes.rst
Expand Up @@ -12,6 +12,7 @@ Release Notes
* Fixes
* Update DataColumn name when using setitem on column with no name (:pr:`426`)
* Don't allow pickle serialization for Koalas DataFrames (:pr:`432`)
* Check DataTable metadata in equality check (:pr:`449`)
* Changes
* Update links to use alteryx org Github URL (:pr:`423`)
* Support column names of any type allowed by the underlying DataFrame (:pr:`442`)
Expand Down
2 changes: 2 additions & 0 deletions woodwork/datatable.py
Expand Up @@ -114,6 +114,8 @@ def __eq__(self, other, deep=True):
return False
if set(self.columns.keys()) != set(other.columns.keys()):
return False
if self.metadata != other.metadata:
return False
for col_name in self.columns.keys():
if self[col_name] != other[col_name]:
return False
Expand Down
5 changes: 5 additions & 0 deletions woodwork/tests/datatable/test_datatable.py
Expand Up @@ -2595,6 +2595,11 @@ def test_datatable_equality(sample_combos):
assert dt_with_ltypes == dt_numeric_time_index.set_types(logical_types={'full_name': Categorical})
assert dt_with_ltypes != dt_numeric_time_index.set_types(logical_types={'full_name': Categorical()})

dt_with_metadata = DataTable(sample_df, index='id', metadata={'created_by': 'user1'})
assert DataTable(sample_df, index='id') != dt_with_metadata
assert DataTable(sample_df, index='id', metadata={'created_by': 'user1'}) == dt_with_metadata
assert DataTable(sample_df, index='id', metadata={'created_by': 'user2'}) != dt_with_metadata


def test_datatable_rename_errors(sample_df):
dt = DataTable(sample_df, index='id', time_index='signup_date')
Expand Down

0 comments on commit 8f3c6cc

Please sign in to comment.