classy-szfast 0.0.12__tar.gz → 0.0.14__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.
Files changed (32) hide show
  1. {classy_szfast-0.0.12/classy_szfast.egg-info → classy_szfast-0.0.14}/PKG-INFO +2 -8
  2. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/classy_szfast/cosmopower.py +14 -26
  3. classy_szfast-0.0.14/classy_szfast/restore_nn.py +395 -0
  4. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/classy_szfast/utils.py +1 -1
  5. {classy_szfast-0.0.12 → classy_szfast-0.0.14/classy_szfast.egg-info}/PKG-INFO +2 -8
  6. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/classy_szfast.egg-info/SOURCES.txt +1 -1
  7. classy_szfast-0.0.14/classy_szfast.egg-info/requires.txt +5 -0
  8. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/pyproject.toml +1 -3
  9. classy_szfast-0.0.14/requirements.txt +2 -0
  10. classy_szfast-0.0.14/setup.py +4 -0
  11. classy_szfast-0.0.12/classy_szfast.egg-info/not-zip-safe +0 -1
  12. classy_szfast-0.0.12/classy_szfast.egg-info/requires.txt +0 -7
  13. classy_szfast-0.0.12/requirements.txt +0 -4
  14. classy_szfast-0.0.12/setup.py +0 -30
  15. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/.gitignore +0 -0
  16. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/MANIFEST.in +0 -0
  17. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/README.md +0 -0
  18. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/classy_szfast/__init__.py +0 -0
  19. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/classy_szfast/classy_sz.py +0 -0
  20. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/classy_szfast/classy_szfast.py +0 -0
  21. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/classy_szfast/config.py +0 -0
  22. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/classy_szfast/cosmosis_classy_szfast_interface.py +0 -0
  23. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/classy_szfast/custom_bias/__init__.py +0 -0
  24. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/classy_szfast/custom_bias/custom_bias.py +0 -0
  25. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/classy_szfast/custom_profiles/__init__.py +0 -0
  26. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/classy_szfast/custom_profiles/custom_profiles.py +0 -0
  27. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/classy_szfast/pks_and_sigmas.py +0 -0
  28. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/classy_szfast/suppress_warnings.py +0 -0
  29. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/classy_szfast.egg-info/dependency_links.txt +0 -0
  30. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/classy_szfast.egg-info/top_level.txt +0 -0
  31. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/pypi_upload.sh +0 -0
  32. {classy_szfast-0.0.12 → classy_szfast-0.0.14}/setup.cfg +0 -0
@@ -1,19 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: classy_szfast
3
- Version: 0.0.12
3
+ Version: 0.0.14
4
4
  Summary: The accelerator of the class_sz code from https://github.com/CLASS-SZ
5
- Home-page: https://github.com/CLASS-SZ/classy_szfast
6
- Download-URL: https://github.com/CLASS-SZ/classy_szfast
7
- Author: Boris Bolliet, Ola Kusiak
8
- Author-email: bb667@cam.ac.uk, akk2175@columbia.edu
9
5
  Maintainer-email: Boris Bolliet <bb667@cam.ac.uk>
10
6
  Project-URL: Homepage, https://github.com/CLASS-SZ
11
7
  Project-URL: GitHub, https://github.com/CLASS-SZ
12
8
  Description-Content-Type: text/markdown
13
9
  Requires-Dist: numpy>=1.19.0
14
10
  Requires-Dist: Cython>=0.29.21
15
- Requires-Dist: tensorflow==2.13.0
16
- Requires-Dist: tensorflow-probability==0.21.0
17
- Requires-Dist: cosmopower
11
+ Requires-Dist: tensorflow
18
12
  Requires-Dist: mcfit
19
13
  Requires-Dist: get_cosmopower_emus
@@ -1,8 +1,8 @@
1
1
  from .utils import *
2
2
  from .config import *
3
3
 
4
- from cosmopower import cosmopower_NN
5
- from cosmopower import cosmopower_PCAplusNN
4
+ from .restore_nn import Restore_NN
5
+ from .restore_nn import Restore_PCAplusNN
6
6
  from .suppress_warnings import suppress_warnings
7
7
 
8
8
  dofftlog_alphas = False
@@ -226,45 +226,33 @@ for mp in cosmo_model_list:
226
226
  # print(folder, version)
227
227
  path_to_emulators = path_to_cosmopower_organization + '/' + folder +'/'
228
228
 
229
- cp_tt_nn[mp] = cosmopower_NN(restore=True,
230
- restore_filename=path_to_emulators + 'TTTEEE/' + emulator_dict[mp]['TT'])
229
+ cp_tt_nn[mp] = Restore_NN(restore_filename=path_to_emulators + 'TTTEEE/' + emulator_dict[mp]['TT'])
231
230
 
232
- cp_te_nn[mp] = cosmopower_PCAplusNN(restore=True,
233
- restore_filename=path_to_emulators + 'TTTEEE/' + emulator_dict[mp]['TE'])
231
+ cp_te_nn[mp] = Restore_PCAplusNN(restore_filename=path_to_emulators + 'TTTEEE/' + emulator_dict[mp]['TE'])
234
232
 
235
233
  with suppress_warnings():
236
- cp_ee_nn[mp] = cosmopower_NN(restore=True,
237
- restore_filename=path_to_emulators + 'TTTEEE/' + emulator_dict[mp]['EE'])
234
+ cp_ee_nn[mp] = Restore_NN(restore_filename=path_to_emulators + 'TTTEEE/' + emulator_dict[mp]['EE'])
238
235
 
239
- cp_pp_nn[mp] = cosmopower_NN(restore=True,
240
- restore_filename=path_to_emulators + 'PP/' + emulator_dict[mp]['PP'])
236
+ cp_pp_nn[mp] = Restore_NN(restore_filename=path_to_emulators + 'PP/' + emulator_dict[mp]['PP'])
241
237
 
242
- cp_pknl_nn[mp] = cosmopower_NN(restore=True,
243
- restore_filename=path_to_emulators + 'PK/' + emulator_dict[mp]['PKNL'])
238
+ cp_pknl_nn[mp] = Restore_NN(restore_filename=path_to_emulators + 'PK/' + emulator_dict[mp]['PKNL'])
244
239
 
245
- cp_pkl_nn[mp] = cosmopower_NN(restore=True,
246
- restore_filename=path_to_emulators + 'PK/' + emulator_dict[mp]['PKL'])
240
+ cp_pkl_nn[mp] = Restore_NN(restore_filename=path_to_emulators + 'PK/' + emulator_dict[mp]['PKL'])
247
241
 
248
242
  if (mp == 'lcdm') and (dofftlog_alphas == True):
249
- cp_pkl_fftlog_alphas_real_nn[mp] = cosmopower_PCAplusNN(restore=True,
250
- restore_filename=path_to_emulators + 'PK/' + emulator_dict[mp]['PKLFFTLOG_ALPHAS_REAL']
243
+ cp_pkl_fftlog_alphas_real_nn[mp] = Restore_PCAplusNN(restore_filename=path_to_emulators + 'PK/' + emulator_dict[mp]['PKLFFTLOG_ALPHAS_REAL']
251
244
  )
252
- cp_pkl_fftlog_alphas_imag_nn[mp] = cosmopower_PCAplusNN(restore=True,
253
- restore_filename=path_to_emulators + 'PK/' + emulator_dict[mp]['PKLFFTLOG_ALPHAS_IMAG']
245
+ cp_pkl_fftlog_alphas_imag_nn[mp] = Restore_PCAplusNN(restore_filename=path_to_emulators + 'PK/' + emulator_dict[mp]['PKLFFTLOG_ALPHAS_IMAG']
254
246
  )
255
247
  cp_pkl_fftlog_alphas_nus[mp] = np.load(path_to_emulators + 'PK/PKL_FFTLog_alphas_nu_v1.npz')
256
248
 
257
- cp_der_nn[mp] = cosmopower_NN(restore=True,
258
- restore_filename=path_to_emulators + 'derived-parameters/' + emulator_dict[mp]['DER'])
249
+ cp_der_nn[mp] = Restore_NN(restore_filename=path_to_emulators + 'derived-parameters/' + emulator_dict[mp]['DER'])
259
250
 
260
- cp_da_nn[mp] = cosmopower_NN(restore=True,
261
- restore_filename=path_to_emulators + 'growth-and-distances/' + emulator_dict[mp]['DAZ'])
251
+ cp_da_nn[mp] = Restore_NN(restore_filename=path_to_emulators + 'growth-and-distances/' + emulator_dict[mp]['DAZ'])
262
252
 
263
- cp_h_nn[mp] = cosmopower_NN(restore=True,
264
- restore_filename=path_to_emulators + 'growth-and-distances/' + emulator_dict[mp]['HZ'])
253
+ cp_h_nn[mp] = Restore_NN(restore_filename=path_to_emulators + 'growth-and-distances/' + emulator_dict[mp]['HZ'])
265
254
 
266
- cp_s8_nn[mp] = cosmopower_NN(restore=True,
267
- restore_filename=path_to_emulators + 'growth-and-distances/' + emulator_dict[mp]['S8Z'])
255
+ cp_s8_nn[mp] = Restore_NN(restore_filename=path_to_emulators + 'growth-and-distances/' + emulator_dict[mp]['S8Z'])
268
256
 
269
257
 
270
258
 
@@ -0,0 +1,395 @@
1
+ from .utils import *
2
+ from .config import *
3
+
4
+
5
+ from .suppress_warnings import suppress_warnings
6
+
7
+ import warnings
8
+ from contextlib import contextmanager
9
+ import logging
10
+
11
+ # Suppress absl warnings
12
+ import absl.logging
13
+ absl.logging.set_verbosity('error')
14
+ # Suppress TensorFlow warnings
15
+ import os
16
+ os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
17
+ with suppress_warnings():
18
+ import tensorflow as tf
19
+ tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
20
+ dtype = tf.float32
21
+ import pickle
22
+
23
+ class Restore_NN(tf.keras.Model):
24
+
25
+ def __init__(self,
26
+ parameters=None,
27
+ modes=None,
28
+ parameters_mean=None,
29
+ parameters_std=None,
30
+ features_mean=None,
31
+ features_std=None,
32
+ n_hidden=[512,512,512],
33
+ restore=False,
34
+ restore_filename=None,
35
+ trainable=True,
36
+ optimizer=None,
37
+ verbose=False,
38
+ ):
39
+
40
+ # super
41
+ super(Restore_NN, self).__init__()
42
+
43
+ # restore
44
+
45
+ self.restore(restore_filename)
46
+
47
+
48
+ # input parameters mean and std
49
+ self.parameters_mean = tf.constant(self.parameters_mean_, dtype=dtype, name='parameters_mean')
50
+ self.parameters_std = tf.constant(self.parameters_std_, dtype=dtype, name='parameters_std')
51
+
52
+ # (log)-spectra mean and std
53
+ self.features_mean = tf.constant(self.features_mean_, dtype=dtype, name='features_mean')
54
+ self.features_std = tf.constant(self.features_std_, dtype=dtype, name='features_std')
55
+
56
+ # weights, biases and activation function parameters for each layer of the network
57
+ self.W = []
58
+ self.b = []
59
+ self.alphas = []
60
+ self.betas = []
61
+ for i in range(self.n_layers):
62
+ self.W.append(tf.Variable(tf.random.normal([self.architecture[i], self.architecture[i+1]], 0., 1e-3), name="W_" + str(i), trainable=trainable))
63
+ self.b.append(tf.Variable(tf.zeros([self.architecture[i+1]]), name = "b_" + str(i), trainable=trainable))
64
+ for i in range(self.n_layers-1):
65
+ self.alphas.append(tf.Variable(tf.random.normal([self.architecture[i+1]]), name = "alphas_" + str(i), trainable=trainable))
66
+ self.betas.append(tf.Variable(tf.random.normal([self.architecture[i+1]]), name = "betas_" + str(i), trainable=trainable))
67
+
68
+ # restore weights if restore = True
69
+
70
+ for i in range(self.n_layers):
71
+ self.W[i].assign(self.W_[i])
72
+ self.b[i].assign(self.b_[i])
73
+ for i in range(self.n_layers-1):
74
+ self.alphas[i].assign(self.alphas_[i])
75
+ self.betas[i].assign(self.betas_[i])
76
+
77
+ # optimizer
78
+ self.optimizer = optimizer or tf.keras.optimizers.Adam()
79
+ self.verbose= verbose
80
+
81
+ # print initialization info, if verbose
82
+ if self.verbose:
83
+ multiline_str = "\nInitialized cosmopower_NN model, \n" \
84
+ f"mapping {self.n_parameters} input parameters to {self.n_modes} output modes, \n" \
85
+ f"using {len(self.n_hidden)} hidden layers, \n" \
86
+ f"with {list(self.n_hidden)} nodes, respectively. \n"
87
+ print(multiline_str)
88
+
89
+
90
+ # restore attributes
91
+ def restore(self,
92
+ filename
93
+ ):
94
+ r"""
95
+ Load pre-trained model
96
+
97
+ Parameters:
98
+ filename (str):
99
+ filename tag (without suffix) where model was saved
100
+ """
101
+ # load attributes
102
+ with open(filename + ".pkl", 'rb') as f:
103
+ self.W_, self.b_, self.alphas_, self.betas_, \
104
+ self.parameters_mean_, self.parameters_std_, \
105
+ self.features_mean_, self.features_std_, \
106
+ self.n_parameters, self.parameters, \
107
+ self.n_modes, self.modes, \
108
+ self.n_hidden, self.n_layers, self.architecture = pickle.load(f)
109
+
110
+
111
+
112
+ # auxiliary function to sort input parameters
113
+ def dict_to_ordered_arr_np(self,
114
+ input_dict,
115
+ ):
116
+ r"""
117
+ Sort input parameters
118
+
119
+ Parameters:
120
+ input_dict (dict [numpy.ndarray]):
121
+ input dict of (arrays of) parameters to be sorted
122
+
123
+ Returns:
124
+ numpy.ndarray:
125
+ parameters sorted according to desired order
126
+ """
127
+ if self.parameters is not None:
128
+ return np.stack([input_dict[k] for k in self.parameters], axis=1)
129
+ else:
130
+ return np.stack([input_dict[k] for k in input_dict], axis=1)
131
+
132
+
133
+ # forward prediction given input parameters implemented in Numpy
134
+ def forward_pass_np(self,
135
+ parameters_arr
136
+ ):
137
+ r"""
138
+ Forward pass through the network to predict the output,
139
+ fully implemented in Numpy
140
+
141
+ Parameters:
142
+ parameters_arr (numpy.ndarray):
143
+ array of input parameters
144
+
145
+ Returns:
146
+ numpy.ndarray:
147
+ output predictions
148
+ """
149
+ # forward pass through the network
150
+ act = []
151
+ layers = [(parameters_arr - self.parameters_mean_)/self.parameters_std_]
152
+ for i in range(self.n_layers-1):
153
+
154
+ # linear network operation
155
+ act.append(np.dot(layers[-1], self.W_[i]) + self.b_[i])
156
+
157
+ # pass through activation function
158
+ layers.append((self.betas_[i] + (1.-self.betas_[i])*1./(1.+np.exp(-self.alphas_[i]*act[-1])))*act[-1])
159
+
160
+ # final (linear) layer -> (standardised) predictions
161
+ layers.append(np.dot(layers[-1], self.W_[-1]) + self.b_[-1])
162
+
163
+ # rescale and output
164
+ return layers[-1]*self.features_std_ + self.features_mean_
165
+
166
+
167
+ # Numpy array predictions
168
+ def predictions_np(self,
169
+ parameters_dict
170
+ ):
171
+ r"""
172
+ Predictions given input parameters collected in a dict.
173
+ Fully implemented in Numpy. Calls ``forward_pass_np``
174
+ after ordering the input parameter dict
175
+
176
+ Parameters:
177
+ parameters_dict (dict [numpy.ndarray]):
178
+ dictionary of (arrays of) parameters
179
+
180
+ Returns:
181
+ numpy.ndarray:
182
+ output predictions
183
+ """
184
+ parameters_arr = self.dict_to_ordered_arr_np(parameters_dict)
185
+ return self.forward_pass_np(parameters_arr)
186
+
187
+
188
+ # Numpy array 10.**predictions
189
+ def ten_to_predictions_np(self,
190
+ parameters_dict
191
+ ):
192
+ r"""
193
+ 10^predictions given input parameters collected in a dict.
194
+ Fully implemented in Numpy. It raises 10 to the output
195
+ from ``forward_pass_np``
196
+
197
+ Parameters:
198
+ parameters_dict (dict [numpy.ndarray]):
199
+ dictionary of (arrays of) parameters
200
+
201
+ Returns:
202
+ numpy.ndarray:
203
+ 10^output predictions
204
+ """
205
+ return 10.**self.predictions_np(parameters_dict)
206
+
207
+
208
+ class Restore_PCAplusNN(tf.keras.Model):
209
+
210
+ def __init__(self,
211
+ cp_pca=None,
212
+ n_hidden=[512,512,512],
213
+ restore=False,
214
+ restore_filename=None,
215
+ trainable=True,
216
+ optimizer=None,
217
+ verbose=False,
218
+ ):
219
+ r"""
220
+ Constructor.
221
+ """
222
+ # super
223
+ super(Restore_PCAplusNN, self).__init__()
224
+
225
+
226
+ self.restore(restore_filename)
227
+
228
+ # input parameters mean and std
229
+ self.parameters_mean = tf.constant(self.parameters_mean_, dtype=dtype, name='parameters_mean')
230
+ self.parameters_std = tf.constant(self.parameters_std_, dtype=dtype, name='parameters_std')
231
+
232
+ # PCA mean and std
233
+ self.pca_mean = tf.constant(self.pca_mean_, dtype=dtype, name='pca_mean')
234
+ self.pca_std = tf.constant(self.pca_std_, dtype=dtype, name='pca_std')
235
+
236
+ # (log)-spectra mean and std
237
+ self.features_mean = tf.constant(self.features_mean_, dtype=dtype, name='features_mean')
238
+ self.features_std = tf.constant(self.features_std_, dtype=dtype, name='features_std')
239
+
240
+ # pca transform matrix
241
+ self.pca_transform_matrix = tf.constant(self.pca_transform_matrix_, dtype=dtype, name='pca_transform_matrix')
242
+
243
+ # weights, biases and activation function parameters for each layer of the network
244
+ self.W = []
245
+ self.b = []
246
+ self.alphas = []
247
+ self.betas = []
248
+ for i in range(self.n_layers):
249
+ self.W.append(tf.Variable(tf.random.normal([self.architecture[i], self.architecture[i+1]], 0., np.sqrt(2./self.n_parameters)), name="W_" + str(i), trainable=trainable))
250
+ self.b.append(tf.Variable(tf.zeros([self.architecture[i+1]]), name = "b_" + str(i), trainable=trainable))
251
+ for i in range(self.n_layers-1):
252
+ self.alphas.append(tf.Variable(tf.random.normal([self.architecture[i+1]]), name = "alphas_" + str(i), trainable=trainable))
253
+ self.betas.append(tf.Variable(tf.random.normal([self.architecture[i+1]]), name = "betas_" + str(i), trainable=trainable))
254
+
255
+ # restore weights if restore = True
256
+ for i in range(self.n_layers):
257
+ self.W[i].assign(self.W_[i])
258
+ self.b[i].assign(self.b_[i])
259
+ for i in range(self.n_layers-1):
260
+ self.alphas[i].assign(self.alphas_[i])
261
+ self.betas[i].assign(self.betas_[i])
262
+
263
+ self.optimizer = optimizer or tf.keras.optimizers.Adam()
264
+ self.verbose= verbose
265
+
266
+ # print initialization info, if verbose
267
+ if self.verbose:
268
+ multiline_str = "\nInitialized cosmopower_PCAplusNN model, \n" \
269
+ f"mapping {self.n_parameters} input parameters to {self.n_pcas} PCA components \n" \
270
+ f"and then inverting the PCA compression to obtain {self.n_modes} modes \n" \
271
+ f"The model uses {len(self.n_hidden)} hidden layers, \n" \
272
+ f"with {list(self.n_hidden)} nodes, respectively. \n"
273
+ print(multiline_str)
274
+
275
+
276
+
277
+ # restore attributes
278
+ def restore(self,
279
+ filename,
280
+ ):
281
+ r"""
282
+ Load pre-trained model
283
+
284
+ Parameters:
285
+ filename (str):
286
+ filename tag (without suffix) where model was saved
287
+ """
288
+ # load attributes
289
+ f = open(filename + ".pkl", 'rb')
290
+ self.W_, self.b_, self.alphas_, self.betas_, \
291
+ self.parameters_mean_, self.parameters_std_, \
292
+ self.pca_mean_, self.pca_std_, \
293
+ self.features_mean_, self.features_std_, \
294
+ self.parameters, self.n_parameters, \
295
+ self.modes, self.n_modes, \
296
+ self.n_pcas, self.pca_transform_matrix_, \
297
+ self.n_hidden, self.n_layers, self.architecture = pickle.load(f)
298
+ f.close()
299
+
300
+
301
+
302
+
303
+ # auxiliary function to sort input parameters
304
+ def dict_to_ordered_arr_np(self,
305
+ input_dict,
306
+ ):
307
+ r"""
308
+ Sort input parameters
309
+
310
+ Parameters:
311
+ input_dict (dict [numpy.ndarray]):
312
+ input dict of (arrays of) parameters to be sorted
313
+
314
+ Returns:
315
+ numpy.ndarray:
316
+ parameters sorted according to desired order
317
+ """
318
+ if self.parameters is not None:
319
+ return np.stack([input_dict[k] for k in self.parameters], axis=1)
320
+ else:
321
+ return np.stack([input_dict[k] for k in input_dict], axis=1)
322
+
323
+
324
+ # forward prediction given input parameters implemented in Numpy
325
+ def forward_pass_np(self,
326
+ parameters_arr,
327
+ ):
328
+ r"""
329
+ Forward pass through the network to predict the output,
330
+ fully implemented in Numpy
331
+
332
+ Parameters:
333
+ parameters_arr (numpy.ndarray):
334
+ array of input parameters
335
+
336
+ Returns:
337
+ numpy.ndarray:
338
+ output predictions
339
+ """
340
+ # forward pass through the network
341
+ act = []
342
+ layers = [(parameters_arr - self.parameters_mean_)/self.parameters_std_]
343
+ for i in range(self.n_layers-1):
344
+
345
+ # linear network operation
346
+ act.append(np.dot(layers[-1], self.W_[i]) + self.b_[i])
347
+
348
+ # pass through activation function
349
+ layers.append((self.betas_[i] + (1.-self.betas_[i])*1./(1.+np.exp(-self.alphas_[i]*act[-1])))*act[-1])
350
+
351
+ # final (linear) layer -> (normalized) PCA coefficients
352
+ layers.append(np.dot(layers[-1], self.W_[-1]) + self.b_[-1])
353
+
354
+ # rescale PCA coefficients, multiply out PCA basis -> normalised (log)-spectrum, shift and re-scale (log)-spectrum -> output (log)-spectrum
355
+ return np.dot(layers[-1]*self.pca_std_ + self.pca_mean_, self.pca_transform_matrix_)*self.features_std_ + self.features_mean_
356
+
357
+
358
+ def predictions_np(self,
359
+ parameters_dict,
360
+ ):
361
+ r"""
362
+ Predictions given input parameters collected in a dict.
363
+ Fully implemented in Numpy. Calls ``forward_pass_np``
364
+ after ordering the input parameter dict
365
+
366
+ Parameters:
367
+ parameters_dict (dict [numpy.ndarray]):
368
+ dictionary of (arrays of) parameters
369
+
370
+ Returns:
371
+ numpy.ndarray:
372
+ output predictions
373
+ """
374
+ parameters_arr = self.dict_to_ordered_arr_np(parameters_dict)
375
+ return self.forward_pass_np(parameters_arr)
376
+
377
+
378
+ # 10.**predictions
379
+ def ten_to_predictions_np(self,
380
+ parameters_dict,
381
+ ):
382
+ r"""
383
+ 10^predictions given input parameters collected in a dict.
384
+ Fully implemented in Numpy. It raises 10 to the output
385
+ from ``forward_pass_np``
386
+
387
+ Parameters:
388
+ parameters_dict (dict [numpy.ndarray]):
389
+ dictionary of (arrays of) parameters
390
+
391
+ Returns:
392
+ numpy.ndarray:
393
+ 10^output predictions
394
+ """
395
+ return 10.**self.predictions_np(parameters_dict)
@@ -13,7 +13,7 @@ import math
13
13
  from numpy import linalg as LA
14
14
  import mcfit
15
15
  from mcfit import P2xi
16
- import cosmopower
16
+ # import cosmopower
17
17
  # import classy_sz as csz
18
18
 
19
19
 
@@ -1,19 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: classy_szfast
3
- Version: 0.0.12
3
+ Version: 0.0.14
4
4
  Summary: The accelerator of the class_sz code from https://github.com/CLASS-SZ
5
- Home-page: https://github.com/CLASS-SZ/classy_szfast
6
- Download-URL: https://github.com/CLASS-SZ/classy_szfast
7
- Author: Boris Bolliet, Ola Kusiak
8
- Author-email: bb667@cam.ac.uk, akk2175@columbia.edu
9
5
  Maintainer-email: Boris Bolliet <bb667@cam.ac.uk>
10
6
  Project-URL: Homepage, https://github.com/CLASS-SZ
11
7
  Project-URL: GitHub, https://github.com/CLASS-SZ
12
8
  Description-Content-Type: text/markdown
13
9
  Requires-Dist: numpy>=1.19.0
14
10
  Requires-Dist: Cython>=0.29.21
15
- Requires-Dist: tensorflow==2.13.0
16
- Requires-Dist: tensorflow-probability==0.21.0
17
- Requires-Dist: cosmopower
11
+ Requires-Dist: tensorflow
18
12
  Requires-Dist: mcfit
19
13
  Requires-Dist: get_cosmopower_emus
@@ -13,12 +13,12 @@ classy_szfast/config.py
13
13
  classy_szfast/cosmopower.py
14
14
  classy_szfast/cosmosis_classy_szfast_interface.py
15
15
  classy_szfast/pks_and_sigmas.py
16
+ classy_szfast/restore_nn.py
16
17
  classy_szfast/suppress_warnings.py
17
18
  classy_szfast/utils.py
18
19
  classy_szfast.egg-info/PKG-INFO
19
20
  classy_szfast.egg-info/SOURCES.txt
20
21
  classy_szfast.egg-info/dependency_links.txt
21
- classy_szfast.egg-info/not-zip-safe
22
22
  classy_szfast.egg-info/requires.txt
23
23
  classy_szfast.egg-info/top_level.txt
24
24
  classy_szfast/custom_bias/__init__.py
@@ -0,0 +1,5 @@
1
+ numpy>=1.19.0
2
+ Cython>=0.29.21
3
+ tensorflow
4
+ mcfit
5
+ get_cosmopower_emus
@@ -11,9 +11,7 @@ readme = "https://github.com/CLASS-SZ/.github/blob/main/profile/README.md"
11
11
  dependencies = [
12
12
  "numpy>=1.19.0",
13
13
  "Cython>=0.29.21",
14
- "tensorflow==2.13.0",
15
- "tensorflow-probability==0.21.0",
16
- "cosmopower",
14
+ "tensorflow",
17
15
  "mcfit",
18
16
  "get_cosmopower_emus"
19
17
  ]
@@ -0,0 +1,2 @@
1
+ tensorflow
2
+ mcfit
@@ -0,0 +1,4 @@
1
+ from setuptools import setup
2
+
3
+ if __name__ == "__main__":
4
+ setup(version="0.0.14")
@@ -1,7 +0,0 @@
1
- numpy>=1.19.0
2
- Cython>=0.29.21
3
- tensorflow==2.13.0
4
- tensorflow-probability==0.21.0
5
- cosmopower
6
- mcfit
7
- get_cosmopower_emus
@@ -1,4 +0,0 @@
1
- tensorflow==2.13.0
2
- tensorflow-probability==0.21.0
3
- cosmopower
4
- mcfit
@@ -1,30 +0,0 @@
1
- from setuptools import setup, find_packages
2
- import os
3
- import sys
4
- import shutil
5
-
6
-
7
- # Setup configuration
8
- setup(
9
- classifiers=[
10
- 'Operating System :: OS Independent',
11
- 'Intended Audience :: Developers',
12
- 'Intended Audience :: Science/Research'
13
- ],
14
- name="classy_szfast",
15
- version="0.0.12",
16
- description="Python package for fast class_sz",
17
- # long_description=long_description,
18
- long_description_content_type='text/markdown',
19
- zip_safe=False,
20
- packages=find_packages(include=["classy_szfast"]),
21
- package_dir={},
22
- package_data={},
23
- author="Boris Bolliet, Ola Kusiak",
24
- author_email="bb667@cam.ac.uk, akk2175@columbia.edu",
25
- url='https://github.com/CLASS-SZ/classy_szfast',
26
- download_url='https://github.com/CLASS-SZ/classy_szfast',
27
-
28
- install_requires=["setuptools", "wheel", "numpy>=1.19.0", "Cython>=0.29.21", "tensorflow==2.13.0", "tensorflow-probability==0.21.0", "cosmopower", "mcfit"],
29
- )
30
-
File without changes
File without changes