sparse-ir 1.0.0__py3-none-any.whl → 1.1.1__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.
sparse_ir/__init__.py CHANGED
@@ -10,9 +10,9 @@ intermediate representation of correlation functions. It provides:
10
10
  - basis functions and singular values are accurate to full precision
11
11
  - routines for sparse sampling
12
12
  """
13
- __copyright__ = "2020-2022 Markus Wallerberger, Hiroshi Shinaoka, and others"
13
+ __copyright__ = "2020-2024 Markus Wallerberger, Hiroshi Shinaoka, and others"
14
14
  __license__ = "MIT"
15
- __version__ = "1.0.0"
15
+ __version__ = "1.1.1"
16
16
 
17
17
  from .kernel import RegularizedBoseKernel, LogisticKernel
18
18
  from .sve import compute as compute_sve, SVEResult
sparse_ir/abstract.py CHANGED
@@ -150,14 +150,26 @@ class AbstractBasis:
150
150
  """Real frequency cutoff or `None` if not present"""
151
151
  raise NotImplementedError()
152
152
 
153
- def default_tau_sampling_points(self):
154
- """Default sampling points on the imaginary time axis"""
153
+ def default_tau_sampling_points(self, *, npoints=None):
154
+ """Default sampling points on the imaginary time axis
155
+
156
+ Arguments:
157
+ npoints (int):
158
+ Minimum number of sampling points to return.
159
+
160
+ .. versionadded: 1.1
161
+ """
155
162
  raise NotImplementedError()
156
163
 
157
- def default_matsubara_sampling_points(self, *, positive_only=False):
164
+ def default_matsubara_sampling_points(self, *, npoints=None,
165
+ positive_only=False):
158
166
  """Default sampling points on the imaginary frequency axis
159
167
 
160
168
  Arguments:
169
+ npoints (int):
170
+ Minimum number of sampling points to return.
171
+
172
+ .. versionadded: 1.1
161
173
  positive_only (bool):
162
174
  Only return non-negative frequencies. This is useful if the
163
175
  object to be fitted is symmetric in Matsubura frequency,
sparse_ir/augment.py CHANGED
@@ -106,13 +106,21 @@ class AugmentedBasis(abstract.AbstractBasis):
106
106
  def wmax(self):
107
107
  return self._basis.wmax
108
108
 
109
- def default_tau_sampling_points(self):
110
- x = basis._default_sampling_points(self._basis.sve_result.u, self.size)
111
- return self.beta/2 * (x + 1)
112
-
113
- def default_matsubara_sampling_points(self, *, positive_only=False):
114
- return basis._default_matsubara_sampling_points(
115
- self._basis._uhat_full, self.size, positive_only=positive_only)
109
+ def default_tau_sampling_points(self, *, npoints=None):
110
+ if npoints is None:
111
+ npoints = self.size
112
+
113
+ # Return the sampling points of the underlying basis, but since we
114
+ # use the size of self, we add two further points. One then has to
115
+ # hope that these give good sampling points.
116
+ return self._basis.default_tau_sampling_points(npoints=npoints)
117
+
118
+ def default_matsubara_sampling_points(self, *, npoints=None,
119
+ positive_only=False):
120
+ if npoints is None:
121
+ npoints = self.size
122
+ return self._basis.default_matsubara_sampling_points(
123
+ npoints=npoints, positive_only=positive_only)
116
124
 
117
125
  @property
118
126
  def is_well_conditioned(self):
sparse_ir/basis.py CHANGED
@@ -169,16 +169,31 @@ class FiniteTempBasis(abstract.AbstractBasis):
169
169
  def sve_result(self):
170
170
  return self._sve_result
171
171
 
172
- def default_tau_sampling_points(self):
173
- x = _default_sampling_points(self._sve_result.u, self.size)
172
+ def default_tau_sampling_points(self, *, npoints=None):
173
+ if npoints is None:
174
+ npoints = self.size
175
+ x = _default_sampling_points(self._sve_result.u, npoints)
174
176
  return self._beta/2 * (x + 1)
175
177
 
176
- def default_matsubara_sampling_points(self, *, positive_only=False):
177
- return _default_matsubara_sampling_points(self._uhat_full, self.size,
178
+ def default_matsubara_sampling_points(self, *, npoints=None,
179
+ positive_only=False):
180
+ if npoints is None:
181
+ npoints = self.size
182
+ return _default_matsubara_sampling_points(self._uhat_full, npoints,
178
183
  positive_only=positive_only)
179
184
 
180
- def default_omega_sampling_points(self):
181
- y = _default_sampling_points(self._sve_result.v, self.size)
185
+ def default_omega_sampling_points(self, *, npoints=None):
186
+ """Return default sampling points in imaginary time.
187
+
188
+ Arguments:
189
+ npoints (int):
190
+ Minimum number of sampling points to return.
191
+
192
+ .. versionadded: 1.1
193
+ """
194
+ if npoints is None:
195
+ npoints = self.size
196
+ y = _default_sampling_points(self._sve_result.v, npoints)
182
197
  return self._wmax * y
183
198
 
184
199
  def rescale(self, new_beta):
sparse_ir/poly.py CHANGED
@@ -208,7 +208,7 @@ class PiecewiseLegendreFT:
208
208
  ``n`` must be odd.
209
209
  """
210
210
  _DEFAULT_GRID = np.hstack([np.arange(2**6),
211
- (2**np.linspace(6, 25, 16*(25-6)+1)).astype(int)])
211
+ (2**np.linspace(6, 35, 16*(35-6)+1)).astype(int)])
212
212
 
213
213
  def __init__(self, poly, freq='even', n_asymp=None, power_model=None):
214
214
  if poly.xmin != -1 or poly.xmax != 1:
sparse_ir/sampling.py CHANGED
@@ -20,13 +20,74 @@ class AbstractSampling:
20
20
  |________________| fit |___________________|
21
21
 
22
22
  """
23
- def evaluate(self, al, axis=None):
24
- """Evaluate the basis coefficients at the sparse sampling points"""
23
+ def evaluate(self, al, axis=None, *, points=None):
24
+ """Evaluate the basis coefficients at sampling points.
25
+
26
+ Arguments:
27
+ al (array):
28
+ Array where the `l`-th item along `axis` corresponds to the
29
+ `l`-th basis coefficient
30
+ axis (integer):
31
+ Axis or dimension of `al` along which to evaluate the function.
32
+ Defaults to the last, i.e., rightmost axis.
33
+ points (vector):
34
+ Points on which the results should be evaluated. Defaults
35
+ to the sampling points for which the sampling objects was
36
+ created.
37
+
38
+ .. versionadded:: 1.1
39
+
40
+ Return:
41
+ Array where the `n`-th item along `axis` corresponds to the
42
+ value on the `n`-th sampling point (or value on `point[n]`, if
43
+ given.)
44
+
45
+ Note:
46
+ If `points` is given, a new sampling is created at each invocation,
47
+ which can result in a performance hit. Consider caching sampling
48
+ objects or simply using the `.u()` and `.uhat()` methods of the
49
+ underlying basis.
50
+ """
51
+ if points is not None:
52
+ return self._for_sampling_points(points).evaluate(al, axis)
53
+
25
54
  return self.matrix.matmul(al, axis)
26
55
 
27
- def fit(self, ax, axis=None):
28
- """Fit basis coefficients from the sparse sampling points"""
29
- return self.matrix.lstsq(ax, axis)
56
+ def fit(self, ax, axis=None, *, points=None):
57
+ """Fit the basis coefficients from the sampling points.
58
+
59
+ Arguments:
60
+ ax (array):
61
+ Array where the `n`-th item along `axis` corresponds to the
62
+ value on the `n`-th sampling point (or value on `point[n]`, if
63
+ given.)
64
+ axis (integer):
65
+ Axis or dimension of `ax` along which to fit the function.
66
+ Defaults to the last, i.e., rightmost axis.
67
+ points (vector):
68
+ Points on which the `ax` is given. Defaults to the sampling
69
+ points for which the sampling objects was created.
70
+
71
+ .. versionadded:: 1.1
72
+
73
+ Return:
74
+ Array where the `l`-th item along `axis` corresponds to the
75
+ `l`-th basis coefficient
76
+
77
+ Note:
78
+ If `points` is given, a new sampling is created at each invocation,
79
+ which can result in a performance hit. Consider caching sampling
80
+ objects.
81
+ """
82
+ if points is not None:
83
+ return self._for_sampling_points(points).fit(ax, axis)
84
+
85
+ matrix = self.matrix
86
+ if self.basis.is_well_conditioned and not (matrix.cond <= 1e8):
87
+ warn(f"Sampling matrix is poorly conditioned "
88
+ f"(kappa = {matrix.cond:.2g})", ConditioningWarning)
89
+
90
+ return matrix.lstsq(ax, axis)
30
91
 
31
92
  @property
32
93
  def cond(self):
@@ -48,6 +109,9 @@ class AbstractSampling:
48
109
  """Basis instance"""
49
110
  raise NotImplementedError()
50
111
 
112
+ def _for_sampling_points(self, x):
113
+ raise RuntimeError("Changing sampling points is not possible")
114
+
51
115
 
52
116
  class TauSampling(AbstractSampling):
53
117
  """Sparse sampling in imaginary time.
@@ -68,10 +132,6 @@ class TauSampling(AbstractSampling):
68
132
  self._sampling_points = sampling_points
69
133
  self._matrix = DecomposedMatrix(matrix)
70
134
 
71
- if basis.is_well_conditioned and self._matrix.cond > 1e8:
72
- warn(f"Sampling matrix is poorly conditioned "
73
- f"(kappa = {self._matrix.cond:.2g})", ConditioningWarning)
74
-
75
135
  @property
76
136
  def basis(self): return self._basis
77
137
 
@@ -86,6 +146,10 @@ class TauSampling(AbstractSampling):
86
146
  """Sampling points in (reduced) imaginary time"""
87
147
  return self._sampling_points
88
148
 
149
+ def _for_sampling_points(self, x):
150
+ x = np.asarray(x)
151
+ return TauSampling(self._basis, x)
152
+
89
153
 
90
154
  class MatsubaraSampling(AbstractSampling):
91
155
  """Sparse sampling in Matsubara frequencies.
@@ -125,10 +189,6 @@ class MatsubaraSampling(AbstractSampling):
125
189
  else:
126
190
  self._matrix = DecomposedMatrix(matrix)
127
191
 
128
- if basis.is_well_conditioned and self._matrix.cond > 1e8:
129
- warn(f"Sampling matrix is poorly conditioned "
130
- f"(kappa = {self._matrix.cond:.2g})", ConditioningWarning)
131
-
132
192
  @property
133
193
  def basis(self): return self._basis
134
194
 
@@ -148,6 +208,11 @@ class MatsubaraSampling(AbstractSampling):
148
208
  """Sampling points as (reduced) Matsubara frequencies"""
149
209
  return self._sampling_points
150
210
 
211
+ def _for_sampling_points(self, x):
212
+ x = np.asarray(x)
213
+ return MatsubaraSampling(self._basis, x,
214
+ positive_only=self._positive_only)
215
+
151
216
 
152
217
  class DecomposedMatrix:
153
218
  """Matrix in SVD decomposed form for fast and accurate fitting.
@@ -314,6 +379,13 @@ class SplitDecomposedMatrix:
314
379
 
315
380
 
316
381
  class ConditioningWarning(RuntimeWarning):
382
+ """Warns about a poorly conditioned problem.
383
+
384
+ This warning is issued if the library detects a poorly conditioned fitting
385
+ problem. This essentially means there is a high degree of ambiguity in how
386
+ to choose the solution. One must therefore expect to lose significant
387
+ precision in the parameter values.
388
+ """
317
389
  pass
318
390
 
319
391
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sparse-ir
3
- Version: 1.0.0
3
+ Version: 1.1.1
4
4
  Summary: intermediate representation (IR) basis for electronic propagator
5
5
  Home-page: https://github.com/SpM-lab/sparse-ir
6
6
  Author: ['Markus Wallerberger', 'Hiroshi Shinaoka', 'Kazuyoshi Yoshimi', 'Junya Otsuki', 'Chikano Naoya']
@@ -16,6 +16,7 @@ Classifier: License :: OSI Approved :: MIT License
16
16
  Classifier: Programming Language :: Python :: 3
17
17
  Requires-Python: >=3
18
18
  Description-Content-Type: text/x-rst
19
+ License-File: LICENSE.txt
19
20
  Requires-Dist: numpy
20
21
  Requires-Dist: scipy
21
22
  Requires-Dist: setuptools
@@ -143,7 +144,7 @@ useful in your research, please consider citing the following papers:
143
144
 
144
145
  - Hiroshi Shinaoka et al., `Phys. Rev. B 96, 035147`_ (2017)
145
146
  - Jia Li et al., `Phys. Rev. B 101, 035144`_ (2020)
146
- - Markus Wallerberger et al., `arXiv 2206.11762`_ (2022)
147
+ - Markus Wallerberger et al., `SoftwareX 21, 101266`_ (2023)
147
148
 
148
149
  If you are discussing sparse sampling in your research specifically, please
149
150
  also consider citing an independently discovered, closely related approach, the
@@ -152,7 +153,7 @@ MINIMAX isometry method (Merzuk Kaltak and Georg Kresse,
152
153
 
153
154
  .. _Phys. Rev. B 96, 035147: https://doi.org/10.1103/PhysRevB.96.035147
154
155
  .. _Phys. Rev. B 101, 035144: https://doi.org/10.1103/PhysRevB.101.035144
155
- .. _arXiv 2206.11762: https://doi.org/10.48550/arXiv.2206.11762
156
+ .. _SoftwareX 21, 101266: https://doi.org/10.1016/j.softx.2022.101266
156
157
  .. _Phys. Rev. B 101, 205145: https://doi.org/10.1103/PhysRevB.101.205145
157
158
 
158
159
 
@@ -0,0 +1,20 @@
1
+ sparse_ir/__init__.py,sha256=dDgJtNgKRy0D9q6rONu50lowMCnrdmvB4L9e-8eG5pc,816
2
+ sparse_ir/_gauss.py,sha256=9Ou38SfucUjY83o8Tz62s-gXfWDC8QEHBjiUzcbWaY4,9621
3
+ sparse_ir/_roots.py,sha256=ARpyYhhI5gR1AT1zDgezVgCxnHEaJwGF38jEv6ebarA,4351
4
+ sparse_ir/_util.py,sha256=93s7tGcXxz3mwHsBQmAh-6EQ26xLbUeFHVtlnzQxRps,3004
5
+ sparse_ir/abstract.py,sha256=I7RMcHwgPrtn_XBZ4x_XPxaqp32OLFtXQ5bC2mKp7ic,6604
6
+ sparse_ir/adapter.py,sha256=ptiHkTBwZ8aNbtFMnr9k2Rt_v5zwrDyPJ1yx-kiDvew,8351
7
+ sparse_ir/augment.py,sha256=vRPMS0Roa2zqCqZVyFFo-g4lfr2ZGOIhfGGbt42Kj98,9976
8
+ sparse_ir/basis.py,sha256=3mW2XKuLxzHomPCbm3MgxvJhrP3HdP-QkGOgI8W7E2o,13316
9
+ sparse_ir/basis_set.py,sha256=zLD51j9X3iuXfX2nzmn5yRRn7S_GOOyCRFqb05OMDXI,2869
10
+ sparse_ir/dlr.py,sha256=X6orDjvsOAsFrZsCh8vfedu0_SmTvIpSQmGabfI9pi8,5361
11
+ sparse_ir/kernel.py,sha256=2HO77HTOK2WJKizDgr1nmmyhd1mGYT2WvKrFwLiMhjM,18487
12
+ sparse_ir/poly.py,sha256=moPMTxJvd2_g43vcyjHSsyBjcQ1lnuPyIjfce6j_AgI,18359
13
+ sparse_ir/sampling.py,sha256=BoHOHcLAvQjYR8KwK8Ee0LgZz3q3OgMBuLPgG494VEM,13879
14
+ sparse_ir/svd.py,sha256=iQwpBCFSPJeKqhAIlufzz9Ybpm1dq382Km3TU-UvNuc,3375
15
+ sparse_ir/sve.py,sha256=pVUKg_cLphx-lRCfrDJXrpkow97vjIgvvSrxA7lhzzg,15179
16
+ sparse_ir-1.1.1.dist-info/LICENSE.txt,sha256=3tGlA0QNYsfjETaQqJO0Ixne5PQ16PNVJiDcGsgHER0,1079
17
+ sparse_ir-1.1.1.dist-info/METADATA,sha256=85T_HOwLPWOF-ScnCIdhyfZBqRV14Iy7SJEc1G9UcBQ,6458
18
+ sparse_ir-1.1.1.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
19
+ sparse_ir-1.1.1.dist-info/top_level.txt,sha256=UsscWAzJg7fKo9qmIwW8jnG7CAfhFzWYBOTXVySzuA0,10
20
+ sparse_ir-1.1.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.34.2)
2
+ Generator: bdist_wheel (0.37.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,20 +0,0 @@
1
- sparse_ir/__init__.py,sha256=OkI2RZqxaEwPtwl-4dlZ6q6wTjreHU1C5p9BqNya-ro,816
2
- sparse_ir/_gauss.py,sha256=9Ou38SfucUjY83o8Tz62s-gXfWDC8QEHBjiUzcbWaY4,9621
3
- sparse_ir/_roots.py,sha256=ARpyYhhI5gR1AT1zDgezVgCxnHEaJwGF38jEv6ebarA,4351
4
- sparse_ir/_util.py,sha256=93s7tGcXxz3mwHsBQmAh-6EQ26xLbUeFHVtlnzQxRps,3004
5
- sparse_ir/abstract.py,sha256=bifLMUuDQzWjZZtB2s7-yBTZ9dhbkkox2lWh1fbzaas,6250
6
- sparse_ir/adapter.py,sha256=ptiHkTBwZ8aNbtFMnr9k2Rt_v5zwrDyPJ1yx-kiDvew,8351
7
- sparse_ir/augment.py,sha256=1Gn57-_13968fsgC-I5oE_nGiP4bWvjEbGGsNdM6jvM,9624
8
- sparse_ir/basis.py,sha256=2PSRgJQyPA_d3cUJhNGvklc6cQLe__yMLzDsuj2JgwQ,12833
9
- sparse_ir/basis_set.py,sha256=zLD51j9X3iuXfX2nzmn5yRRn7S_GOOyCRFqb05OMDXI,2869
10
- sparse_ir/dlr.py,sha256=X6orDjvsOAsFrZsCh8vfedu0_SmTvIpSQmGabfI9pi8,5361
11
- sparse_ir/kernel.py,sha256=2HO77HTOK2WJKizDgr1nmmyhd1mGYT2WvKrFwLiMhjM,18487
12
- sparse_ir/poly.py,sha256=XbNjgFaofE9zSvPPPYmsDVLLea2k8CSEopfxx-e48ko,18359
13
- sparse_ir/sampling.py,sha256=nrGKNJ11edfTvreq6ta99aZTTYCqxwGtEShQJZagc8g,11130
14
- sparse_ir/svd.py,sha256=iQwpBCFSPJeKqhAIlufzz9Ybpm1dq382Km3TU-UvNuc,3375
15
- sparse_ir/sve.py,sha256=pVUKg_cLphx-lRCfrDJXrpkow97vjIgvvSrxA7lhzzg,15179
16
- sparse_ir-1.0.0.dist-info/LICENSE.txt,sha256=3tGlA0QNYsfjETaQqJO0Ixne5PQ16PNVJiDcGsgHER0,1079
17
- sparse_ir-1.0.0.dist-info/METADATA,sha256=VRsSzL4kbv-MolfCp0drykoDMzYYnt59tSh9sHHRd2U,6422
18
- sparse_ir-1.0.0.dist-info/WHEEL,sha256=g4nMs7d-Xl9-xC9XovUrsDHGXt-FT0E17Yqo92DEfvY,92
19
- sparse_ir-1.0.0.dist-info/top_level.txt,sha256=UsscWAzJg7fKo9qmIwW8jnG7CAfhFzWYBOTXVySzuA0,10
20
- sparse_ir-1.0.0.dist-info/RECORD,,