Skip to content

Fix Flat/HalfFlat initial value dimensionality #4996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions pymc3/tests/test_initvals.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import aesara.tensor as at
import numpy as np
import pytest

Expand Down Expand Up @@ -92,6 +93,27 @@ def test_automatically_assigned_test_values(self):
assert hasattr(rv.tag, "test_value")
pass

@pytest.mark.parametrize("rv_cls", [pm.Flat, pm.HalfFlat])
def test_initval_shape(self, rv_cls):
rv = rv_cls.dist(shape=(2,))
assert np.shape(rv.tag.test_value) == (2,)
# Can't set numeric test values when dimensionality is symbolic
rv = rv_cls.dist(shape=(at.scalar(),))
assert rv.tag.test_value is None
pass

@pytest.mark.parametrize("rv_cls", [pm.Flat, pm.HalfFlat])
def test_initval_dims(self, rv_cls):
with pm.Model(
coords={
"year": [2019, 2020, 2021],
}
) as pmodel:
rv = rv_cls("rv", dims=("year",))
# Can't set numeric test values when dimensionality is symbolic
assert rv.tag.test_value is None
pass


class TestMoment:
def test_basic(self):
Expand Down