classy-szfast 0.0.13__tar.gz → 0.0.15__tar.gz
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.
- {classy_szfast-0.0.13/classy_szfast.egg-info → classy_szfast-0.0.15}/PKG-INFO +1 -2
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast/restore_nn.py +108 -36
- {classy_szfast-0.0.13 → classy_szfast-0.0.15/classy_szfast.egg-info}/PKG-INFO +1 -2
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast.egg-info/requires.txt +0 -1
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/pyproject.toml +0 -1
- classy_szfast-0.0.15/requirements.txt +2 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/setup.py +1 -1
- classy_szfast-0.0.13/requirements.txt +0 -4
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/.gitignore +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/MANIFEST.in +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/README.md +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast/__init__.py +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast/classy_sz.py +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast/classy_szfast.py +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast/config.py +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast/cosmopower.py +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast/cosmosis_classy_szfast_interface.py +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast/custom_bias/__init__.py +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast/custom_bias/custom_bias.py +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast/custom_profiles/__init__.py +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast/custom_profiles/custom_profiles.py +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast/pks_and_sigmas.py +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast/suppress_warnings.py +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast/utils.py +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast.egg-info/SOURCES.txt +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast.egg-info/dependency_links.txt +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast.egg-info/top_level.txt +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/pypi_upload.sh +0 -0
- {classy_szfast-0.0.13 → classy_szfast-0.0.15}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: classy_szfast
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.15
|
4
4
|
Summary: The accelerator of the class_sz code from https://github.com/CLASS-SZ
|
5
5
|
Maintainer-email: Boris Bolliet <bb667@cam.ac.uk>
|
6
6
|
Project-URL: Homepage, https://github.com/CLASS-SZ
|
@@ -9,6 +9,5 @@ Description-Content-Type: text/markdown
|
|
9
9
|
Requires-Dist: numpy>=1.19.0
|
10
10
|
Requires-Dist: Cython>=0.29.21
|
11
11
|
Requires-Dist: tensorflow
|
12
|
-
Requires-Dist: cosmopower
|
13
12
|
Requires-Dist: mcfit
|
14
13
|
Requires-Dist: get_cosmopower_emus
|
@@ -87,27 +87,62 @@ class Restore_NN(tf.keras.Model):
|
|
87
87
|
print(multiline_str)
|
88
88
|
|
89
89
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
):
|
90
|
+
|
91
|
+
# from https://github.com/HTJense/cosmopower/blob/packaging-paper/cosmopower/cosmopower_NN.py
|
92
|
+
def restore(self, filename: str, allow_pickle: bool = False) -> None:
|
94
93
|
r"""
|
95
|
-
Load pre-trained model
|
94
|
+
Load pre-trained model.
|
95
|
+
The default file format is compressed numpy files (.npz). The
|
96
|
+
Module will attempt to use this as a file extension and restore
|
97
|
+
from there (i.e. look for `filename.npz`). If this file does
|
98
|
+
not exist, and `allow_pickle` is set to True, then the file
|
99
|
+
`filename.pkl` will be attempted to be read by `restore_pickle`.
|
100
|
+
|
101
|
+
The function will trim the file extension from `filename`, so
|
102
|
+
`restore("filename")` and `restore("filename.npz")` are identical.
|
96
103
|
|
97
104
|
Parameters:
|
98
|
-
|
99
|
-
|
105
|
+
:param filename: filename (without suffix) where model was saved.
|
106
|
+
:param allow_pickle: whether or not to permit passing this filename
|
107
|
+
to the `restore_pickle` function.
|
100
108
|
"""
|
101
|
-
#
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
109
|
+
# Check if npz file exists.
|
110
|
+
filename_npz = filename + ".npz"
|
111
|
+
if not os.path.exists(filename_npz):
|
112
|
+
# Can we load this file as a pickle file?
|
113
|
+
filename_pkl = filename + ".pkl"
|
114
|
+
if allow_pickle and os.path.exists(filename_pkl):
|
115
|
+
self.restore_pickle(filename_pkl)
|
116
|
+
return
|
117
|
+
|
118
|
+
raise IOError(f"Failed to restore network from {filename}: "
|
119
|
+
+ (" is a pickle file, try setting 'allow_pickle = \
|
120
|
+
True'" if os.path.exists(filename_pkl) else
|
121
|
+
" does not exist."))
|
122
|
+
|
123
|
+
with open(filename_npz, "rb") as fp:
|
124
|
+
fpz = np.load(fp)
|
125
|
+
|
126
|
+
self.architecture = fpz["architecture"]
|
127
|
+
self.n_layers = fpz["n_layers"]
|
128
|
+
self.n_hidden = fpz["n_hidden"]
|
129
|
+
self.n_parameters = fpz["n_parameters"]
|
130
|
+
self.n_modes = fpz["n_modes"]
|
131
|
+
|
132
|
+
self.parameters = list(fpz["parameters"])
|
133
|
+
self.modes = fpz["modes"]
|
134
|
+
|
135
|
+
self.parameters_mean_ = fpz["parameters_mean"]
|
136
|
+
self.parameters_std_ = fpz["parameters_std"]
|
137
|
+
self.features_mean_ = fpz["features_mean"]
|
138
|
+
self.features_std_ = fpz["features_std"]
|
139
|
+
|
140
|
+
self.W_ = [fpz[f"W_{i}"] for i in range(self.n_layers)]
|
141
|
+
self.b_ = [fpz[f"b_{i}"] for i in range(self.n_layers)]
|
142
|
+
self.alphas_ = [
|
143
|
+
fpz[f"alphas_{i}"] for i in range(self.n_layers - 1)
|
144
|
+
]
|
145
|
+
self.betas_ = [fpz[f"betas_{i}"] for i in range(self.n_layers - 1)]
|
111
146
|
|
112
147
|
# auxiliary function to sort input parameters
|
113
148
|
def dict_to_ordered_arr_np(self,
|
@@ -274,29 +309,66 @@ class Restore_PCAplusNN(tf.keras.Model):
|
|
274
309
|
|
275
310
|
|
276
311
|
|
277
|
-
#
|
278
|
-
def restore(self,
|
279
|
-
filename,
|
280
|
-
):
|
312
|
+
# from https://github.com/HTJense/cosmopower/blob/packaging-paper/cosmopower/cosmopower_PCAplusNN.py
|
313
|
+
def restore(self, filename: str, allow_pickle: bool = False) -> None:
|
281
314
|
r"""
|
282
|
-
Load pre-trained model
|
315
|
+
Load pre-trained model.
|
316
|
+
The default file format is compressed numpy files (.npz). The
|
317
|
+
Module will attempt to use this as a file extension and restore
|
318
|
+
from there (i.e. look for `filename.npz`). If this file does
|
319
|
+
not exist, and `allow_pickle` is set to True, then the file
|
320
|
+
`filename.pkl` will be attempted to be read by `restore_pickle`.
|
321
|
+
|
322
|
+
The function will trim the file extension from `filename`, so
|
323
|
+
`restore("filename")` and `restore("filename.npz")` are identical.
|
283
324
|
|
284
325
|
Parameters:
|
285
|
-
|
286
|
-
|
326
|
+
:param filename: filename (without suffix) where model was saved.
|
327
|
+
:param allow_pickle: whether or not to permit passing this filename to
|
328
|
+
the `restore_pickle` function.
|
287
329
|
"""
|
288
|
-
#
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
330
|
+
# Check if npz file exists.
|
331
|
+
filename_npz = filename + ".npz"
|
332
|
+
if not os.path.exists(filename_npz):
|
333
|
+
# Can we load this file as a pickle file?
|
334
|
+
filename_pkl = filename + ".pkl"
|
335
|
+
if allow_pickle and os.path.exists(filename_pkl):
|
336
|
+
self.restore_pickle(filename_pkl)
|
337
|
+
return
|
338
|
+
|
339
|
+
raise IOError(f"Failed to restore network from {filename}: "
|
340
|
+
+ (" is a pickle file, try setting 'allow_pickle = \
|
341
|
+
True'" if os.path.exists(filename_pkl) else
|
342
|
+
" does not exist."))
|
343
|
+
|
344
|
+
with open(filename_npz, "rb") as fp:
|
345
|
+
fpz = np.load(fp)
|
346
|
+
|
347
|
+
self.architecture = fpz["architecture"]
|
348
|
+
self.n_layers = fpz["n_layers"]
|
349
|
+
self.n_hidden = fpz["n_hidden"]
|
350
|
+
self.n_parameters = fpz["n_parameters"]
|
351
|
+
self.n_modes = fpz["n_modes"]
|
352
|
+
|
353
|
+
self.parameters = fpz["parameters"]
|
354
|
+
self.modes = fpz["modes"]
|
355
|
+
|
356
|
+
self.parameters_mean_ = fpz["parameters_mean"]
|
357
|
+
self.parameters_std_ = fpz["parameters_std"]
|
358
|
+
self.features_mean_ = fpz["features_mean"]
|
359
|
+
self.features_std_ = fpz["features_std"]
|
360
|
+
|
361
|
+
self.pca_mean_ = fpz["pca_mean"]
|
362
|
+
self.pca_std_ = fpz["pca_std"]
|
363
|
+
self.n_pcas = fpz["n_pcas"]
|
364
|
+
self.pca_transform_matrix_ = fpz["pca_transform_matrix"]
|
365
|
+
|
366
|
+
self.W_ = [fpz[f"W_{i}"] for i in range(self.n_layers)]
|
367
|
+
self.b_ = [fpz[f"b_{i}"] for i in range(self.n_layers)]
|
368
|
+
self.alphas_ = [
|
369
|
+
fpz[f"alphas_{i}"] for i in range(self.n_layers - 1)
|
370
|
+
]
|
371
|
+
self.betas_ = [fpz[f"betas_{i}"] for i in range(self.n_layers - 1)]
|
300
372
|
|
301
373
|
|
302
374
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: classy_szfast
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.15
|
4
4
|
Summary: The accelerator of the class_sz code from https://github.com/CLASS-SZ
|
5
5
|
Maintainer-email: Boris Bolliet <bb667@cam.ac.uk>
|
6
6
|
Project-URL: Homepage, https://github.com/CLASS-SZ
|
@@ -9,6 +9,5 @@ Description-Content-Type: text/markdown
|
|
9
9
|
Requires-Dist: numpy>=1.19.0
|
10
10
|
Requires-Dist: Cython>=0.29.21
|
11
11
|
Requires-Dist: tensorflow
|
12
|
-
Requires-Dist: cosmopower
|
13
12
|
Requires-Dist: mcfit
|
14
13
|
Requires-Dist: get_cosmopower_emus
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast/cosmosis_classy_szfast_interface.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{classy_szfast-0.0.13 → classy_szfast-0.0.15}/classy_szfast/custom_profiles/custom_profiles.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|