sxs 2024.0.40__py3-none-any.whl → 2024.0.42__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.
sxs/__version__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2024.0.40"
1
+ __version__ = "2024.0.42"
sxs/metadata/metadata.py CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import re
4
4
  import collections
5
+ import numpy as np
5
6
 
6
7
 
7
8
  _valid_identifier_pattern = re.compile(r'\W|^(?=\d)')
@@ -29,8 +30,11 @@ def _backwards_compatibility(metadata):
29
30
  # it's probably a good idea to duplicate whatever is included here
30
31
  # in that function, just to make sure nothing slips through the
31
32
  # cracks.
32
- if "number_of_orbits" not in metadata and "number_of_orbits_from_start" in metadata:
33
- metadata["number_of_orbits"] = metadata["number_of_orbits_from_start"]
33
+ if "number_of_orbits" not in metadata:
34
+ if "number_of_orbits_from_start" in metadata:
35
+ metadata["number_of_orbits"] = metadata["number_of_orbits_from_start"]
36
+ else:
37
+ metadata["number_of_orbits"] = np.nan
34
38
  return metadata
35
39
 
36
40
 
sxs/metadata/metric.py CHANGED
@@ -14,6 +14,9 @@ class MetadataMetric:
14
14
  metadata, rather than as a strict metric for clustering or
15
15
  classification.
16
16
 
17
+ Note that calling an object of this class with two metadata
18
+ collections will return the *squared* distance between them.
19
+
17
20
  Parameters
18
21
  ----------
19
22
  parameters : list of str, optional
@@ -60,13 +63,14 @@ class MetadataMetric:
60
63
  def __init__(
61
64
  self,
62
65
  parameters=[
63
- "reference_mass_ratio",
66
+ "reference_mass1",
67
+ "reference_mass2",
64
68
  "reference_dimensionless_spin1",
65
69
  "reference_dimensionless_spin2",
66
70
  "reference_eccentricity",
67
71
  "reference_mean_anomaly",
68
72
  ],
69
- metric=np.diag([1, 1, 1, 1, 1, 1, 1, 1, 1/np.pi**2]),
73
+ metric=np.diag([1, 1, 1, 1, 1, 1, 1, 1, 1, 1/np.pi**2]),
70
74
  allow_different_object_types=False,
71
75
  eccentricity_threshold1=1e-2,
72
76
  eccentricity_threshold2=1e-3,
@@ -113,7 +117,7 @@ class MetadataMetric:
113
117
  values1[i], values2[i] = np.unwrap([floater(values1[i]), floater(values2[i])])
114
118
 
115
119
  if "reference_eccentricity" in self.parameters:
116
- # Either way, we first make sure that the corresponding entries are floats.
120
+ # Either way, we first try to make sure that the corresponding entries are floats.
117
121
  i = self.parameters.index("reference_eccentricity")
118
122
  values1[i] = metadata1.get("reference_eccentricity_bound", floaterbound(values1[i]))
119
123
  values2[i] = metadata2.get("reference_eccentricity_bound", floaterbound(values2[i]))
sxs/simulations/local.py CHANGED
@@ -153,7 +153,14 @@ def local_simulations(annex_dir, compute_md5=False, show_progress=False):
153
153
  files = files_to_upload(dirpath, annex_dir)
154
154
 
155
155
  metadata["mtime"] = datetime.fromtimestamp(
156
- max(file.resolve().stat().st_mtime for file in files),
156
+ max(
157
+ (
158
+ file.resolve().stat().st_mtime
159
+ for file in files
160
+ if file.exists()
161
+ ),
162
+ default=0.0,
163
+ ),
157
164
  tz=timezone.utc,
158
165
  ).isoformat()
159
166
 
@@ -164,6 +171,7 @@ def local_simulations(annex_dir, compute_md5=False, show_progress=False):
164
171
  "checksum": md5checksum(file) if compute_md5 else "",
165
172
  }
166
173
  for file in files
174
+ if file.exists()
167
175
  }
168
176
  except KeyboardInterrupt:
169
177
  raise
@@ -59,13 +59,14 @@ def Simulation(location, *args, **kwargs):
59
59
  If `True`, completely bypass checking for deprecation or
60
60
  supersession. No warnings or errors will be issued. Default
61
61
  is `False`.
62
- auto_supersede : bool, optional
63
- If `True`, automatically load the superseding simulation, if
64
- there is only one. If there are multiple superseding
65
- simulations, an error will be raised, and you must explicitly
66
- choose one. If there is only one, a warning will still be
67
- issued, but the superseding simulation will be loaded. Note
68
- that this can also be set in the configuration file with
62
+ auto_supersede : bool or float, optional
63
+ If present, automatically load the closest undeprecated
64
+ simulation. If this is a float and the distance to the
65
+ closest undeprecated simulation (see the following argument)
66
+ is larger, a ValueError will be raised. Otherwise, a warning
67
+ will be issued with the ID of the new simulation and the
68
+ distance. Note that this can also be set in the configuration
69
+ file by calling, e.g.,
69
70
  `sxs.write_config(auto_supersede=True)`.
70
71
  metadata_metric : MetadataMetric, optional
71
72
  Metric to use for comparing simulations when automatically
@@ -147,8 +148,9 @@ def Simulation(location, *args, **kwargs):
147
148
  f"Simulation '{location}' is deprecated. You could\n"
148
149
  + " 1. pass `ignore_deprecation=True` to load the latest available version,\n"
149
150
  + " 2. manually choose a different simulation from the catalog,\n"
150
- + " 3. pass `auto_supersede=True` to load the closest match in the catalog, or\n"
151
- + f" 4. include the version number, as in '{sxs_id_stem}v2.0', to load a specific version.\n"
151
+ + " 3. pass `auto_supersede=0.01` to load a match closer than 0.01 in the catalog if one exists,\n"
152
+ + " 4. pass `auto_supersede=True` to load the closest match in the catalog, or\n"
153
+ + f" 5. include the version number, as in '{sxs_id_stem}v2.0', to load a specific version.\n"
152
154
  )
153
155
  else:
154
156
  message = ("\n"
@@ -170,11 +172,25 @@ def Simulation(location, *args, **kwargs):
170
172
  original_kwargs["ignore_deprecation"] = True
171
173
  original = Simulation(location, *args, **original_kwargs)
172
174
  metadata_metric = kwargs.pop("metadata_metric", MetadataMetric())
173
- superseding = original.closest_simulation(
175
+ superseding, distance = original.closest_simulation(
174
176
  dataframe=simulations.dataframe,
175
177
  metadata_metric=metadata_metric
176
178
  )
177
- message = f"\nSimulation '{sxs_id}' is being automatically superseded by '{superseding}'."
179
+ if isinstance(auto_supersede, str):
180
+ try:
181
+ auto_supersede = float(auto_supersede)
182
+ except:
183
+ pass
184
+ if isinstance(auto_supersede, float) and distance > auto_supersede:
185
+ raise ValueError(
186
+ f"Simulation '{sxs_id}' is deprecated, but the closest undeprecated\n"
187
+ f"simulation is more distant than allowed by `auto_supersede` argument:\n"
188
+ f"{distance:.3g} > {auto_supersede:.3g}.\n"
189
+ )
190
+ message = (
191
+ f"\nSimulation '{sxs_id}' is being automatically superseded by '{superseding}'."
192
+ f"\nThe distance between them in the given metadata metric is {distance:.3g}."
193
+ )
178
194
  warn(message)
179
195
  new_location = f"{superseding}{input_version}"
180
196
  if input_lev_number:
@@ -342,6 +358,7 @@ class SimulationBase:
342
358
  metadata
343
359
 
344
360
  """
361
+ from numpy import sqrt
345
362
  from ..metadata.metric import MetadataMetric
346
363
  from .. import load
347
364
  if dataframe is None:
@@ -350,11 +367,11 @@ class SimulationBase:
350
367
  if drop_deprecated:
351
368
  dataframe = dataframe[~dataframe.deprecated]
352
369
  return dataframe.apply(
353
- lambda m: metadata_metric(self.metadata, m),
370
+ lambda m: sqrt(metadata_metric(self.metadata, m)),
354
371
  axis=1
355
372
  )
356
373
 
357
- def closest_simulation(self, dataframe=None, metadata_metric=None):
374
+ def closest_simulation(self, dataframe=None, metadata_metric=None, warning_threshold=1e-2):
358
375
  """Return the closest undeprecated simulation to this one
359
376
 
360
377
  Note that any simulation in `dataframe` with zero distance
@@ -370,12 +387,17 @@ class SimulationBase:
370
387
  metadata_metric : MetadataMetric, optional
371
388
  Metric to use for comparing simulations. If not provided,
372
389
  the default metric will be used.
390
+ warning_threshold : float, optional
391
+ Threshold distance above which a warning will be issued
392
+ that the closest simulation is fairly distant. Default is
393
+ 1e-3.
373
394
 
374
395
  Returns
375
396
  -------
376
397
  closest_index : str
377
398
  Index of the closest undeprecated simulation in the
378
399
  `dataframe`.
400
+ distance : float
379
401
 
380
402
  """
381
403
  d = self.distances(
@@ -384,7 +406,9 @@ class SimulationBase:
384
406
  drop_deprecated=True
385
407
  )
386
408
  d = d[d > 0].sort_values()
387
- return d.index[0]
409
+ if d.iloc[0] > warning_threshold:
410
+ warn(f"\nClosest simulation ({d.index[0]}) is fairly distant: {d.iloc[0]:.3g}")
411
+ return d.index[0], d.iloc[0]
388
412
 
389
413
  @property
390
414
  def dataframe(self):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sxs
3
- Version: 2024.0.40
3
+ Version: 2024.0.42
4
4
  Summary: Interface to data produced by the Simulating eXtreme Spacetimes collaboration
5
5
  Project-URL: Homepage, https://github.com/sxs-collaboration/sxs
6
6
  Project-URL: Documentation, https://sxs.readthedocs.io/
@@ -1,5 +1,5 @@
1
1
  sxs/__init__.py,sha256=hbydsXWR88sFiKExPJ1NHWGEvWRbbJBjSc1irSMYKgY,2623
2
- sxs/__version__.py,sha256=EGvErJKyfOAcfUYNKwYjEPAOmSCXucQ-3166Z0QMqHw,26
2
+ sxs/__version__.py,sha256=ottZ66pDpZJXsL9jK_3ggKCu87Pdr1LjtjI0B6EzUkI,26
3
3
  sxs/handlers.py,sha256=Nc1_aDKm_wDHg2cITI_ljbqU4VRWpwQ7fdgy3c1XcE8,17531
4
4
  sxs/juliapkg.json,sha256=-baaa3Za_KBmmiGjlh2YYLWmvUvZl6GaKKXwNI4S7qU,178
5
5
  sxs/time_series.py,sha256=OKaLg8tFyrtKcef7900ri-a0C6A8wKxA68KovZXvH6I,41081
@@ -16,11 +16,11 @@ sxs/horizons/xor_multishuffle_bzip2.py,sha256=y4AKuxmLuj8K1pkdhIoSzENGyMu4uhpiPr
16
16
  sxs/julia/GWFrames.py,sha256=47H9Ugff7ldGBujiUTcADT3b4MSxUtqmajvSApI91WA,2892
17
17
  sxs/julia/__init__.py,sha256=uSLP_xfU-GZG7IO5vs0TEkCR4LH8aBYMF-852wDY3kI,3490
18
18
  sxs/metadata/__init__.py,sha256=jz0A3sBYQoNVZ5sdHv6LgI6y4kP2051-esCR62xt6bM,184
19
- sxs/metadata/metadata.py,sha256=xB4Cz2V_7qwabK_x0L5rPuWS1XOOWXQKx4EPXtlbZLo,28515
20
- sxs/metadata/metric.py,sha256=zWyM23SQUMXwpDvQNnp2USJrwxiC3SoobFXm0h_sMMs,6615
19
+ sxs/metadata/metadata.py,sha256=vqzNufg46BrbFAuvDF55JvrQc0ZIBxSG4eH2awv5PDs,28610
20
+ sxs/metadata/metric.py,sha256=W_PMNmsJ2qBjIeAll4TgUz79-SZkiBTswTfK4gKWrPU,6785
21
21
  sxs/simulations/__init__.py,sha256=GrZym0PHTULDg_hyFmISNzDfqVLz_hQo-djbgecZs54,134
22
- sxs/simulations/local.py,sha256=nh1coOPunVD0hB6pp2WTm31rFdakNEoP5niMbV4s04o,7992
23
- sxs/simulations/simulation.py,sha256=HRm6vaVGjRziQZ1VPOG1ESxaITgLAJCp4lhGZ4fpez8,36232
22
+ sxs/simulations/local.py,sha256=kyFvlw9CywlyBy0H2GiSgOp4M7Uq31Db5LIdd2do43M,8242
23
+ sxs/simulations/simulation.py,sha256=lVA2aSRy4-V1-1bFE74zIN8Tpvf7QDtn9n7xmR7oqcU,37579
24
24
  sxs/simulations/simulations.py,sha256=xP1ljseDSkfs6_u25-DnSNlFQtQexiP25Kwtm7nWdsE,23910
25
25
  sxs/utilities/__init__.py,sha256=WSStlqljfgQheMxHGfuofSc5LdmASGvO3FNO3f_zaT0,4806
26
26
  sxs/utilities/bitwise.py,sha256=G9ZNYgwDQRhq5wbDf-p2HcUqkEP_IRDiQoXW4KyU17k,13205
@@ -82,7 +82,7 @@ sxs/zenodo/api/__init__.py,sha256=EM_eh4Q8R5E0vIfMhyIR1IYFfOBu6vA0UTasgX9gHys,21
82
82
  sxs/zenodo/api/deposit.py,sha256=J4RGvGjh0cEOrN4bBZWEDcPAhNscqB2fzLlvRZ5HTHM,36948
83
83
  sxs/zenodo/api/login.py,sha256=Yz0ytgi81_5BpDzhrS0WPMXlvU2qUaCK8yn8zxfEbko,18007
84
84
  sxs/zenodo/api/records.py,sha256=nKkhoHZ95CTztHF9Zzaug5p7IiUCJG4Em1i-l-WqH6U,3689
85
- sxs-2024.0.40.dist-info/METADATA,sha256=574RUXvZj-1zsevIFQ2to3JPHtKL_Wf6vHiflSeYKN0,9253
86
- sxs-2024.0.40.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
87
- sxs-2024.0.40.dist-info/licenses/LICENSE,sha256=ptVOd5m7LDM5ZF0x32cxb8c2Nd5NDmAhy6DX7xt_7VA,1080
88
- sxs-2024.0.40.dist-info/RECORD,,
85
+ sxs-2024.0.42.dist-info/METADATA,sha256=46jHQPJbcRe8xSeA1qul7zXbf0_11yfOJO5l1v0Dd2s,9253
86
+ sxs-2024.0.42.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
87
+ sxs-2024.0.42.dist-info/licenses/LICENSE,sha256=ptVOd5m7LDM5ZF0x32cxb8c2Nd5NDmAhy6DX7xt_7VA,1080
88
+ sxs-2024.0.42.dist-info/RECORD,,