Changes between Version 22 and Version 23 of FAQ


Ignore:
Timestamp:
Jan 13, 2011, 3:14:53 PM (10 years ago)
Author:
dtodd
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FAQ

    v22 v23  
    1414
    1515'''[#WhydoesSimulationappeartohangorslowdownforlargespinsystems Why does Simulation appear to hang or slow down for large spin systems?]'''
     16
     17'''[#MyPYGAMMAProgramIsUnstableorBehavesBadlyandYetitLooksFine My PYGAMMA Program Is Unstable or Behaves Badly and Yet it Looks Fine?]'''
    1618
    1719
     
    3638Note: The time it takes to run these specific jobs is virtually identical in GAMMA versus Simulation - as there is little overhead (e.g. converting arrays between python and C++) when compared to the overall time of the calculations.
    3739
     40=== My PYGAMMA Program Is Unstable or Behaves Badly and Yet it Looks Fine? ===
     41Under certain circumstances your pyGamma code can be written in perfectly good Python style yet give unpredictable errors (or no error at all). This is caused by the default behavior of SWIG when applied to C++ code to create Python interfaces. If you have written code that involves subroutines, like this pseudocode,
     42{{{
     43import pygamma as pg
     44
     45def binning()
     46   # do something interesting
     47   pass
     48
     49def my_pulse_sequence()
     50    sys = pg.spin_system()
     51    # do something else interesting
     52    ACQ = pg.acquire1D(pygamma.gen_op(D), H, 0.000001)
     53    mx = ACQ.table(sigma0)
     54    return mx
     55
     56mxa = my_pulse_sequence()
     57
     58# About to have a problem...
     59binning(mxa, field, spin_count)
     60}}}
     61
     62You are at risk of having one of a number of problems. This is because mxa points to a an object that is contained within another object that has been made available for deletion. So far we have see these errors:
     63
     64    * Segfault
     65    * Bus Errors
     66    * Pointers to uninitialized data
     67    * An error box saying something bad happened
     68    * Pointer to the correct value with no notification that it may not be valid the next time you look
     69
     70We list here a [gamma:SwigIssueSegfault detailed description of the problem and suggest some work arounds].
     71
     72In this example we are returning a transition table (TTable1D), which is an object that is contained within ACQ, an acquire1D object. The