Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
io
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bioroboticslab
robofish
io
Commits
3c0d61be
Commit
3c0d61be
authored
4 years ago
by
Andi Gerken
Browse files
Options
Downloads
Patches
Plain Diff
Added possibility to create files with path
parent
a07a5180
No related branches found
No related tags found
No related merge requests found
Pipeline
#35126
failed
4 years ago
Stage: test
Stage: package
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/robofish/evaluate/app.py
+13
-0
13 additions, 0 deletions
src/robofish/evaluate/app.py
src/robofish/io/file.py
+5
-3
5 additions, 3 deletions
src/robofish/io/file.py
tests/robofish/io/test_file.py
+11
-0
11 additions, 0 deletions
tests/robofish/io/test_file.py
with
29 additions
and
3 deletions
src/robofish/evaluate/app.py
+
13
−
0
View file @
3c0d61be
...
@@ -30,6 +30,19 @@ def evaluate(args=None):
...
@@ -30,6 +30,19 @@ def evaluate(args=None):
nargs
=
"
+
"
,
nargs
=
"
+
"
,
help
=
"
The paths to io/hdf5 files. Multiple paths can be given which will be shown in different colors
"
,
help
=
"
The paths to io/hdf5 files. Multiple paths can be given which will be shown in different colors
"
,
)
)
parser
.
add_argument
(
"
--names
"
,
type
=
str
,
nargs
=
"
+
"
,
help
=
"
Names, that should be used in the graphs instead of the pahts
"
,
default
=
None
,
)
parser
.
add_argument
(
"
--save_folder
"
,
type
=
str
,
help
=
"
Output folder for saving resulting graphics
"
,
default
=
None
,
)
if
args
is
None
:
if
args
is
None
:
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
...
...
This diff is collapsed.
Click to expand it.
src/robofish/io/file.py
+
5
−
3
View file @
3c0d61be
...
@@ -71,7 +71,8 @@ class File(h5py.File):
...
@@ -71,7 +71,8 @@ class File(h5py.File):
self
.
_tf_path
=
Path
(
temp_dir
.
name
)
/
self
.
_name
self
.
_tf_path
=
Path
(
temp_dir
.
name
)
/
self
.
_name
self
.
load
(
path
,
strict_validate
)
self
.
load
(
path
,
strict_validate
)
if
path
is
None
:
if
path
is
None
or
not
Path
(
path
).
exists
():
# Initialize new file
# Initialize new file
assert
world_size_cm
is
not
None
and
format_version
is
not
None
assert
world_size_cm
is
not
None
and
format_version
is
not
None
...
@@ -99,9 +100,11 @@ class File(h5py.File):
...
@@ -99,9 +100,11 @@ class File(h5py.File):
path: path to a io file as a string or path object
path: path to a io file as a string or path object
strict_validate: optional boolean, if the file should be strictly validated, when loaded from a path. The default is False.
strict_validate: optional boolean, if the file should be strictly validated, when loaded from a path. The default is False.
"""
"""
if
path
is
not
None
:
self
.
_f_path
=
Path
(
path
)
if
path
is
not
None
and
Path
(
path
).
exists
():
if
path
is
not
None
and
Path
(
path
).
exists
():
logging
.
info
(
f
"
Opening File
{
path
}
"
)
logging
.
info
(
f
"
Opening File
{
path
}
"
)
self
.
_f_path
=
Path
(
path
)
shutil
.
copyfile
(
self
.
_f_path
,
self
.
_tf_path
)
shutil
.
copyfile
(
self
.
_f_path
,
self
.
_tf_path
)
super
().
__init__
(
self
.
_tf_path
,
"
r+
"
)
super
().
__init__
(
self
.
_tf_path
,
"
r+
"
)
self
.
validate
(
strict_validate
)
self
.
validate
(
strict_validate
)
...
@@ -149,7 +152,6 @@ class File(h5py.File):
...
@@ -149,7 +152,6 @@ class File(h5py.File):
calendar_time_points
:
Iterable
=
None
,
calendar_time_points
:
Iterable
=
None
,
default
:
bool
=
False
,
default
:
bool
=
False
,
):
):
print
(
frequency_hz
,
monotonic_time_points_us
)
if
frequency_hz
is
not
None
and
monotonic_time_points_us
is
not
None
:
if
frequency_hz
is
not
None
and
monotonic_time_points_us
is
not
None
:
logging
.
exception
(
"
Specify either frequency_hz or timestamps, not both.
"
)
logging
.
exception
(
"
Specify either frequency_hz or timestamps, not both.
"
)
...
...
This diff is collapsed.
Click to expand it.
tests/robofish/io/test_file.py
+
11
−
0
View file @
3c0d61be
...
@@ -15,6 +15,7 @@ def full_path(path):
...
@@ -15,6 +15,7 @@ def full_path(path):
valid_file_path
=
full_path
(
"
../../resources/valid.hdf5
"
)
valid_file_path
=
full_path
(
"
../../resources/valid.hdf5
"
)
created_by_test_path
=
full_path
(
"
../../resources/created_by_test.hdf5
"
)
created_by_test_path
=
full_path
(
"
../../resources/created_by_test.hdf5
"
)
created_by_test_path_2
=
full_path
(
"
../../resources/created_by_test_2.hdf5
"
)
def
test_constructor
():
def
test_constructor
():
...
@@ -23,6 +24,15 @@ def test_constructor():
...
@@ -23,6 +24,15 @@ def test_constructor():
sf
.
validate
()
sf
.
validate
()
def
test_new_file_w_path
():
sf
=
robofish
.
io
.
File
(
created_by_test_path_2
,
world_size_cm
=
[
100
,
100
],
frequency_hz
=
25
)
sf
.
create_entity
(
"
fish
"
)
sf
.
save
()
sf
.
validate
()
def
test_missing_attribute
():
def
test_missing_attribute
():
sf
=
robofish
.
io
.
File
(
world_size_cm
=
[
10
,
10
])
sf
=
robofish
.
io
.
File
(
world_size_cm
=
[
10
,
10
])
sf
.
attrs
.
pop
(
"
world_size_cm
"
)
sf
.
attrs
.
pop
(
"
world_size_cm
"
)
...
@@ -164,6 +174,7 @@ def test_validate_created_file_after_reloading():
...
@@ -164,6 +174,7 @@ def test_validate_created_file_after_reloading():
def
test_z_cleanup
():
def
test_z_cleanup
():
"""
This cleans up after all tests and removes all test artifacts
"""
"""
This cleans up after all tests and removes all test artifacts
"""
created_by_test_path
.
unlink
()
created_by_test_path
.
unlink
()
created_by_test_path_2
.
unlink
()
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment