Skip to content

Commit

Permalink
changed df comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
adamamer20 committed Jul 4, 2024
1 parent 9264523 commit d8ea0c4
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions tests/test_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,28 +324,16 @@ def test_remove(
def test_select(self, fix_AgentsDF: AgentsDF):
agents = fix_AgentsDF

def compare_dataframes(df1, df2):
if isinstance(df1, pd.DataFrame) and isinstance(df2, pd.DataFrame):
# For pandas DataFrames
return df1.equals(df2)
elif isinstance(df1, pl.DataFrame) and isinstance(df2, pl.DataFrame):
# For polars DataFrames
return df1.frame_equal(df2)
else:
# If the types are not the same, they are not equal
return False

# Test with default arguments. Should select all agents
selected = agents.select(inplace=False)
active_agents_dict = selected.active_agents
agents_dict = selected.agents
assert active_agents_dict.keys() == agents_dict.keys()
# Using assert to compare all DataFrames in the dictionaries
assert (active_agents_dict.values()[0] == agents_dict.values()[0]).all().all()
assert all(
compare_dataframes(df_active, df_all)
for df_active, df_all in zip(
active_agents_dict.values(), agents_dict.values()
)
series.all()
for series in (active_agents_dict.values()[1] == agents_dict.values()[1])
)

# Test with a mask
Expand Down

0 comments on commit d8ea0c4

Please sign in to comment.