| 973 | |
| 974 | |
| 975 | class SortValues(BaseSetIndexSortValues): |
| 976 | _parameters = [ |
| 977 | "frame", |
| 978 | "by", |
| 979 | "ascending", |
| 980 | "na_position", |
| 981 | "npartitions", |
| 982 | "partition_size", |
| 983 | "sort_function", |
| 984 | "sort_function_kwargs", |
| 985 | "upsample", |
| 986 | "ignore_index", |
| 987 | "shuffle_method", |
| 988 | "options", # Options for the chosen shuffle method |
| 989 | ] |
| 990 | _defaults = { |
| 991 | "partition_size": 128e6, |
| 992 | "ascending": True, |
| 993 | "npartitions": None, |
| 994 | "na_position": "last", |
| 995 | "sort_function": None, |
| 996 | "sort_function_kwargs": None, |
| 997 | "upsample": 1.0, |
| 998 | "ignore_index": False, |
| 999 | "shuffle_method": None, |
| 1000 | } |
| 1001 | _filter_passthrough = True |
| 1002 | |
| 1003 | def _divisions(self): |
| 1004 | if self.frame.npartitions == 1: |
| 1005 | # Protect against triggering calculations when we only have one division |
| 1006 | return (None, None) |
| 1007 | |
| 1008 | divisions, mins, maxes, presorted = _get_divisions( |
| 1009 | self.frame, |
| 1010 | self.frame[self.by[0]], |
| 1011 | self._npartitions_input, |
| 1012 | self._divisions_ascending, |
| 1013 | upsample=self.upsample, |
| 1014 | ) |
| 1015 | if presorted: |
| 1016 | return self.frame.divisions |
| 1017 | return (None,) * len(divisions) |
| 1018 | |
| 1019 | @property |
| 1020 | def _divisions_ascending(self) -> bool: |
| 1021 | divisions_ascending = self.ascending |
| 1022 | if not isinstance(divisions_ascending, bool): |
| 1023 | divisions_ascending = divisions_ascending[0] |
| 1024 | assert isinstance(divisions_ascending, bool) |
| 1025 | return divisions_ascending |
| 1026 | |
| 1027 | @property |
| 1028 | def sort_function(self): |
| 1029 | if self.operand("sort_function") is not None: |
| 1030 | return self.operand("sort_function") |
| 1031 | return M.sort_values |
| 1032 |
no outgoing calls
no test coverage detected