Created
May 29, 2017 14:19
-
-
Save crackwitz/e13b600a1a0158cc3301918b7edf5200 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import numpy as np | |
mydtype = np.dtype({ | |
'names': 'x y xy'.split(), | |
'formats': 'f4 f4 2f4'.split(), | |
'offsets': [0, 4, 0] | |
}) | |
mapfile = "numpy-union-example.dat" | |
if os.path.exists(mapfile): | |
os.unlink(mapfile) | |
mapped = np.memmap( | |
mapfile, | |
shape=(1,), | |
dtype=mydtype, | |
mode='w+') | |
mapped[0]['xy'] = np.nan | |
record = np.empty((), dtype=mydtype) | |
record['xy'] = np.nan | |
mapped[0] = record # THIS is where it crashes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment