pygeoinf 1.1.5__py3-none-any.whl → 1.1.6__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,21 +219,6 @@ 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
  # ------------------------------------------------------------------- #
@@ -498,6 +493,17 @@ class DualHilbertSpace(HilbertSpace):
498
493
 
499
494
  return LinearForm(self._underlying_space, components=c)
500
495
 
496
+ def __eq__(self, other: object) -> bool:
497
+ """
498
+ Checks for equality with another dual space.
499
+
500
+ Two dual spaces are considered equal if and only if their underlying
501
+ primal spaces are equal.
502
+ """
503
+ if not isinstance(other, DualHilbertSpace):
504
+ return NotImplemented
505
+ return self.underlying_space == other.underlying_space
506
+
501
507
  @final
502
508
  def duality_product(self, xp: LinearForm, x: Vector) -> float:
503
509
  """
@@ -572,6 +578,11 @@ class EuclideanSpace(HilbertSpace):
572
578
  """Maps a `LinearForm` back to a vector via its components."""
573
579
  return self.dual.to_components(xp)
574
580
 
581
+ def __eq__(self, other: object):
582
+ if not isinstance(other, EuclideanSpace):
583
+ return NotImplemented
584
+ return self.dim == other.dim
585
+
575
586
 
576
587
  class MassWeightedHilbertSpace(HilbertSpace):
577
588
  """
@@ -651,6 +662,22 @@ class MassWeightedHilbertSpace(HilbertSpace):
651
662
  x = self.underlying_space.from_dual(xp)
652
663
  return self._inverse_mass_operator(x)
653
664
 
665
+ def __eq__(self, other: object) -> bool:
666
+ """
667
+ Checks for equality with another MassWeightedHilbertSpace.
668
+
669
+ Two mass-weighted spaces are considered equal if they share an equal
670
+ underlying space and their mass operators are also equal.
671
+ """
672
+ if not isinstance(other, MassWeightedHilbertSpace):
673
+ return NotImplemented
674
+
675
+ return (
676
+ self.underlying_space == other.underlying_space
677
+ and (self.mass_operator == other.mass_operator)
678
+ and (self.inverse_mass_operator == other.inverse_mass_operator)
679
+ )
680
+
654
681
 
655
682
  class MassWeightedHilbertModule(MassWeightedHilbertSpace, HilbertModule):
656
683
  """
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.6
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=GIQMeU5yYDtGUv_nR9TjvJ6DJQKIVSe1JEMZy_qyLjg,23363
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
10
  pygeoinf/linear_solvers.py,sha256=P9SEjZ1LZdulr2KQrZojbvdCtAm--hMd4EArSu73L34,12154
11
- pygeoinf/operators.py,sha256=XO2_Y8d8Qo1RqGu3c5AgnAwsPAkial--LH9qdGtVs4M,33235
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.6.dist-info/LICENSE,sha256=GrTQnKJemVi69FSbHprq60KN0OJGsOSR-joQoTq-oD8,1501
18
+ pygeoinf-1.1.6.dist-info/METADATA,sha256=FzoajwK5kOs47gJmHXkDrd9T1VeyPpxO9ERBFo7iJuc,15324
19
+ pygeoinf-1.1.6.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
20
+ pygeoinf-1.1.6.dist-info/RECORD,,