Skip to content

Commit

Permalink
Add _validate_shape
Browse files Browse the repository at this point in the history
  • Loading branch information
makbigc committed Dec 18, 2018
1 parent f4315ac commit 7939d93
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,10 @@ def _add_comparison_ops(cls):
cls.__le__ = cls._create_comparison_method(operator.le)
cls.__ge__ = cls._create_comparison_method(operator.ge)

def _validate_shape(self, other):
if len(self) != len(other):
raise ValueError('Lengths must match to compare')


class ExtensionScalarOpsMixin(ExtensionOpsMixin):
"""
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ def wrapper(self, other):
elif isinstance(other, cls):
self._check_compatible_with(other)

if other.ndim > 0 and len(self) != len(other):
raise ValueError('Lengths must match to compare')
self._validate_shape(other)

if not_implemented:
return NotImplemented
Expand Down

0 comments on commit 7939d93

Please sign in to comment.