bartz 0.3.0__py3-none-any.whl → 0.4.1__py3-none-any.whl
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.
- bartz/__init__.py +3 -3
- bartz/_version.py +1 -1
- bartz/jaxext.py +4 -23
- bartz/mcmcstep.py +375 -306
- bartz-0.4.1.dist-info/METADATA +52 -0
- bartz-0.4.1.dist-info/RECORD +13 -0
- {bartz-0.3.0.dist-info → bartz-0.4.1.dist-info}/WHEEL +1 -1
- bartz-0.3.0.dist-info/METADATA +0 -77
- bartz-0.3.0.dist-info/RECORD +0 -13
- {bartz-0.3.0.dist-info → bartz-0.4.1.dist-info}/LICENSE +0 -0
bartz/__init__.py
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
11
|
# copies of the Software, and to permit persons to whom the Software is
|
|
12
12
|
# furnished to do so, subject to the following conditions:
|
|
13
|
-
#
|
|
13
|
+
#
|
|
14
14
|
# The above copyright notice and this permission notice shall be included in all
|
|
15
15
|
# copies or substantial portions of the Software.
|
|
16
|
-
#
|
|
16
|
+
#
|
|
17
17
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
18
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
19
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
# SOFTWARE.
|
|
24
24
|
|
|
25
25
|
"""
|
|
26
|
-
|
|
26
|
+
Super-fast BART (Bayesian Additive Regression Trees) in Python
|
|
27
27
|
|
|
28
28
|
See the manual at https://gattocrucco.github.io/bartz/docs
|
|
29
29
|
"""
|
bartz/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.
|
|
1
|
+
__version__ = '0.4.1'
|
bartz/jaxext.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# bartz/src/bartz/jaxext.py
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c) 2024, Giacomo Petrillo
|
|
3
|
+
# Copyright (c) 2024-2025, Giacomo Petrillo
|
|
4
4
|
#
|
|
5
5
|
# This file is part of bartz.
|
|
6
6
|
#
|
|
@@ -45,27 +45,6 @@ def castto(func, type):
|
|
|
45
45
|
return func(*args, **kw).astype(type)
|
|
46
46
|
return newfunc
|
|
47
47
|
|
|
48
|
-
def pure_callback_ufunc(callback, dtype, *args, excluded=None, **kwargs):
|
|
49
|
-
""" version of `jax.pure_callback` that deals correctly with ufuncs,
|
|
50
|
-
see `<https://github.com/google/jax/issues/17187>`_ """
|
|
51
|
-
if excluded is None:
|
|
52
|
-
excluded = ()
|
|
53
|
-
shape = jnp.broadcast_shapes(*(
|
|
54
|
-
a.shape
|
|
55
|
-
for i, a in enumerate(args)
|
|
56
|
-
if i not in excluded
|
|
57
|
-
))
|
|
58
|
-
ndim = len(shape)
|
|
59
|
-
padded_args = [
|
|
60
|
-
a if i in excluded
|
|
61
|
-
else jnp.expand_dims(a, tuple(range(ndim - a.ndim)))
|
|
62
|
-
for i, a in enumerate(args)
|
|
63
|
-
]
|
|
64
|
-
result = jax.ShapeDtypeStruct(shape, dtype)
|
|
65
|
-
return jax.pure_callback(callback, result, *padded_args, vectorized=True, **kwargs)
|
|
66
|
-
|
|
67
|
-
# TODO when jax solves this, check version and piggyback on original if new
|
|
68
|
-
|
|
69
48
|
class scipy:
|
|
70
49
|
|
|
71
50
|
class special:
|
|
@@ -74,9 +53,11 @@ class scipy:
|
|
|
74
53
|
def gammainccinv(a, y):
|
|
75
54
|
a = jnp.asarray(a)
|
|
76
55
|
y = jnp.asarray(y)
|
|
56
|
+
shape = jnp.broadcast_shapes(a.shape, y.shape)
|
|
77
57
|
dtype = float_type(a.dtype, y.dtype)
|
|
58
|
+
dummy = jax.ShapeDtypeStruct(shape, dtype)
|
|
78
59
|
ufunc = castto(special.gammainccinv, dtype)
|
|
79
|
-
return
|
|
60
|
+
return jax.pure_callback(ufunc, dummy, a, y, vmap_method='expand_dims')
|
|
80
61
|
|
|
81
62
|
class stats:
|
|
82
63
|
|