Print the diff to the last time the state of objects was measured.

        keyword arguments
        ignore -- list of objects to ignore
6695
def print_diff(self, ignore=[]):
        
        # ignore this and the caller frame
        ignore.append(inspect.currentframe()) #PYCHOK change ignore
        diff = self.get_diff(ignore)
        print("Added objects:")
        summary.print_(summary.summarize(diff['+']))
        print("Removed objects:")
        summary.print_(summary.summarize(diff['-']))
        # manual cleanup, see comment above
        del ignore[:]
969505
def diff_a_thing(thing, opt):
    """"""
    changed = thing.diff()
    if changed == ADD:
        print("%s %s" % (maybe_colored("+", "green", opt), str(thing)))
    elif changed == DEL:
        print("%s %s" % (maybe_colored("-", "red", opt), str(thing)))
    elif changed == CHANGED:
        print("%s %s" % (maybe_colored("~", "yellow", opt), str(thing)))
    elif changed == OVERWRITE:
        print("%s %s" % (maybe_colored("+", "yellow", opt), str(thing)))
    elif changed == CONFLICT:
        print("%s %s" % (maybe_colored("!", "red", opt), str(thing)))

    if changed != OVERWRITE and changed != NOOP:
        maybe_details(thing, opt)
948819
def diffs(self):
        '''
        
        '''
        differences = []
        for item in self._get_recursive_difference(type='all'):
            if item.diffs:
                if item.past_dict:
                    differences.append({item.past_dict[self._key]: item.diffs})
                elif item.current_dict:
                    differences.append({item.current_dict[self._key]: item.diffs})
        return differences
984734
def diff_iter(self, other, **kwargs):
        
        for diff in super(JsonRecord, self).diff_iter(other, **kwargs):
            # TODO: object copy/upgrade constructor
            newargs = diff.__getstate__()
            yield JsonDiffInfo(**(newargs))
1177711
def get_diffs(ptrms_vectors, ptrm_checks_vectors, ptrms_orig, checks_orig):
    
    ptrm_temps = numpy.array(ptrms_orig)[:,0]
    check_temps = numpy.array(checks_orig)[:,0]
    index = numpy.zeros(len(ptrm_temps))
    for num, temp in enumerate(ptrm_temps):
        if len(numpy.where(check_temps == temp)[0]):
            index[num] = numpy.where(check_temps == temp)[0][0]
        else:
            index[num] = float('nan')
    diffs = numpy.zeros((len(ptrms_vectors), 3))
    for num, ptrm in enumerate(ptrms_vectors):
        if numpy.isnan(index[num]):
            diffs[num] = numpy.array([0,0,0])
        else:
            diffs[num] = ptrm_checks_vectors[int(index[num])] - ptrm
    C = numpy.cumsum(diffs, 0)
    #print "diffs (should be same as to_sum"
    #print diffs
    #print "C (should be same as dpal_sum)"
    #print C
    return diffs, C
1129117
def get_diff(left, right):
    
    res = {'+': [], '-': []}

    def partition(objects):
        """Partition the passed object list."""
        res = {}
        for o in objects:
            t = type(o)
            if type(o) not in res:
                res[t] = []
            res[t].append(o)
        return res

    def get_not_included(foo, bar):
        """Compare objects from foo with objects defined in the values of
        bar (set of partitions).
        Returns a list of all objects included in list, but not dict values.
        """
        res = []
        for o in foo:
            if not compat.object_in_list(type(o), bar):
                res.append(o)
            elif not compat.object_in_list(o, bar[type(o)]):
                res.append(o)
        return res

    # Create partitions of both lists. This will reduce the time required for
    # the comparison
    left_objects = partition(left)
    right_objects = partition(right)
    # and then do the diff
    res['+'] = get_not_included(right, left_objects)
    res['-'] = get_not_included(left, right_objects)
    return res
539102
def :
    
    changes = True
    deletedStates = []
    while changes:
        changes = False
        for i in range(1, len(tempStates)):
            if i in deletedStates:
                continue
            for j in range(0, i):
                if j in deletedStates:
                    continue
                if sameState(tempStates[i], tempStates[j]):
                    deletedStates.append(i)
                    for k in range(0, len(tempStates)):
                        if k in deletedStates:
                            continue
                        for arc in tempStates[k][1]:
                            if arc[1] == i:
                                arc[1] = j
                    changes = True
                    break
    for stateIndex in deletedStates:
        tempStates[stateIndex] = None
    return tempStates
422394
def diff(self, *args):
        """"""
        arg_dicts = self._parse_args_forward_mode(*args)
        val, diff = self._forward_mode(*arg_dicts)
        return diff
952870
def last_change(self):
        
        try:
            cdt = self.latest('created')
            udt = self.latest('updated')
            #print cdt, udt
            return max(cdt.created, udt.updated)

        except ObjectDoesNotExist:
            return None
280081
def inactive_time(self):
        
        if self._inactive_event.is_set():
            return self.pin_factory.ticks_diff(self.pin_factory.ticks(),
                                               self._last_changed)
        else:
            return None
849673
def indicate_last(items):
    
    last_index = len(items) - 1
    for (i, item) in enumerate(items):
        yield (i == last_index, item)
183112
def _record_blank(self, current, dict_obj):
        
        if not self.list_blank:
            return
        if self.list_blank not in current:
            self.blank.append(dict_obj)
554994
def lastProgress(self):
        
        lastProgress = self._jsq.lastProgress()
        if lastProgress:
            return json.loads(lastProgress.json())
        else:
            return None
996033
def print_diff(diff, color=True):
    """"""
    import colorama

    if not diff:
        return

    if not color:
        colorama.init = lambda autoreset: None
        colorama.Fore.RED = ''
        colorama.Back.RED = ''
        colorama.Fore.GREEN = ''
        colorama.deinit = lambda: None

    colorama.init(autoreset=True)  # TODO use context_manager
    for line in diff.splitlines():
        if line.startswith('+') and not line.startswith('+++ '):
            # Note there shouldn't be trailing whitespace
            # but may be nice to generalise this
            print(colorama.Fore.GREEN + line)
        elif line.startswith('-') and not line.startswith('--- '):
            split_whitespace = re.split('(\s+)$', line)
            if len(split_whitespace) > 1:  # claim it must be 3
                line, trailing, _ = split_whitespace
            else:
                line, trailing = split_whitespace[0], ''
            print(colorama.Fore.RED + line, end='')
            # give trailing whitespace a RED background
            print(colorama.Back.RED + trailing)
        elif line == '\ No newline at end of file':
            # The assumption here is that there is now a new line...
            print(colorama.Fore.RED + line)
        else:
            print(line)
    colorama.deinit()
403730
def _clear_ignore(endpoint_props):
    '''
    
    '''
    return dict(
        (prop_name, prop_val)
        for prop_name, prop_val in six.iteritems(endpoint_props)
        if prop_name not in _DO_NOT_COMPARE_FIELDS and prop_val is not None
    )
82890
def diff(self, obj=None):
        """"""
        if self.no_resource:
            return NOOP

        if not self.present:
            if self.existing:
                return DEL

            return NOOP

        if not obj:
            obj = self.obj()

        is_diff = NOOP
        if self.present and self.existing:
            if isinstance(self.existing, dict):
                current = dict(self.existing)
                if 'refresh_interval' in current:
                    del current['refresh_interval']

                if diff_dict(current, obj):
                    is_diff = CHANGED
            elif is_unicode(self.existing):
                if self.existing != obj:
                    is_diff = CHANGED

        elif self.present and not self.existing:
            is_diff = ADD

        return is_diff
379528
def last_iteration(self, parameter=None):
        
        if parameter is None:
            try:
                parameter = list(self[self.samples_group].keys())[0]
            except (IndexError, KeyError):
                # nothing has been written yet, just return 0
                return 0
        try:
            lastiter = self[self.samples_group][parameter].shape[-1]
        except KeyError:
            # no samples have been written, just return 0
            lastiter = 0
        # account for thinning
        return lastiter * self.thinned_by