Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c8388f9

Browse filesBrowse files
committed
Close files or use safer access functions
1 parent f5da34f commit c8388f9
Copy full SHA for c8388f9

File tree

Expand file treeCollapse file tree

1 file changed

+2
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-1
lines changed

‎examples/pylab_examples/mri_with_eeg.py

Copy file name to clipboardExpand all lines: examples/pylab_examples/mri_with_eeg.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
dfile = cbook.get_sample_data('s1045.ima.gz')
2121
im = np.fromstring(dfile.read(), np.uint16).astype(float)
2222
im.shape = (256, 256)
23+
dfile.close()
2324

2425
# Plot the MRI image
2526
ax0 = fig.add_subplot(2, 2, 1)
@@ -41,7 +42,7 @@
4142
numSamples, numRows = 800, 4
4243
eegfile = cbook.get_sample_data('eeg.dat', asfileobj=False)
4344
print('Loading EEG %s' % eegfile)
44-
data = np.fromstring(open(eegfile, 'rb').read(), float)
45+
data = np.fromfile(eegfile, dtype=float)
4546
data.shape = (numSamples, numRows)
4647
t = 10.0 * np.arange(numSamples) / numSamples
4748

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.