Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gpuCI] Forward-merge branch-22.10 to branch-22.12 [skip gpuci] #11820

Merged
merged 1 commit into from
Sep 29, 2022

Commits on Sep 29, 2022

  1. Fix operator NotImplemented issue with numpy (#11816)

    Root cause:
    ```python
    In [1]: import numpy as np
    
    In [2]: x = np.uint8(1)
    
    In [3]: y = np.float64(1.0)
    
    In [4]: x.__ge__(y)
    Out[4]: NotImplemented
    
    In [8]: x >= y
    Out[8]: True
    ```
    This is leading to the following error whenever there is a Scalar binary operation involved:
    ```python
    python/cudf/cudf/tests/test_series.py:449: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    ../envs/cudfdev/lib/python3.9/contextlib.py:79: in inner
        return func(*args, **kwds)
    ../envs/cudfdev/lib/python3.9/site-packages/cudf/core/series.py:2988: in describe
        data = _describe_categorical(self, percentiles)
    ../envs/cudfdev/lib/python3.9/site-packages/cudf/core/series.py:152: in _describe_categorical
        val_counts = obj.value_counts(ascending=False)
    ../envs/cudfdev/lib/python3.9/contextlib.py:79: in inner
        return func(*args, **kwds)
    ../envs/cudfdev/lib/python3.9/site-packages/cudf/core/series.py:2862: in value_counts
        res = res.sort_values(ascending=ascending)
    ../envs/cudfdev/lib/python3.9/contextlib.py:79: in inner
        return func(*args, **kwds)
    ../envs/cudfdev/lib/python3.9/site-packages/cudf/core/series.py:1910: in sort_values
        return super().sort_values(
    ../envs/cudfdev/lib/python3.9/site-packages/cudf/core/indexed_frame.py:1916: in sort_values
        out = self._gather(
    ../envs/cudfdev/lib/python3.9/site-packages/cudf/core/indexed_frame.py:1523: in _gather
        if not libcudf.copying._gather_map_is_valid(
    copying.pyx:67: in cudf._lib.copying._gather_map_is_valid
        ???
    ../envs/cudfdev/lib/python3.9/site-packages/cudf/core/mixins/mixin_factory.py:11: in wrapper
        return method(self, *args1, *args2, **kwargs1, **kwargs2)
    ../envs/cudfdev/lib/python3.9/site-packages/cudf/core/scalar.py:350: in _binaryop
        return Scalar(result, dtype=out_dtype)
    ../envs/cudfdev/lib/python3.9/site-packages/cudf/core/scalar.py:56: in __call__
        obj = super().__call__(value, dtype=dtype)
    ../envs/cudfdev/lib/python3.9/site-packages/cudf/core/scalar.py:128: in __init__
        self._host_value, self._host_dtype = self._preprocess_host_value(
    ../envs/cudfdev/lib/python3.9/site-packages/cudf/core/scalar.py:222: in _preprocess_host_value
        value = to_cudf_compatible_scalar(value, dtype=dtype)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    val = NotImplemented, dtype = <class 'numpy.bool_'>
    
        def to_cudf_compatible_scalar(val, dtype=None):
            """
            Converts the value `val` to a numpy/Pandas scalar,
            optionally casting to `dtype`.
        
            If `val` is None, returns None.
            """
        
            if cudf._lib.scalar._is_null_host_scalar(val) or isinstance(
                val, cudf.Scalar
            ):
                return val
        
            if not cudf.api.types._is_scalar_or_zero_d_array(val):
    >           raise ValueError(
                    f"Cannot convert value of type {type(val).__name__} "
                    "to cudf scalar"
                )
    E           ValueError: Cannot convert value of type NotImplementedType to cudf scalar
    
    ../envs/cudfdev/lib/python3.9/site-packages/cudf/utils/dtypes.py:248: ValueError
    ```
    This PR fixes the issue by first trying to call the `op` with `operator` standard library and then try to `getattr` if the `op` is not found in `operator` module.
    
    Authors:
      - GALI PREM SAGAR (https://github.com/galipremsagar)
    
    Approvers:
      - Lawrence Mitchell (https://github.com/wence-)
      - https://github.com/brandon-b-miller
    
    URL: #11816
    galipremsagar authored Sep 29, 2022
    Configuration menu
    Copy the full SHA
    ddfd07f View commit details
    Browse the repository at this point in the history