def __or__(self, other): if not isinstance(other, Record): raise TypeError("Cannot union Record with %r of type %s" % (other, other.__name__)) if len(other.labels) > len(self.labels): self, other = other, self if other.contained_in(self): return self return Record(merge_arrays(self.labels, other.labels))
def __or__(self, other): if not isinstance(other, Record): raise TypeError("Cannot union Record with %r of type %s" % ( other, other.__name__ )) if len(other.labels) > len(self.labels): self, other = other, self if other.contained_in(self): return self return Record( merge_arrays(self.labels, other.labels) )
def test_merges_correctly(x, y): t = merge_arrays(x, y) assert list(t) == sorted(set(x) | set(y))