Skip to content

Commit f74c047

Browse files
authored
BitGenerator support (#499)
1 parent b8d3489 commit f74c047

8 files changed

Lines changed: 440 additions & 2 deletions

File tree

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ __pycache__
1818

1919
# Coverage files
2020
*.lcov
21+
22+
# IDEs
23+
/.vscode/

‎Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ num-integer = "0.1"
2929
num-traits = "0.2"
3030
ndarray = ">= 0.15, <=0.17"
3131
pyo3 = { version = "0.29.0", default-features = false, features = ["macros"] }
32+
rand_core = { version = "0.9.3", default-features = false, optional = true }
3233
rustc-hash = "2.0"
3334

3435
[dev-dependencies]
3536
pyo3 = { version = "0.29.0", default-features = false, features = ["auto-initialize"]}
3637
nalgebra = { version = ">=0.30, <0.35", default-features = false, features = ["std"] }
3738
criterion = "0.8.2"
39+
rand = { version = "0.9.1", default-features = false }
3840

3941
[build-dependencies]
4042
pyo3-build-config = { version = "0.29", features = ["resolve-config"]}

‎src/lib.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pub mod datetime;
7979
mod dtype;
8080
mod error;
8181
pub mod npyffi;
82+
pub mod random;
8283
mod slice_container;
8384
mod strings;
8485
mod sum_products;

‎src/npyffi/mod.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ pub mod flags;
155155
mod npy_common;
156156
mod numpyconfig;
157157
pub mod objects;
158+
pub mod random;
158159
pub mod types;
159160
pub mod ufunc;
160161

@@ -163,5 +164,6 @@ pub use self::flags::*;
163164
pub use self::npy_common::*;
164165
pub use self::numpyconfig::*;
165166
pub use self::objects::*;
167+
pub use self::random::*;
166168
pub use self::types::*;
167169
pub use self::ufunc::*;

‎src/npyffi/objects.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Low-Lebel binding for NumPy C API C-objects
1+
//! Low-Level binding for NumPy C API C-objects
22
//!
33
//! <https://numpy.org/doc/stable/reference/c-api/types-and-structures.html>
44
#![allow(non_camel_case_types)]

‎src/npyffi/random.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use std::ffi::c_void;
2+
3+
#[repr(C)]
4+
#[derive(Debug)]
5+
pub struct bitgen_t {
6+
pub state: *mut c_void,
7+
pub next_uint64: unsafe extern "C" fn(*mut c_void) -> super::npy_uint64, //nogil
8+
pub next_uint32: unsafe extern "C" fn(*mut c_void) -> super::npy_uint32, //nogil
9+
pub next_double: unsafe extern "C" fn(*mut c_void) -> libc::c_double, //nogil
10+
pub next_raw: unsafe extern "C" fn(*mut c_void) -> super::npy_uint64, //nogil
11+
}

0 commit comments

Comments
 (0)