sxs 2024.0.28__py3-none-any.whl → 2024.0.30__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.28"
1
+ __version__ = "2024.0.30"
sxs/metadata/metadata.py CHANGED
@@ -23,6 +23,17 @@ def _valid_identifier_to_metadata_key(key):
23
23
  return _metadata_key_map.get(key, key.replace('_', '-'))
24
24
 
25
25
 
26
+ def _backwards_compatibility(metadata):
27
+ """Deal with the fact that keys have been removed/renamed"""
28
+ # See also `sxs.simulations.simulations.Simulations.dataframe`;
29
+ # it's probably a good idea to duplicate whatever is included here
30
+ # in that function, just to make sure nothing slips through the
31
+ # 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"]
34
+ return metadata
35
+
36
+
26
37
  class Metadata(collections.OrderedDict):
27
38
  """Interface to metadata
28
39
 
@@ -72,25 +83,27 @@ class Metadata(collections.OrderedDict):
72
83
  txt_path = path.with_suffix(".txt")
73
84
 
74
85
  if path.suffix == ".json":
75
- return cls.from_json_file(json_path)
86
+ metadata = cls.from_json_file(json_path)
76
87
  elif path.suffix == ".txt":
77
- return cls.from_txt_file(txt_path, ignore_invalid_lines=ignore_invalid_lines, cache_json=cache_json)
88
+ metadata = cls.from_txt_file(txt_path, ignore_invalid_lines=ignore_invalid_lines, cache_json=cache_json)
78
89
  else:
79
90
  json_exists = json_path.exists()
80
91
  txt_exists = txt_path.exists()
81
92
  if json_exists and not txt_exists:
82
- return cls.from_json_file(json_path)
93
+ metadata = cls.from_json_file(json_path)
83
94
  elif txt_exists and not json_exists:
84
- return cls.from_txt_file(txt_path, ignore_invalid_lines=ignore_invalid_lines, cache_json=cache_json)
95
+ metadata = cls.from_txt_file(txt_path, ignore_invalid_lines=ignore_invalid_lines, cache_json=cache_json)
85
96
  elif json_exists and txt_exists:
86
97
  json_time = json_path.stat().st_mtime
87
98
  txt_time = txt_path.stat().st_mtime
88
99
  if txt_time > json_time:
89
- return cls.from_txt_file(txt_path, ignore_invalid_lines=ignore_invalid_lines, cache_json=cache_json)
100
+ metadata = cls.from_txt_file(txt_path, ignore_invalid_lines=ignore_invalid_lines, cache_json=cache_json)
90
101
  else:
91
- return cls.from_json_file(json_path)
102
+ metadata = cls.from_json_file(json_path)
92
103
  else:
93
104
  raise ValueError(f"Could not find file named '{json_path}' or '{txt_path}'")
105
+
106
+ return _backwards_compatibility(metadata)
94
107
 
95
108
  load = from_file
96
109
 
@@ -113,7 +126,7 @@ class Metadata(collections.OrderedDict):
113
126
  """
114
127
  import json
115
128
  # noinspection PyTypeChecker
116
- return json.load(json_data, object_pairs_hook=cls)
129
+ return _backwards_compatibility(json.load(json_data, object_pairs_hook=cls))
117
130
 
118
131
  @classmethod
119
132
  def from_json_file(cls, json_file):
@@ -136,7 +149,7 @@ class Metadata(collections.OrderedDict):
136
149
  # noinspection PyTypeChecker
137
150
  metadata = json.load(metadata_file, object_pairs_hook=cls)
138
151
  metadata["metadata_path"] = str(json_file)
139
- return metadata
152
+ return _backwards_compatibility(metadata)
140
153
 
141
154
  @classmethod
142
155
  def from_txt_file(cls, txt_file, ignore_invalid_lines=False, cache_json=True):
@@ -259,7 +272,7 @@ class Metadata(collections.OrderedDict):
259
272
  metadata.to_json_file(path.with_suffix(".json"))
260
273
 
261
274
  metadata["metadata_path"] = str(txt_file)
262
- return metadata
275
+ return _backwards_compatibility(metadata)
263
276
 
264
277
  def to_json(self, indent=4, separators=(",", ": ")):
265
278
  """Export to JSON string"""
@@ -133,7 +133,7 @@ def Simulation(location, *args, **kwargs):
133
133
  url = f"{doi_url}{sxs_id}"
134
134
 
135
135
  # Deal with "superseded_by" field, or "deprecated" keyword in the metadata
136
- deprecated = ("deprecated" in metadata.get("keywords", []) or metadata.get("superseded_by", False))
136
+ deprecated = ("deprecated" in metadata.get("keywords", []) )#or metadata.get("superseded_by", False))
137
137
  if not kwargs.get("ignore_deprecation", False):
138
138
  auto_supersede = kwargs.get("auto_supersede", read_config("auto_supersede", False))
139
139
  if (
@@ -160,6 +160,12 @@ def Simulation(location, *args, **kwargs):
160
160
  + "specify a version to load this waveform anyway."
161
161
  )
162
162
  elif auto_supersede and isinstance(superseded_by, str):
163
+ # raise NotImplementedError(
164
+ # f"\nSimulation '{sxs_id}' cannot be automatically superseded.\n"
165
+ # + "The auto_supersede option is temporarily disabled. The superseding\n"
166
+ # + "simulations have been removed from the metadata, and the new function\n"
167
+ # + "to load them has not yet been implemented. Please specify a version.\n"
168
+ # )
163
169
  message = f"\nSimulation '{sxs_id}' is being automatically superseded by '{superseded_by}'."
164
170
  warn(message)
165
171
  new_location = f"{superseded_by}{input_version}"
@@ -404,6 +404,18 @@ class Simulations(collections.OrderedDict):
404
404
 
405
405
  simulations = pd.DataFrame.from_dict(self, orient="index")
406
406
 
407
+ # See also below for "number_of_orbits" field.
408
+ # See also `sxs.metadata.metadata._backwards_compatibility`;
409
+ # it's probably a good idea to duplicate whatever is included
410
+ # here in that function, just to make sure nothing slips
411
+ # through the cracks.
412
+ for col in [
413
+ "number_of_orbits", "number_of_orbits_from_start",
414
+ "number_of_orbits_from_reference_time"
415
+ ]:
416
+ if col not in simulations.columns:
417
+ simulations[col] = np.nan
418
+
407
419
  def floater(x):
408
420
  try:
409
421
  f = float(x)
@@ -509,7 +521,9 @@ class Simulations(collections.OrderedDict):
509
521
  # simulations["end_of_trajectory_time"].map(floater),
510
522
  # simulations["merger_time"].map(floater),
511
523
  simulations["number_of_orbits"].map(floater),
512
- simulations["superseded_by"],
524
+ simulations["number_of_orbits_from_start"].map(floater),
525
+ simulations["number_of_orbits_from_reference_time"].map(floater),
526
+ # simulations["superseded_by"],
513
527
  simulations["DOI_versions"],
514
528
  simulations["keywords"],
515
529
  simulations["date_link_earliest"].map(datetime_from_string),
@@ -519,10 +533,18 @@ class Simulations(collections.OrderedDict):
519
533
  ), axis=1))
520
534
 
521
535
  sims_df.insert(0, "deprecated", (
522
- ~sims_df.superseded_by.isna()
523
- | sims_df["keywords"].map(lambda ks: "deprecated" in ks)
536
+ # ~sims_df.superseded_by.isna() |
537
+ sims_df["keywords"].map(lambda ks: "deprecated" in ks)
524
538
  ))
525
539
 
540
+ # See also `sxs.metadata.metadata._backwards_compatibility`;
541
+ # it's probably a good idea to duplicate whatever is included
542
+ # here in that function, just to make sure nothing slips
543
+ # through the cracks.
544
+ sims_df["number_of_orbits"] = sims_df["number_of_orbits"].fillna(
545
+ sims_df["number_of_orbits_from_start"]
546
+ )
547
+
526
548
  # We have ignored the following fields present in the
527
549
  # simulations.json file (as of 2024-08-04), listed here with
528
550
  # the number of non-null entries:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sxs
3
- Version: 2024.0.28
3
+ Version: 2024.0.30
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=rDUgberUhElUJ11tdd-wIqTEN89R9jsiJcCrA3lr_Gg,26
2
+ sxs/__version__.py,sha256=fxgBGH8XprJkhrY7eEz-aU7IFQ3A5JmJ9zKlM--2i1E,26
3
3
  sxs/handlers.py,sha256=Nc1_aDKm_wDHg2cITI_ljbqU4VRWpwQ7fdgy3c1XcE8,17531
4
4
  sxs/juliapkg.json,sha256=higH1UDu30K_PN6-o7lAz0j1xjgYEiCCYBAc-Iaw1Iw,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=KCvJ9Cf1WhIZp-z28UzarKcmUAzV2BOv2gqKiorILjo,149
19
- sxs/metadata/metadata.py,sha256=y6X7LcsJKiZFjBPTwRHGtsT2uHf2s0r0OG_EGjD27pE,27663
19
+ sxs/metadata/metadata.py,sha256=EEax1WTKL4G5U__wHefbBX0l4vtIHTcYFnHwziGkVhM,28348
20
20
  sxs/simulations/__init__.py,sha256=GrZym0PHTULDg_hyFmISNzDfqVLz_hQo-djbgecZs54,134
21
21
  sxs/simulations/local.py,sha256=CEu8PzumNB1-JA05M4tYSW_UZVrldKzOB5T_I3pFWls,5789
22
- sxs/simulations/simulation.py,sha256=pSwC82oeoaQTs2TB7uJLl0pScN6b9AgHdmTxf_iRKB4,34161
23
- sxs/simulations/simulations.py,sha256=YttUK3WTU786OrHKMWya8myuMmmjMbazfIVs7A8FPlk,23781
22
+ sxs/simulations/simulation.py,sha256=OqQh6xq-s_JoQI6e2XA5j194L0DT3HGYIW8ZZiurZ2Y,34631
23
+ sxs/simulations/simulations.py,sha256=ATxrcihvblGgRHdR7vIMg5eKghN5Jo6U0CafTro4wYA,24827
24
24
  sxs/utilities/__init__.py,sha256=WSStlqljfgQheMxHGfuofSc5LdmASGvO3FNO3f_zaT0,4806
25
25
  sxs/utilities/bitwise.py,sha256=G9ZNYgwDQRhq5wbDf-p2HcUqkEP_IRDiQoXW4KyU17k,13205
26
26
  sxs/utilities/dicts.py,sha256=CCpm3upG_9SRj9gjawukSUfaJ5asF-XRG2ausEXhYyg,695
@@ -80,7 +80,7 @@ sxs/zenodo/api/__init__.py,sha256=EM_eh4Q8R5E0vIfMhyIR1IYFfOBu6vA0UTasgX9gHys,21
80
80
  sxs/zenodo/api/deposit.py,sha256=J4RGvGjh0cEOrN4bBZWEDcPAhNscqB2fzLlvRZ5HTHM,36948
81
81
  sxs/zenodo/api/login.py,sha256=Yz0ytgi81_5BpDzhrS0WPMXlvU2qUaCK8yn8zxfEbko,18007
82
82
  sxs/zenodo/api/records.py,sha256=nKkhoHZ95CTztHF9Zzaug5p7IiUCJG4Em1i-l-WqH6U,3689
83
- sxs-2024.0.28.dist-info/METADATA,sha256=66Nu2saeF56y1gQdN_LuULWiApf-otPsC86HQCSIPGk,9250
84
- sxs-2024.0.28.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
85
- sxs-2024.0.28.dist-info/licenses/LICENSE,sha256=ptVOd5m7LDM5ZF0x32cxb8c2Nd5NDmAhy6DX7xt_7VA,1080
86
- sxs-2024.0.28.dist-info/RECORD,,
83
+ sxs-2024.0.30.dist-info/METADATA,sha256=EZmCk2Nq9dYEQJHrhHxkGazpNy8G8_xDlfyLCw5pPSE,9250
84
+ sxs-2024.0.30.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
85
+ sxs-2024.0.30.dist-info/licenses/LICENSE,sha256=ptVOd5m7LDM5ZF0x32cxb8c2Nd5NDmAhy6DX7xt_7VA,1080
86
+ sxs-2024.0.30.dist-info/RECORD,,