Showing the changes to python/tests/utils.py (1 of 5 files). Show all
Unified · Split
| @@ -4,8 +4,10 @@ def array_from_text_file(filename, dtype = 'float'): · 3 unmodified lines | ||
| 4 | 4 | import os.path |
| 5 | 5 | from numpy import array |
| 6 | 6 | filename = os.path.join(os.path.dirname(__file__), filename) |
| 7 | − return array([line.split() for line in open(filename).readlines()], | |
| 8 | − dtype = dtype) | |
| 7 | + with open(filename) as f: | |
| 8 | + lines = f.readlines() | |
| 9 | + return array([line.split() for line in lines], | |
| 10 | + dtype = dtype) | |
| 9 | 11 | |
| 10 | 12 | def list_all_sounds(rel_dir): |
| 11 | 13 | import os.path, glob |