Skip to content

Commit

Permalink
Keep 0 dimensional parameters as 0 dimensional instead of 1 dimension…
Browse files Browse the repository at this point in the history
…al (#575)

* start to reimplement predictions

* add playground notebooks, so we don't loose the work

* More advances

* Univariate families now use xarray

* Advances in multivariate families, there are bugs

* categorical family bug fixed

* First 'working' version of new predictions

* Fix shape in predictions with offset

* Final tweaks. Run all examples

* 1d caveats

* shape[1] instead of just shape
  • Loading branch information
tomicapretto authored Oct 22, 2022
1 parent 2b213be commit 9a29a27
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions bambi/backend/pymc.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def _build_common_terms(self, spec):

# Column vector of coefficients and design matrix
coefs = at.concatenate(coefs)

data = np.hstack(columns)

# If there's an intercept, center the data
Expand Down
4 changes: 3 additions & 1 deletion bambi/backend/terms.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def build(self, spec):
if dims:
coef = distribution(label, dims=dims, **args)
else:
coef = distribution(label, shape=data.shape[1], **args)
shape = None if data.shape[1] == 1 else data.shape[1]
coef = distribution(label, shape=shape, **args)
coef = at.atleast_1d(coef) # If only a single numeric column it wont be 1d

# Prepends one dimension if response is multivariate categorical and predictor is 1d
if response_dims and len(dims) == 1:
Expand Down

0 comments on commit 9a29a27

Please sign in to comment.