You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
acroucher edited this page Sep 15, 2014
·
6 revisions
Deleting generators
Deleting selected generators from a t2data object has to be done a little carefully. If you try to loop over the generator list and delete the generators you don't want, like this:
dat=t2data('mydata.dat')
# this code won't work:forgenindat.generatorlist:
ifgen.name.startswith('r'):
dat.delete_generator((gen.block, gen.name))
it won't work. The reason is that the delete_generator() method is altering the list you are iterating over, which confuses the looping process.
The solution is to first make a separate list of the generators you want to delete, and iterate over that instead of the t2data generator list, e.g.: