Skip to content

Make Constant and Shared variables subclasses of the respective Variables #628

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
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pytensor/sparse/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def pytensor_hash(self):
return hash_from_sparse(d)


class SparseConstant(TensorConstant, _sparse_py_operators):
class SparseConstant(SparseVariable, TensorConstant):
format = property(lambda self: self.type.format)

def signature(self):
Expand Down
4 changes: 2 additions & 2 deletions pytensor/sparse/sharedvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import scipy.sparse

from pytensor.compile import shared_constructor
from pytensor.sparse.basic import SparseTensorType, _sparse_py_operators
from pytensor.sparse.basic import SparseTensorType, SparseVariable
from pytensor.tensor.sharedvar import TensorSharedVariable


class SparseTensorSharedVariable(TensorSharedVariable, _sparse_py_operators):
class SparseTensorSharedVariable(TensorSharedVariable, SparseVariable):
@property
def format(self):
return self.type.format
Expand Down
4 changes: 2 additions & 2 deletions pytensor/tensor/sharedvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pytensor.misc.safe_asarray import _asarray
from pytensor.tensor import _get_vector_length
from pytensor.tensor.type import TensorType
from pytensor.tensor.variable import _tensor_py_operators
from pytensor.tensor.variable import TensorVariable


def load_shared_variable(val):
Expand All @@ -19,7 +19,7 @@ def load_shared_variable(val):
return tensor_constructor(val)


class TensorSharedVariable(_tensor_py_operators, SharedVariable):
class TensorSharedVariable(SharedVariable, TensorVariable):
def zero(self, borrow: bool = False):
r"""Set the values of a shared variable to 0.

Expand Down