Hi Jacob,
PyQSTEM sometimes crashes when you reuse the same object with a different number of slices. Using a new pyqstem object in each iteration instead leads to a memory leak.
The attached script shows the problem. On a Mac, it gives the error
Corrupt value: 0x3f0278d13f0278d1
Python(6133,0x1136c5dc0) malloc: *** set a breakpoint in malloc_error_break to debug
Abort trap: 6
On linux, it just gives a Segmentation fault (core dumped). It is not 100% reproducible, the attached script crashes every second time or so.