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
5b6a23f3
Commit
5b6a23f3
authored
3 years ago
by
mhocke
Browse files
Options
Downloads
Patches
Plain Diff
Abbreviate long texts in rendering
parent
46fc793f
No related branches found
No related tags found
1 merge request
!28
Draft: Update show_text render option + fix grid points
Pipeline
#49071
passed
3 years ago
Stage: package
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/robofish/io/file.py
+16
-7
16 additions, 7 deletions
src/robofish/io/file.py
src/robofish/io/utils.py
+12
-3
12 additions, 3 deletions
src/robofish/io/utils.py
with
28 additions
and
10 deletions
src/robofish/io/file.py
+
16
−
7
View file @
5b6a23f3
...
@@ -902,8 +902,12 @@ class File(h5py.File):
...
@@ -902,8 +902,12 @@ class File(h5py.File):
points
=
[
grid_points
,
goal_point
,
target_line
]
points
=
[
grid_points
,
goal_point
,
target_line
]
if
options
[
"
show_text
"
]:
if
options
[
"
show_text
"
]:
label_top_right
=
ax_text
.
text
(
0
,
0.95
,
""
,
fontsize
=
10
)
label_top_right
=
ax_text
.
text
(
label_bottom_right
=
ax_text
.
text
(
0
,
0
,
""
,
fontsize
=
10
)
0
,
0.90
,
""
,
fontsize
=
9
,
fontfamily
=
"
monospace
"
)
label_bottom_right
=
ax_text
.
text
(
0
,
0.1
,
""
,
fontsize
=
9
,
fontfamily
=
"
monospace
"
)
labels
=
[
label_top_right
,
label_bottom_right
]
labels
=
[
label_top_right
,
label_bottom_right
]
else
:
else
:
labels
=
[]
labels
=
[]
...
@@ -935,20 +939,25 @@ class File(h5py.File):
...
@@ -935,20 +939,25 @@ class File(h5py.File):
def
get_attributes_as_text
()
->
str
:
def
get_attributes_as_text
()
->
str
:
attrs
=
{}
attrs
=
{}
width
=
92
for
key
,
val
in
self
.
attrs
.
items
():
for
key
,
val
in
self
.
attrs
.
items
():
if
key
==
"
experiment_setup
"
:
if
key
==
"
experiment_setup
"
:
continue
continue
attrs
[
key
]
=
val
attrs
[
key
]
=
val
separator
=
"
-
"
*
130
+
"
\n
"
separator
=
"
\u2500
"
*
width
+
"
\n
"
text
=
""
text
=
""
text
+=
separator
text
+=
separator
text
+=
"
experiment_setup:
\n
%s
\n
"
%
utils
.
wrap_newline
(
text
+=
"
experiment_setup:
\n
"
self
.
attrs
[
"
experiment_setup
"
],
60
text
+=
utils
.
wrap_newline
(
text
=
self
.
attrs
[
"
experiment_setup
"
],
width
=
width
,
justify
=
True
,
maxlines
=
10
,
)
)
text
+=
separator
text
+=
"
\n
"
+
separator
text
+=
"
\n
"
.
join
(
text
+=
"
\n
"
.
join
(
[
[
"
%s: %s
"
%
(
key
,
utils
.
wrap_newline
(
val
,
60
))
f
"
{
key
}
:
{
utils
.
wrap_newline
(
text
=
val
,
width
=
width
-
len
(
key
)
-
2
,
justify
=
True
,
maxlines
=
3
)
}
"
for
key
,
val
in
attrs
.
items
()
for
key
,
val
in
attrs
.
items
()
]
]
)
)
...
...
This diff is collapsed.
Click to expand it.
src/robofish/io/utils.py
+
12
−
3
View file @
5b6a23f3
import
robofish.io
import
robofish.io
import
numpy
as
np
import
numpy
as
np
from
typing
import
Union
,
Iterable
from
typing
import
Union
,
Iterable
,
Optional
from
pathlib
import
Path
from
pathlib
import
Path
from
tqdm
import
tqdm
from
tqdm
import
tqdm
import
textwrap
import
textwrap
...
@@ -123,5 +123,14 @@ def get_all_data_from_paths(
...
@@ -123,5 +123,14 @@ def get_all_data_from_paths(
return
all_data
,
expected_settings
return
all_data
,
expected_settings
def
wrap_newline
(
text
,
width
=
60
):
def
wrap_newline
(
return
"
\n
"
.
join
(
textwrap
.
wrap
(
str
(
text
),
width
))
text
:
str
,
width
:
int
=
60
,
justify
:
bool
=
False
,
maxlines
:
Optional
[
int
]
=
None
)
->
str
:
text
=
str
(
text
).
strip
()
if
justify
:
text
=
text
.
replace
(
"
\n
"
,
"
"
)
lines
=
textwrap
.
wrap
(
text
,
width
)
if
maxlines
and
len
(
lines
)
>
maxlines
:
lines
=
lines
[:
maxlines
]
lines
[
-
1
]
=
lines
[
-
1
][:
width
-
3
]
+
"
...
"
return
"
\n
"
.
join
(
lines
)
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