Skip to content

Fix recursive_stringify

mhocke requested to merge stringify into master

I made some changes to recursive_stringify.

  • attribute values that are long get forced to one line and abbreviated if needed.
  • alignment of attribute values and dataset shapes is improved:
    • at least siblings now have consistent alignment
  • Tree lines are now more clear (to me at least)
  • Gitlab renders the text with increased line height (see plain text outputs below). The vertical box-drawing characters should connect if the terminal is set up correctly (see screenshot).

File I used for testing: test.hdf5

Screen_Shot_2022-03-11_at_17.44.10

New output on testfile:

├─── experiment_setup                   Robots communicating with fish: Investigating the role of electric signals and ...
├─── experiment_type                    baseline2
├─── format_url                         https://git.imp.fu-berlin.de/bioroboticslab/robofish/track_format/-/releases/1.0
├─── format_version                     [1 0]
├─── forward_velocity                   1.0
├─── hostname                           dory
├─── leading_goal_reached_threshold_cm  5.0
├─── leading_goals                      [[20, 20], [80, 80]]
├─── leading_lost_fish_threshold_ts     10
├─── locomotion_type                    random
├─── passing_angle_deg                  20
├─── passing_length_ts                  50
├─── passing_random_length_ts           100
├─── random_locomotion_forward_cm       6.0
├─── random_locomotion_scale            0.1
├─── recording_length_seconds           120
├─── safe_wall_distance_cm              10.0
├─── safety_distance_cm                 10.0
├─── simulation                         True
├─── trajectories_dir                   /home/mathis/trajectories
├─── turn_velocity                      1.0
├─── world_size_cm                      [100. 100.]
├─┬─ entities
│ ├─┬─ Fish 0
│ │ ├─── category      organism
│ │ ├─── orientations  Shape (2255, 2)
│ │ └─┬─ positions     Shape (2255, 2)
│ │   ├─── bar  test second attribute of dataset.
│ │   └─── foo  test attribute of dataset.
│ ├─┬─ Fish 1
│ │ ├─── category      organism
│ │ ├─── orientations  Shape (2255, 2)
│ │ └─── positions     Shape (2255, 2)
│ └─┬─ Robot
│   ├─── category          robot
│   ├─── goals             Shape (2255, 2)
│   ├─── locomotion_state  Shape (2255,)
│   ├─── orientations      Shape (2255, 2)
│   ├─── positions         Shape (2255, 2)
│   ├─── target_fish_id    Shape (2255,)
│   └─── targets           Shape (2255, 2)
└─┬─ samplings
  ├─── default           default_sampling
  └─┬─ default_sampling
    ├─── frequency_hz              25.0
    ├─── calendar_time_points      Shape (2255,)
    └─┬─ monotonic_time_points_us  Shape (2255,)
      └─── bar  test attr of dataset at end of file. test attr of dataset at end of file. test attr of dataset at end o...


Valid file

Old output for comparison:

 experiment_setup:	
Robots communicating with fish: Investigating the role of electric
signals and locomotor displays following episodes of mutual attention
in weakly electric fish

*NOTE: This trajectory was created in simulation!*

In baseline experiment 2, we will test whether locomotor interaction
alone (without synchronization) will cause behavioural change in the
fish. The robot will emit electrical playback of natural EODs assembled
to a static sequence of randomized IDI-durations (open- loop). This
means, the robot will not interact electrically with the fish (no
synchronization).
 experiment_type:	baseline2
 format_url:	https://git.imp.fu-berlin.de/bioroboticslab/robofish/track_format/-/releases/1.0
 format_version:	[1 0]
 forward_velocity:	1.0
 hostname:	dory
 leading_goal_reached_threshold_cm:	5.0
 leading_goals:	[[20, 20], [80, 80]]
 leading_lost_fish_threshold_ts:	10
 locomotion_type:	random
 passing_angle_deg:	20
 passing_length_ts:	50
 passing_random_length_ts:	100
 random_locomotion_forward_cm:	6.0
 random_locomotion_scale:	0.1
 recording_length_seconds:	120
 safe_wall_distance_cm:	10.0
 safety_distance_cm:	10.0
 simulation:	True
 trajectories_dir:	/home/mathis/trajectories
 turn_velocity:	1.0
 world_size_cm:	[100. 100.]
| entities
|---| Fish 0
|---|--- category:	organism
|---|--- orientations:	 Shape (2255, 2)
|---|--- positions:	 Shape (2255, 2)
|---|---|--- bar:	test second attribute of dataset.
|---|---|--- foo:	test attribute of dataset.
|---| Fish 1
|---|--- category:	organism
|---|--- orientations:	 Shape (2255, 2)
|---|--- positions:	 Shape (2255, 2)
|---| Robot
|---|--- category:	robot
|---|--- goals:	 Shape (2255, 2)
|---|--- locomotion_state:	 Shape (2255,)
|---|--- orientations:	 Shape (2255, 2)
|---|--- positions:	 Shape (2255, 2)
|---|--- target_fish_id:	 Shape (2255,)
|---|--- targets:	 Shape (2255, 2)
| samplings
|--- default:	default_sampling
|---| default_sampling
|---|--- frequency_hz:	25.0
|---|--- calendar_time_points:	 Shape (2255,)
|---|--- monotonic_time_points_us:	 Shape (2255,)
|---|---|--- bar:	test attr of dataset at end of file.
test attr of dataset at end of file.
test attr of dataset at end of file.
test attr of dataset at end of file.
test attr of dataset at end of file.



Valid file

Merge request reports