Esempio n. 1
0
    def sort_by_x(self, pinfo):
        """
        Sort the lists in pinfo according to pinfo['x']
        This function is useful for geom's that expect
        the x-values to come in sorted order
        """
        # Remove list types from pinfo
        _d = {}
        for k in list(pinfo.keys()):
            if not is_string(pinfo[k]) and iterable(pinfo[k]):
                _d[k] = pinfo.pop(k)

        # Sort numerically if all items can be cast
        try:
            x = list(map(np.float, _d['x']))
        except (ValueError, TypeError):
            x = _d['x']

        # Make sure we don't try to sort something unsortable
        try:
            idx = np.argsort(x)
            # Put sorted lists back in pinfo
            for key in _d:
                pinfo[key] = [_d[key][i] for i in idx]
        except:
            pass
        return pinfo
Esempio n. 2
0
    def _sort_list_types_by_x(self, pinfo):
        """
        Sort the lists in pinfo according to pinfo['x']
        """
        # Remove list types from pinfo
        _d = {}
        for k in list(pinfo.keys()):
            if not is_string(pinfo[k]) and cbook.iterable(pinfo[k]):
                _d[k] = pinfo.pop(k)

        # Sort numerically if all items can be cast
        try:
            x = list(map(np.float, _d['x']))
        except ValueError:
            x = _d['x']
        idx = np.argsort(x)

        # Put sorted lists back in pinfo
        for key in _d:
            pinfo[key] = [_d[key][i] for i in idx]

        return pinfo
Esempio n. 3
0
    def _sort_list_types_by_x(self, pinfo):
        """
        Sort the lists in pinfo according to pinfo['x']
        """
        # Remove list types from pinfo
        _d = {}
        for k in list(pinfo.keys()):
            if not is_string(pinfo[k]) and cbook.iterable(pinfo[k]):
                _d[k] = pinfo.pop(k)

        # Sort numerically if all items can be cast
        try:
            x = list(map(np.float, _d['x']))
        except ValueError:
            x = _d['x']
        idx = np.argsort(x)

        # Put sorted lists back in pinfo
        for key in _d:
            pinfo[key] = [_d[key][i] for i in idx]

        return pinfo