pygeoinf 1.1.5__py3-none-any.whl → 1.1.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pygeoinf/hilbert_space.py CHANGED
@@ -118,6 +118,16 @@ class HilbertSpace(ABC):
118
118
  The corresponding vector in the space.
119
119
  """
120
120
 
121
+ @abstractmethod
122
+ def __eq__(self, other: object) -> bool:
123
+ """
124
+ Defines equality between two HilbertSpace instances.
125
+
126
+ This is an abstract method, requiring all concrete subclasses to
127
+ implement a meaningful comparison. This ensures that equality is
128
+ defined by mathematical equivalence rather than object identity.
129
+ """
130
+
121
131
  # ------------------------------------------------------------------- #
122
132
  # Default implementations that can be overridden #
123
133
  # ------------------------------------------------------------------- #
@@ -209,25 +219,12 @@ class HilbertSpace(ABC):
209
219
  """
210
220
  return self.from_components(np.random.randn(self.dim))
211
221
 
212
- def __eq__(self, other: object) -> bool:
213
- """
214
- Defines equality between Hilbert spaces.
215
-
216
- For dual spaces, equality is determined by the equality of their
217
- underlying primal spaces. For non-dual spaces, this is not implemented,
218
- requiring concrete subclasses to define a meaningful comparison.
219
- """
220
- if isinstance(self, DualHilbertSpace):
221
- return (
222
- isinstance(other, DualHilbertSpace)
223
- and self.underlying_space == other.underlying_space
224
- )
225
- return NotImplemented
226
-
227
222
  # ------------------------------------------------------------------- #
228
223
  # Final (Non-Overridable) Methods #
229
224
  # ------------------------------------------------------------------- #
230
225
 
226
+
227
+
231
228
  @final
232
229
  @property
233
230
  def coordinate_inclusion(self) -> LinearOperator:
@@ -498,6 +495,17 @@ class DualHilbertSpace(HilbertSpace):
498
495
 
499
496
  return LinearForm(self._underlying_space, components=c)
500
497
 
498
+ def __eq__(self, other: object) -> bool:
499
+ """
500
+ Checks for equality with another dual space.
501
+
502
+ Two dual spaces are considered equal if and only if their underlying
503
+ primal spaces are equal.
504
+ """
505
+ if not isinstance(other, DualHilbertSpace):
506
+ return NotImplemented
507
+ return self.underlying_space == other.underlying_space
508
+
501
509
  @final
502
510
  def duality_product(self, xp: LinearForm, x: Vector) -> float:
503
511
  """
@@ -572,6 +580,11 @@ class EuclideanSpace(HilbertSpace):
572
580
  """Maps a `LinearForm` back to a vector via its components."""
573
581
  return self.dual.to_components(xp)
574
582
 
583
+ def __eq__(self, other: object):
584
+ if not isinstance(other, EuclideanSpace):
585
+ return NotImplemented
586
+ return self.dim == other.dim
587
+
575
588
 
576
589
  class MassWeightedHilbertSpace(HilbertSpace):
577
590
  """
@@ -651,6 +664,22 @@ class MassWeightedHilbertSpace(HilbertSpace):
651
664
  x = self.underlying_space.from_dual(xp)
652
665
  return self._inverse_mass_operator(x)
653
666
 
667
+ def __eq__(self, other: object) -> bool:
668
+ """
669
+ Checks for equality with another MassWeightedHilbertSpace.
670
+
671
+ Two mass-weighted spaces are considered equal if they share an equal
672
+ underlying space and their mass operators are also equal.
673
+ """
674
+ if not isinstance(other, MassWeightedHilbertSpace):
675
+ return NotImplemented
676
+
677
+ return (
678
+ self.underlying_space == other.underlying_space
679
+ and (self.mass_operator == other.mass_operator)
680
+ and (self.inverse_mass_operator == other.inverse_mass_operator)
681
+ )
682
+
654
683
 
655
684
  class MassWeightedHilbertModule(MassWeightedHilbertSpace, HilbertModule):
656
685
  """
@@ -172,7 +172,12 @@ class IterativeLinearSolver(LinearSolver):
172
172
  """
173
173
  Solves the adjoint linear system A*y = x for y.
174
174
  """
175
- return self.solve_linear_system(operator.adjoint, preconditioner.adjoint, x, y0)
175
+ adjoint_preconditioner = (
176
+ None
177
+ if preconditioner is None
178
+ else preconditioner.adjoint
179
+ )
180
+ return self.solve_linear_system(operator.adjoint, adjoint_preconditioner, x, y0)
176
181
 
177
182
  def __call__(
178
183
  self,
pygeoinf/operators.py CHANGED
@@ -232,8 +232,6 @@ class LinearOperator(Operator):
232
232
  raise ValueError("Domain mismatch")
233
233
 
234
234
  if codomain_base != operator.codomain:
235
- print(codomain_base)
236
- print(operator.codomain)
237
235
  raise ValueError("Codomain mismatch")
238
236
 
239
237
  return LinearOperator(
@@ -458,8 +458,14 @@ class Lebesgue(SphereHelper, HilbertModule, AbstractInvariantLebesgueSpace):
458
458
  return LinearOperator.self_adjoint(self, mapping)
459
459
 
460
460
  def __str__(self) -> str:
461
- """Returns the string representation of the form's components."""
462
- return f"Lebesgue space on sphere\nlmax={self.lmax}\nradius={self.radius}\ngrid={self.grid}\nextend={self.extend}"
461
+ """Returns a human-readable string summary of the space."""
462
+ return (
463
+ f"Lebesgue space on sphere:\n"
464
+ f"lmax={self.lmax}\n"
465
+ f"radius={self.radius}\n"
466
+ f"grid={self.grid}\n"
467
+ f"extend={self.extend}"
468
+ )
463
469
 
464
470
 
465
471
  class Sobolev(SphereHelper, MassWeightedHilbertModule, AbstractInvariantSobolevSpace):
@@ -610,3 +616,15 @@ class Sobolev(SphereHelper, MassWeightedHilbertModule, AbstractInvariantSobolevS
610
616
 
611
617
  c = self._coefficient_to_component(ulm)
612
618
  return self.dual.from_components(c)
619
+
620
+ def __str__(self) -> str:
621
+ """Returns a human-readable string summary of the space."""
622
+ return (
623
+ f"Lebesgue space on sphere:\n"
624
+ f"lmax={self.lmax}\n"
625
+ f"order={self.order}\n"
626
+ f"scale={self.scale}\n"
627
+ f"radius={self.radius}\n"
628
+ f"grid={self.grid}\n"
629
+ f"extend={self.extend}"
630
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pygeoinf
3
- Version: 1.1.5
3
+ Version: 1.1.7
4
4
  Summary: A package for solving geophysical inference and inverse problems
5
5
  License: BSD-3-Clause
6
6
  Author: David Al-Attar and Dan Heathcote
@@ -2,19 +2,19 @@ pygeoinf/__init__.py,sha256=uYRwiHKi4nvzUBwQJxNdt8OZodFQ_nj5rUv2YkDXL9Q,1185
2
2
  pygeoinf/direct_sum.py,sha256=r0h-3bK6RQiOMoq086oupYaXgUM4pFIV8XNKOB2q9BE,17095
3
3
  pygeoinf/forward_problem.py,sha256=RnnVBMg8Ih7TqZylfSkQ7pdHEowEfCkTiXiKFrxBpnM,9754
4
4
  pygeoinf/gaussian_measure.py,sha256=SFnHmEjpcrUy09AfO3fXLLB_SaGwA9oc5PU630e3hNM,22826
5
- pygeoinf/hilbert_space.py,sha256=42RSYoIPf0hruyysBVoeJGmsmDtTrpaet5YMZnxwgys,22429
5
+ pygeoinf/hilbert_space.py,sha256=90aaUPUBCqsEuXroOwCmvbRFhi1vf6F9bS4pU3DCseI,23369
6
6
  pygeoinf/inversion.py,sha256=p9k_iDVgJGLM1cGlT-0rgRwqdYVdsYC_euTXZk3kuOc,3199
7
7
  pygeoinf/linear_bayesian.py,sha256=aIOzTZbjJtdtwHKh5e01iS8iMiyr8XuwGx91udS3VK4,9624
8
8
  pygeoinf/linear_forms.py,sha256=Uizipi67i1Sd6m0TzsrJd99Xreo_6V8Db0gMy76fG6g,5953
9
9
  pygeoinf/linear_optimisation.py,sha256=7lklTRRBGkz8M9WsfvkDl-eoGkc4Ty7BOJq7LWkdxCg,11091
10
- pygeoinf/linear_solvers.py,sha256=P9SEjZ1LZdulr2KQrZojbvdCtAm--hMd4EArSu73L34,12154
11
- pygeoinf/operators.py,sha256=XO2_Y8d8Qo1RqGu3c5AgnAwsPAkial--LH9qdGtVs4M,33235
10
+ pygeoinf/linear_solvers.py,sha256=zymKX9oZCkhxWbKxP4ZH8g-GDC5gf_rFhlx7viWZo4Q,12294
11
+ pygeoinf/operators.py,sha256=kbDfHpaWaSnd0zvoAVMBpWWiQRNfW0ImVhtzEEIH6mM,33165
12
12
  pygeoinf/random_matrix.py,sha256=_XVwXqM_c0SMpy6JU-8IboXpotug6dDDHKdSPAJpH7c,7788
13
13
  pygeoinf/symmetric_space/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  pygeoinf/symmetric_space/circle.py,sha256=0EHPg2FcvWTOvCb8ualCW0uUp8RuUNfQ7oK6NHXtG1Q,17552
15
- pygeoinf/symmetric_space/sphere.py,sha256=BYh3-Eajdzx4YOd1cMagOG3PfqbgibSq4zSdFRg5Jg8,20768
15
+ pygeoinf/symmetric_space/sphere.py,sha256=edxLWXMqW857hYdN54X76HZyIe0lVVFdzrtCdTHM9Oc,21234
16
16
  pygeoinf/symmetric_space/symmetric_space.py,sha256=YkRjHucc2cO7IAoyJS5KMdiRBuytRpUfTUsVMHBPZYs,16146
17
- pygeoinf-1.1.5.dist-info/LICENSE,sha256=GrTQnKJemVi69FSbHprq60KN0OJGsOSR-joQoTq-oD8,1501
18
- pygeoinf-1.1.5.dist-info/METADATA,sha256=NPePR0GmfcViZ39WixMb1ETS8o6Ld4OjjTTHyl3id7U,15324
19
- pygeoinf-1.1.5.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
20
- pygeoinf-1.1.5.dist-info/RECORD,,
17
+ pygeoinf-1.1.7.dist-info/LICENSE,sha256=GrTQnKJemVi69FSbHprq60KN0OJGsOSR-joQoTq-oD8,1501
18
+ pygeoinf-1.1.7.dist-info/METADATA,sha256=JFTA2uZ_d5Drss7-rHQvUPYAKdcW933M3XfRVP_qCBA,15324
19
+ pygeoinf-1.1.7.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
20
+ pygeoinf-1.1.7.dist-info/RECORD,,