1010import scipy .linalg
1111import scipy .sparse
1212
13- from probnum import config
13+ from probnum import config # pylint: disable=cyclic-import
1414from probnum .typing import ArrayLike , DTypeLike , ScalarLike , ShapeLike
1515import probnum .utils
1616
@@ -384,6 +384,13 @@ def todense(self, cache: bool = True) -> np.ndarray:
384384 This method can be computationally very costly depending on the shape of the
385385 linear operator. Use with caution.
386386
387+ Parameters
388+ ----------
389+ cache
390+ If this is set to :data:`True`, then the dense matrix representation will
391+ be cached and subsequent calls will return the cached value (even if
392+ :code:`dense` is set to :data:`False` in these subsequent calls).
393+
387394 Returns
388395 -------
389396 matrix : np.ndarray
@@ -413,7 +420,14 @@ def is_symmetric(self) -> Optional[bool]:
413420 """Whether the ``LinearOperator`` :math:`L` is symmetric, i.e. :math:`L = L^T`.
414421
415422 If this is ``None``, it is unknown whether the operator is symmetric or not.
416- Only square operators can be symmetric."""
423+ Only square operators can be symmetric.
424+
425+ Raises
426+ ------
427+ ValueError
428+ When setting :attr:`is_symmetric` to :data:`True` on a non-square
429+ :class:`LinearOperator`.
430+ """
417431 return self ._is_symmetric
418432
419433 @is_symmetric .setter
@@ -458,6 +472,12 @@ def is_positive_definite(self) -> Optional[bool]:
458472
459473 If this is ``None``, it is unknown whether the matrix is positive-definite or
460474 not. Only symmetric operators can be positive-definite.
475+
476+ Raises
477+ ------
478+ ValueError
479+ When setting :attr:`is_positive_definite` to :data:`True` while
480+ :attr:`is_symmetric` is :data:`False`.
461481 """
462482 return self ._is_positive_definite
463483
@@ -520,7 +540,13 @@ def _eigvals(self) -> np.ndarray:
520540 return np .linalg .eigvals (self .todense (cache = False ))
521541
522542 def eigvals (self ) -> np .ndarray :
523- """Eigenvalue spectrum of the linear operator."""
543+ """Eigenvalue spectrum of the linear operator.
544+
545+ Raises
546+ ------
547+ numpy.linalg.LinAlgError
548+ If :meth:`eigvals` is called on a non-square operator.
549+ """
524550 if self ._eigvals_cache is None :
525551 if not self .is_square :
526552 raise np .linalg .LinAlgError (
@@ -871,9 +897,8 @@ def _lu_factor(self):
871897 ####################################################################################
872898
873899 def __neg__ (self ) -> "LinearOperator" :
874- from ._arithmetic import ( # pylint: disable=import-outside-toplevel
875- NegatedLinearOperator ,
876- )
900+ # pylint: disable=import-outside-toplevel,cyclic-import
901+ from ._arithmetic import NegatedLinearOperator
877902
878903 return NegatedLinearOperator (self )
879904
@@ -912,6 +937,18 @@ def transpose(self, *axes: Union[int, Tuple[int]]) -> "LinearOperator":
912937 """Transpose this linear operator.
913938
914939 Can be abbreviated self.T instead of self.transpose().
940+
941+ Parameters
942+ ----------
943+ *axes
944+ Permutation of the axes of the :class:`LinearOperator`.
945+
946+ Raises
947+ ------
948+ ValueError
949+ If the given axis indices do not constitute a valid permutation of the axes.
950+ numpy.AxisError
951+ If the axis indices are out of bounds.
915952 """
916953 if len (axes ) > 0 :
917954 if len (axes ) == 1 and isinstance (axes [0 ], tuple ):
@@ -1167,7 +1204,8 @@ def __matmul__(
11671204
11681205 return y
11691206
1170- from ._arithmetic import matmul # pylint: disable=import-outside-toplevel
1207+ # pylint: disable=import-outside-toplevel,cyclic-import
1208+ from ._arithmetic import matmul
11711209
11721210 return matmul (self , other )
11731211
@@ -1193,7 +1231,8 @@ def __rmatmul__(
11931231
11941232 return y
11951233
1196- from ._arithmetic import matmul # pylint: disable=import-outside-toplevel
1234+ # pylint: disable=import-outside-toplevel,cyclic-import
1235+ from ._arithmetic import matmul
11971236
11981237 return matmul (other , self )
11991238
@@ -1731,7 +1770,7 @@ def __init__(self, indices, shape, dtype=np.double):
17311770 )
17321771
17331772 @property
1734- def indices (self ):
1773+ def indices (self ) -> Tuple [ int ] :
17351774 """Indices which will be selected when applying the linear operator to a
17361775 vector."""
17371776 return self ._indices
0 commit comments