<div class="gmail_quote">On Wed, Mar 7, 2012 at 08:49, Gaetan Kenway <span dir="ltr">&lt;<a href="mailto:kenway@utias.utoronto.ca">kenway@utias.utoronto.ca</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What is the &#39;with block&#39; option. I don&#39;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&#39;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 &quot;gotten&quot; array falls out of scope.) I recommend using the &#39;with&#39; statement, it&#39;s much clearer and more explicit about resource management.</div>