-
-
Notifications
You must be signed in to change notification settings - Fork 62
Merge statespace module from http://github.com/jessegrabowski/pymc_statespace #174
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
Merged
Merged
Merge statespace module from http://github.com/jessegrabowski/pymc_statespace #174
Changes from 12 commits
Commits
Show all changes
140 commits
Select commit
Hold shift + click to select a range
6dba1dc
move http://github.com/jessegrabowski/pymc_statespace to pymc-experim…
jessegrabowski d9f3239
Make tests compatible with float32
jessegrabowski c37fb77
Fix remaining tests that failed when dtype is float32
jessegrabowski 5f48976
Fix remaining tests that failed when dtype is float32
jessegrabowski d04adaf
Merge remote-tracking branch 'origin/statespace' into statespace
jessegrabowski 6b0a123
Merge branch 'main' into statespace
jessegrabowski 12b4db5
Merge branch 'pymc-devs:main' into statespace
jessegrabowski ead1036
Merge branch 'statespace' of https://github.com/jessegrabowski/pymc-e…
jessegrabowski c6a4f85
Replace print with `logger.info`
jessegrabowski 8e18779
Use `getattr` to access model variables in `gather_required_random_va…
jessegrabowski 8b05fb7
Reduce code duplication, eliminate use of `pathlib` in favor of expli…
jessegrabowski 389bfbe
Refactor `PyMCStateSpace` and `PytensorRepresentation` to no longer r…
jessegrabowski b3d5c2a
Merge remote-tracking branch 'origin/statespace' into statespace
jessegrabowski e577590
Refactor kalman filters to remove singleton dimensions everywhere pos…
jessegrabowski c761d85
Add tests for sarimax, add first pass at state space distribution
jessegrabowski 4d5cf7e
Merge remote-tracking branch 'origin/statespace' into statespace
jessegrabowski 96cca74
Add more helpers to statespace class for building PyMC model
jessegrabowski 9532901
Changes to SARIMAX to make states interpretable, plus bad draft pymc …
jessegrabowski 953542e
Distribution attempt 2
jessegrabowski ec03342
Distribution attempt 3
jessegrabowski 9cf56d1
Fix broken tests
jessegrabowski 496f815
Fix remaining tests
jessegrabowski 7e3ed2f
Preserve name/shape information after updates to matrices
jessegrabowski 9efa465
Add test for `SequenceMvNormal`
jessegrabowski 5ef77a9
Add logp as parameter to `SequenceMvNormal`
jessegrabowski 8648155
Add logp argument to `SequenceMvNormal` test
jessegrabowski 9a4636d
Refactor shape checking to use `type.shape`
jessegrabowski ceecd15
Refactor shape checking to use `type.shape`
jessegrabowski d31c220
Add float32 test skip back to `test_filters_match_statsmodel_output`
jessegrabowski cf49e92
Refactor `LinearGaussianStateSpace` for use in prior/posterior predic…
jessegrabowski 570d613
Infer coordinates for statespace matrices from parameters
jessegrabowski 90dcf69
Refactor posterior predictive sampling, coords, and data handling
jessegrabowski 15a337c
Remove typecheck with `Union`
jessegrabowski d76a12c
Fix float32 error in tests
jessegrabowski 6b8575a
Fix float32 error in tests
jessegrabowski 2f19ec1
Fix bugs in SARMIAX, add measurement error option to SARIMAX, update …
jessegrabowski ef32c5b
always add `TIME_DIM` to model coords, even when data aren't given dims
jessegrabowski de72922
always add `TIME_DIM` to model coords, even when data aren't given dims
jessegrabowski d982566
Add forecast method to `Statespace`, add coord/dim info to `VARMAX`, …
jessegrabowski dd81173
Add `impulse_response_function` method to `Statespace`, update `ARIMA…
jessegrabowski 6538d18
Update VARMAX notebook, remove `pm.DiracDelta` from `Statespace.forec…
jessegrabowski 36d7901
Update VARMAX example notebook
jessegrabowski c1208db
Add docstrings to statespace methods and utilities
jessegrabowski d9caa01
Merge remote-tracking branch 'origin/statespace' into statespace
jessegrabowski 8f47ef3
More docstrings
jessegrabowski 96b1f37
documentation
jessegrabowski 04ad689
More docs, fix failing tests
jessegrabowski 4f41b2a
Implement conditional and unconditonal sampling from prior idata
jessegrabowski 1b6297f
Trying to get the API docs to render
jessegrabowski 3f766d3
Trying to get the API docs to render
jessegrabowski ca91078
Revert "Trying to get the API docs to render"
jessegrabowski 1de05e8
Trying to get the API docs to render, revert local change to `pyproje…
jessegrabowski 94876b1
Trying to get the API docs to render
jessegrabowski 8cf95b4
Remove `specify_broadcast` in `SingleTimeseriesFilter.update`
jessegrabowski 849ba1b
Fixing docstrings
jessegrabowski 7ff39e2
Fixing docstrings
jessegrabowski e921698
create toctree hierarchy
jessegrabowski 4e0b463
create toctree hierarchy
jessegrabowski a0f3343
create toctree hierarchy
jessegrabowski d91fc37
docstrings
jessegrabowski ad933b7
docstrings
jessegrabowski 29a88ff
docstrings
jessegrabowski 61b6945
Making a table in a docstring
jessegrabowski ae106c2
Making a table in a docstring
jessegrabowski b75ff41
More docs
jessegrabowski 12f56c4
More docstrings
jessegrabowski 812d6c5
More docstrings
jessegrabowski c7772ac
More docstrings
jessegrabowski 7670f4e
Remove `BayesianLocalLevel`, add a new `StructuralTimeSeries` module
jessegrabowski f525166
Remove `BayesianLocalLevel`, add a new `StructuralTimeSeries` module
jessegrabowski 32c58bc
Bug fixes in `structural`, new example notebook
jessegrabowski a231c29
Bug fixes in `structural`, update structural example
jessegrabowski e2b93e6
Kalman filter no longer returns a forecast on the predicted states
jessegrabowski 0f2a2b9
Fix bugs in IRF API
jessegrabowski 95a9860
Fix bugs in IRF API
jessegrabowski caa3e0b
Add `airpass.csv` test data
jessegrabowski cf2157e
More docstrings
jessegrabowski 6b8c9c9
More docstrings
jessegrabowski 01d063a
More docstrings
jessegrabowski 7f824dc
More docstrings
jessegrabowski f2b5281
Fix VARMAX tests
jessegrabowski 669382a
More docs
jessegrabowski f961eac
More docs, allow user to name states in seasonal components
jessegrabowski 5631ad3
more docs, rename `test_structural_model` to `test_structural`
jessegrabowski 21570c2
Allow non-integer seasonal length in `FrequencySeasonality` (breaks t…
jessegrabowski 5b1dbc8
Seed `sample_posterior` and `sample_prior` tests, unbreak `test_struc…
jessegrabowski edcd9ca
Set test seed as a global constant
jessegrabowski ee4a817
Remove numba dependency
jessegrabowski 68ac3c2
Add helper function to `StructuralTimeSeries` to reconstruct componen…
jessegrabowski f899096
Add `fast_eval` as test utility
jessegrabowski c4aee6b
Changes from review feedback
jessegrabowski 29d1778
Try to fix failing test
jessegrabowski f324db2
Catch expected test warnings with `pytest.mark.filterwarnings`
jessegrabowski b9a6dd2
Scope fixtures in sampling tests to speed them up a bit
jessegrabowski 69395ef
More fixes from review
jessegrabowski c6485a0
Trying to fix the failing test
jessegrabowski 90f9fdd
Remove numba from `windows-environment-test.yml`
jessegrabowski 86b7642
Test for NaNs in sampled statespace objects
jessegrabowski 6b69719
Redo the `Custom Statespace` notebooks
jessegrabowski b4a2d87
Add `ImputationWarning` to `mask_missing_values_in_data`
jessegrabowski 5a3d4cd
Add `ImputationWarning` to `mask_missing_values_in_data`
jessegrabowski b2cdc1c
Add off-diagonal averaging to covariance `stabilize` function.
jessegrabowski ab67bb8
Covariance matrices output by kalman filter not always PSD
jessegrabowski 795910c
Add some stability tricks to Kalman filters
jessegrabowski cd7e712
Add `measurement_error` kwarg to `PyMCStateSpace`
jessegrabowski 221a6ef
Allow `eig == 0.0` to pass PSD test
jessegrabowski ff0cd98
Add stability tests to VARMAX and SARIMAX
jessegrabowski adf5e82
LGSS distribution doesn't need to know anything about measurement error
jessegrabowski 78d982f
Re-run Structural Timeseries Modeling.ipynb with some new features
jessegrabowski cf0f0c0
Delete out-of-date example notebook
jessegrabowski 3060676
Updates to Making a Custom Statespace Model.ipynb
jessegrabowski 53226cb
Link to the bVAR example notebook in the VARMAX Example.ipynb
jessegrabowski bd2e7e7
Make the IRF plots more readable in ARIMA Example.ipynb
jessegrabowski 225810f
Increase `JITTER_DEFAULT` when pytensor is in `float32` mode
jessegrabowski fdefbee
Increase `JITTER_DEFAULT` when pytensor is in `float32` mode
jessegrabowski de9618d
Merge remote-tracking branch 'origin/statespace' into statespace
jessegrabowski b8995aa
Add stabilization to univariate filter covariance
jessegrabowski b0cf3de
Trying to get the last tests to pass
jessegrabowski 3a143a3
Different stability strategy for UnivariateFilter
jessegrabowski 259f6f4
Skip overly sensitive float32 tests
jessegrabowski 7f299a3
Remove `update` function
jessegrabowski 1ce2c7a
All tests pass
jessegrabowski 593745c
Update Making a Custom Statespace Model.ipynb to reflect refactor
jessegrabowski 5748bca
Relax float32 test tolerance in `test_structural.py`
jessegrabowski 2f87538
Set dtype on numpy arrays used in test_structural.py
jessegrabowski c3dcfa8
Remove dictionary merge with pipe
jessegrabowski 3cd9dd9
Disable all PSD tests for univariate filter when floatX=float32
jessegrabowski 44d7db0
Remove `variable_by_shape` helper, use `pt.tensor` directly.
jessegrabowski c60ff4e
Remove unused helper functions
jessegrabowski 27163c5
Adjust new tests for float32
jessegrabowski 03c59db
Add test for equivalence between SARIMA representations
jessegrabowski 731228f
Add test for equivalence between SARIMA representations
jessegrabowski 0c8b590
Use `self.mode` in all kalman filter scans
jessegrabowski 688fd01
Begin adding seasonal components to SARIMAX.py
jessegrabowski 891a823
Implement seasonal lags and differences in SARIMAX
jessegrabowski a3b0958
Add an Exogenous Regression component to `structural.py`
jessegrabowski 65b4294
Expand support for exogenous variables in statespace models
jessegrabowski cfe6e0a
Tweak tests
jessegrabowski e4cdd12
Tweak tests
jessegrabowski 1342afa
Merge remote-tracking branch 'origin/statespace' into statespace
jessegrabowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from pymc_experimental.statespace.models.local_level import BayesianLocalLevel | ||
from pymc_experimental.statespace.models.SARIMAX import BayesianARMA | ||
from pymc_experimental.statespace.models.VARMAX import BayesianVARMAX | ||
|
||
__all__ = ["BayesianLocalLevel", "BayesianARMA", "BayesianVARMAX"] |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,285 @@ | ||
from functools import reduce | ||
from typing import List, Optional, Tuple, Type, Union | ||
|
||
import numpy as np | ||
import pandas.core.tools.datetimes | ||
import pytensor | ||
import pytensor.tensor as pt | ||
from pandas import DataFrame | ||
|
||
floatX = pytensor.config.floatX | ||
KeyLike = Union[Tuple[Union[str, int]], str] | ||
|
||
NEVER_TIME_VARYING = ["initial_state", "initial_state_cov", "a0", "P0"] | ||
VECTOR_VALUED = ["initial_state", "state_intercept", "obs_intercept", "a0", "c", "d"] | ||
|
||
|
||
def _preprocess_data(data: Union[DataFrame, np.ndarray], expected_dims=3): | ||
if isinstance(data, pandas.DataFrame): | ||
data = data.values | ||
elif not isinstance(data, np.ndarray): | ||
raise ValueError("Expected pandas Dataframe or numpy array as data") | ||
|
||
if data.ndim < expected_dims: | ||
n_dims = data.ndim | ||
n_to_add = expected_dims - n_dims + 1 | ||
data = reduce(lambda a, b: np.expand_dims(a, -1), [data] * n_to_add) | ||
jessegrabowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return data | ||
|
||
|
||
class PytensorRepresentation: | ||
def __init__( | ||
self, | ||
k_endog: int, | ||
k_states: int, | ||
k_posdef: int, | ||
design: Optional[np.ndarray] = None, | ||
obs_intercept: Optional[np.ndarray] = None, | ||
obs_cov=None, | ||
transition=None, | ||
state_intercept=None, | ||
selection=None, | ||
state_cov=None, | ||
initial_state=None, | ||
initial_state_cov=None, | ||
) -> None: | ||
""" | ||
A representation of a State Space model, in Pytensor. Shamelessly copied from the Statsmodels.api implementation | ||
found here: | ||
|
||
https://github.com/statsmodels/statsmodels/blob/main/statsmodels/tsa/statespace/representation.py | ||
|
||
Parameters | ||
---------- | ||
k_endog: int | ||
Number of observed states (called "endogeous states" in statsmodels) | ||
k_states: int | ||
Number of hidden states | ||
k_posdef: int | ||
Number of states that have exogenous shocks; also the rank of the selection matrix R. | ||
design: ArrayLike, optional | ||
Design matrix, denoted 'Z' in [1]. | ||
obs_intercept: ArrayLike, optional | ||
Constant vector in the observation equation, denoted 'd' in [1]. Currently | ||
not used. | ||
obs_cov: ArrayLike, optional | ||
Covariance matrix for multivariate-normal errors in the observation equation. Denoted 'H' in | ||
[1]. | ||
transition: ArrayLike, optional | ||
Transition equation that updates the hidden state between time-steps. Denoted 'T' in [1]. | ||
state_intercept: ArrayLike, optional | ||
Constant vector for the observation equation, denoted 'c' in [1]. Currently not used. | ||
selection: ArrayLike, optional | ||
Selection matrix that matches shocks to hidden states, denoted 'R' in [1]. This is the identity | ||
matrix when k_posdef = k_states. | ||
state_cov: ArrayLike, optional | ||
Covariance matrix for state equations, denoted 'Q' in [1]. Null matrix when there is no observation | ||
noise. | ||
initial_state: ArrayLike, optional | ||
Experimental setting to allow for Bayesian estimation of the initial state, denoted `alpha_0` in [1]. Default | ||
It should potentially be removed in favor of the closed-form diffuse initialization. | ||
initial_state_cov: ArrayLike, optional | ||
Experimental setting to allow for Bayesian estimation of the initial state, denoted `P_0` in [1]. Default | ||
It should potentially be removed in favor of the closed-form diffuse initialization. | ||
|
||
References | ||
---------- | ||
.. [1] Durbin, James, and Siem Jan Koopman. 2012. | ||
Time Series Analysis by State Space Methods: Second Edition. | ||
Oxford University Press. | ||
""" | ||
self.k_states = k_states | ||
self.k_endog = k_endog | ||
self.k_posdef = k_posdef if k_posdef is not None else k_states | ||
|
||
# The last dimension is for time varying matrices; it could be n_obs. Not thinking about that now. | ||
self.shapes = { | ||
"design": (self.k_endog, self.k_states, 1), | ||
"obs_intercept": (self.k_endog, 1), | ||
"obs_cov": (self.k_endog, self.k_endog, 1), | ||
"transition": (self.k_states, self.k_states, 1), | ||
"state_intercept": (self.k_states, 1), | ||
"selection": (self.k_states, self.k_posdef, 1), | ||
"state_cov": (self.k_posdef, self.k_posdef, 1), | ||
"initial_state": (self.k_states,), | ||
"initial_state_cov": (self.k_states, self.k_states), | ||
} | ||
|
||
# Initialize the representation matrices | ||
scope = locals() | ||
for name, shape in self.shapes.items(): | ||
if scope[name] is not None: | ||
matrix = self._numpy_to_pytensor(name, scope[name]) | ||
setattr(self, name, matrix) | ||
|
||
else: | ||
setattr(self, name, pt.zeros(shape, dtype=floatX)) | ||
|
||
def _validate_key(self, key: KeyLike) -> None: | ||
if key not in self.shapes: | ||
raise IndexError(f"{key} is an invalid state space matrix name") | ||
|
||
def update_shape(self, key: KeyLike, value: Union[np.ndarray, pt.TensorType]) -> None: | ||
# TODO: Get rid of these evals | ||
if isinstance(value, (pt.TensorConstant, pt.TensorVariable)): | ||
shape = value.shape.eval() | ||
else: | ||
shape = value.shape | ||
|
||
old_shape = self.shapes[key] | ||
check_slice = slice(None, 2) if key not in VECTOR_VALUED else slice(None, 1) | ||
|
||
if not all([a == b for a, b in zip(shape[check_slice], old_shape[check_slice])]): | ||
raise ValueError( | ||
f"The first two dimensions of {key} must be {old_shape[check_slice]}, found {shape[check_slice]}" | ||
) | ||
|
||
# Add time dimension dummy if none present | ||
if len(shape) == 2 and key not in NEVER_TIME_VARYING: | ||
self.shapes[key] = shape + (1,) | ||
|
||
self.shapes[key] = shape | ||
|
||
def _add_time_dim_to_slice( | ||
self, name: str, slice_: Union[List[int], Tuple[int]], n_dim: int | ||
) -> Tuple[int]: | ||
# Case 1: There is never a time dim. No changes needed. | ||
if name in NEVER_TIME_VARYING: | ||
return slice_ | ||
|
||
# Case 2: The matrix has a time dim, and it was requested. No changes needed. | ||
if len(slice_) == n_dim: | ||
return slice_ | ||
|
||
# Case 3: There's no time dim on the matrix, and none requested. Slice away the dummy dim. | ||
if len(slice_) < n_dim: | ||
empty_slice = (slice(None, None, None),) | ||
n_omitted = n_dim - len(slice_) - 1 | ||
return tuple(slice_) + empty_slice * n_omitted + (0,) | ||
|
||
@staticmethod | ||
def _validate_key_and_get_type(key: KeyLike) -> Type[str]: | ||
if isinstance(key, tuple) and not isinstance(key[0], str): | ||
raise IndexError("First index must the name of a valid state space matrix.") | ||
|
||
return type(key) | ||
|
||
def _validate_matrix_shape(self, name: str, X: np.ndarray) -> None: | ||
*expected_shape, time_dim = self.shapes[name] | ||
expected_shape = tuple(expected_shape) | ||
|
||
is_vector = name in VECTOR_VALUED | ||
not_time_varying = name in NEVER_TIME_VARYING | ||
|
||
if not_time_varying: | ||
if is_vector: | ||
if X.ndim != 1: | ||
raise ValueError( | ||
f"Array provided for {name} has {X.ndim} dimensions, but it must have exactly 1." | ||
) | ||
|
||
else: | ||
if X.ndim != 2: | ||
raise ValueError( | ||
f"Array provided for {name} has {X.ndim} dimensions, but it must have exactly 2." | ||
) | ||
|
||
else: | ||
if is_vector: | ||
if X.ndim not in [1, 2]: | ||
raise ValueError( | ||
f"Array provided for {name} has {X.ndim} dimensions, " | ||
f"expecting 1 (static) or 2 (time-varying)" | ||
) | ||
if X.ndim == 2 and X.shape[:-1] != expected_shape: | ||
raise ValueError( | ||
f"First dimension of array provided for {name} has shape {X.shape[0]}, " | ||
f"expected {expected_shape}" | ||
) | ||
|
||
else: | ||
if X.ndim not in [2, 3]: | ||
raise ValueError( | ||
f"Array provided for {name} has {X.ndim} dimensions, " | ||
f"expecting 2 (static) or 3 (time-varying)" | ||
) | ||
|
||
if X.ndim == 3 and X.shape[:-1] != expected_shape: | ||
raise ValueError( | ||
f"First two dimensions of array provided for {name} has shape {X.shape[:-1]}, " | ||
f"expected {expected_shape}" | ||
) | ||
|
||
# TODO: Think of another way to validate shapes of time-varying matrices if we don't know the data | ||
# when the PytensorRepresentation is recreated | ||
# if X.shape[-1] != self.data.shape[0]: | ||
# raise ValueError( | ||
# f"Last dimension (time dimension) of array provided for {name} has shape " | ||
# f"{X.shape[-1]}, expected {self.data.shape[0]} (equal to the first dimension of the " | ||
# f"provided data)" | ||
# ) | ||
|
||
def _numpy_to_pytensor(self, name: str, X: np.ndarray) -> pt.TensorVariable: | ||
X = X.copy() | ||
self._validate_matrix_shape(name, X) | ||
|
||
# Add a time dimension if one isn't provided | ||
if name not in NEVER_TIME_VARYING: | ||
if X.ndim == 1 and name in VECTOR_VALUED: | ||
X = X[..., None] | ||
elif X.ndim == 2: | ||
X = X[..., None] | ||
return pt.as_tensor(X, name=name, dtype=floatX) | ||
|
||
def __getitem__(self, key: KeyLike) -> pt.TensorVariable: | ||
_type = self._validate_key_and_get_type(key) | ||
|
||
# Case 1: user asked for an entire matrix by name | ||
if _type is str: | ||
self._validate_key(key) | ||
matrix = getattr(self, key) | ||
|
||
# Slice away the time dimension if it's a dummy | ||
if (self.shapes[key][-1] == 1) and (key not in NEVER_TIME_VARYING): | ||
return matrix[(slice(None),) * (matrix.ndim - 1) + (0,)] | ||
|
||
# If it's time varying, return everything | ||
else: | ||
return matrix | ||
|
||
# Case 2: user asked for a particular matrix and some slices of it | ||
elif _type is tuple: | ||
name, *slice_ = key | ||
self._validate_key(name) | ||
|
||
matrix = getattr(self, name) | ||
slice_ = self._add_time_dim_to_slice(name, slice_, matrix.ndim) | ||
|
||
return matrix[slice_] | ||
|
||
# Case 3: There is only one slice index, but it's not a string | ||
else: | ||
raise IndexError("First index must the name of a valid state space matrix.") | ||
|
||
def __setitem__(self, key: KeyLike, value: Union[float, int, np.ndarray]) -> None: | ||
_type = type(key) | ||
# Case 1: key is a string: we are setting an entire matrix. | ||
if _type is str: | ||
self._validate_key(key) | ||
if isinstance(value, np.ndarray): | ||
value = self._numpy_to_pytensor(key, value) | ||
setattr(self, key, value) | ||
self.update_shape(key, value) | ||
|
||
# Case 2: key is a string plus a slice: we are setting a subset of a matrix | ||
elif _type is tuple: | ||
name, *slice_ = key | ||
self._validate_key(name) | ||
|
||
matrix = getattr(self, name) | ||
|
||
slice_ = self._add_time_dim_to_slice(name, slice_, matrix.ndim) | ||
|
||
matrix = pt.set_subtensor(matrix[slice_], value) | ||
setattr(self, name, matrix) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.