Skip to content

Instantly share code, notes, and snippets.

@crackwitz
Created May 29, 2017 14:19
Show Gist options
  • Save crackwitz/e13b600a1a0158cc3301918b7edf5200 to your computer and use it in GitHub Desktop.
Save crackwitz/e13b600a1a0158cc3301918b7edf5200 to your computer and use it in GitHub Desktop.
#!/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