python3Packages.funsor: 0.4.7 -> 0.4.8 (#548882)

This commit is contained in:
Nick Cao
2026-08-03 22:03:31 +00:00
committed by GitHub
4 changed files with 92 additions and 85 deletions

View File

@@ -3,6 +3,7 @@
stdenv,
buildPythonPackage,
fetchFromGitHub,
fetchpatch,
# build-system
setuptools,
@@ -42,6 +43,16 @@ buildPythonPackage (finalAttrs: {
hash = "sha256-tUTtImqPlbS8g1oLoTTCCWQbeLwLop13qPjFrQeMtb8=";
};
patches = [
# Allow scipy 1.18 in batched L-BFGS-B fast path
# https://github.com/meta-pytorch/botorch/pull/3328
(fetchpatch {
name = "scipy-1.18.patch";
url = "https://github.com/meta-pytorch/botorch/commit/611f14acc8c1b2f30ce2ae058568d90f96bbb2ec.patch";
hash = "sha256-PiXq9GmPaWQXh+emY7aNI53Y+ufl8K5uOFa8GD0clP8=";
})
];
build-system = [
setuptools
setuptools-scm

View File

@@ -2,7 +2,6 @@
lib,
buildPythonPackage,
fetchFromGitHub,
fetchpatch,
# build-system
setuptools,
@@ -29,7 +28,7 @@
buildPythonPackage (finalAttrs: {
pname = "funsor";
version = "0.4.7";
version = "0.4.8";
pyproject = true;
__structuredAttrs = true;
@@ -37,15 +36,15 @@ buildPythonPackage (finalAttrs: {
owner = "pyro-ppl";
repo = "funsor";
tag = finalAttrs.version;
hash = "sha256-0STJv1OOliJaHdmYUXdnOnocH3hVXceH/Uw5nILvT+U=";
hash = "sha256-iTkDd6vz4wesY3jABSMxLtTKioP98DhGB0plLL+vhNY=";
};
patches = [
# Compatibility with torch >= 2.5 (arg_constraints is now a property)
(fetchpatch {
url = "https://github.com/pyro-ppl/funsor/commit/c5e2a48d73cad4e98058147af4090171272a44e5.patch";
hash = "sha256-sTR+hbJtS0Th5sIqlvB2bReEC0wnEbnB7gAiZKiqjAQ=";
})
# Compatibility with torch >= 2.5, where `Uniform.arg_constraints` is a property.
# Remaining part of the pending upstream PR https://github.com/pyro-ppl/funsor/pull/610
# (the `Uniform` parameter registration was already merged as part of
# https://github.com/pyro-ppl/funsor/pull/614).
./torch-arg-constraints-property.patch
];
build-system = [ setuptools ];

View File

@@ -0,0 +1,52 @@
diff --git a/funsor/distribution.py b/funsor/distribution.py
index 5a48ecb..cfb2d2e 100644
--- a/funsor/distribution.py
+++ b/funsor/distribution.py
@@ -309,7 +309,10 @@ class Distribution(Funsor, metaclass=DistributionMeta):
@classmethod
@functools.lru_cache(maxsize=5000)
def _infer_param_domain(cls, name, raw_shape):
- support = cls.dist_class.arg_constraints.get(name, None)
+ constraints = getattr(cls.dist_class, "arg_constraints", {})
+ if isinstance(constraints, property):
+ constraints = {}
+ support = constraints.get(name, None)
# XXX: if the backend does not have the same definition of constraints, we should
# define backend-specific distributions and overide these `infer_value_domain`,
# `infer_param_domain` methods.
@@ -330,9 +333,8 @@ class Distribution(Funsor, metaclass=DistributionMeta):
# for discrete multivariate distributions in Pyro
elif support_name == "Real":
if name == "logits" and (
- "probs" in cls.dist_class.arg_constraints
- and type(cls.dist_class.arg_constraints["probs"]).__name__.lstrip("_")
- == "Simplex"
+ "probs" in constraints
+ and type(constraints.get("probs")).__name__.lstrip("_") == "Simplex"
):
output = Reals[raw_shape[-1 - event_dim :]]
else:
@@ -377,10 +379,13 @@ def make_dist(
backend_dist_class, param_names=(), generate_eager=True, generate_to_funsor=True
):
if not param_names:
+ constraints = getattr(backend_dist_class, "arg_constraints", {})
+ if isinstance(constraints, property):
+ constraints = {}
param_names = tuple(
name
for name in inspect.getfullargspec(backend_dist_class.__init__)[0][1:]
- if name in backend_dist_class.arg_constraints
+ if name in constraints
)
@makefun.with_signature(
@@ -608,7 +613,7 @@ class CoerceDistributionToFunsor:
def __call__(self, cls, args, kwargs):
# Check whether distribution class takes any tensor inputs.
arg_constraints = getattr(cls, "arg_constraints", None)
- if not arg_constraints:
+ if not arg_constraints or isinstance(arg_constraints, property):
return
# Check whether any tensor inputs are actually funsors.

View File

@@ -1,6 +1,5 @@
{
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
@@ -11,119 +10,65 @@
dill,
numpy,
pandas,
psutil,
scikit-learn,
sortedcontainers,
statsmodels,
tqdm,
typing-extensions,
xgboost,
# optional-dependencies
autograd,
# tests
botorch,
# configspace,
fastparquet,
h5py,
huggingface-hub,
matplotlib,
pymoo,
scikit-learn,
scipy,
# smac,
statsmodels,
xgboost,
# yahpo-gym,
# tests
pytestCheckHook,
pytest-timeout,
ray,
pytestCheckHook,
writableTmpDirAsHomeHook,
}:
buildPythonPackage (finalAttrs: {
pname = "syne-tune";
version = "0.15.0";
version = "0.16.0";
pyproject = true;
__structuredAttrs = true;
src = fetchFromGitHub {
owner = "syne-tune";
repo = "syne-tune";
tag = "v${finalAttrs.version}";
hash = "sha256-UNBpfC+aLXhkbyvCG2K00yedJnpYpfldqisZ/wDPtuA=";
hash = "sha256-fejG/KWWT6HrGCGzGh4p/Q3kzIDgYbRgfwGQf5sgKic=";
};
build-system = [
setuptools
];
pythonRelaxDeps = [
"numpy"
];
dependencies = [
dill
numpy
pandas
psutil
scikit-learn
sortedcontainers
statsmodels
tqdm
typing-extensions
xgboost
];
optional-dependencies = lib.fix (self: {
blackbox-repository = [
fastparquet
h5py
huggingface-hub
numpy
pandas
scikit-learn
xgboost
];
bore = [
scikit-learn
xgboost
];
botorch = [ botorch ];
gpsearchers = [
autograd
scipy
];
kde = [ statsmodels ];
moo = [
pymoo
scipy
];
sklearn = [ scikit-learn ];
# smac = [ smac swig ]; # smac unavailable on nixpkgs
visual = [ matplotlib ];
# yahpo = [ configspace onnxruntime pandas pyyaml yahpo-gym ]; # yahpo-gym unavailable on nixpkgs
});
pythonImportsCheck = [ "syne_tune" ];
nativeCheckInputs = [
pytestCheckHook
botorch
fastparquet
h5py
huggingface-hub
pymoo
pytest-timeout
ray
pytestCheckHook
writableTmpDirAsHomeHook
]
++ ray.optional-dependencies.tune
++ finalAttrs.passthru.optional-dependencies.blackbox-repository
++ finalAttrs.passthru.optional-dependencies.bore
++ finalAttrs.passthru.optional-dependencies.botorch
++ finalAttrs.passthru.optional-dependencies.gpsearchers
++ finalAttrs.passthru.optional-dependencies.kde
++ finalAttrs.passthru.optional-dependencies.sklearn;
disabledTests = [
# NameError: name 'HV' is not defined
# these require pkg `pymoo` and adding `pymoo` raises:
# setuptools.errors.PackageDiscoveryError: Multiple top-level packages discovered in a flat-layout: ['cma', 'notebooks'].
"test_append_hypervolume_indicator"
"test_hypervolume"
"test_hypervolume_progress"
"test_hypervolume_simple"
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
# assert np.float64(1.0114686865847489e-12) < 1e-12
"test_cholesky_factorization"
];
pythonImportsCheck = [
"syne_tune"
];
meta = {