Пример #1
0
 def find_first_value(
     self, value: ScalarLike, closest: bool = False
 ) -> int:
     """
     Returns offset of first value that matches. For monotonic
     columns, returns the offset of the first larger value
     if closest=True.
     """
     value = to_cudf_compatible_scalar(value)
     if not pd.api.types.is_number(value):
         raise ValueError("Expected a numeric value")
     found = 0
     if len(self):
         found = cudautils.find_first(
             self.data_array_view, value, mask=self.mask
         )
     if found == -1 and self.is_monotonic and closest:
         if value < self.min():
             found = 0
         elif value > self.max():
             found = len(self)
         else:
             found = cudautils.find_first(
                 self.data_array_view, value, mask=self.mask, compare="gt",
             )
             if found == -1:
                 raise ValueError("value not found")
     elif found == -1:
         raise ValueError("value not found")
     return found
Пример #2
0
 def find_first_value(self, value, closest=False):
     """
     Returns offset of first value that matches. For monotonic
     columns, returns the offset of the first larger value
     if closest=True.
     """
     found = 0
     if len(self):
         found = cudautils.find_first(self.data_array_view,
                                      value,
                                      mask=self.mask)
     if found == -1 and self.is_monotonic and closest:
         if value < self.min():
             found = 0
         elif value > self.max():
             found = len(self)
         else:
             found = cudautils.find_first(
                 self.data_array_view,
                 value,
                 mask=self.mask,
                 compare="gt",
             )
             if found == -1:
                 raise ValueError("value not found")
     elif found == -1:
         raise ValueError("value not found")
     return found
Пример #3
0
 def find_first_value(self, value):
     """
     Returns offset of first value that matches
     """
     found = cudautils.find_first(
         self.data.mem,
         value)
     if found == -1:
         raise ValueError('value not found')
     return found
Пример #4
0
 def find_first_value(self, value):
     """
     Returns offset of first value that matches. For monotonic
     columns, returns the offset of the first larger value.
     """
     found = cudautils.find_first(self.data.mem, value)
     if found == -1 and self.is_monotonic:
         if value < self.min():
             found = 0
         elif value > self.max():
             found = len(self)
         else:
             found = cudautils.find_first(self.data.mem,
                                          value,
                                          compare="gt")
             if found == -1:
                 raise ValueError("value not found")
     elif found == -1:
         raise ValueError("value not found")
     return found