Skip to content
Snippets Groups Projects
Commit 9f2ae981 authored by Andi Gerken's avatar Andi Gerken
Browse files

Optimized evaluation performance heavily.

Bugfix in relative orientation evaluation.
parent 5a78c9f7
Branches
Tags
No related merge requests found
...@@ -22,13 +22,13 @@ def function_dict(): ...@@ -22,13 +22,13 @@ def function_dict():
"turn": base.evaluate_turn, "turn": base.evaluate_turn,
"orientation": base.evaluate_orientation, "orientation": base.evaluate_orientation,
"relative_orientation": base.evaluate_relative_orientation, "relative_orientation": base.evaluate_relative_orientation,
"distance_to_wall": base.evaluate_distanceToWall, "distance_to_wall": base.evaluate_distance_to_wall,
"tank_positions": base.evaluate_tankpositions, "tank_position": base.evaluate_tank_position,
"tracks": base.evaluate_tracks, "tracks": base.evaluate_tracks,
"tracks_distance": base.evaluate_tracks_distance, "tracks_distance": base.evaluate_tracks_distance,
"socialVec": base.evaluate_socialVec, "social_vector": base.evaluate_social_vector,
"follow_iid": base.evaluate_follow_iid, "follow_iid": base.evaluate_follow_iid,
"individual_speeds": base.evaluate_individual_speeds, "individual_speed": base.evaluate_individual_speed,
"individual_iid": base.evaluate_individual_iid, "individual_iid": base.evaluate_individual_iid,
"all": base.evaluate_all, "all": base.evaluate_all,
} }
......
This diff is collapsed.
...@@ -37,12 +37,11 @@ def print_file(args=None): ...@@ -37,12 +37,11 @@ def print_file(args=None):
if args is None: if args is None:
args = parser.parse_args() args = parser.parse_args()
sf = robofish.io.File(path=args.path, strict_validate=False) with robofish.io.File(path=args.path, strict_validate=False) as f:
print(f.to_string(args.output_format))
print(sf.to_string(args.output_format)) print()
print() valid = f.validate(strict_validate=False)[0]
valid = sf.validate(strict_validate=False)[0] print("Valid file" if valid else "Invalid file")
print("Valid file" if valid else "Invalid file")
return not valid return not valid
...@@ -95,6 +94,7 @@ def validate(args=None): ...@@ -95,6 +94,7 @@ def validate(args=None):
error_code = 0 error_code = 0
for file, sf in sf_dict.items(): for file, sf in sf_dict.items():
filled_file = (str)(file).ljust(max_filename_width + 3) filled_file = (str)(file).ljust(max_filename_width + 3)
file.close()
validity, validity_message = sf.validate(strict_validate=False) validity, validity_message = sf.validate(strict_validate=False)
if not validity: if not validity:
error_code = 1 error_code = 1
......
...@@ -7,6 +7,7 @@ import logging ...@@ -7,6 +7,7 @@ import logging
import numpy as np import numpy as np
import pandas import pandas
import random import random
import deprecation
def now_iso8061() -> str: def now_iso8061() -> str:
...@@ -20,6 +21,11 @@ def now_iso8061() -> str: ...@@ -20,6 +21,11 @@ def now_iso8061() -> str:
) )
@deprecation.deprecated(
deprecated_in="0.2.10",
removed_in="0.3",
details="Loading all files first and then handling them is slow, memory intensive and inconvenient. Don't use this method.",
)
def read_multiple_files( def read_multiple_files(
paths: Union[Path, str, Iterable[Path], Iterable[str]], paths: Union[Path, str, Iterable[Path], Iterable[str]],
strict_validate: bool = False, strict_validate: bool = False,
......
...@@ -6,8 +6,7 @@ import numpy as np ...@@ -6,8 +6,7 @@ import numpy as np
def test_get_all_poses_from_paths(): def test_get_all_poses_from_paths():
valid_file_path = utils.full_path(__file__, "../../resources/valid_1.hdf5") valid_file_path = utils.full_path(__file__, "../../resources/valid_1.hdf5")
poses, frequency = robofish.evaluate.get_all_poses_from_paths([valid_file_path]) poses, file_settings = robofish.evaluate.get_all_poses_from_paths([valid_file_path])
# (1 input array, 1 file, 2 fishes, 100 timesteps, 4 poses) # (1 input array, 1 file, 2 fishes, 100 timesteps, 4 poses)
assert np.array(poses).shape == (1, 1, 2, 100, 4) assert np.array(poses).shape == (1, 1, 2, 100, 4)
assert frequency == 25
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment