Skip to content
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

Release v2.3.0 #604

Merged
merged 145 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
e49b33f
Merge pull request #544 from PyLops/master
mrava87 Nov 11, 2023
a6bca01
build: added python3.11 to github actions
mrava87 Nov 11, 2023
e69a172
Merge pull request #545 from mrava87/build-python311
mrava87 Nov 11, 2023
1c7c9e0
fix: change BlendingContinuous to work with pylops solvers
mrava87 Nov 14, 2023
99f5aa8
Merge pull request #546 from mrava87/patch-contdeb
mrava87 Nov 15, 2023
9523ae1
fix: ensure sliding ops work with fp32
mrava87 Nov 22, 2023
01568da
minor: removed sliding1dNEW
mrava87 Nov 22, 2023
cc52ae8
Merge pull request #549 from mrava87/patch-slidingdtype
mrava87 Nov 22, 2023
55c42ac
changing to 128/256 bit to c/longdouble (#552)
alex-rakowski Nov 26, 2023
294f951
adding make dev-install_conda_arm (#553)
alex-rakowski Nov 28, 2023
a227115
feature: handles https://github.com/PyLops/pylops/issues/554
mrava87 Nov 28, 2023
f130a96
fix: force dtype for shift operator inputs
mrava87 Nov 29, 2023
5f32e0b
Merge pull request #557 from mrava87/patch-shifttype
mrava87 Nov 29, 2023
3e48cbf
Merge pull request #555 from mrava87/feat-vzdegh
mrava87 Nov 29, 2023
32d60d5
doc: adding info about decorator in new operator doc
mrava87 Dec 16, 2023
d6e484c
Merge pull request #558 from mrava87/doc-decorator
mrava87 Dec 16, 2023
77eca0f
Changing how optional dependencies are import state are checked (#551)
alex-rakowski Dec 17, 2023
b67845e
minor: added typing to metrics
mrava87 Dec 17, 2023
64556cd
Merge pull request #559 from mrava87/dev
mrava87 Dec 17, 2023
68ee8b9
fix: better handling of nttot in BlendingContinuous
mrava87 Jan 9, 2024
6668038
feature: remove cusignal dependency
mrava87 Jan 9, 2024
54bef33
Merge pull request #563 from mrava87/patch-debl
mrava87 Jan 9, 2024
05df62b
minor: remove commented code from backend.py
mrava87 Jan 9, 2024
a6d09c1
Merge pull request #564 from mrava87/patch-cusignal
mrava87 Jan 10, 2024
38fe5ee
feat: added exponent to cosinetaper
mrava87 Jan 24, 2024
e588fe3
Merge pull request #566 from mrava87/feat-unittaper
mrava87 Jan 25, 2024
b56ab83
feat: added DTCWT 1d operator
mrava87 Feb 29, 2024
65571ee
Merge pull request #569 from mrava87/feature-dtcwtclean
mrava87 Feb 29, 2024
e12027e
doc: add dtcwt to doc api
mrava87 Feb 29, 2024
0d19f56
Merge pull request #570 from mrava87/fix-dtcwtdoc
mrava87 Feb 29, 2024
5451f4d
fix: ensure dtcwt is not used in typing annotations
mrava87 Mar 4, 2024
7b8727a
Merge pull request #571 from mrava87/fix-dtcwtimport
mrava87 Mar 4, 2024
b9b47ce
invert dips check
Beramos Mar 4, 2024
3bd3386
add unit test slope vs. dips
Beramos Mar 4, 2024
ae77c86
doc: added safe typing to dtcwt
mrava87 Mar 16, 2024
99d91f1
Merge pull request #573 from Beramos/BDJ_fix_dips
mrava87 Mar 17, 2024
b8e35b2
Annotation as NewType dtcwt.py
cako Mar 19, 2024
ad3d9cc
Merge pull request #575 from mrava87/dev
mrava87 Mar 19, 2024
74e8c68
build: modernized ci (#576)
mrava87 Apr 14, 2024
42c6b2f
feature: added kwargs to FFTND (#577)
mrava87 May 1, 2024
493e4d4
feature: improved Sliding1d
mrava87 May 8, 2024
2df59f0
feature: improved Sliding2d and Sliding3d
mrava87 May 12, 2024
9cabdf4
feature: improved Patch2D
mrava87 May 12, 2024
63425e3
feature: improved Patch3D
mrava87 May 13, 2024
9411580
feat: added savetaper to Sliding1d and Sliding2d
mrava87 May 15, 2024
c3da131
feat: added savetaper to Sliding3d
mrava87 May 16, 2024
3066a4f
feat: added savetaper to Patch2D and Patch3D
mrava87 May 18, 2024
6c57fc3
minor: added versionadded to docstrings
mrava87 May 18, 2024
cd3aadf
minor: moved repeated code into private method
mrava87 May 18, 2024
af5d8ae
minor: remove unused i
mrava87 May 18, 2024
4c82d21
minor: added verb to *_design methods and few other small fixes
mrava87 May 22, 2024
60997e0
bug: fixes https://github.com/PyLops/pylops/issues/579
mrava87 May 22, 2024
23c5539
Merge pull request #578 from mrava87/feature-newslidepatch
mrava87 May 22, 2024
eb2966b
minor: fix typo in docstrings
mrava87 May 22, 2024
27636e5
Merge pull request #580 from mrava87/bug-to_cupy_cond
mrava87 May 22, 2024
4a85bb0
Merge pull request #581 from mrava87/doc-patchslide
mrava87 May 22, 2024
accc36e
minor: remove ravel from Fredholm1 _matvev
mrava87 Jun 5, 2024
7acf812
minor: fix typo in fredholm1 docstring
mrava87 Jun 5, 2024
e537125
minor: added args_FFT1 to MDC
mrava87 Jun 6, 2024
d1a341a
Merge pull request #582 from mrava87/patch-fred
mrava87 Jun 6, 2024
b5ca8cc
Add N-dimensional discrete wavelet transforms
solldavid Jun 14, 2024
3956a99
Clean up docstring
solldavid Jun 14, 2024
3f271e2
doc: updated bayesian tutorial
mrava87 Jun 16, 2024
b19a63c
Merge pull request #584 from mrava87/dev
mrava87 Jun 16, 2024
24771ea
Address review comments
solldavid Jun 17, 2024
9b0c9b9
Add name to README.txt
solldavid Jun 17, 2024
4860e7a
Merge pull request #583 from solldavid/sollberger/3d-dwt
mrava87 Jun 17, 2024
a07762a
doc: fix notes in dip_estimate
mrava87 Jun 17, 2024
b6099a6
Merge pull request #585 from mrava87/doc-dipest
mrava87 Jun 17, 2024
d055f97
build: force torch cpuonly
mrava87 Jun 21, 2024
dac0368
Merge pull request #587 from mrava87/patch-torchcpu
mrava87 Jun 21, 2024
dfc95fa
doc: fix GA badge (#588)
mrava87 Jul 2, 2024
c3e5a27
fix: adapted tests for scipy v1.14
mrava87 Jul 2, 2024
771010f
minor: fix again tol
mrava87 Jul 2, 2024
2b8b71a
fix: bump minimum scipy to v1.11
mrava87 Jul 2, 2024
02fa492
minor: bump minimum python to 3.9
mrava87 Jul 2, 2024
5ed015a
build: remove python 3.12
mrava87 Jul 2, 2024
95c62ff
test: change tol to atol in test_leastsquares
mrava87 Jul 2, 2024
2a94687
test: fix dense extraction in scipy sparse
mrava87 Jul 2, 2024
ec82589
fix: change atol behaviour for cg
mrava87 Jul 2, 2024
3d0b222
build: bump azure pipelines python to 3.9
mrava87 Jul 2, 2024
0cdbfe4
build: added jax to environments
mrava87 Jul 3, 2024
21659ae
feat: added JaxOperator
mrava87 Jul 3, 2024
a060af7
feat: enabled jax in basicoperators
mrava87 Jul 3, 2024
d372de7
feat: enabled jax in avo
mrava87 Jul 3, 2024
6067fa2
feat: enabled jax in signalprocessing
mrava87 Jul 3, 2024
ca81494
feat: enabled jax in waveeqprocessing
mrava87 Jul 3, 2024
6216128
doc: added jax integration to doc
mrava87 Jul 3, 2024
05c78e9
build: remove python 3.8 from CI
mrava87 Jul 3, 2024
cd0ebb8
minor: added sphinxemoji to requirements-dev
mrava87 Jul 3, 2024
e27faa0
minor: change jax integration for sliding and patching in gpu.rst
mrava87 Jul 3, 2024
bce58c1
bug: fix shape of x0 in RegularizedInversion
mrava87 Jul 4, 2024
3a27486
Merge pull request #591 from mrava87/dev
mrava87 Jul 4, 2024
eae806f
minor: fixed some error messages
mrava87 Jul 4, 2024
126515d
minor: removed commented code in prestack
mrava87 Jul 4, 2024
c9d0eae
doc: improved doc for JaxOperator
mrava87 Jul 4, 2024
14adc13
feat: enable jax in todense
mrava87 Jul 4, 2024
391104c
minor: remove commented codes
mrava87 Jul 4, 2024
6af08b6
minor: fix typo in fredholm1 docstring
mrava87 Jul 5, 2024
b499968
feature: added updatesrc method to AcousticWave2D
mrava87 Jul 22, 2024
733533e
minor: remove unused method
mrava87 Jul 22, 2024
8094963
Merge pull request #593 from mrava87/feature-devitowav
mrava87 Jul 22, 2024
98b1ebf
Removes the creation of the solver from within the shots iteration loop
Jul 24, 2024
869ddc5
Merge pull request #589 from mrava87/patch-scipyv14
mrava87 Jul 26, 2024
2ec2745
doc: added guaacoelho to contributors
mrava87 Jul 26, 2024
af1530a
Merge pull request #594 from guaacoelho/performance-refactor
mrava87 Jul 26, 2024
493d2e5
ci: bumpy python to 3.9 in coverage-reporter
mrava87 Jul 26, 2024
a9c7f0f
Merge pull request #595 from mrava87/contrib-guaacoelho
mrava87 Jul 26, 2024
9da0fd4
build: remove forcing numpy<2
mrava87 Jul 26, 2024
3f9b941
bug: fix linearoperator for numpy2
mrava87 Jul 26, 2024
28cc528
test: add safeguards to dtcwt and spgl1 for numpy2
mrava87 Jul 26, 2024
59de650
doc: force readthedocs to use numpy<v2
mrava87 Jul 26, 2024
85dfc1b
doc: force also test_sparsity
mrava87 Jul 26, 2024
599c5ab
tests: disable tests for TorchOperator on darwin os
mrava87 Jul 27, 2024
24848c4
minor: change numpy import to suppress depracation warning
mrava87 Jul 27, 2024
45b5fbc
minor: different import in Restriction based on numpy version
mrava87 Jul 27, 2024
b9618f5
chore: simplify testing logic
cako Aug 5, 2024
734776d
chore: simplify testing logic
cako Aug 5, 2024
f8e3323
chore: simplify testing logic
cako Aug 5, 2024
6510207
fix: add warning that NumPy 2 is not supported with dtcwt and spgl1
cako Aug 5, 2024
1560889
chore: smaller diffs
cako Aug 5, 2024
cfef27a
chore: import order
cako Aug 5, 2024
694e2ff
fix: docs using the wrong array type
cako Aug 5, 2024
1890d16
fix: randn arguments
cako Aug 5, 2024
162d72a
fix: remove unused import
cako Aug 5, 2024
32bad36
Merge pull request #596 from mrava87/patch_numpyv2
mrava87 Aug 9, 2024
5a8a20b
minor: fixed typing of jax
mrava87 Aug 9, 2024
29a4dc2
Merge branch 'feature-jax' of https://github.com/mrava87/pylops into …
mrava87 Aug 9, 2024
310b2a9
minor: one more fix of typing of jax
mrava87 Aug 9, 2024
054c5b8
minor: fix linting
mrava87 Aug 9, 2024
21e590b
Merge pull request #590 from mrava87/feature-jax
mrava87 Aug 9, 2024
ad6c6f3
doc: added jax to installation.rst
mrava87 Aug 9, 2024
fae0f00
bug: added sphinxemoji to requirements-doc
mrava87 Aug 9, 2024
628f60b
bug: added jax to requirements-doc
mrava87 Aug 9, 2024
b199b3a
Merge pull request #598 from mrava87/doc-jax
mrava87 Aug 9, 2024
0c2e852
bug: move _CustomSource to private file
mrava87 Aug 13, 2024
1b3ad18
bug: added AcousticWaveSolverType
mrava87 Aug 13, 2024
ad54bb5
bug: fix _CustomSource import
mrava87 Aug 13, 2024
899a407
doc:fixed cupy minimum version
mrava87 Aug 13, 2024
87b9be6
Merge pull request #600 from mrava87/fix-devitoimport
mrava87 Aug 13, 2024
3e6dc8f
Merge pull request #601 from mrava87/doc-cupyversion
mrava87 Aug 13, 2024
375c353
build: restore tests for spgl1
mrava87 Aug 16, 2024
9f8a5b1
doc: added changelog
mrava87 Aug 16, 2024
a7ad7d0
minor: small fix to CHANGELOG
mrava87 Aug 16, 2024
c204095
Merge pull request #602 from mrava87/v2.3
mrava87 Aug 16, 2024
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
8 changes: 4 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ jobs:
build:
strategy:
matrix:
platform: [ ubuntu-latest, macos-latest ]
python-version: ["3.8", "3.9", "3.10"]
platform: [ ubuntu-latest, macos-13 ]
python-version: ["3.9", "3.10", "3.11"]

runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/codacy-coverage-reporter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ jobs:
strategy:
matrix:
platform: [ ubuntu-latest, ]
python-version: ["3.8", ]
python-version: ["3.9", ]

runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/flake8.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
name: Lint
steps:
- name: Check out source repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python environment
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: flake8 Lint
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ sphinx:
# Declare the Python requirements required to build your docs
python:
install:
- requirements: requirements-dev.txt
- requirements: requirements-doc.txt
- method: pip
path: .
29 changes: 28 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
Changelog
=========

# 2.3.0

* Added `pylops.JaxOperator`, `pylops.signalprocessing.DWTND`, and `pylops.signalprocessing.DTCWT` operators.
* Added `updatesrc` method to `pylops.waveeqprocessing.AcousticWave2D`.
* Added `verb` to `pylops.signalprocessing.Sliding1D.sliding1d_design`, `pylops.signalprocessing.Sliding2D.sliding2d_design`, `pylops.signalprocessing.Sliding3D.sliding3d_design`, `pylops.signalprocessing.Patch2D.patch2d_design`, and `pylops.signalprocessing.Patch3D.patch3d_design`.
* Added `kwargs_fft` to `pylops.signalprocessing.FFTND`.
* Added `cosinetaper` to `pylops.utils.tapers.cosinetaper`.
* Added `kind` to `pylops.waveeqprocessing.Deghosting`.
* Modified all methods in `pylops.utils.backend` to enable jax integration.
* Modified implementations of `pylops.signalprocessing.Sliding1D`, `pylops.signalprocessing.Sliding2D`,
`pylops.signalprocessing.Sliding3D`, `pylops.signalprocessing.Patch2D`, and
`pylops.signalprocessing.Patch3D` to being directly implemented instead of relying on other PyLops operators. Added also `savetaper` parameter and an option to apply the operator `Op` simultaneously to all windows.
* Modified `pylops.waveeqprocessing.AcousticWave2D._born_oneshot` and
`pylops.waveeqprocessing.AcousticWave2D._born_allshots` to avoid recreating the devito solver for each shot (and enabling internal caching...)
* Modified `dtype` of `pylops.signalprocessing.Shift` to be that of the input vector.
* Modified `pylops.waveeqprocessing.BlendingContinuous` to use `matvec/rmatvec` instead of `@/.H @` for compatibility with pylops solvers.
* Removed `cusignal` as optional dependency and `cupy`'s equivalent methods (since the library
is now unmantained and merged into `cupy`).
* Fixed ImportError of optional dependencies when installed but not correctly functioning (see [Issue #548](https://github.com/PyLops/pylops/issues/548))
* Fixed bug in :py:func:`pylops.utils.deps.to_cupy_conditional` (see [Issue #579](https://github.com/PyLops/pylops/issues/579))
* Fixed bug in the definition of `nttot` in :py:class:`pylops.waveeqprocessing.BlendingContinuous`
* Fixed bug in :py:func:`pylops.utils.signalprocessing.dip_estimate` (see [Issue #572](https://github.com/PyLops/pylops/issues/572))


# 2.2.0

* Added `pylops.signalprocessing.NonStationaryConvolve3D` operator
Expand Down Expand Up @@ -287,7 +314,7 @@ To aid users in navigating the breaking changes, we provide the following docume
``pylops.waveeqprocessing.UpDownComposition3Doperator``, and
``pylops.waveeqprocessing.PhaseShift`` operators
* Fix bug in ``pylops.basicoperators.Kronecker``
(see [Issue #125](https://github.com/Statoil/pylops/issues/125))
(see [Issue #125](https://github.com/PyLops/pylops/issues/125))

# 1.7.0
* Added ``pylops.basicoperators.Gradient``,
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PIP := $(shell command -v pip3 2> /dev/null || command which pip 2> /dev/null)
PYTHON := $(shell command -v python3 2> /dev/null || command which python 2> /dev/null)

.PHONY: install dev-install install_conda dev-install_conda tests doc docupdate
.PHONY: install dev-install install_conda dev-install_conda tests doc docupdate servedoc lint typeannot coverage

pipcheck:
ifndef PIP
Expand Down Expand Up @@ -29,6 +29,9 @@ install_conda:
dev-install_conda:
conda env create -f environment-dev.yml && conda activate pylops && pip install -e .

dev-install_conda_arm:
conda env create -f environment-dev-arm.yml && conda activate pylops && pip install -e .

tests:
make pythoncheck
pytest
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![PyPI version](https://badge.fury.io/py/pylops.svg)](https://badge.fury.io/py/pylops)
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/pylops/badges/version.svg)](https://anaconda.org/conda-forge/pylops)
[![AzureDevOps Status](https://dev.azure.com/matteoravasi/PyLops/_apis/build/status/PyLops.pylops?branchName=dev)](https://dev.azure.com/matteoravasi/PyLops/_build/latest?definitionId=9&branchName=dev)
[![GithubAction Status](https://github.com/mrava87/pylops/actions/workflows/build.yaml/badge.svg)](https://github.com/mrava87/pylops/actions/workflows/build.yaml)
[![GithubAction Status](https://github.com/PyLops/pylops/actions/workflows/build.yaml/badge.svg?branch=dev)](https://github.com/PyLops/pylops/actions/workflows/build.yaml)
[![Documentation Status](https://readthedocs.org/projects/pylops/badge/?version=stable)](https://pylops.readthedocs.io/en/stable/?badge=stable)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/17fd60b4266347d8890dd6b64f2c0807)](https://www.codacy.com/gh/PyLops/pylops/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=PyLops/pylops&amp;utm_campaign=Badge_Grade)
[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/17fd60b4266347d8890dd6b64f2c0807)](https://www.codacy.com/gh/PyLops/pylops/dashboard?utm_source=github.com&utm_medium=referral&utm_content=PyLops/pylops&utm_campaign=Badge_Coverage)
Expand Down Expand Up @@ -149,3 +149,6 @@ A list of video tutorials to learn more about PyLops:
* Rohan Babbar, rohanbabbar04
* Wei Zhang, ZhangWeiGeo
* Fedor Goncharov, fedor-goncharov
* Alex Rakowski, alex-rakowski
* David Sollberger, solldavid
* Gustavo Coelho, guaacoelho
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
# steps:
# - task: UsePythonVersion@0
# inputs:
# versionSpec: '3.7'
# versionSpec: '3.9'
# architecture: 'x64'
#
# - script: |
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
versionSpec: '3.9'
architecture: 'x64'

- script: |
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
versionSpec: '3.9'
architecture: 'x64'

- script: |
Expand Down
45 changes: 31 additions & 14 deletions docs/source/adding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Implementing new operators
==========================
Users are welcome to create new operators and add them to the PyLops library.

In this tutorial, we will go through the key steps in the definition of an operator, using the
:py:class:`pylops.Diagonal` as an example. This is a very simple operator that applies a diagonal matrix to the model
in forward mode and to the data in adjoint mode.
In this tutorial, we will go through the key steps in the definition of an operator, using a simplified version of the
:py:class:`pylops.Diagonal` operator as an example. This is a very simple operator that applies a diagonal matrix
to the model in forward mode and to the data in adjoint mode.


Creating the operator
Expand Down Expand Up @@ -45,14 +45,17 @@ Initialization (``__init__``)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

We then need to create the ``__init__`` where the input parameters are passed and saved as members of our class.
While the input parameters change from operator to operator, it is always required to create three members, the first
called ``shape`` with a tuple containing the dimensions of the operator in the data and model space, the second
called ``dtype`` with the data type object (:obj:`np.dtype`) of the model and data, and the third
called ``explicit`` with a boolean (``True`` or ``False``) identifying if the operator can be inverted by a direct
solver or requires an iterative solver. This member is ``True`` if the operator has also a member ``A`` that contains
the matrix to be inverted like for example in the :py:class:`pylops.MatrixMult` operator, and it will be ``False`` otherwise.
In this case we have another member called ``d`` which is equal to the input vector containing the diagonal elements
of the matrix we want to multiply to the model and data.
While the input parameters change from operator to operator, it is always required to create three members:

- ``dtype``: data type object (of type :obj:`str` or :obj:`np.dtype`) of the model and data;
- ``shape``: a tuple containing the dimensions of the operator in the data and model space;
- ``explicit``: a boolean (``True`` or ``False``) identifying if the operator can be inverted by a direct solver or
requires an iterative solver. This member is ``True`` if the operator has also a member ``A`` that contains
the matrix to be inverted like for example in the :py:class:`pylops.MatrixMult` operator, and it will be
``False`` otherwise.

In this specific case, we have another member called ``d`` which is equal to the input vector containing the diagonal
elements of the matrix we want to multiply to the model and data.

.. code-block:: python

Expand All @@ -62,7 +65,7 @@ of the matrix we want to multiply to the model and data.
self.dtype = np.dtype(dtype)
self.explicit = False

Alternatively, since version 2.0.0, the recommended way of initializing operators derived from the base
Alternatively, since version ``v2.0.0``, the recommended way of initializing operators derived from the base
:py:class:`pylops.LinearOperator` class is to invoke ``super`` to assign the required attributes:

.. code-block:: python
Expand All @@ -72,8 +75,14 @@ Alternatively, since version 2.0.0, the recommended way of initializing operator
super().__init__(dtype=np.dtype(dtype), shape=(len(self.d), len(self.d)))

In this case, there is no need to declare ``explicit`` as it already defaults to ``False``.
Since version 2.0.0, every :py:class:`pylops.LinearOperator` class is imbued with ``dims``,
``dimsd``, ``clinear`` and ``explicit``, in addition to the required ``dtype`` and ``shape``.

Moreover, since version ``v2.0.0``, every :py:class:`pylops.LinearOperator` class is imbued with ``dims``,
``dimsd``, and ``clinear`` in addition to the required ``dtype``, ``shape``, and ``explicit``. Note that
``dims`` and ``dimsd`` can be defined in spite of ``shape``, which will be automatically assigned within the
``super`` method: the main difference between ``dims``/``dimsd`` and ``shape`` is the the former variables can be
used the define the n-dimensional nature of the input of an operator, whilst the latter variable refers to their overall
shape when the input is flattened.

See the docs of :py:class:`pylops.LinearOperator` for more information about what these
attributes mean.

Expand All @@ -91,6 +100,10 @@ We will finally need to ``return`` the result of this operation:
def _matvec(self, x):
return self.d * x

Note that since version ``v2.0.0``, this method can be decorated by the decorator ``@reshaped``. As discussed in
more details in the decorator documentation, by adding such decorator the input ``x`` is initially reshaped into
a nd-array of shape ``dims``, fed to the actual code in ``_matvec`` and then flattened.

Adjoint mode (``_rmatvec``)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Finally we need to implement the *adjoint mode* in the method ``_rmatvec``. In other words, we will need to write
Expand All @@ -106,6 +119,10 @@ different from operator to operator):

And that's it, we have implemented our first linear operator!

Similar to ``_matvec``, since version ``v2.0.0``, this method can also be decorated by the decorator ``@reshaped``.
When doing so, the input ``x`` is initially reshaped into
a nd-array of shape ``dimsd``, fed to the actual code in ``_rmatvec`` and then flattened.

Testing the operator
--------------------
Being able to write an operator is not yet a guarantee of the fact that the operator is correct, or in other words
Expand Down
3 changes: 3 additions & 0 deletions docs/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Templates
FunctionOperator
MemoizeOperator
TorchOperator
JaxOperator

Basic operators
~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -102,7 +103,9 @@ Signal processing
Shift
DWT
DWT2D
DWTND
DCT
DTCWT
Seislet
Radon2D
Radon3D
Expand Down
Loading
Loading