Skip to content

Commit

Permalink
Merge pull request #604 from PyLops/dev
Browse files Browse the repository at this point in the history
Release v2.3.0
  • Loading branch information
mrava87 authored Aug 16, 2024
2 parents 98dc07f + c204095 commit 3868bca
Show file tree
Hide file tree
Showing 88 changed files with 4,814 additions and 1,289 deletions.
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&utm_medium=referral&utm_content=PyLops/pylops&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

0 comments on commit 3868bca

Please sign in to comment.