From 03b8f8c54ca0c7a46442779bb42945322990e617 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 15 Oct 2026 04:53:48 -0700 Subject: [PATCH 01/13] Remove dead PyString fallbacks from mklrand_py_helper.h --- mkl_random/src/mklrand_py_helper.h | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/mkl_random/src/mklrand_py_helper.h b/mkl_random/src/mklrand_py_helper.h index 90860965..2ac993c5 100644 --- a/mkl_random/src/mklrand_py_helper.h +++ b/mkl_random/src/mklrand_py_helper.h @@ -8,36 +8,15 @@ static PyObject *empty_py_bytes(npy_intp length, void **bytesVec) { PyObject *b; -#if PY_MAJOR_VERSION >= 3 b = PyBytes_FromStringAndSize(NULL, length); if (b) { *bytesVec = PyBytes_AS_STRING(b); } -#else - b = PyString_FromStringAndSize(NULL, length); - if (b) { - *bytesVec = PyString_AS_STRING(b); - } -#endif return b; } -static char *py_bytes_DataPtr(PyObject *b) -{ -#if PY_MAJOR_VERSION >= 3 - return PyBytes_AS_STRING(b); -#else - return PyString_AS_STRING(b); -#endif -} +static char *py_bytes_DataPtr(PyObject *b) { return PyBytes_AS_STRING(b); } -static int is_bytes_object(PyObject *b) -{ -#if PY_MAJOR_VERSION >= 3 - return PyBytes_Check(b); -#else - return PyString_Check(b); -#endif -} +static int is_bytes_object(PyObject *b) { return PyBytes_Check(b); } #endif /* _MKLRAND_PY_HELPER_H_ */ From 07774f9bfd595b6e71e6553e71efe6ca70a554c8 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 15 Oct 2026 04:58:07 -0700 Subject: [PATCH 02/13] Add gh-192 to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf6573c8..5fd13e98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed * Removed the `python-gil` constraint from the conda recipes, which pinned `mkl_random` to GIL-enabled Python 3.14 builds [gh-159](https://github.com/IntelPython/mkl_random/pull/159) +* Removed the dead `PyString_*` Python 2 branches from `mklrand_py_helper.h`, since the project requires Python 3.10+ [gh-192](https://github.com/IntelPython/mkl_random/pull/192) ## [1.5.0] (08/12/2026) From 3beb87d8960d0f29f48bcc8b9bd0245fb40e23cd Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 15 Oct 2026 06:50:45 -0700 Subject: [PATCH 03/13] Replace mklrand_py_helper.h with cpython.bytes cimports With the Python 2 branches gone, the three helpers only wrapped calls that Cython already declares in cpython.bytes, so the header had no reason to exist. Dropping it also removes its hidden dependency on include order: it used npy_intp while including only . PyBytes_Check stands in for isinstance(x, bytes) because the module-level `bytes = _rand.bytes` alias shadows the builtin here. --- mkl_random/mklrand.pyx | 29 ++++++++++++++++------------- mkl_random/src/mklrand_py_helper.h | 22 ---------------------- 2 files changed, 16 insertions(+), 35 deletions(-) delete mode 100644 mkl_random/src/mklrand_py_helper.h diff --git a/mkl_random/mklrand.pyx b/mkl_random/mklrand.pyx index 959b7bfd..2a2a98fc 100644 --- a/mkl_random/mklrand.pyx +++ b/mkl_random/mklrand.pyx @@ -38,6 +38,11 @@ cdef extern from "numpy/npy_no_deprecated_api.h": cimport cpython.tuple cimport cython cimport numpy as cnp +from cpython.bytes cimport ( + PyBytes_AS_STRING, + PyBytes_Check, + PyBytes_FromStringAndSize, +) from libc.stdint cimport int64_t from libc.string cimport memcpy, memset @@ -48,11 +53,6 @@ cdef extern from "math.h": cdef extern from "numpy/npy_math.h": int npy_isfinite(double x) -cdef extern from "mklrand_py_helper.h": - object empty_py_bytes(cnp.npy_intp length, void **bytesVec) - char* py_bytes_DataPtr(object b) - int is_bytes_object(object b) - cdef extern from "numpy_multiiter_workaround.h": cnp.npy_intp cnp_PyArray_MultiIter_SIZE \ "workaround_PyArray_MultiIter_SIZE"(cnp.broadcast multi) nogil @@ -1917,7 +1917,7 @@ cdef class _MKLRandomState: cdef int state_buffer_size = 0 cdef int cur_size cdef int brng_id - cdef void *bytesPtr + cdef char *bytesPtr bytestring = None # Reseed can change the size; grow until the buffer fits, then save @@ -1926,10 +1926,11 @@ cdef class _MKLRandomState: cur_size = irk_get_stream_size(self.internal_state) if cur_size <= state_buffer_size: brng_id = irk_get_brng_mkl(self.internal_state) - irk_get_state_mkl(self.internal_state, bytesPtr) + irk_get_state_mkl(self.internal_state, bytesPtr) break state_buffer_size = cur_size - bytestring = empty_py_bytes(state_buffer_size, &bytesPtr) + bytestring = PyBytes_FromStringAndSize(NULL, state_buffer_size) + bytesPtr = PyBytes_AS_STRING(bytestring) if cur_size != state_buffer_size: bytestring = bytestring[:cur_size] @@ -2037,10 +2038,11 @@ cdef class _MKLRandomState: expected_brng = _brng_dict[algorithm_name] stream_buf = state[1] - if not is_bytes_object(stream_buf): + # NB: the module-level `bytes` alias shadows the builtin here + if not PyBytes_Check(stream_buf): raise ValueError("state is expected to be bytes") - bytes_ptr = py_bytes_DataPtr(stream_buf) + bytes_ptr = PyBytes_AS_STRING(stream_buf) with self.lock: err = irk_set_state_mkl( @@ -2670,10 +2672,11 @@ cdef class _MKLRandomState: ' eh\\x85\\x022SZ\\xbf\\xa4' #random """ - cdef void *bytes - bytestring = empty_py_bytes(length, &bytes) + cdef char *bytes_ptr + bytestring = PyBytes_FromStringAndSize(NULL, length) + bytes_ptr = PyBytes_AS_STRING(bytestring) with self.lock, nogil: - irk_fill(bytes, length, self.internal_state) + irk_fill(bytes_ptr, length, self.internal_state) return bytestring def choice(self, a, size=None, replace=True, p=None): diff --git a/mkl_random/src/mklrand_py_helper.h b/mkl_random/src/mklrand_py_helper.h deleted file mode 100644 index 2ac993c5..00000000 --- a/mkl_random/src/mklrand_py_helper.h +++ /dev/null @@ -1,22 +0,0 @@ -// clang-format off -#ifndef _MKLRAND_PY_HELPER_H_ -#define _MKLRAND_PY_HELPER_H_ - -#include -// clang-format on - -static PyObject *empty_py_bytes(npy_intp length, void **bytesVec) -{ - PyObject *b; - b = PyBytes_FromStringAndSize(NULL, length); - if (b) { - *bytesVec = PyBytes_AS_STRING(b); - } - return b; -} - -static char *py_bytes_DataPtr(PyObject *b) { return PyBytes_AS_STRING(b); } - -static int is_bytes_object(PyObject *b) { return PyBytes_Check(b); } - -#endif /* _MKLRAND_PY_HELPER_H_ */ From 289076fe856028560543f1359ff4fa9a33816046 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 15 Oct 2026 06:51:09 -0700 Subject: [PATCH 04/13] Remove the no-op __future__ import absolute_import, division and print_function are unconditional on Python 3, and the project requires Python 3.10+. --- mkl_random/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/mkl_random/__init__.py b/mkl_random/__init__.py index 774811b2..65abf2ce 100644 --- a/mkl_random/__init__.py +++ b/mkl_random/__init__.py @@ -23,8 +23,6 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from __future__ import absolute_import, division, print_function - from . import _init_helper from ._version import __version__ from .mklrand import ( From 116f219d290fcd223d54fa3f69bd398d916a623d Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 15 Oct 2026 06:51:17 -0700 Subject: [PATCH 05/13] Update the bytes and tomaxint docstrings for Python 3 `bytes` documented its return as `str` and showed a repr without the `b` prefix; `tomaxint` compared against `sys.maxint`. The comparison now uses `np.iinfo("long").max`, matching the range in the summary line, and the bool array drops the `dtype=bool` suffix NumPy 2 no longer prints. --- mkl_random/mklrand.pyx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/mkl_random/mklrand.pyx b/mkl_random/mklrand.pyx index 2a2a98fc..167efb32 100644 --- a/mkl_random/mklrand.pyx +++ b/mkl_random/mklrand.pyx @@ -2663,13 +2663,13 @@ cdef class _MKLRandomState: Returns ------- - out : str + out : bytes String of length `length`. Examples -------- >>> mkl_random.bytes(10) - ' eh\\x85\\x022SZ\\xbf\\xa4' #random + b' eh\\x85\\x022SZ\\xbf\\xa4' #random """ cdef char *bytes_ptr @@ -3580,14 +3580,12 @@ cdef class _MKLRandomState: [ 739731006, 1947757578]], [[1871712945, 752307660], [1601631370, 1479324245]]]) - >>> import sys - >>> sys.maxint - 2147483647 - >>> RS.tomaxint((2,2,2)) < sys.maxint + >>> import numpy as np + >>> RS.tomaxint((2,2,2)) < np.iinfo("long").max array([[[ True, True], [ True, True]], [[ True, True], - [ True, True]]], dtype=bool) + [ True, True]]]) """ return vec_long_disc0_array( From f77982f7cd938836fb71b2c4a149feb526384e07 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 15 Oct 2026 06:51:25 -0700 Subject: [PATCH 06/13] Move the gh-192 changelog entry out of Removed Per review, "Removed" is for functionality users lose. Log the cleanup under "Changed" and the docstring corrections under "Fixed". --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fd13e98..ece1b8e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Updated the `randint_untyped` implementation, which now supports `array_like` (broadcastable) `low`/`high` bounds [gh-176](https://github.com/IntelPython/mkl_random/pull/176) * Sped up `randint` with `array_like` bounds by generating words in cache-sized chunks and by picking the Lemire rejection test by range width [gh-173](https://github.com/IntelPython/mkl_random/pull/173) * Reduced the memory use and sped up integer generation with `WH`, `MCG31`, `R250` and `MRG32K3A`, which lack `viRngUniformBits` support [gh-178](https://github.com/IntelPython/mkl_random/pull/178) +* Replaced the `mklrand_py_helper.h` shim with `cpython.bytes` cimports and dropped the no-op `__future__` import, since the project requires Python 3.10+ [gh-192](https://github.com/IntelPython/mkl_random/pull/192) ### Fixed * Fixed an out-of-range integer `brng` indexing `brng_list` past its end, which returned uninitialized memory as random values; it now warns and falls back to `MT19937` [gh-177](https://github.com/IntelPython/mkl_random/pull/177) @@ -41,10 +42,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Fixed 64-bit integer generation returning zeros or crashing with `PHILOX4X32X10` and `ARS5` for requests of `2**30` elements or more [gh-175](https://github.com/IntelPython/mkl_random/pull/175) * Fixed `randint_untyped` raising `OverflowError` for bounds outside the C `long` range, e.g. `2**40` on Windows [gh-176](https://github.com/IntelPython/mkl_random/pull/176) * Fixed `multinormal_cholesky` silently returning wrong output, e.g. every sample equal to `mean`, when the number of samples times the dimension exceeds `MKL_INT_MAX` [gh-187](https://github.com/IntelPython/mkl_random/pull/187) +* Fixed the `bytes` and `tomaxint` docstrings, which documented a `str` return type and the Python 2 `sys.maxint` [gh-192](https://github.com/IntelPython/mkl_random/pull/192) ### Removed * Removed the `python-gil` constraint from the conda recipes, which pinned `mkl_random` to GIL-enabled Python 3.14 builds [gh-159](https://github.com/IntelPython/mkl_random/pull/159) -* Removed the dead `PyString_*` Python 2 branches from `mklrand_py_helper.h`, since the project requires Python 3.10+ [gh-192](https://github.com/IntelPython/mkl_random/pull/192) ## [1.5.0] (08/12/2026) From 5285bf407892247fdedc17c424078daafca5ac6b Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 15 Oct 2026 06:58:32 -0700 Subject: [PATCH 07/13] Describe the bytes return value as bytes, not a string The return type was corrected to `bytes`, but the line below it still read "String of length `length`.", matching NumPy's own wording. --- mkl_random/mklrand.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkl_random/mklrand.pyx b/mkl_random/mklrand.pyx index 167efb32..33af97cc 100644 --- a/mkl_random/mklrand.pyx +++ b/mkl_random/mklrand.pyx @@ -2664,7 +2664,7 @@ cdef class _MKLRandomState: Returns ------- out : bytes - String of length `length`. + Bytes of length `length`. Examples -------- From 65e146f77e8af73ce0d4685fa04a192fcb9f3fde Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 15 Oct 2026 16:22:00 -0700 Subject: [PATCH 08/13] Replace the remaining Python 2 references in docs and comments The `random_sample` and `random_integers` examples printed `` reprs, `random_integers` described `np.int` as Python 2's "short" integer type, `randint` documented its default dtype as `'np.int'` (removed in NumPy 1.24), and the `zipf` comment described the C long bounds as `sys.maxint`. Wording follows NumPy's current docstrings. Also marks the `tomaxint` example output as `# random`, which the removed `sys.maxint` lines used to imply. --- mkl_random/mklrand.pyx | 19 ++++++++++--------- mkl_random/src/mkl_distributions.cpp | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/mkl_random/mklrand.pyx b/mkl_random/mklrand.pyx index 33af97cc..d697b371 100644 --- a/mkl_random/mklrand.pyx +++ b/mkl_random/mklrand.pyx @@ -2093,7 +2093,7 @@ cdef class _MKLRandomState: >>> mkl_random.random_sample() 0.47108547995356098 >>> type(mkl_random.random_sample()) - + >>> mkl_random.random_sample((5,)) array([ 0.30220482, 0.86820401, 0.1654503 , 0.11659149, 0.54323428]) @@ -2552,7 +2552,7 @@ cdef class _MKLRandomState: Desired dtype of the result. All dtypes are determined by their name, i.e., 'int64', 'int', etc, so byteorder is not available and a specific precision may have different C types depending - on the platform. The default value is 'np.int'. + on the platform. The default value is long. .. versionadded:: 1.11.0 @@ -3095,13 +3095,14 @@ cdef class _MKLRandomState: """ random_integers(low, high=None, size=None) - Random integers of type np.int between `low` and `high`, inclusive. + Random integers of type `numpy.int_` between `low` and `high`, + inclusive. - Return random integers of type np.int from the "discrete uniform" + Return random integers of type `numpy.int_` from the "discrete uniform" distribution in the closed interval [`low`, `high`]. If `high` is - None (the default), then results are from [1, `low`]. The np.int - type translates to the C long type used by Python 2 for "short" - integers and its precision is platform dependent. + None (the default), then results are from [1, `low`]. The `numpy.int_` + type translates to the C long integer type and its precision + is platform dependent. This function has been deprecated. Use randint instead. @@ -3145,7 +3146,7 @@ cdef class _MKLRandomState: >>> mkl_random.random_integers(5) 4 >>> type(mkl_random.random_integers(5)) - + >>> mkl_random.random_integers(5, size=(3.,2.)) array([[5, 4], [3, 3], @@ -3576,7 +3577,7 @@ cdef class _MKLRandomState: -------- >>> RS = mkl_random.MKLRandomState() # need a MKLRandomState object >>> RS.tomaxint((2,2,2)) - array([[[1170048599, 1600360186], + array([[[1170048599, 1600360186], # random [ 739731006, 1947757578]], [[1871712945, 752307660], [1601631370, 1479324245]]]) diff --git a/mkl_random/src/mkl_distributions.cpp b/mkl_random/src/mkl_distributions.cpp index 9320ad78..81c6f0e1 100644 --- a/mkl_random/src/mkl_distributions.cpp +++ b/mkl_random/src/mkl_distributions.cpp @@ -1507,10 +1507,10 @@ void irk_zipf_long_vec(irk_state *state, V = Vvec[i]; X = (long)floor(pow(U, (-1.0) / am1)); /* The real result may be above what can be represented in a signed - * long. It will get casted to -sys.maxint-1. Since this is + * long. It will get casted to LONG_MIN. Since this is * a straightforward rejection algorithm, we can just reject this * value in the rejection condition below. This function then models - * a Zipf distribution truncated to sys.maxint. + * a Zipf distribution truncated to LONG_MAX. */ T = pow(d_one + d_one / X, am1); if ((X > 0) && ((V * X) * (T - d_one) / (b - d_one) <= T / b)) { From 1b670b1f25841083fa8582544586f3e6f9110040 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 15 Oct 2026 16:22:16 -0700 Subject: [PATCH 09/13] Initialize the get_state buffer pointer to NULL If irk_get_stream_size returns 0 or a negative MKL error code on the first pass, the loop takes the save branch with bytesPtr never assigned, which g++ reports under -Wmaybe-uninitialized. NULL also makes that path well defined: vslSaveStreamM rejects a NULL buffer instead of writing. --- mkl_random/mklrand.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkl_random/mklrand.pyx b/mkl_random/mklrand.pyx index d697b371..3352724b 100644 --- a/mkl_random/mklrand.pyx +++ b/mkl_random/mklrand.pyx @@ -1917,7 +1917,7 @@ cdef class _MKLRandomState: cdef int state_buffer_size = 0 cdef int cur_size cdef int brng_id - cdef char *bytesPtr + cdef char *bytesPtr = NULL bytestring = None # Reseed can change the size; grow until the buffer fits, then save From da0d22c987cf6989801169990dd7c5a211ba3de3 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 15 Oct 2026 16:22:19 -0700 Subject: [PATCH 10/13] Split the gh-192 changelog entries The single entry read as if both docstrings had both defects; only `bytes` documented a `str` return and only `tomaxint` used `sys.maxint`. --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ece1b8e9..803255b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,7 +42,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Fixed 64-bit integer generation returning zeros or crashing with `PHILOX4X32X10` and `ARS5` for requests of `2**30` elements or more [gh-175](https://github.com/IntelPython/mkl_random/pull/175) * Fixed `randint_untyped` raising `OverflowError` for bounds outside the C `long` range, e.g. `2**40` on Windows [gh-176](https://github.com/IntelPython/mkl_random/pull/176) * Fixed `multinormal_cholesky` silently returning wrong output, e.g. every sample equal to `mean`, when the number of samples times the dimension exceeds `MKL_INT_MAX` [gh-187](https://github.com/IntelPython/mkl_random/pull/187) -* Fixed the `bytes` and `tomaxint` docstrings, which documented a `str` return type and the Python 2 `sys.maxint` [gh-192](https://github.com/IntelPython/mkl_random/pull/192) +* Fixed the `bytes` docstring, which documented a `str` return type instead of `bytes` [gh-192](https://github.com/IntelPython/mkl_random/pull/192) +* Fixed the `tomaxint` example, which compared against the Python 2 `sys.maxint` [gh-192](https://github.com/IntelPython/mkl_random/pull/192) +* Fixed the remaining Python 2 references in the `random_sample`, `random_integers` and `randint` docstrings and in the `zipf` implementation comment: the `` reprs, `np.int` and `sys.maxint` [gh-192](https://github.com/IntelPython/mkl_random/pull/192) ### Removed * Removed the `python-gil` constraint from the conda recipes, which pinned `mkl_random` to GIL-enabled Python 3.14 builds [gh-159](https://github.com/IntelPython/mkl_random/pull/159) From 543277e7eddf4f8d1a13adb843474e5e912f8262 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Thu, 15 Oct 2026 16:24:34 -0700 Subject: [PATCH 11/13] Initialize the set_state error code to zero Same -Wmaybe-uninitialized case as the buffer pointer: `err` is assigned inside the lock and read after it, so g++ cannot prove the assignment. Zero is the "no error" value the checks below compare against. --- mkl_random/mklrand.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkl_random/mklrand.pyx b/mkl_random/mklrand.pyx index 3352724b..e8eae9fd 100644 --- a/mkl_random/mklrand.pyx +++ b/mkl_random/mklrand.pyx @@ -1990,7 +1990,7 @@ cdef class _MKLRandomState: """ cdef char *bytes_ptr - cdef int err + cdef int err = 0 cdef cnp.ndarray obj "arrayObject_obj" if isinstance(state, dict): From dcce30f78ca30f52e4a8cd5ff17023ced5301f2a Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 16 Oct 2026 02:45:30 -0700 Subject: [PATCH 12/13] Describe random_integers as returning a C long Per review: on NumPy 2 `numpy.int_` is `intp`, which is 64-bit on Windows, while this returns a 32-bit C long there, so the wording borrowed from NumPy is wrong. The example type was wrong too, in the same way the original `` was: `random_integers` delegates to `randint(..., dtype="l")`, which returns a NumPy scalar, not a Python int. Also fixes the neighbouring example, which passed a float `size` that raises TypeError now, and marks the random output as NumPy does. --- mkl_random/mklrand.pyx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/mkl_random/mklrand.pyx b/mkl_random/mklrand.pyx index e8eae9fd..fb5d71c6 100644 --- a/mkl_random/mklrand.pyx +++ b/mkl_random/mklrand.pyx @@ -3095,14 +3095,12 @@ cdef class _MKLRandomState: """ random_integers(low, high=None, size=None) - Random integers of type `numpy.int_` between `low` and `high`, - inclusive. + Random integers of C `long` type between `low` and `high`, inclusive. - Return random integers of type `numpy.int_` from the "discrete uniform" + Return random integers of C `long` type from the "discrete uniform" distribution in the closed interval [`low`, `high`]. If `high` is - None (the default), then results are from [1, `low`]. The `numpy.int_` - type translates to the C long integer type and its precision - is platform dependent. + None (the default), then results are from [1, `low`]. The precision + of C `long` is platform dependent. This function has been deprecated. Use randint instead. @@ -3144,11 +3142,11 @@ cdef class _MKLRandomState: Examples -------- >>> mkl_random.random_integers(5) - 4 + 4 # random >>> type(mkl_random.random_integers(5)) - - >>> mkl_random.random_integers(5, size=(3.,2.)) - array([[5, 4], + + >>> mkl_random.random_integers(5, size=(3,2)) + array([[5, 4], # random [3, 3], [4, 5]]) From 336a8f19cc21c38f8c52456f803f0d6ec45dfe2c Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Fri, 16 Oct 2026 02:46:00 -0700 Subject: [PATCH 13/13] Add the random_integers docstring fix to the changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 803255b9..cc9a00b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Fixed the `bytes` docstring, which documented a `str` return type instead of `bytes` [gh-192](https://github.com/IntelPython/mkl_random/pull/192) * Fixed the `tomaxint` example, which compared against the Python 2 `sys.maxint` [gh-192](https://github.com/IntelPython/mkl_random/pull/192) * Fixed the remaining Python 2 references in the `random_sample`, `random_integers` and `randint` docstrings and in the `zipf` implementation comment: the `` reprs, `np.int` and `sys.maxint` [gh-192](https://github.com/IntelPython/mkl_random/pull/192) +* Fixed the `random_integers` docstring, which described the result as `numpy.int_` rather than a C `long`, documented the wrong scalar return type, and passed a float `size` that no longer works [gh-192](https://github.com/IntelPython/mkl_random/pull/192) ### Removed * Removed the `python-gil` constraint from the conda recipes, which pinned `mkl_random` to GIL-enabled Python 3.14 builds [gh-159](https://github.com/IntelPython/mkl_random/pull/159)