MCPcopy
hub / github.com/quantopian/zipline / method

Method method

zipline/lib/labelarray.py:472–500  ·  view source on GitHub ↗
(self, other)

Source from the content-addressed store, hash-verified

470 comparison operator to use.
471 """
472 def method(self, other):
473
474 if isinstance(other, LabelArray):
475 self_mv = self.missing_value
476 other_mv = other.missing_value
477 if self_mv != other_mv:
478 raise MissingValueMismatch(self_mv, other_mv)
479
480 self_categories = self.categories
481 other_categories = other.categories
482 if not compare_arrays(self_categories, other_categories):
483 raise CategoryMismatch(self_categories, other_categories)
484
485 return (
486 op(self.as_int_array(), other.as_int_array())
487 & self.not_missing()
488 & other.not_missing()
489 )
490
491 elif isinstance(other, ndarray):
492 # Compare to ndarrays as though we were an array of strings.
493 # This is fairly expensive, and should generally be avoided.
494 return op(self.as_string_array(), other) & self.not_missing()
495
496 elif isinstance(other, self.SUPPORTED_SCALAR_TYPES):
497 i = self._reverse_categories.get(other, -1)
498 return op(self.as_int_array(), i) & self.not_missing()
499
500 return op(super(LabelArray, self), other)
501 return method
502
503 __eq__ = _equality_check(eq)

Callers

nothing calls this directly

Calls 7

as_int_arrayMethod · 0.95
not_missingMethod · 0.95
as_string_arrayMethod · 0.95
compare_arraysFunction · 0.85
CategoryMismatchClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected