parallelkdepy.core

Low-level plumbing: Manage Julia session and interfacing between Python and Julia.

Functions

create_density_estimation(data, grid[, ...])

create_grid(ranges[, device, b32])

Create a grid instance of the Julia object ParallelKDE.Grid.

device_to_str(device)

estimate_density(density_estimation, ...)

find_grid(data[, grid_bounds, grid_dims, ...])

get_density(density_estimation, **kwargs)

grid_bounds(grid_jl)

grid_coordinates(grid_jl)

grid_device(grid_jl)

grid_fftgrid(grid_jl)

grid_initial_bandwidth(grid_jl)

grid_shape(grid_jl)

grid_step(grid_jl)

initialize_dirac_sequence(data[, grid_jl, ...])

Creates a numpy array with the dirac sequence obtained from the data on the grid.

str_to_symbol(s)

parallelkdepy.core.create_density_estimation(data: ndarray, grid, dims: Sequence | None = None, grid_bounds: Sequence[tuple] | None = None, grid_padding: Sequence | None = None, device: str = 'cpu')[source]
parallelkdepy.core.create_grid(ranges: Sequence, device: str = 'cpu', b32: bool | None = None)[source]

Create a grid instance of the Julia object ParallelKDE.Grid.

Parameters:
  • ranges (Sequence) – The ranges for the grid.

  • device (str, optional) – The device type, e.g., ‘cpu’ or ‘cuda’. Default is ‘cpu’.

  • b32 (Optional[bool], optional) – Whether to use 32-bit precision for GPU devices. Default is None, which behaves as True (32-bit precision) if the device is ‘cuda’. Setting it as False for ‘cuda’ devices will use 64-bit precision. This keyword argument is ignored when device is ‘cpu’.

Returns:

The created grid object in Julia.

Return type:

juliacall.AnyValue

parallelkdepy.core.device_to_str(device) str[source]
parallelkdepy.core.estimate_density(density_estimation, estimation_method: str, **kwargs)[source]
parallelkdepy.core.find_grid(data: ndarray, grid_bounds: Sequence[tuple] | None = None, grid_dims: Sequence | None = None, grid_steps: Sequence | None = None, grid_padding: Sequence | None = None, device: str = 'cpu')[source]
parallelkdepy.core.get_density(density_estimation, **kwargs) ndarray[source]
parallelkdepy.core.grid_bounds(grid_jl) list[tuple][source]
parallelkdepy.core.grid_coordinates(grid_jl) tuple[ndarray, ...][source]
parallelkdepy.core.grid_device(grid_jl) str[source]
parallelkdepy.core.grid_fftgrid(grid_jl)[source]
parallelkdepy.core.grid_initial_bandwidth(grid_jl) list[source]
parallelkdepy.core.grid_shape(grid_jl) tuple[source]
parallelkdepy.core.grid_step(grid_jl) list[source]
parallelkdepy.core.initialize_dirac_sequence(data: ndarray, grid_jl=None, bootstrap_indices: ndarray | None = None, device: str = 'cpu', method: str | None = None) ndarray[source]

Creates a numpy array with the dirac sequence obtained from the data on the grid.

Parameters:
  • data (np.ndarray) – Numpy array of the data with shape (n_samples, n_features).

  • grid_jl – Julia grid object.

  • bootstrap_indices (Optional[np.ndarray], optional) – Optional numpy array of bootstrap indices. If provided, it should have shape (n_bootstraps, n_samples).

  • device (str, optional) – The device to store the array, e.g., ‘cpu’ or ‘cuda’. Default is ‘cpu’.

  • method (str, optional) – The method to use for initializing the Dirac sequence, e.g., ‘serial’ or ‘parallel’. Default is ‘serial’.

parallelkdepy.core.str_to_symbol(s: str)[source]