On 8 September 2011 11:15, Jose Fonseca <span dir="ltr">&lt;<a href="mailto:jfonseca@vmware.com" target="_blank">jfonseca@vmware.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

I think this is pretty brittle -- who knows when numpy decides to create different type objects.<br>
<br>
It&#39;s better to use numpy dtypes [1] for this. With your example one gets:<br>
<br>
  Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on<br>
<div>  win32<br>
  Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br>
  &gt;&gt;&gt; import numpy<br>
  &gt;&gt;&gt; x = numpy.int32(5)<br>
  &gt;&gt;&gt; y = numpy.abs(x)<br>
</div><div>  &gt;&gt;&gt; type(x) == type(y)<br>
  False<br>
</div>  &gt;&gt;&gt; x.dtype == y.dtype<br>
  True<br>
  &gt;&gt;&gt;<br>
<br>
That is, the type checking code should use<br>
<br>
if isinstance(x, numpy.number):<br>
   if x.dtype == numpy.dtype(numpy.int32)<br>
   ...<br>
<br>
... </blockquote><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<br>
<br>
<br>
Jose<br>
<br>
[1] <a href="http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html" target="_blank">http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html</a><br>
<div><div></div><div><br>
<br></div></div></blockquote><div><br>I&#39;m sorry, Jose.  I pushed this patch to Piglit master as soon as I got a tested-by from Vinson Lee, which was right around the time you sent this email, so I didn&#39;t see your comments until after it was too late.  Normally my rule is to wait one working day between receiving a reviewed-by, tested-by, or acked-by, to give others a chance to object.  But I made an exception in this case because the magnitude of the breakage was so severe (Vinson was completely unable to build piglit on Windows before this patch).  Your comments are making me rethink whether I was right to make an exception.<br>

<br>I suspect that a solution along the lines of what you propose would work.  I&#39;m not convinced it would be any more or less brittle, because I don&#39;t really know what is causing this numpy bug in the first place, but I bet it would be less ugly than what I did.<br>
<br>How important is this to you, on a scale from &quot;gee it would be nice to do things differently&quot; to &quot;the code is unacceptable as is&quot;?  I would prefer to leave the patch as it is, mostly because my dev environment is Linux, so developing and testing on Windows requires me to go home and temporarily repurpose my home machine for Piglit development--that takes me a lot of time.  But if you would be willing to work your dtype idea into a patch and try it on Windows, I would be happy to code review it and verify that it doesn&#39;t break on Linux.<br>
<br>Paul<br>
</div></div>