Skip to content

Commit

Permalink
Fix pandas related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Aug 28, 2023
1 parent e7f773d commit 74398e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions holonote/annotate/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def delete_annotation(self, index):

def update_annotation_fields(self, index, **fields):
for column, value in fields.items():
self._field_df.loc[index][column] = value
self._field_df.loc[index, column] = value

self._edits.append({'operation':'update', 'id':index,
'fields' : [c for c in fields.keys()],
Expand Down Expand Up @@ -303,7 +303,7 @@ def define_points(self, dims, posx, posy=None):
raise KeyError(f'Keys {mismatches} do not match any fields entries')

dim2 = None if len(dims)==1 else dims[1]
value = zip(posx, pd.Series([None for el in range(len(posx))])) if len(dims)==1 else zip(posx, posy)
value = zip(posx, [None] * len(posx)) if len(dims)==1 else zip(posx, posy)
additions = pd.DataFrame({"region_type":'Point',
"dim1":dims[0],
"dim2":dim2,
Expand Down
12 changes: 7 additions & 5 deletions holonote/tests/test_connectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_add_row(self, database, request):
end = pd.Timestamp('2022-06-03')
description = 'A description'
insertion = {"uuid": id1, 'description':description, 'start':start, 'end':end}
df = pd.DataFrame({"uuid":pd.Series([id1], dtype=object),
df = pd.DataFrame({"uuid":[database.primary_key.cast(id1)],
'description':[description], 'start':[start], 'end':[end]}).set_index("uuid")
database.add_row(**insertion)
pd.testing.assert_frame_equal(database.load_dataframe(), df)
Expand All @@ -102,10 +102,12 @@ def test_add_three_rows_delete_one(self, database):
'start':pd.Timestamp('2026-06-01'),
'end':pd.Timestamp('2026-06-03')}

df_data = {'uuid': pd.Series([insertion1['uuid'], insertion3['uuid']], dtype=object),
'description':[insertion1['description'], insertion3['description']],
'start':[insertion1['start'], insertion3['start']],
'end':[insertion1['end'], insertion3['end']]}
df_data = {
'uuid': map(database.primary_key.cast, [insertion1['uuid'], insertion3['uuid']]),
'description':[insertion1['description'], insertion3['description']],
'start':[insertion1['start'], insertion3['start']],
'end':[insertion1['end'], insertion3['end']]
}
df = pd.DataFrame(df_data).set_index('uuid')
database.add_row(**insertion1)
database.add_row(**insertion2)
Expand Down

0 comments on commit 74398e1

Please sign in to comment.