Skip to content

Commit 0f5c0ca

Browse files
committed
JAX can now work with shape inputs
1 parent fa8a052 commit 0f5c0ca

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

tests/distributions/test_random_alternative_backends.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from contextlib import nullcontext
15-
1614
import numpy as np
1715
import pytest
1816

@@ -44,15 +42,13 @@ def test_dirichlet_multinomial_dims(mode):
4442
with pm.Model(coords={"trial": range(3), "item": range(3)}) as m:
4543
dm = DirichletMultinomial("dm", n=5, a=np.eye(3) * 1e6 + 0.01, dims=("trial", "item"))
4644

47-
# JAX does not allow us to JIT a function with dynamic shape
48-
expected_ctxt = pytest.raises(TypeError) if mode == "JAX" else nullcontext()
49-
with expected_ctxt:
50-
pm.draw(dm, mode=mode)
45+
dm_draws = pm.draw(dm, mode=mode, random_seed=36)
46+
np.testing.assert_equal(dm_draws, np.eye(3) * 5)
5147

52-
# Should be fine after freezing the dims that specify the shape
48+
# Should also work after freezing the dims that specify the shape
5349
frozen_dm = freeze_dims_and_data(m)["dm"]
54-
dm_draws = pm.draw(frozen_dm, mode=mode, random_seed=36)
55-
np.testing.assert_equal(dm_draws, np.eye(3) * 5)
50+
frozen_dm_draws = pm.draw(frozen_dm, mode=mode, random_seed=36)
51+
np.testing.assert_equal(frozen_dm_draws, np.eye(3) * 5)
5652

5753

5854
def test_mvstudentt(mode):

0 commit comments

Comments
 (0)