<div class="gmail_quote">On Wed, Mar 7, 2012 at 08:49, Gaetan Kenway <span dir="ltr"><<a href="mailto:kenway@utias.utoronto.ca">kenway@utias.utoronto.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What is the 'with block' option. I don't see anything related to that when I run help(PETSc.Vec()). Does it return a (N/bs,bs) array instead of an (N) array? </blockquote><div><br></div><div>with X as x:</div>
<div> print(numpy.sin(x)) # x is a Numpy array</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Also in petsc4py the call for resetting the pointer from getArray() is actually resetArray() which is different from C/Fortran where it is restoreArray(). I've got them confused as well. </blockquote>
</div><br><div>No, resetArray() is VecResetArray() which is a different thing, getArray() in Python does not need an explicit restore. (I believe the restore is called when the "gotten" array falls out of scope.) I recommend using the 'with' statement, it's much clearer and more explicit about resource management.</div>