MCPcopy Create free account
hub / github.com/Cantera/cantera / sort

Method sort

interfaces/cython/cantera/composite.py:832–851  ·  view source on GitHub ↗

Sort SolutionArray by column ``col``. :param col: Column that is used to sort the SolutionArray. :param reverse: If True, the sorted list is reversed (descending order).

(self, col, reverse=False)

Source from the content-addressed store, hash-verified

830 self._indices.append(len(self._indices))
831
832 def sort(self, col, reverse=False):
833 """
834 Sort SolutionArray by column ``col``.
835
836 :param col: Column that is used to sort the SolutionArray.
837 :param reverse: If True, the sorted list is reversed (descending order).
838 """
839 if len(self.shape) != 1:
840 raise TypeError("sort only works for 1D SolutionArray objects")
841
842 indices = np.argsort(getattr(self, col))
843 if reverse:
844 indices = indices[::-1]
845 states = [self._get_state(ix) for ix in indices]
846 for loc in range(self.size):
847 self._set_state(loc, states[loc])
848
849 for k in self.extra:
850 v = self._get_component(k)
851 self._set_component(k, v[indices])
852
853 def equilibrate(self, *args, **kwargs):
854 """ See `ThermoPhase.equilibrate` """

Callers 3

test_sortMethod · 0.95
compare_profilesFunction · 0.80
compareProfilesFunction · 0.80

Calls 1

lenFunction · 0.85

Tested by 1

test_sortMethod · 0.76