(self, column)
return None
Prepare the arrays with which we will sort the rows. If we want to
        sort based on a single value e.g. the name, return a 1d array.
        Sometimes we may want to sort by multiple criteria, comparing
        continuous variances with discrete entropies makes no sense, so we want
        to group those variable types together.
Prepare the arrays with which we will sort the rows. If we want to
        sort based on a single value e.g. the name, return a 1d array.
        Sometimes we may want to sort by multiple criteria, comparing
        continuous variances with discrete entropies makes no sense, so we want
        to group those variable types together.
Prepare the arrays with which we will sort the rows . If we want to sort based on a single value e . g . the name return a 1d array . Sometimes we may want to sort by multiple criteria comparing continuous variances with discrete entropies makes no sense so we want to group those variable types together .
def sortColumnData(self, column):
        """Prepare the arrays with which we will sort the rows. If we want to
        sort based on a single value e.g. the name, return a 1d array.
        Sometimes we may want to sort by multiple criteria, comparing
        continuous variances with discrete entropies makes no sense, so we want
        to group those variable types together.
        """
        # Prepare indices for variable types so we can group them together
        order = [ContinuousVariable, TimeVariable,
                 DiscreteVariable, StringVariable]
        mapping = {var: idx for idx, var in enumerate(order)}
        vmapping = np.vectorize(mapping.__getitem__)
        var_types_indices = vmapping(self._variable_types)

        # Store the variable name sorted indices so we can pass a default
        # order when sorting by multiple keys
        # Double argsort is "inverse" argsort:
        # data will be *sorted* by these indices
        var_name_indices = np.argsort(np.argsort(self._variable_names))

        # Prepare vartype indices so ready when needed
        disc_idx, _, time_idx, str_idx = self._attr_indices(self.variables)

        # Sort by: (type)
        if column == self.Columns.ICON:
            return var_types_indices
        # Sort by: (name)
        elif column == self.Columns.NAME:
            # We use `_variable_names` here and not the indices because the
            # last (or single) row is actually sorted and we don't want to sort
            # the indices
            return self._variable_names
        # Sort by: (None)
        elif column == self.Columns.DISTRIBUTION:
            return np.ones_like(var_types_indices)
        # Sort by: (type, center)
        elif column == self.Columns.CENTER:
            # Sorting discrete or string values by mean makes no sense
            vals = np.array(self._center)
            vals[disc_idx] = var_name_indices[disc_idx]
            vals[str_idx] = var_name_indices[str_idx]
            return np.vstack((var_types_indices, np.zeros_like(vals), vals)).T
        # Sort by: (type, median)
        elif column == self.Columns.MEDIAN:
            # Sorting discrete or string values by median makes no sense
            vals = np.array(self._median)
            vals[disc_idx] = var_name_indices[disc_idx]
            vals[str_idx] = var_name_indices[str_idx]
            return np.vstack((var_types_indices, np.zeros_like(vals), vals)).T
        # Sort by: (type, dispersion)
        elif column == self.Columns.DISPERSION:
            # Sort time variables by their dispersion, which is not stored in
            # the dispersion array
            vals = np.array(self._dispersion)
            vals[time_idx] = self._max[time_idx] - self._min[time_idx]
            return np.vstack((var_types_indices, np.zeros_like(vals), vals)).T
        # Sort by: (type, min)
        elif column == self.Columns.MIN:
            # Sorting discrete or string values by min makes no sense
            vals = np.array(self._min)
            vals[disc_idx] = var_name_indices[disc_idx]
            vals[str_idx] = var_name_indices[str_idx]
            return np.vstack((var_types_indices, np.zeros_like(vals), vals)).T
        # Sort by: (type, max)
        elif column == self.Columns.MAX:
            # Sorting discrete or string values by min makes no sense
            vals = np.array(self._max)
            vals[disc_idx] = var_name_indices[disc_idx]
            vals[str_idx] = var_name_indices[str_idx]
            return np.vstack((var_types_indices, np.zeros_like(vals), vals)).T
        # Sort by: (missing)
        elif column == self.Columns.MISSING:
            return self._missing

        return None
def sortColumnData ( self , column ) : # Prepare indices for variable types so we can group them together order = [ ContinuousVariable , TimeVariable , DiscreteVariable , StringVariable ] mapping = { var : idx for idx , var in enumerate ( order ) } vmapping = np . vectorize ( mapping . __getitem__ ) var_types_indices = vmapping ( self . _variable_types ) # Store the variable name sorted indices so we can pass a default # order when sorting by multiple keys # Double argsort is "inverse" argsort: # data will be *sorted* by these indices var_name_indices = np . argsort ( np . argsort ( self . _variable_names ) ) # Prepare vartype indices so ready when needed disc_idx , _ , time_idx , str_idx = self . _attr_indices ( self . variables ) # Sort by: (type) if column == self . Columns . ICON : return var_types_indices # Sort by: (name) elif column == self . Columns . NAME : # We use `_variable_names` here and not the indices because the # last (or single) row is actually sorted and we don't want to sort # the indices return self . _variable_names # Sort by: (None) elif column == self . Columns . DISTRIBUTION : return np . ones_like ( var_types_indices ) # Sort by: (type, center) elif column == self . Columns . CENTER : # Sorting discrete or string values by mean makes no sense vals = np . array ( self . _center ) vals [ disc_idx ] = var_name_indices [ disc_idx ] vals [ str_idx ] = var_name_indices [ str_idx ] return np . vstack ( ( var_types_indices , np . zeros_like ( vals ) , vals ) ) . T # Sort by: (type, median) elif column == self . Columns . MEDIAN : # Sorting discrete or string values by median makes no sense vals = np . array ( self . _median ) vals [ disc_idx ] = var_name_indices [ disc_idx ] vals [ str_idx ] = var_name_indices [ str_idx ] return np . vstack ( ( var_types_indices , np . zeros_like ( vals ) , vals ) ) . T # Sort by: (type, dispersion) elif column == self . Columns . DISPERSION : # Sort time variables by their dispersion, which is not stored in # the dispersion array vals = np . array ( self . _dispersion ) vals [ time_idx ] = self . _max [ time_idx ] - self . _min [ time_idx ] return np . vstack ( ( var_types_indices , np . zeros_like ( vals ) , vals ) ) . T # Sort by: (type, min) elif column == self . Columns . MIN : # Sorting discrete or string values by min makes no sense vals = np . array ( self . _min ) vals [ disc_idx ] = var_name_indices [ disc_idx ] vals [ str_idx ] = var_name_indices [ str_idx ] return np . vstack ( ( var_types_indices , np . zeros_like ( vals ) , vals ) ) . T # Sort by: (type, max) elif column == self . Columns . MAX : # Sorting discrete or string values by min makes no sense vals = np . array ( self . _max ) vals [ disc_idx ] = var_name_indices [ disc_idx ] vals [ str_idx ] = var_name_indices [ str_idx ] return np . vstack ( ( var_types_indices , np . zeros_like ( vals ) , vals ) ) . T # Sort by: (missing) elif column == self . Columns . MISSING : return self . _missing return None