classy-szfast 0.0.15__tar.gz → 0.0.20__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 (29) hide show
  1. {classy_szfast-0.0.15/classy_szfast.egg-info → classy_szfast-0.0.20}/PKG-INFO +2 -1
  2. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast/config.py +2 -1
  3. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast/restore_nn.py +88 -23
  4. {classy_szfast-0.0.15 → classy_szfast-0.0.20/classy_szfast.egg-info}/PKG-INFO +2 -1
  5. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast.egg-info/SOURCES.txt +0 -6
  6. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast.egg-info/requires.txt +1 -0
  7. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/pyproject.toml +4 -3
  8. classy_szfast-0.0.20/setup.cfg +4 -0
  9. classy_szfast-0.0.15/.gitignore +0 -6
  10. classy_szfast-0.0.15/MANIFEST.in +0 -1
  11. classy_szfast-0.0.15/pypi_upload.sh +0 -44
  12. classy_szfast-0.0.15/requirements.txt +0 -2
  13. classy_szfast-0.0.15/setup.cfg +0 -14
  14. classy_szfast-0.0.15/setup.py +0 -4
  15. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/README.md +0 -0
  16. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast/__init__.py +0 -0
  17. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast/classy_sz.py +0 -0
  18. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast/classy_szfast.py +0 -0
  19. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast/cosmopower.py +0 -0
  20. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast/cosmosis_classy_szfast_interface.py +0 -0
  21. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast/custom_bias/__init__.py +0 -0
  22. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast/custom_bias/custom_bias.py +0 -0
  23. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast/custom_profiles/__init__.py +0 -0
  24. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast/custom_profiles/custom_profiles.py +0 -0
  25. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast/pks_and_sigmas.py +0 -0
  26. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast/suppress_warnings.py +0 -0
  27. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast/utils.py +0 -0
  28. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast.egg-info/dependency_links.txt +0 -0
  29. {classy_szfast-0.0.15 → classy_szfast-0.0.20}/classy_szfast.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: classy_szfast
3
- Version: 0.0.15
3
+ Version: 0.0.20
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
@@ -11,3 +11,4 @@ Requires-Dist: Cython>=0.29.21
11
11
  Requires-Dist: tensorflow
12
12
  Requires-Dist: mcfit
13
13
  Requires-Dist: get_cosmopower_emus
14
+ Requires-Dist: class_sz_data
@@ -1,10 +1,11 @@
1
1
  import os
2
2
 
3
3
  import get_cosmopower_emus
4
-
4
+ import class_sz_data
5
5
 
6
6
  def get_cosmopower_path():
7
7
  get_cosmopower_emus.set()
8
8
  return os.getenv('PATH_TO_COSMOPOWER_ORGANIZATION')
9
9
 
10
10
  path_to_cosmopower_organization = get_cosmopower_path()
11
+ class_sz_data.get_data_from_class_sz_repo(path_to_cosmopower_organization)
@@ -18,7 +18,7 @@ with suppress_warnings():
18
18
  import tensorflow as tf
19
19
  tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
20
20
  dtype = tf.float32
21
- import pickle
21
+
22
22
 
23
23
  class Restore_NN(tf.keras.Model):
24
24
 
@@ -121,7 +121,10 @@ class Restore_NN(tf.keras.Model):
121
121
  " does not exist."))
122
122
 
123
123
  with open(filename_npz, "rb") as fp:
124
- fpz = np.load(fp)
124
+ fpz = np.load(fp, allow_pickle=True)["arr_0"].flatten()[0]
125
+
126
+ # print('filename_npz:', filename_npz)
127
+ # print("Keys in the .npz file:", list(fpz.keys()))
125
128
 
126
129
  self.architecture = fpz["architecture"]
127
130
  self.n_layers = fpz["n_layers"]
@@ -132,17 +135,35 @@ class Restore_NN(tf.keras.Model):
132
135
  self.parameters = list(fpz["parameters"])
133
136
  self.modes = fpz["modes"]
134
137
 
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"]
138
+ # self.parameters_mean_ = fpz["parameters_mean"]
139
+ # self.parameters_std_ = fpz["parameters_std"]
140
+ # self.features_mean_ = fpz["features_mean"]
141
+ # self.features_std_ = fpz["features_std"]
142
+
143
+ # Attempt to load 'parameters_mean' or fall back to 'param_train_mean'
144
+ self.parameters_mean_ = fpz.get("parameters_mean", fpz.get("param_train_mean"))
145
+ self.parameters_std_ = fpz.get("parameters_std", fpz.get("param_train_std"))
146
+ self.features_mean_ = fpz.get("features_mean", fpz.get("feature_train_mean"))
147
+ self.features_std_ = fpz.get("features_std", fpz.get("feature_train_std"))
148
+
149
+
150
+ # Fallback to 'weights_' if individual 'W_i' are not found
151
+ if "weights_" in fpz:
152
+ # Assign the list of weight arrays from 'weights_' directly
153
+ self.W_ = fpz["weights_"]
154
+ else:
155
+ # Use individual weight arrays if available
156
+ self.W_ = [fpz[f"W_{i}"] for i in range(self.n_layers)]
157
+
158
+ # Fallback to 'biases_' if individual 'b_i' are not found
159
+ if "biases_" in fpz:
160
+ self.b_ = fpz["biases_"]
161
+ else:
162
+ self.b_ = [fpz[f"b_{i}"] for i in range(self.n_layers)]
163
+
164
+ self.alphas_ = fpz[f"alphas_"]
165
+ self.betas_ = fpz[f"betas_"]
139
166
 
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)]
146
167
 
147
168
  # auxiliary function to sort input parameters
148
169
  def dict_to_ordered_arr_np(self,
@@ -342,7 +363,11 @@ class Restore_PCAplusNN(tf.keras.Model):
342
363
  " does not exist."))
343
364
 
344
365
  with open(filename_npz, "rb") as fp:
345
- fpz = np.load(fp)
366
+ fpz = np.load(fp, allow_pickle=True)["arr_0"].flatten()[0]
367
+
368
+ # print('filename_npz:', filename_npz)
369
+ # print("Keys in the .npz file:", list(fpz.keys()))
370
+
346
371
 
347
372
  self.architecture = fpz["architecture"]
348
373
  self.n_layers = fpz["n_layers"]
@@ -353,22 +378,62 @@ class Restore_PCAplusNN(tf.keras.Model):
353
378
  self.parameters = fpz["parameters"]
354
379
  self.modes = fpz["modes"]
355
380
 
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"]
381
+ # Attempt to load 'parameters_mean' or fall back to 'param_train_mean'
382
+ self.parameters_mean_ = fpz.get("parameters_mean", fpz.get("param_train_mean"))
383
+ self.parameters_std_ = fpz.get("parameters_std", fpz.get("param_train_std"))
384
+ self.features_mean_ = fpz.get("features_mean", fpz.get("feature_train_mean"))
385
+ self.features_std_ = fpz.get("features_std", fpz.get("feature_train_std"))
386
+
387
+ # Handle PCA-related keys
388
+ # self.pca_mean_ = fpz["pca_mean"]
389
+ # self.pca_std_ = fpz["pca_std"]
390
+ # self.n_pcas = fpz["n_pcas"]
360
391
 
361
392
  self.pca_mean_ = fpz["pca_mean"]
362
393
  self.pca_std_ = fpz["pca_std"]
363
394
  self.n_pcas = fpz["n_pcas"]
364
395
  self.pca_transform_matrix_ = fpz["pca_transform_matrix"]
365
396
 
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)]
397
+ # print('n_pcas:', self.n_pcas)
398
+
399
+ # filename = "/Users/boris/Work/CLASS-SZ/SO-SZ/cosmopower-organization/lcdm/TTTEEE/TE_v1.pkl"
400
+ # f = open(filename, 'rb')
401
+ # self.W_, self.b_, self.alphas_, self.betas_, \
402
+ # self.parameters_mean_, self.parameters_std_, \
403
+ # self.pca_mean_, self.pca_std_, \
404
+ # self.features_mean_, self.features_std_, \
405
+ # self.parameters, self.n_parameters, \
406
+ # self.modes, self.n_modes, \
407
+ # self.n_pcas, self.pca_transform_matrix_, \
408
+ # self.n_hidden, self.n_layers, self.architecture = pickle.load(f)
409
+
410
+ # print('self.n_pcas:', self.n_pcas)
411
+ # print('self.pca_transform_matrix_:', self.pca_transform_matrix_)
412
+ # print('PCA mean:', self.pca_mean_)
413
+ # print('PCA std:', self.pca_std_)
414
+ # f.close()
415
+ # import sys
416
+ # sys.exit(0)
417
+
418
+ # self.pca_transform_matrix_ = fpz["pca_transform_matrix"]
419
+
420
+ # Fallback to 'weights_' if individual 'W_i' are not found
421
+ if "weights_" in fpz:
422
+ # Assign the list of weight arrays from 'weights_' directly
423
+ self.W_ = fpz["weights_"]
424
+ else:
425
+ # Use individual weight arrays if available
426
+ self.W_ = [fpz[f"W_{i}"] for i in range(self.n_layers)]
427
+
428
+ # Fallback to 'biases_' if individual 'b_i' are not found
429
+ if "biases_" in fpz:
430
+ self.b_ = fpz["biases_"]
431
+ else:
432
+ self.b_ = [fpz[f"b_{i}"] for i in range(self.n_layers)]
433
+
434
+ # Handle alphas and betas
435
+ self.alphas_ = fpz.get("alphas_", [fpz.get(f"alphas_{i}") for i in range(self.n_layers - 1)])
436
+ self.betas_ = fpz.get("betas_", [fpz.get(f"betas_{i}") for i in range(self.n_layers - 1)])
372
437
 
373
438
 
374
439
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: classy_szfast
3
- Version: 0.0.15
3
+ Version: 0.0.20
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
@@ -11,3 +11,4 @@ Requires-Dist: Cython>=0.29.21
11
11
  Requires-Dist: tensorflow
12
12
  Requires-Dist: mcfit
13
13
  Requires-Dist: get_cosmopower_emus
14
+ Requires-Dist: class_sz_data
@@ -1,11 +1,5 @@
1
- .gitignore
2
- MANIFEST.in
3
1
  README.md
4
- pypi_upload.sh
5
2
  pyproject.toml
6
- requirements.txt
7
- setup.cfg
8
- setup.py
9
3
  classy_szfast/__init__.py
10
4
  classy_szfast/classy_sz.py
11
5
  classy_szfast/classy_szfast.py
@@ -3,3 +3,4 @@ Cython>=0.29.21
3
3
  tensorflow
4
4
  mcfit
5
5
  get_cosmopower_emus
6
+ class_sz_data
@@ -3,7 +3,7 @@ requires = ["setuptools", "wheel"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
- dynamic = ["version"]
6
+ version = "0.0.20"
7
7
  name = "classy_szfast"
8
8
  maintainers = [{name = "Boris Bolliet",email="bb667@cam.ac.uk"}]
9
9
  description = "The accelerator of the class_sz code from https://github.com/CLASS-SZ"
@@ -13,9 +13,10 @@ dependencies = [
13
13
  "Cython>=0.29.21",
14
14
  "tensorflow",
15
15
  "mcfit",
16
- "get_cosmopower_emus"
16
+ "get_cosmopower_emus",
17
+ "class_sz_data"
17
18
  ]
18
19
 
19
20
  [project.urls]
20
21
  Homepage = "https://github.com/CLASS-SZ"
21
- GitHub = "https://github.com/CLASS-SZ"
22
+ GitHub = "https://github.com/CLASS-SZ"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -1,6 +0,0 @@
1
-
2
- .DS_Store
3
- *egg-info
4
- test_classy_szfast.py
5
- test_classy_szfast-mnu3state.py
6
- __pycache__
@@ -1 +0,0 @@
1
-
@@ -1,44 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Ensure to manually update the version number in setup.py before running this script
4
-
5
- # Function to increment version
6
- increment_version() {
7
- current_version=$(grep -Eo 'version="[^"]*' setup.py | cut -d'"' -f2)
8
- IFS='.' read -r -a version_parts <<< "$current_version"
9
-
10
- major=${version_parts[0]}
11
- minor=${version_parts[1]}
12
- patch=${version_parts[2]}
13
-
14
- patch=$((patch + 1))
15
- if [ $patch -ge 100 ]; then
16
- patch=0
17
- minor=$((minor + 1))
18
- fi
19
- if [ $minor -ge 100 ]; then
20
- minor=0
21
- major=$((major + 1))
22
- fi
23
-
24
- new_version="$major.$minor.$patch"
25
-
26
- # Update the setup.py with the new version
27
- sed -i '' "s/version=\"$current_version\"/version=\"$new_version\"/" setup.py
28
- }
29
-
30
- # Increment the version
31
- increment_version
32
-
33
-
34
- # Remove old build files
35
- rm -rf build dist *.egg-info
36
-
37
- # Build the package
38
- python setup.py sdist bdist_wheel
39
-
40
- # Upload the package
41
- twine upload dist/*
42
-
43
- # Clean up build directories
44
- rm -rf build dist *.egg-info
@@ -1,2 +0,0 @@
1
- tensorflow
2
- mcfit
@@ -1,14 +0,0 @@
1
- [metadata]
2
- description-file = README.md
3
-
4
- [options]
5
- install_requires =
6
- tensorflow==2.13.0
7
- tensorflow-probability==0.21.0
8
- cosmopower
9
- mcfit
10
-
11
- [egg_info]
12
- tag_build =
13
- tag_date = 0
14
-
@@ -1,4 +0,0 @@
1
- from setuptools import setup
2
-
3
- if __name__ == "__main__":
4
- setup(version="0.0.15")
File without changes