bayinx 0.2.25__tar.gz → 0.2.27__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. {bayinx-0.2.25 → bayinx-0.2.27}/PKG-INFO +1 -1
  2. {bayinx-0.2.25 → bayinx-0.2.27}/pyproject.toml +2 -2
  3. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/mhx/vi/flows/fullaffine.py +18 -3
  4. {bayinx-0.2.25 → bayinx-0.2.27}/tests/test_variational.py +1 -1
  5. {bayinx-0.2.25 → bayinx-0.2.27}/.github/workflows/release_and_publish.yml +0 -0
  6. {bayinx-0.2.25 → bayinx-0.2.27}/.gitignore +0 -0
  7. {bayinx-0.2.25 → bayinx-0.2.27}/README.md +0 -0
  8. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/__init__.py +0 -0
  9. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/core/__init__.py +0 -0
  10. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/core/constraints.py +0 -0
  11. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/core/flow.py +0 -0
  12. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/core/model.py +0 -0
  13. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/core/utils.py +0 -0
  14. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/core/variational.py +0 -0
  15. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/dists/__init__.py +0 -0
  16. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/dists/bernoulli.py +0 -0
  17. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/dists/binomial.py +0 -0
  18. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/dists/gamma.py +0 -0
  19. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/dists/gamma2.py +0 -0
  20. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/dists/normal.py +0 -0
  21. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/dists/uniform.py +0 -0
  22. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/mhx/__init__.py +0 -0
  23. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/mhx/vi/__init__.py +0 -0
  24. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/mhx/vi/flows/__init__.py +0 -0
  25. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/mhx/vi/flows/planar.py +0 -0
  26. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/mhx/vi/flows/radial.py +0 -0
  27. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/mhx/vi/flows/sylvester.py +0 -0
  28. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/mhx/vi/meanfield.py +0 -0
  29. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/mhx/vi/normalizing_flow.py +0 -0
  30. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/mhx/vi/standard.py +0 -0
  31. {bayinx-0.2.25 → bayinx-0.2.27}/src/bayinx/py.typed +0 -0
  32. {bayinx-0.2.25 → bayinx-0.2.27}/tests/__init__.py +0 -0
  33. {bayinx-0.2.25 → bayinx-0.2.27}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bayinx
3
- Version: 0.2.25
3
+ Version: 0.2.27
4
4
  Summary: Bayesian Inference with JAX
5
5
  Requires-Python: >=3.12
6
6
  Requires-Dist: equinox>=0.11.12
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "bayinx"
3
- version = "0.2.25"
3
+ version = "0.2.27"
4
4
  description = "Bayesian Inference with JAX"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -19,7 +19,7 @@ build-backend = "hatchling.build"
19
19
  addopts = "-q --benchmark-min-rounds=30 --benchmark-columns=rounds,mean,median,stddev --benchmark-group-by=func"
20
20
 
21
21
  [tool.bumpversion]
22
- current_version = "0.2.25"
22
+ current_version = "0.2.27"
23
23
  parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
24
24
  serialize = ["{major}.{minor}.{patch}"]
25
25
  search = "{current_version}"
@@ -33,11 +33,26 @@ class FullAffine(Flow):
33
33
  "scale": jnp.zeros((dim, dim)),
34
34
  }
35
35
 
36
- self.constraints = {"scale": lambda m: jnp.tril(jnp.exp(m))}
36
+ self.constraints = {"scale": lambda m: jnp.tril(m)}
37
+
38
+ def transform_pars(self):
39
+ # Get constrained parameters
40
+ params = self.constrain_pars()
41
+
42
+ # Extract diagonal and apply exponential
43
+ diag: Array = jnp.exp(jnp.diag(params['scale']))
44
+
45
+ # Fill diagonal
46
+ params['scale'] = jnp.fill_diagonal(params['scale'], diag, inplace=False)
47
+
48
+
49
+ return params
50
+
51
+
37
52
 
38
53
  @eqx.filter_jit
39
54
  def forward(self, draws: Array) -> Array:
40
- params = self.constrain_pars()
55
+ params = self.transform_pars()
41
56
 
42
57
  # Extract parameters
43
58
  shift: Array = params["shift"]
@@ -51,7 +66,7 @@ class FullAffine(Flow):
51
66
  @eqx.filter_jit
52
67
  @partial(jax.vmap, in_axes=(None, 0))
53
68
  def adjust_density(self, draws: Array) -> Tuple[Scalar, Array]:
54
- params = self.constrain_pars()
69
+ params = self.transform_pars()
55
70
 
56
71
  # Extract parameters
57
72
  shift: Array = params["shift"]
@@ -88,7 +88,7 @@ def test_affine(benchmark, var_draws):
88
88
  benchmark(benchmark_fit)
89
89
  vari = vari.fit(20000,var_draws=var_draws)
90
90
 
91
- params = vari.flows[0].constrain_pars()
91
+ params = vari.flows[0].transform_pars()
92
92
  assert (abs(10.0 - vari.flows[0].params["shift"]) < 0.1).all() and (
93
93
  abs(jnp.eye(2) - params["scale"]) < 0.1
94
94
  ).all()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes