Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1c3c66f
feat: init unuran python api
wrdxwrdxwrdx Dec 10, 2025
d61a468
feat: init unuran build
wrdxwrdxwrdx Dec 10, 2025
93947cb
feat: unuran sampler and strategy implementation
wrdxwrdxwrdx Dec 11, 2025
e9b26d9
feat: new registry graph
LeonidElkin Nov 6, 2025
0daadb0
feat: init unuran python api
wrdxwrdxwrdx Dec 10, 2025
7149909
refactor: code style
wrdxwrdxwrdx Dec 18, 2025
eef7832
refactor: global typing + ruff fix
wrdxwrdxwrdx Dec 21, 2025
c267cc1
fixup! refactor: global typing + ruff fix
wrdxwrdxwrdx Dec 21, 2025
140f0d1
test: unuran sampling
wrdxwrdxwrdx Dec 21, 2025
69f0415
refactor: split unuran sampler into _unuran_sampler dir
wrdxwrdxwrdx Dec 23, 2025
c03f7f0
docs: sampling examples
wrdxwrdxwrdx Dec 23, 2025
13eae11
fixup! docs: sampling examples
wrdxwrdxwrdx Dec 23, 2025
3e9fc74
feat: ppf usage
wrdxwrdxwrdx Dec 23, 2025
91a14bf
feat: poetry unuran build
wrdxwrdxwrdx Dec 23, 2025
ab016ed
fixup! feat: poetry unuran build
wrdxwrdxwrdx Dec 23, 2025
2ee5ba3
fix: windows build
wrdxwrdxwrdx Dec 23, 2025
672e40a
Revert "fix: windows build"
wrdxwrdxwrdx Dec 23, 2025
d08e429
fix: turn off windows build
wrdxwrdxwrdx Dec 23, 2025
25c50f4
fixup! fix: turn off windows build
wrdxwrdxwrdx Dec 23, 2025
60f68a5
fix: extra diff from main
wrdxwrdxwrdx Dec 23, 2025
22e651b
fixup! fix: extra diff from main
wrdxwrdxwrdx Dec 23, 2025
93ea645
fix: mark vendor as generated code
wrdxwrdxwrdx Dec 23, 2025
80178c1
fixup! fix: mark vendor as generated code
wrdxwrdxwrdx Dec 23, 2025
59aa55f
Revert "fixup! fix: mark vendor as generated code"
wrdxwrdxwrdx Dec 23, 2025
377c693
Revert "fix: mark vendor as generated code"
wrdxwrdxwrdx Dec 23, 2025
af15d3b
feat: CODEOWNERS for ignoring vendor
wrdxwrdxwrdx Dec 23, 2025
3b9d102
fix: remove vendor binary files
wrdxwrdxwrdx Dec 23, 2025
5da78ec
fixup! fix: remove vendor binary files
wrdxwrdxwrdx Dec 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ __pycache__/

# C extensions
*.so
*.o

# Distribution / packaging
.Python
Expand Down Expand Up @@ -125,3 +126,6 @@ poetry.lock
# refer to https://docs.cursor.com/context/ignore-files
.cursorignore
.cursorindexingignore

# Log files
*.log
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ exclude: >
| \.gitignore$
| LICENSE$
| .*\.md$
| vendor/.*
)$

repos:
Expand Down Expand Up @@ -67,3 +68,4 @@ repos:
- scipy>=1.13
- pytest>=8
- scipy-stubs>=1.13
- types-setuptools>=75
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ git clone https://github.com/PySATL/pysatl-core.git
cd pysatl-core
```

Install dependencies (via Poetry):
Install dependencies and build project (via Poetry):

```bash
poetry install
poetry build
```

Or install the package locally with `pip` (editable):
Expand Down
590 changes: 590 additions & 0 deletions examples/example_sampling_strategy_custom_distribution.ipynb

Large diffs are not rendered by default.

Binary file added examples/plots/discrete_pmf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/plots/exp_cdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/plots/exp_pdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/plots/normal_override.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
[build-system]
build-backend = "poetry.core.masonry.api"

requires = [ "poetry-core>=1.9" ]
requires = [
"cffi>=1.16",
"poetry-core>=1.9",
"setuptools>=69",
]

[tool.poetry]
name = "pysatl-core"
Expand Down Expand Up @@ -41,10 +45,14 @@ homepage = "https://github.com/PySATL/pysatl-core"
repository = "https://github.com/PySATL/pysatl-core"
urls.Issues = "https://github.com/PySATL/pysatl-core/issues"

[tool.poetry.build]
script = "src/pysatl_core/stats/_unuran/bindings/_cffi_build.py"

[tool.poetry.dependencies]
python = ">=3.12"
numpy = "^2.0.0"
scipy = ">=1.13"
cffi = "^1.16.0"

[tool.poetry.group.dev.dependencies]
ruff = ">=0.6"
Expand All @@ -55,6 +63,7 @@ coverage = { version = ">=7.5", extras = [ "toml" ] }
pre-commit = ">=3.6"
types-setuptools = "*"
scipy-stubs = ">=1.13.0.0"
types-cffi = ">=1.17.0.0"

[tool.poetry.group.docs.dependencies]
jupyter = "^1.1.1"
Expand All @@ -63,6 +72,7 @@ matplotlib = "^3.10.6"
[tool.ruff]
target-version = "py312"
line-length = 100
exclude = [ "vendor" ]

format.line-ending = "lf"

Expand All @@ -77,6 +87,9 @@ lint.isort.force-single-line = false
lint.isort.known-first-party = [ "pysatl_core" ]
lint.isort.order-by-type = true

[tool.codespell]
skip = "vendor/**"

[tool.pytest.ini_options]
addopts = "-q --cov=pysatl_core --cov-report=term-missing"
testpaths = [ "tests" ]
Expand Down
13 changes: 13 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
Setup script for pysatl-core with CFFI support.

This file is needed to integrate CFFI modules with Poetry.
"""

from setuptools import setup

setup(
cffi_modules=[
"src/pysatl_core/stats/_unuran/bindings/_cffi_build.py:ffi",
],
)
57 changes: 57 additions & 0 deletions src/pysatl_core/stats/_unuran/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""
UNU.RAN Integration API
=======================

This module defines the API for UNU.RAN (Universal Non-Uniform Random Number
Generator) integration. UNU.RAN provides efficient methods for generating
non-uniform random variates from various distributions.

The API described here will be implemented through C bindings to the UNU.RAN
library in the future. Currently, this module only provides the interface
specification for integration with the distribution sampling system.

Notes
-----
- UNU.RAN supports multiple sampling methods (inversion, rejection, etc.)
- Methods can be selected automatically or specified explicitly
- The API integrates with the :class:`~pysatl_core.distributions.strategies.SamplingStrategy`
protocol
- Currently, only univariate distributions are supported

Examples
--------
Create a UNU.RAN sampling strategy for a distribution:

>>> from pysatl_core.stats._unuran import (
>>> create_unuran_strategy, UnuranMethodConfig, UnuranMethod
>>> )
>>> config = UnuranMethodConfig(method=UnuranMethod.AUTO)
>>> strategy = create_unuran_strategy(config)
>>> sample = strategy.sample(n=1000, distr=my_distribution)
"""

from __future__ import annotations

__author__ = "Artem Romanyuk"
__copyright__ = "Copyright (c) 2025 PySATL project"
__license__ = "SPDX-License-Identifier: MIT"

from pysatl_core.stats._unuran.api import (
UnuranMethod,
UnuranMethodConfig,
UnuranSampler,
UnuranSamplingStrategy,
)
from pysatl_core.stats._unuran.bindings import (
DefaultUnuranSampler,
DefaultUnuranSamplingStrategy,
)

__all__ = [
"UnuranMethod",
"UnuranMethodConfig",
"UnuranSampler",
"UnuranSamplingStrategy",
"DefaultUnuranSampler",
"DefaultUnuranSamplingStrategy",
]
Loading