#8293·cupy

Complete implementation of cp.random.choice()

Author: FloWsnrCreated Apr 16, 2024Updated Sep 12, 2026
Labelscontribution welcomecat:numpy-compat

Description

Hi guys,

First of all, thank you for the amazing work. I'm interested in using cp.random.choice with replace=False as well as a given probability array. Currently this feature is not implemented. see here

Before I just write my own version of this function, I'd like to try and add the functionality to cupy. Since this would be my first contribution to cupy, I'd like to get some starter help...

Questions:

  1. Are there any ongoing efforts / PRs to do that?
  2. The choice function for the Generator class is completely missing. Is it worth it to add the functionality to cp.random.choice or should I directly try to add the choice function to the Generator class?
  3. Am I understanding the code correctly?
  • _sample.py just calls _generator.py (old random functions)
  • _generator_api.pyx is the new Generator class
  1. Since I am no cuda/Cython pro: Why is the old choice function exclusively in python while the new Generator class requires Cython?

Additional Information

No response