- 
                Notifications
    
You must be signed in to change notification settings  - Fork 26
 
BUG: Failing type return on masked array on LHS #176
Conversation
| 
           This can be fixed by adding the  diff --git a/biggus/__init__.py b/biggus/__init__.py
index bb7c181..2a8c4c9 100644
--- a/biggus/__init__.py
+++ b/biggus/__init__.py
@@ -737,6 +737,10 @@ class ArrayContainer(Array):
         except AttributeError:
             return np.array(self.array)
+    @property
+    def __array_priority__(self):
+        return self.array.__array_priority__
+
     def masked_array(self):
         try:
             return self.array.masked_array()
@@ -1306,6 +1310,10 @@ class _ArrayAdapter(Array):
     def shape(self):
         return _sliced_shape(self.concrete.shape, self._keys)
+    @property
+    def __array_priority__(self):
+        return self.concrete.__array_priority__
+
     def _cleanup_new_key(self, key, size, axis):
         """
         Return a key of type int, slice, or tuple that is guaranteed@cpelley - interested in taking this forwards?  | 
    
          
 Thanks for your interest @pelson. I'm glad that I'm not just being silly (I was sure that something must have run into this before now, but hey..). Happy to make the change myself. Thanks for pointing out the solution. Is it OK to be calling this private attribute within the numpy object? (not that we have any choice). Is there a discussion to raise to have numpy expose this via the public interface following this ticket? Cheers  | 
    
          
 Double underscore doesn't really mean private, it is generally a indication of "interface". In truth, even if it did mean private, it is not something that can be readily changed in numpy - we are stuck with that with older versions anyway, so any change would have to have additional logic above an beyond what we would currently need to do. All in all, I don't believe raising a numpy ticket is a worthwhile pursuit in all honesty. If you're happy to carry this forwards, I'd be happy to review any tests added.  | 
    
          
 Sure, thanks @pelson  | 
    
5c09455    to
    7da22e6      
    Compare
  
    | 
           The solution doesn't work for numpy v1.7 for whatever reason and we are supporting v1.7 for biggus for some reason. Since iris requires numpy >= 1.9, I propose we have travis run tests for biggus with numpy v1.9 of numpy rather than v1.7. What do you think?  | 
    
71a0172    to
    e65a6fe      
    Compare
  
    e65a6fe    to
    a39485e      
    Compare
  
    | 
           OK done  | 
    
| 
           Hello, just checking that this doesn't get missed for the v1.11 iris milestone. Cheers  | 
    
| 
           👍  from me. Small, simple change to fix a very specific issue.  | 
    
| 
           Actually, would you mind catching the case where the contained arrays don't have an   | 
    
| 
           Hey @pelson, thanks for looking at this. I have now added a test case which uses a ConstantArray and pass that to a NumpyArrayAdapter as the ConstantArray class does not define an array_priority attribute. Hmm can't we define this property on the Array parent class?  | 
    
| 
           Turns out numpy must be catching this AttributeError anyways. Thanks for adding the test @cpelley.  | 
    
| 
           Thanks @pelson and thanks for pointing me in the right direction on fixing this.  | 
    
| 
           Thank you @cpelley. We need to cut a release of biggus at some point. I have a few substantial changes that can probably wait for the next (major) release 😉  | 
    
| from __future__ import absolute_import, division, print_function | ||
| from six.moves import (filter, input, map, range, zip) # noqa | ||
| 
               | 
          ||
| import mock | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be from biggus.tests import mock. I'm not sure why Travis has mock installed on Python 3; it's not supposed to be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, #197
Self contained unittest which I have added and shown to fail (demonstrating what I believe to be a bug). Essentially, the mask is thrown away.
I suspect it's because its the
__mul__from the masked numpy array that is being called and for whatever reason, it doesn't think the biggus array is masked.