@@ -117,10 +117,6 @@ def na_op(x, y):
117
117
else :
118
118
result = lib .scalar_compare (x , y , op )
119
119
else :
120
- if (isinstance (x , np .ndarray ) and
121
- isinstance (y , np .ndarray ) and
122
- len (x ) != len (y )):
123
- raise ValueError ('Array lengths must equal to compare' )
124
120
result = op (x , y )
125
121
126
122
return result
@@ -130,11 +126,15 @@ def wrapper(self, other):
130
126
131
127
if isinstance (other , Series ):
132
128
name = _maybe_match_name (self , other )
129
+ if len (self ) != len (other ):
130
+ raise ValueError ('Series lengths must match to compare' )
133
131
return Series (na_op (self .values , other .values ),
134
132
index = self .index , name = name )
135
133
elif isinstance (other , DataFrame ): # pragma: no cover
136
134
return NotImplemented
137
135
elif isinstance (other , np .ndarray ):
136
+ if len (self ) != len (other ):
137
+ raise ValueError ('Lengths must match to compare' )
138
138
return Series (na_op (self .values , np .asarray (other )),
139
139
index = self .index , name = self .name )
140
140
else :
0 commit comments