sxs 2024.0.14__py3-none-any.whl → 2024.0.16__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.14"
1
+ __version__ = "2024.0.16"
sxs/handlers.py CHANGED
@@ -281,13 +281,18 @@ def load(location, download=None, cache=None, progress=None, truepath=None, **kw
281
281
  return Catalog.load(download=download)
282
282
 
283
283
  elif location == "simulations":
284
- return Simulations.load(download=download)
285
-
286
- elif location == "local_simulations":
287
- return Simulations.local(download=download)
284
+ return Simulations.load(
285
+ download=download,
286
+ local=kwargs.get("local", False),
287
+ annex_dir=kwargs.get("annex_dir", None)
288
+ )
288
289
 
289
290
  elif location == "dataframe":
290
- return Simulations.load(download=download).dataframe
291
+ return Simulations.load(
292
+ download=download,
293
+ local=kwargs.get("local", False),
294
+ annex_dir=kwargs.get("annex_dir", None)
295
+ ).dataframe
291
296
 
292
297
  elif sxs_id_version_lev_exact_re.match(location):
293
298
  return Simulation(location, download=download, cache=cache, progress=progress, **kwargs)
@@ -97,14 +97,20 @@ def Simulation(location, *args, **kwargs):
97
97
  """
98
98
  from .. import load, sxs_directory
99
99
 
100
+ # Load the simulation catalog
101
+ simulations = load("simulations")
102
+
100
103
  # Extract the simulation ID, version, and Lev from the location string
101
104
  simulation_id, input_version = sxs_id_and_version(location)
102
105
  if not simulation_id:
103
- raise ValueError(f"Invalid SXS ID in '{simulation_id}'")
106
+ if location in simulations:
107
+ simulation_id = location.split("/Lev")[0]
108
+ input_version = "v0.0"
109
+ else:
110
+ raise ValueError(f"Invalid SXS ID in '{simulation_id}'")
104
111
  input_lev_number = lev_number(location) # Will be `None` if not present
105
112
 
106
- # Load the simulation catalog and check if simulation ID exists in the catalog
107
- simulations = load("simulations")
113
+ # Check if simulation ID exists in the catalog
108
114
  if simulation_id not in simulations:
109
115
  raise ValueError(f"Simulation '{simulation_id}' not found in simulation catalog")
110
116
 
@@ -113,7 +119,7 @@ def Simulation(location, *args, **kwargs):
113
119
  series = simulations.dataframe.loc[simulation_id]
114
120
 
115
121
  # Check if the specified version exists in the simulation catalog
116
- if input_version not in metadata.DOI_versions:
122
+ if input_version != "v0.0" and input_version not in metadata.DOI_versions:
117
123
  raise ValueError(f"Version '{input_version}' not found in simulation catalog for '{simulation_id}'")
118
124
 
119
125
  # Set various pieces of information about the simulation
@@ -205,7 +211,7 @@ def Simulation(location, *args, **kwargs):
205
211
  sim = Simulation_v1(
206
212
  metadata, series, version, sxs_id_stem, sxs_id, url, files, lev_numbers, output_lev_number, location, *args, **kwargs
207
213
  )
208
- elif 2 <= version_number < 3.0:
214
+ elif 2 <= version_number < 3.0 or version == "v0.0":
209
215
  sim = Simulation_v2(
210
216
  metadata, series, version, sxs_id_stem, sxs_id, url, files, lev_numbers, output_lev_number, location, *args, **kwargs
211
217
  )
@@ -174,31 +174,45 @@ class Simulations(collections.OrderedDict):
174
174
  return simulations
175
175
 
176
176
  @classmethod
177
- @functools.lru_cache()
178
- def load(cls, download=None):
177
+ def load(cls, download=None, *, local=False, annex_dir=None):
179
178
  """Load the catalog of SXS simulations
180
179
 
181
- Note that — unlike most SXS data files — the simulations file is updated
182
- frequently. As a result, this function — unlike the loading functions for most
183
- SXS data files — will download the simulations by default each time it is called.
184
- However, also note that this function is itself cached, meaning that the same
185
- dict will be returned on each call in a given python session. If you want to
186
- avoid that behavior, use `Simulations.reload`.
180
+ Note that — unlike most SXS data files — the simulations file
181
+ is updated frequently. As a result, this function — unlike
182
+ the loading functions for most SXS data files — will download
183
+ the simulations by default each time it is called. However,
184
+ also note that this function is itself cached, meaning that
185
+ the same dict will be returned on each call in a given python
186
+ session. If you want to avoid that behavior, use
187
+ `Simulations.reload`.
187
188
 
188
189
  Parameters
189
190
  ----------
190
191
  download : {None, bool}, optional
191
- If False, this function will look for the simulations in the sxs cache and
192
- raise an error if it is not found. If True, this function will download
193
- the simulations and raise an error if the download fails. If None (the
194
- default), it will try to download the file, warn but fall back to the cache
195
- if that fails, and only raise an error if the simulations is not found in the
196
- cache. Note that this ignores the sxs configuration file entirely.
192
+ If False, this function will look for the simulations in
193
+ the sxs cache and raise an error if it is not found. If
194
+ True, this function will download the simulations and
195
+ raise an error if the download fails. If None (the
196
+ default), it will try to download the file, warn but fall
197
+ back to the cache if that fails, and only raise an error
198
+ if the simulations is not found in the cache. Note that
199
+ this ignores the sxs configuration file entirely.
200
+
201
+ Keyword-only Parameters
202
+ -----------------------
203
+ local : {None, bool}, optional
204
+ If True, this function will load local simulations from
205
+ the sxs cache. To prepare the cache, you may wish to call
206
+ `sxs.write_local_simulations`.
207
+ annex_dir : {None, str, Path}, optional
208
+ If provided and `local=True`, this function will load
209
+ local simulations from the given directory. This is
210
+ equivalent to calling `Simulations.local(directory)`.
197
211
 
198
212
  See Also
199
213
  --------
200
- sxs.sxs_directory : Locate cache directory
201
- Simulations.reload : Avoid caching the result of this function
214
+ sxs.sxs_directory : Locate cache directory Simulations.reload
215
+ : Avoid caching the result of this function
202
216
 
203
217
  """
204
218
  from datetime import datetime, timezone
@@ -207,6 +221,13 @@ class Simulations(collections.OrderedDict):
207
221
  from .. import sxs_directory, read_config
208
222
  from ..utilities import download_file
209
223
 
224
+ if hasattr(cls, "_simulations"):
225
+ return cls._simulations
226
+
227
+ if local or annex_dir is not None:
228
+ cls._simulations = cls.local(annex_dir, download=download)
229
+ return cls._simulations
230
+
210
231
  progress = read_config("download_progress", True)
211
232
 
212
233
  remote_timestamp = cls.remote_timestamp(download is not False) # Test for literal `False`
@@ -268,6 +289,8 @@ class Simulations(collections.OrderedDict):
268
289
 
269
290
  sims = cls(simulations)
270
291
  sims.__file__ = str(cache_path)
292
+
293
+ cls._simulations = sims
271
294
  return sims
272
295
 
273
296
  @classmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sxs
3
- Version: 2024.0.14
3
+ Version: 2024.0.16
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,6 +1,6 @@
1
1
  sxs/__init__.py,sha256=hbydsXWR88sFiKExPJ1NHWGEvWRbbJBjSc1irSMYKgY,2623
2
- sxs/__version__.py,sha256=vdCUhZemn99E8FoC13JF2FXz3SWQuB-IUxT4uez_vj8,26
3
- sxs/handlers.py,sha256=B3mCX7sPtnyYpkzuDCUrpHL4pmHDo9I7UjaHAIJ2s5A,16874
2
+ sxs/__version__.py,sha256=Y9aaAFW7eTBLUBcBXdQZd1KNgLbPAplcEe8kdPULxS4,26
3
+ sxs/handlers.py,sha256=7x6LeBR7nYwq83ObL9KS9UsZ1qxd7yvOsjmQarhUHro,17045
4
4
  sxs/juliapkg.json,sha256=higH1UDu30K_PN6-o7lAz0j1xjgYEiCCYBAc-Iaw1Iw,178
5
5
  sxs/time_series.py,sha256=OKaLg8tFyrtKcef7900ri-a0C6A8wKxA68KovZXvH6I,41081
6
6
  sxs/caltechdata/__init__.py,sha256=s-RXyBiImKsQenqJIU6NAjlsjOX7f1MkIIW9rPtWYyg,14761
@@ -19,8 +19,8 @@ sxs/metadata/__init__.py,sha256=KCvJ9Cf1WhIZp-z28UzarKcmUAzV2BOv2gqKiorILjo,149
19
19
  sxs/metadata/metadata.py,sha256=y6X7LcsJKiZFjBPTwRHGtsT2uHf2s0r0OG_EGjD27pE,27663
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=WgxvZexjBH9fwd5qKID7YwvA1wglHerXwS_VQT1LlkY,33915
23
- sxs/simulations/simulations.py,sha256=orsogZOyktC5EiY2U4HzHlF_evMKT5du7t6s6jGphSk,21132
22
+ sxs/simulations/simulation.py,sha256=UN7cQ8y1Ccr3TPI8TyMAr9hvzQuM8NcitqXJJ0IXNPs,34110
23
+ sxs/simulations/simulations.py,sha256=8R3EVfq0OLT2wAE5vjLbx4gCte79M7depb-SB6PLSRU,21971
24
24
  sxs/utilities/__init__.py,sha256=KTtsBKblP02t20anSzV_7tucRUw_bFObY5my5ZuJEBU,4793
25
25
  sxs/utilities/bitwise.py,sha256=G9ZNYgwDQRhq5wbDf-p2HcUqkEP_IRDiQoXW4KyU17k,13205
26
26
  sxs/utilities/dicts.py,sha256=CCpm3upG_9SRj9gjawukSUfaJ5asF-XRG2ausEXhYyg,695
@@ -79,7 +79,7 @@ sxs/zenodo/api/__init__.py,sha256=EM_eh4Q8R5E0vIfMhyIR1IYFfOBu6vA0UTasgX9gHys,21
79
79
  sxs/zenodo/api/deposit.py,sha256=J4RGvGjh0cEOrN4bBZWEDcPAhNscqB2fzLlvRZ5HTHM,36948
80
80
  sxs/zenodo/api/login.py,sha256=Yz0ytgi81_5BpDzhrS0WPMXlvU2qUaCK8yn8zxfEbko,18007
81
81
  sxs/zenodo/api/records.py,sha256=nKkhoHZ95CTztHF9Zzaug5p7IiUCJG4Em1i-l-WqH6U,3689
82
- sxs-2024.0.14.dist-info/METADATA,sha256=KttQT3Xa2eCymq08LJ5S0oXqQj_S1f8W2gfDNwJgqGc,9245
83
- sxs-2024.0.14.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
84
- sxs-2024.0.14.dist-info/licenses/LICENSE,sha256=ptVOd5m7LDM5ZF0x32cxb8c2Nd5NDmAhy6DX7xt_7VA,1080
85
- sxs-2024.0.14.dist-info/RECORD,,
82
+ sxs-2024.0.16.dist-info/METADATA,sha256=rIJB0m7egc53y17106x0JYCZlwo1PmDcT-UVwRf3TDI,9245
83
+ sxs-2024.0.16.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
84
+ sxs-2024.0.16.dist-info/licenses/LICENSE,sha256=ptVOd5m7LDM5ZF0x32cxb8c2Nd5NDmAhy6DX7xt_7VA,1080
85
+ sxs-2024.0.16.dist-info/RECORD,,