Пример #1
0
    def _from_tree_type_changes(self, tree):
        if 'type_changes' in tree:
            for change in tree['type_changes']:
                include_values = None
                if type(change.t1) is type:
                    include_values = False
                    old_type = change.t1
                    new_type = change.t2
                else:
                    old_type = get_type(change.t1)
                    new_type = get_type(change.t2)
                    include_values = True
                    try:
                        if new_type in numpy_numbers:
                            new_t1 = change.t1.astype(new_type)
                            include_values = not np.array_equal(
                                new_t1, change.t2)
                        else:
                            new_t1 = new_type(change.t1)
                            # If simply applying the type from one value converts it to the other value,
                            # there is no need to include the actual values in the delta.
                            include_values = new_t1 != change.t2
                    except Exception:
                        pass

                remap_dict = RemapDict({
                    'old_type': old_type,
                    'new_type': new_type
                })
                self['type_changes'][change.path(
                    force=FORCE_DEFAULT)] = remap_dict
                if include_values:
                    remap_dict.update(old_value=change.t1, new_value=change.t2)
Пример #2
0
 def _from_tree_type_changes(self, tree):
     if 'type_changes' in tree:
         for change in tree['type_changes']:
             remap_dict = RemapDict({
                 'old_type': type(change.t1),
                 'new_type': type(change.t2)
             })
             self['type_changes'][change.path(
                 force=FORCE_DEFAULT)] = remap_dict
             if Verbose.level:
                 remap_dict.update(old_value=change.t1, new_value=change.t2)
Пример #3
0
 def _from_tree_type_changes(self, tree):
     if 'type_changes' in tree:
         for change in tree['type_changes']:
             remap_dict = RemapDict({
                 'old_type': type(change.t1),
                 'new_type': type(change.t2)
             })
             self['type_changes'][change.path(
                 force=FORCE_DEFAULT)] = remap_dict
             if Verbose.level:
                 remap_dict.update(old_value=change.t1, new_value=change.t2)
Пример #4
0
 def _from_tree_repetition_change(self, tree):
     if 'repetition_change' in tree:
         for change in tree['repetition_change']:
             path = change.path(force=FORCE_DEFAULT)
             self['repetition_change'][path] = RemapDict(
                 change.additional['repetition'])
             self['repetition_change'][path]['value'] = change.t1
Пример #5
0
 def _from_tree_type_changes(self, tree):
     if 'type_changes' in tree:
         for change in tree['type_changes']:
             if type(change.t1) is type:
                 include_values = False
                 old_type = change.t1
                 new_type = change.t2
             else:
                 include_values = True
                 old_type = type(change.t1)
                 new_type = type(change.t2)
             remap_dict = RemapDict({
                 'old_type': old_type,
                 'new_type': new_type
             })
             self['type_changes'][change.path(
                 force=FORCE_DEFAULT)] = remap_dict
             if Verbose.level and include_values:
                 remap_dict.update(old_value=change.t1, new_value=change.t2)
Пример #6
0
 def _from_tree_type_changes(self, tree):
     if 'type_changes' in tree:
         for change in tree['type_changes']:
             if type(change.t1) is type:
                 include_values = False
                 old_type = change.t1
                 new_type = change.t2
             else:
                 include_values = True
                 old_type = type(change.t1)
                 new_type = type(change.t2)
             remap_dict = RemapDict({
                 'old_type': old_type,
                 'new_type': new_type
             })
             self['type_changes'][change.path(
                 force=FORCE_DEFAULT)] = remap_dict
             if Verbose.level and include_values:
                 remap_dict.update(old_value=change.t1, new_value=change.t2)
Пример #7
0
 def _from_tree_repetition_change(self, tree):
     if 'repetition_change' in tree:
         for change in tree['repetition_change']:
             path, _, _ = change.path(get_parent_too=True)
             repetition = RemapDict(change.additional['repetition'])
             value = change.t1
             try:
                 iterable_items_added_at_indexes = self['iterable_items_added_at_indexes'][path]
             except KeyError:
                 iterable_items_added_at_indexes = self['iterable_items_added_at_indexes'][path] = dict_()
             for index in repetition['new_indexes']:
                 iterable_items_added_at_indexes[index] = value