From ef5d2f72290df6546a82cf49b35d1bbee84d88fe Mon Sep 17 00:00:00 2001 From: janisshin Date: Thu, 6 Jun 2024 11:35:54 -0700 Subject: [PATCH] Revert "fixed shape calls to tensors" This reverts commit 57177f19640c70d4d42ba868852324a0b229c465. --- src/emll/data_model_integration.py | 2 +- src/emll/linlog_model.py | 2 +- tests/test_data_model_integration.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/emll/data_model_integration.py b/src/emll/data_model_integration.py index bf22a45..8b640e2 100644 --- a/src/emll/data_model_integration.py +++ b/src/emll/data_model_integration.py @@ -24,7 +24,7 @@ def create_noisy_observations_of_computed_values(name:str, computed_tensor:T.ten raise ValueError("Data shape does not match standard deviation shape!") # check shape of data == computed_tensor - if any(data.shape != computed_tensor.eval().shape): + if any(data.shape != computed_tensor.shape.eval()): raise ValueError(f"Data shape {data.shape} does not match computed tensor shape {pytensor.tensor.shape(computed_tensor)}!") # check that standard deviations are all positive diff --git a/src/emll/linlog_model.py b/src/emll/linlog_model.py index 93b73ee..556a67c 100644 --- a/src/emll/linlog_model.py +++ b/src/emll/linlog_model.py @@ -135,7 +135,7 @@ def steady_state_pytensor(self, Ex, Ey=None, en=None, yn=None, method="scan"): en = np.atleast_2d(en) n_exp = en.shape[0] else: - n_exp = en.eval().shape[0] + n_exp = en.shape.eval()[0] if isinstance(yn, np.ndarray): yn = np.atleast_2d(yn) diff --git a/tests/test_data_model_integration.py b/tests/test_data_model_integration.py index 0d36d3d..d497c75 100644 --- a/tests/test_data_model_integration.py +++ b/tests/test_data_model_integration.py @@ -394,8 +394,8 @@ def test_create_pytensor_from_data(): data_tensor = create_pytensor_from_data_naive(input_string, input_dataframe_mixed, input_stdev_dataframe_mixed, input_laplace_dataframe_mixed) # check that the n-dim and shape are correct - assert np.size(data_tensor.eval().shape) == np.size(input_dataframe_mixed.shape), f"Expected tensor n dim {np.size(input_dataframe_mixed.shape)}, found {np.size(data_tensor.eval().shape)}" - assert tuple(data_tensor.eval().shape) == input_dataframe_mixed.shape, f"Expected tensor shape {input_dataframe_mixed.shape}, found {data_tensor.eval().shape}" + assert np.size(data_tensor.shape.eval()) == np.size(input_dataframe_mixed.shape), f"Expected tensor n dim {np.size(input_dataframe_mixed.shape)}, found {np.size(data_tensor.shape.eval())}" + assert tuple(data_tensor.shape.eval()) == input_dataframe_mixed.shape, f"Expected tensor shape {input_dataframe_mixed.shape}, found {data_tensor.shape.eval()}" # Check that the steady_state_pytensor method runs error_occurred = False @@ -422,8 +422,8 @@ def test_create_pytensor_from_data(): y_n = pm.Normal("yn_t", mu=0, sigma=10, - shape=(data_tensor.eval().shape[0], lin_log.ny), - initval=0.1 * np.random.randn(data_tensor.eval().shape[0], lin_log.ny) + shape=(data_tensor.shape.eval()[0], lin_log.ny), + initval=0.1 * np.random.randn(data_tensor.shape.eval()[0], lin_log.ny) ) chi_ss, vn_ss = lin_log.steady_state_pytensor(