Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for tensor_db get_aggregated_tensor returns tuple in corner case 1087 #1121

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openfl/databases/tensor_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def get_aggregated_tensor(
& (self.tensor_db["tags"] == tags)
]["nparray"]
if len(raw_df) > 0:
return np.array(raw_df.iloc[0]), {}
return np.array(raw_df.iloc[0])

for col in collaborator_names:
new_tags = change_tags(tags, add_field=col)
Expand Down
4 changes: 2 additions & 2 deletions tests/openfl/databases/test_tensor_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_get_aggregated_tensor_directly(nparray, tensor_key):
)

db.cache_tensor({tensor_key: nparray})
agg_nparray, agg_metadata_dict = db.get_aggregated_tensor(tensor_key, {}, WeightedAverage())
agg_nparray = db.get_aggregated_tensor(tensor_key, {}, WeightedAverage())

assert np.array_equal(nparray, agg_nparray)

Expand Down Expand Up @@ -170,7 +170,7 @@ def test_get_aggregated_tensor(nparray, tensor_key):
db.cache_tensor({tensor_key: nparray})

collaborator_weight_dict = {'col1': 0.5, 'col2': 0.5}
agg_nparray, agg_metadata_dict = db.get_aggregated_tensor(
agg_nparray = db.get_aggregated_tensor(
tensor_key, collaborator_weight_dict, WeightedAverage())

assert np.array_equal(nparray, agg_nparray)
Expand Down
Loading