-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Package restructuring and naming (#223)
* moved linops up in the namespace * isort * imports unified * tests moved to correct dir and changed name back to linops * renamed back to linops * doctest problems fixed * refactored aslinop into own file * pylint fix * doctest bug fixed in aslinop * api doc structure unified * unified import in tests
- Loading branch information
1 parent
07e3599
commit 8a0cc0d
Showing
20 changed files
with
102 additions
and
88 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -1,12 +1,5 @@ | ||
probnum.linalg | ||
============== | ||
|
||
probnum.linalg | ||
************** | ||
.. automodapi:: probnum.linalg | ||
:no-heading: | ||
|
||
probnum.linalg.linops | ||
********************* | ||
.. automodapi::probnum.linalg.linops | ||
:no-heading: |
This file contains 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 @@ | ||
probnum.linops | ||
============== | ||
|
||
.. automodapi:: probnum.linops | ||
:no-heading: |
8 changes: 3 additions & 5 deletions
8
docs/source/public_api/probnum.rst → docs/source/public_api/random_variables.rst
This file contains 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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
probnum | ||
======= | ||
|
||
probnum.random_variables | ||
************************ | ||
======================== | ||
|
||
.. automodapi:: probnum.random_variables | ||
:no-heading: | ||
:no-heading: |
This file contains 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 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 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 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 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 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 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,41 @@ | ||
import numpy as np | ||
import scipy.sparse | ||
|
||
from . import _linear_operator | ||
|
||
|
||
def aslinop(A) -> _linear_operator.LinearOperator: | ||
""" | ||
Return ``A`` as a :class:`LinearOperator`. | ||
Parameters | ||
---------- | ||
A : array-like or LinearOperator or RandomVariable or object | ||
Argument to be represented as a linear operator. When `A` is an object it needs | ||
to have the attributes `.shape` and `.matvec`. | ||
See Also | ||
-------- | ||
LinearOperator : Class representing linear operators. | ||
Notes | ||
----- | ||
If `A` has no `.dtype` attribute, the data type is determined by calling | ||
:func:`LinearOperator.matvec()` - set the `.dtype` attribute to prevent this | ||
call upon the linear operator creation. | ||
Examples | ||
-------- | ||
>>> import numpy as np | ||
>>> from probnum.linops import aslinop | ||
>>> M = np.array([[1,2,3],[4,5,6]], dtype=np.int32) | ||
>>> aslinop(M) | ||
<2x3 MatrixMult with dtype=int32> | ||
""" | ||
if isinstance(A, scipy.sparse.linalg.LinearOperator): | ||
return A | ||
elif isinstance(A, (np.ndarray, scipy.sparse.spmatrix)): | ||
return _linear_operator.MatrixMult(A=A) | ||
else: | ||
op = scipy.sparse.linalg.aslinearoperator(A) | ||
return _linear_operator.LinearOperator(op) |
This file contains 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 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 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
File renamed without changes.
This file contains 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 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
Oops, something went wrong.