Skip to content

Commit 72a37cb

Browse files
authored
Do not include empty lists/dicts in NWBFile repr(). Fix #940 (#998)
1 parent af9c98a commit 72a37cb

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

src/pynwb/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ def __repr__(self):
165165
template = "\n{} {}\nFields:\n""".format(getattr(self, 'name'), type(self))
166166
for k in sorted(self.fields): # sorted to enable tests
167167
v = self.fields[k]
168-
template += " {}: {}\n".format(k, self.__smart_str(v, 1))
168+
if not hasattr(v, '__len__') or len(v) > 0:
169+
template += " {}: {}\n".format(k, self.__smart_str(v, 1))
169170
return template
170171

171172
@staticmethod

tests/unit/test_core.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -335,22 +335,11 @@ def test_print_file(self):
335335
name <class 'pynwb.base.TimeSeries'>,
336336
name2 <class 'pynwb.base.TimeSeries'>
337337
}
338-
analysis: { }
339-
devices: { }
340-
electrode_groups: { }
341338
epoch_tags: {
342339
tag1,
343340
tag2
344341
}
345342
epochs: epochs <class 'pynwb.epoch.TimeIntervals'>
346-
ic_electrodes: { }
347-
imaging_planes: { }
348-
intervals: { }
349-
lab_meta_data: { }
350-
ogen_sites: { }
351-
processing: { }
352-
stimulus: { }
353-
stimulus_template: { }
354343
""")
355344

356345

0 commit comments

Comments
 (0)