Esempio n. 1
0
 def __eq__(self, other):
     if isinstance(other, UnionType):
         return (self._typestr == other._typestr and _parameters_equal(
             self._parameters, other._parameters, only_array_record=True)
                 and self._contents == other._contents)
     else:
         return False
Esempio n. 2
0
 def __eq__(self, other):
     if isinstance(other, ArrayType):
         return (self._length == other._length and _parameters_equal(
             self._content._parameters, other._content._parameters)
                 and self._content._typestr == other._content._typestr)
     else:
         return False
Esempio n. 3
0
    def mergeable(self, other, mergebool):
        if not _parameters_equal(self._parameters, other._parameters):
            return False

        if isinstance(
                other,
            (
                ak._v2.contents.emptyarray.EmptyArray,
                ak._v2.contents.unionarray.UnionArray,
            ),
        ):
            return True

        if isinstance(
                other,
            (
                ak._v2.contents.indexedarray.IndexedArray,
                ak._v2.contents.indexedoptionarray.IndexedOptionArray,
                ak._v2.contents.bytemaskedarray.ByteMaskedArray,
                ak._v2.contents.bitmaskedarray.BitMaskedArray,
                ak._v2.contents.unmaskedarray.UnmaskedArray,
            ),
        ):
            return self._content.mergeable(other.content, mergebool)

        else:
            return self._content.mergeable(other, mergebool)
Esempio n. 4
0
 def __eq__(self, other):
     if isinstance(other, UnmaskedForm):
         return (self._has_identifier == other._has_identifier
                 and self._form_key == other._form_key
                 and _parameters_equal(self._parameters, other._parameters)
                 and self._content == other._content)
     else:
         return False
Esempio n. 5
0
    def generated_compatibility(self, other):
        if other is None:
            return True

        elif isinstance(other, EmptyForm):
            return _parameters_equal(self._parameters, other._parameters)

        else:
            return False
Esempio n. 6
0
 def __eq__(self, other):
     if isinstance(other, NumpyForm):
         return (self._has_identifier == other._has_identifier
                 and self._form_key == other._form_key
                 and self._primitive == other._primitive
                 and self._inner_shape == other._inner_shape
                 and _parameters_equal(self._parameters, other._parameters))
     else:
         return False
Esempio n. 7
0
 def __eq__(self, other):
     if isinstance(other, NumpyType):
         return (self._typestr == other._typestr
                 and self._primitive == other._primitive
                 and _parameters_equal(self._parameters,
                                       other._parameters,
                                       only_array_record=True))
     else:
         return False
Esempio n. 8
0
    def mergeable(self, other, mergebool):
        if not _parameters_equal(self._parameters, other._parameters):
            return False

        if isinstance(
                other,
            (
                ak._v2.contents.emptyarray.EmptyArray,
                ak._v2.contents.unionarray.UnionArray,
            ),
        ):
            return True

        elif isinstance(
                other,
            (
                ak._v2.contents.indexedarray.IndexedArray,
                ak._v2.contents.indexedoptionarray.IndexedOptionArray,
                ak._v2.contents.bytemaskedarray.ByteMaskedArray,
                ak._v2.contents.bitmaskedarray.BitMaskedArray,
                ak._v2.contents.unmaskedarray.UnmaskedArray,
            ),
        ):
            return self.mergeable(other._content, mergebool)

        if isinstance(other, ak._v2.contents.numpyarray.NumpyArray):
            if self._data.ndim != other._data.ndim:
                return False

            matching_dtype = self._data.dtype == other._data.dtype

            if (not mergebool and not matching_dtype
                    and (self._data.dtype.type is np.bool_
                         or other._data.dtype.type is np.bool_)):
                return False

            if not matching_dtype and np.datetime64 in (
                    self._data.dtype,
                    other._data.dtype,
            ):
                return False

            if not matching_dtype and np.timedelta64 in (
                    self._data.dtype,
                    other._data.dtype,
            ):
                return False

            if (len(self._data.shape) > 1
                    and self._data.shape[1:] != other._data.shape[1:]):
                return False

            return True

        else:
            return False
Esempio n. 9
0
    def __eq__(self, other):
        if (isinstance(other, UnionForm)
                and self._has_identifier == other._has_identifier
                and self._form_key == other._form_key
                and self._tags == other._tags and self._index == other._index
                and len(self._contents) == len(other._contents)
                and _parameters_equal(self._parameters, other._parameters)):
            return self._contents == other._contents

        return False
Esempio n. 10
0
 def __eq__(self, other):
     if isinstance(other, RegularType):
         return (self._typestr == other._typestr
                 and self._size == other._size
                 and _parameters_equal(self._parameters,
                                       other._parameters,
                                       only_array_record=True)
                 and self._content == other._content)
     else:
         return False
Esempio n. 11
0
    def generated_compatibility(self, other):
        if other is None:
            return True

        elif isinstance(other, IndexedOptionForm):
            return (self._index == other._index
                    and _parameters_equal(self._parameters, other._parameters)
                    and self._content.generated_compatibility(other._content))

        else:
            return False
Esempio n. 12
0
    def generated_compatibility(self, other):
        if other is None:
            return True

        elif isinstance(other, RegularForm):
            return (self._size == other._size
                    and _parameters_equal(self._parameters, other._parameters)
                    and self._content.generated_compatibility(other._content))

        else:
            return False
Esempio n. 13
0
 def __eq__(self, other):
     if isinstance(other, BitMaskedForm):
         return (self._has_identifier == other._has_identifier
                 and self._form_key == other._form_key
                 and self._mask == other._mask
                 and self._valid_when == other._valid_when
                 and self._lsb_order == other._lsb_order
                 and _parameters_equal(self._parameters, other._parameters)
                 and self._content == other._content)
     else:
         return False
Esempio n. 14
0
    def generated_compatibility(self, other):
        if other is None:
            return True

        elif isinstance(other, ListOffsetForm):
            return (self._offsets == other._offsets
                    and _parameters_equal(self._parameters, other._parameters)
                    and self._content.generated_compatibility(other._content))

        else:
            return False
Esempio n. 15
0
    def generated_compatibility(self, other):
        if other is None:
            return True

        elif isinstance(other, UnmaskedForm):
            return _parameters_equal(
                self._parameters,
                other._parameters) and self._content.generated_compatibility(
                    other._content)

        else:
            return False
Esempio n. 16
0
    def generated_compatibility(self, other):
        if other is None:
            return True

        elif isinstance(other, ByteMaskedForm):
            return (self._mask == other._mask
                    and self._valid_when == other._valid_when
                    and _parameters_equal(self._parameters, other._parameters)
                    and self._content.generated_compatibility(other._content))

        else:
            return False
Esempio n. 17
0
    def generated_compatibility(self, other):
        if other is None:
            return True

        elif isinstance(other, NumpyForm):
            return (ak._v2.types.numpytype.primitive_to_dtype(
                self._primitive) == ak._v2.types.numpytype.primitive_to_dtype(
                    other._primitive)
                    and self._inner_shape == other._inner_shape
                    and _parameters_equal(self._parameters, other._parameters))

        else:
            return False
Esempio n. 18
0
    def mergeable(self, other, mergebool=True):
        if not _parameters_equal(self._parameters, other._parameters):
            return False

        if isinstance(
            other,
            (
                ak._v2.contents.emptyarray.EmptyArray,
                ak._v2.contents.unionarray.UnionArray,
            ),
        ):
            return True

        elif isinstance(
            other,
            (
                ak._v2.contents.indexedarray.IndexedArray,
                ak._v2.contents.indexedoptionarray.IndexedOptionArray,
                ak._v2.contents.bytemaskedarray.ByteMaskedArray,
                ak._v2.contents.bitmaskedarray.BitMaskedArray,
                ak._v2.contents.unmaskedarray.UnmaskedArray,
            ),
        ):
            return self.mergeable(other.content, mergebool)

        if isinstance(other, RecordArray):
            if self.is_tuple and other.is_tuple:
                if len(self._contents) == len(other._contents):
                    for self_cont, other_cont in zip(self._contents, other._contents):
                        if not self_cont.mergeable(other_cont, mergebool):
                            return False

                    return True

            elif not self.is_tuple and not other.is_tuple:
                if set(self._fields) != set(other._fields):
                    return False

                for i, field in enumerate(self._fields):
                    x = self._contents[i]
                    y = other._contents[other.field_to_index(field)]
                    if not x.mergeable(y, mergebool):
                        return False
                return True

            else:
                return False

        else:
            return False
Esempio n. 19
0
    def generated_compatibility(self, other):
        if other is None:
            return True

        elif isinstance(other, UnionForm):
            if len(self._contents) == len(other._contents):
                return _parameters_equal(
                    self._parameters, other._parameters) and all(
                        x.generated_compatibility(y)
                        for x, y in zip(self._contents, other._contents))
            else:
                return False

        else:
            return False
Esempio n. 20
0
 def __eq__(self, other):
     if isinstance(other, RecordForm):
         if (self._has_identifier == other._has_identifier
                 and self._form_key == other._form_key
                 and self.is_tuple == other.is_tuple
                 and len(self._contents) == len(other._contents) and
                 _parameters_equal(self._parameters, other._parameters)):
             if self.is_tuple:
                 return self._contents == other._contents
             else:
                 return dict(zip(self._fields, self._contents)) == dict(
                     zip(other._fields, other._contents))
         else:
             return False
     else:
         return False
Esempio n. 21
0
    def generated_compatibility(self, other):
        if other is None:
            return True

        elif isinstance(other, RecordForm):
            if self.is_tuple == other.is_tuple:
                self_fields = set(self._fields)
                other_fields = set(other._fields)
                if self_fields == other_fields:
                    return _parameters_equal(
                        self._parameters, other._parameters) and all(
                            self.content(x).generated_compatibility(
                                other.content(x)) for x in self_fields)
                else:
                    return False
            else:
                return False

        else:
            return False
Esempio n. 22
0
    def __eq__(self, other):
        if isinstance(other, RecordType):
            if self._typestr != other._typestr or not _parameters_equal(
                    self._parameters, other._parameters,
                    only_array_record=True):
                return False

            if self._fields is None and other._fields is None:
                return self._contents == other._contents

            elif self._fields is not None and other._fields is not None:
                if set(self._fields) != set(other._fields):
                    return False
                for field in self._fields:
                    if self.content(field) != other.content(field):
                        return False

                return True

            else:
                return False

        else:
            return False
Esempio n. 23
0
 def mergeable(self, other, mergebool):
     if not _parameters_equal(self._parameters, other._parameters):
         return False
     return True
Esempio n. 24
0
 def __eq__(self, other):
     if isinstance(other, UnknownType):
         return self._typestr == other._typestr and _parameters_equal(
             self._parameters, other._parameters, only_array_record=True)
     else:
         return False