Skip to content
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 environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ channels:
dependencies:
- python >= 3.8.0
- pip
- numpy>=1.15.0,<=2.3.5
- numpy>=1.15.0
- scipy>=1.8.0
- mpi4py
- pylops
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
- conda-forge
dependencies:
- python>=3.8.0
- numpy>=1.15.0,<=2.3.5
- numpy>=1.15.0
- scipy>=1.8.0
- pylops>=2.0
- matplotlib
Expand Down
4 changes: 2 additions & 2 deletions pylops_mpi/basicoperators/BlockDiag.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ def __init__(self, ops: Sequence[MPILinearOperator], base_comm: MPI.Comm = MPI.C
dtype: Optional[DTypeLike] = None):
self.ops = ops
dtype = _get_dtype(self.ops) if dtype is None else np.dtype(dtype)
shape = (int(np.sum(op.shape[0] for op in ops)),
int(np.sum(op.shape[1] for op in ops)))
shape = (int(sum(op.shape[0] for op in ops)),
int(sum(op.shape[1] for op in ops)))
super().__init__(shape=shape, dtype=dtype, base_comm=base_comm)

def _matvec(self, x: StackedDistributedArray) -> StackedDistributedArray:
Expand Down
2 changes: 1 addition & 1 deletion pylops_mpi/basicoperators/VStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def __init__(self, ops: Sequence[MPILinearOperator],
self.ops = ops
if len(set(op.shape[1] for op in ops)) > 1:
raise ValueError("Operators have different number of columns")
shape = (int(np.sum(op.shape[0] for op in ops)), ops[0].shape[1])
shape = (int(sum(op.shape[0] for op in ops)), ops[0].shape[1])
dtype = _get_dtype(self.ops) if dtype is None else np.dtype(dtype)
super().__init__(shape=shape, dtype=dtype, base_comm=base_comm)

Expand Down
20 changes: 10 additions & 10 deletions pylops_mpi/optimization/cls_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def setup(
self.r = self.y - self.Op.matvec(x)
self.rank = x.rank
self.c = self.r.copy()
self.kold = float(np.abs(self.r.dot(self.r.conj())))
self.kold = float(np.abs(self.r.dot(self.r.conj())).item())

# create variables to track the residual norm and iterations
self.cost: List = []
Expand Down Expand Up @@ -127,10 +127,10 @@ def step(self, x: Union[DistributedArray, StackedDistributedArray],
"""
Opc = self.Op.matvec(self.c)
cOpc = np.abs(self.c.dot(Opc.conj()))
a = float(self.kold / cOpc)
a = float((self.kold / cOpc).item())
x += a * self.c
self.r -= a * Opc
k = float(np.abs(self.r.dot(self.r.conj())))
k = float(np.abs(self.r.dot(self.r.conj())).item())
b = float(k / self.kold)
self.c = self.r + b * self.c
self.kold = k
Expand Down Expand Up @@ -349,13 +349,13 @@ def setup(self,
self.rank = x.rank
self.c = r.copy()
self.q = self.Op.matvec(self.c)
self.kold = float(np.abs(r.dot(r.conj())))
self.kold = float(np.abs(r.dot(r.conj())).item())

# create variables to track the residual norm and iterations
self.cost = []
self.cost1 = []
self.cost.append(float(self.s.norm()))
self.cost1.append(np.sqrt(float(self.cost[0] ** 2 + damp * np.abs(x.dot(x.conj())))))
self.cost.append(float(self.s.norm().item()))
self.cost1.append(np.sqrt(float(self.cost[0] ** 2 + damp * np.abs(x.dot(x.conj())).item())))
self.iiter = 0

# print setup
Expand Down Expand Up @@ -386,19 +386,19 @@ def step(self, x: Union[DistributedArray, StackedDistributedArray],

"""

a = float(np.abs(self.kold / (self.q.dot(self.q.conj()) + self.damp * self.c.dot(self.c.conj()))))
a = float(np.abs(self.kold / (self.q.dot(self.q.conj()) + self.damp * self.c.dot(self.c.conj()))).item())
x += a * self.c
self.s -= a * self.q
damped_x = self.damp * x
r = self.Op.rmatvec(self.s) - damped_x
k = float(np.abs(r.dot(r.conj())))
k = float(np.abs(r.dot(r.conj())).item())
b = float(k / self.kold)
self.c = r + b * self.c
self.q = self.Op.matvec(self.c)
self.kold = k
self.iiter += 1
self.cost.append(float(self.s.norm()))
self.cost1.append(np.sqrt(float(self.cost[self.iiter] ** 2 + self.damp * np.abs(x.dot(x.conj())))))
self.cost.append(float(self.s.norm().item()))
self.cost1.append(np.sqrt(float(self.cost[self.iiter] ** 2 + self.damp * np.abs(x.dot(x.conj())).item())))
if show and self.rank == 0:
self._print_step(x)
return x
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ classifiers = [
"Topic :: Scientific/Engineering :: Mathematics",
]
dependencies = [
"numpy>=1.15.0,<=2.3.5",
"numpy>=1.15.0",
"scipy >= 1.4.0",
"pylops >= 2.0",
"mpi4py",
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numpy>=1.15.0,<=2.3.5
numpy>=1.15.0
scipy>=1.8.0
pylops
mpi4py
Expand Down