@@ -4140,17 +4140,18 @@ def _comparison(self, other, compare):
4140
4140
if isinstance (check , (np .bool_ , bool )):
4141
4141
return masked if mask else check
4142
4142
4143
- if mask is not nomask and compare in (operator .eq , operator .ne ):
4144
- # Adjust elements that were masked, which should be treated
4145
- # as equal if masked in both, unequal if masked in one.
4146
- # Note that this works automatically for structured arrays too.
4147
- # Ignore this for operations other than `==` and `!=`
4148
- check = np .where (mask , compare (smask , omask ), check )
4149
-
4150
- if mask .shape != check .shape :
4151
- # Guarantee consistency of the shape, making a copy since the
4152
- # the mask may need to get written to later.
4153
- mask = np .broadcast_to (mask , check .shape ).copy ()
4143
+ if mask is not nomask :
4144
+ if compare in (operator .eq , operator .ne ):
4145
+ # Adjust elements that were masked, which should be treated
4146
+ # as equal if masked in both, unequal if masked in one.
4147
+ # Note that this works automatically for structured arrays too.
4148
+ # Ignore this for operations other than `==` and `!=`
4149
+ check = np .where (mask , compare (smask , omask ), check )
4150
+
4151
+ if mask .shape != check .shape :
4152
+ # Guarantee consistency of the shape, making a copy since the
4153
+ # the mask may need to get written to later.
4154
+ mask = np .broadcast_to (mask , check .shape ).copy ()
4154
4155
4155
4156
check = check .view (type (self ))
4156
4157
check ._update_from (self )
0 commit comments