pyANOVAapprox 2.0.1__tar.gz → 2.0.3__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 (37) hide show
  1. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/PKG-INFO +1 -1
  2. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/pyproject.toml +1 -1
  3. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/simpleTest/exampleAutoapproximate.py +1 -1
  4. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/simpleTest/exampleCheb.py +5 -5
  5. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/simpleTest/exampleClassification.py +2 -2
  6. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/simpleTest/exampleNonPeriodic.py +10 -8
  7. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/simpleTest/examplePeriodic.py +1 -1
  8. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/simpleTest/exampleWavelet.py +10 -10
  9. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/src/pyANOVAapprox/__init__.py +2 -0
  10. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/src/pyANOVAapprox/approx.py +60 -20
  11. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/src/pyANOVAapprox/bandwidth.py +39 -23
  12. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/.github/workflows/ci.yml +0 -0
  13. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/.github/workflows/documentation.yml +0 -0
  14. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/.github/workflows/format.yml +0 -0
  15. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/.github/workflows/release.yml +0 -0
  16. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/.gitignore +0 -0
  17. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/LICENSE +0 -0
  18. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/README.md +0 -0
  19. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/docs/Makefile +0 -0
  20. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/docs/source/Analysis.rst +0 -0
  21. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/docs/source/Approximation.rst +0 -0
  22. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/docs/source/Errors.rst +0 -0
  23. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/docs/source/conf.py +0 -0
  24. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/docs/source/index.rst +0 -0
  25. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/simpleTest/TestFunctionPeriodic.py +0 -0
  26. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/src/pyANOVAapprox/analysis.py +0 -0
  27. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/src/pyANOVAapprox/errors.py +0 -0
  28. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/src/pyANOVAapprox/fista.py +0 -0
  29. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/src/pyANOVAapprox/trafos.py +0 -0
  30. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/tests/TestFunctionCheb.py +0 -0
  31. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/tests/TestFunctionPeriodic.py +0 -0
  32. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/tests/cheb_fista.py +0 -0
  33. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/tests/cheb_lsqr.py +0 -0
  34. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/tests/per_fista.py +0 -0
  35. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/tests/per_lsqr.py +0 -0
  36. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/tests/run_tests.py +0 -0
  37. {pyanovaapprox-2.0.1 → pyanovaapprox-2.0.3}/tests/wav_lsqr.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyANOVAapprox
3
- Version: 2.0.1
3
+ Version: 2.0.3
4
4
  Summary: Approximation Package for High-Dimensional Functions
5
5
  Project-URL: Homepage, https://github.com/NFFT/pyGroupedTransforms
6
6
  Author-email: Felix Wirth <fwi012001@gmail.com>
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pyANOVAapprox"
7
- version = "2.0.1"
7
+ version = "2.0.3"
8
8
  authors = [
9
9
  { name="Felix Wirth", email="fwi012001@gmail.com" },
10
10
  ]
@@ -56,7 +56,7 @@ ads.autoapproximate()
56
56
  ## get approximation accuracy ##
57
57
  ################################
58
58
 
59
- # mse = ANOVAapprox.get_mse(ads) # get mse error at the given training points
59
+ # mse = ads.get_mse() # get mse error at the given training points
60
60
  mse = ads.get_mse(X=X_test, y=y_test) # get mse error at the test points
61
61
  λ_min = min(
62
62
  mse, key=mse.get
@@ -86,8 +86,8 @@ ads.approximate(lam=lambdas, max_iter=max_iter, solver="lsqr")
86
86
  ## get approximation accuracy ##
87
87
  ################################
88
88
 
89
- # mse = ANOVAapprox.get_mse(ads) # get mse error at the given training points
90
- mse = ANOVAapprox.get_mse(ads, X_test, y_test) # get mse error at the test points
89
+ # mse = ads.get_mse() # get mse error at the given training points
90
+ mse = ads.get_mse(X=X_test, y=y_test) # get mse error at the test points
91
91
  λ_min = min(
92
92
  mse, key=mse.get
93
93
  ) # get the regularisation parameter which leads to the minimal error
@@ -100,7 +100,7 @@ print("mse = " + str(mse_min))
100
100
  ###############################################
101
101
 
102
102
 
103
- ar = ANOVAapprox.get_AttributeRanking(ads, λ_min) # get the attrbute ranking
103
+ ar = ads.get_AttributeRanking(lam=λ_min) # get the attrbute ranking
104
104
 
105
105
  plt.figure()
106
106
  markers, stemlines, baseline = plt.stem(
@@ -121,7 +121,7 @@ plt.grid(True, which="both", ls="--", linewidth=0.5)
121
121
  plt.show() # plot the arrtibute ranking in an logplot
122
122
  print("active dimensions: " + str(ar[ar > 1e-2]))
123
123
 
124
- gsis = ANOVAapprox.get_GSI(ads, λ_min)
124
+ gsis = ads.get_GSI(lam=λ_min)
125
125
  label = list(ads.U[1:])
126
126
  l = len(label)
127
127
  plt.figure()
@@ -166,7 +166,7 @@ a.approximate(
166
166
  lam=lambdas, max_iter=max_iter, solver="lsqr"
167
167
  ) # do the approximation for all specified regularisation parameters
168
168
 
169
- mse = ANOVAapprox.get_mse(a, X_test, y_test) # get mse error at the test points
169
+ mse = a.get_mse(X=X_test, y=y_test) # get mse error at the test points
170
170
  λ_min = min(
171
171
  mse, key=mse.get
172
172
  ) # get the regularisation parameter which leads to the minimal error
@@ -97,7 +97,7 @@ print("accuracity = " + str(acc))
97
97
  ## Analyze the model to improve the accuracy ##
98
98
  ###############################################
99
99
 
100
- ar = ANOVAapprox.get_AttributeRanking(ads, 0.0) # get the attrbute ranking
100
+ ar = ads.get_AttributeRanking(lam=0.0) # get the attrbute ranking
101
101
 
102
102
  plt.figure()
103
103
  markers, stemlines, baseline = plt.stem(
@@ -118,7 +118,7 @@ plt.grid(True, which="both", ls="--", linewidth=0.5)
118
118
  plt.show() # plot the arrtibute ranking in an logplot
119
119
  print("active dimensions: " + str(ar[ar > 1e-2]))
120
120
 
121
- gsis = ANOVAapprox.get_GSI(ads, 0.0)
121
+ gsis = ads.get_GSI(lam=0.0)
122
122
  label = list(ads.U[1:])
123
123
  l = len(label)
124
124
  plt.figure()
@@ -84,8 +84,8 @@ ads.approximate(lam=lambdas, max_iter=max_iter, solver="lsqr")
84
84
  ## get approximation accuracy ##
85
85
  ################################
86
86
 
87
- # mse = ANOVAapprox.get_mse(ads) # get mse error at the given training points
88
- mse = ANOVAapprox.get_mse(ads, X_test, y_test) # get mse error at the test points
87
+ # mse = ads.get_mse() # get mse error at the given training points
88
+ mse = ads.get_mse(X=X_test, y=y_test) # get mse error at the test points
89
89
  λ_min = min(
90
90
  mse, key=mse.get
91
91
  ) # get the regularisation parameter which leads to the minimal error
@@ -98,7 +98,7 @@ print("mse = " + str(mse_min))
98
98
  ###############################################
99
99
 
100
100
 
101
- ar = ANOVAapprox.get_AttributeRanking(ads, λ_min) # get the attrbute ranking
101
+ ar = ads.get_AttributeRanking(lam=λ_min) # get the attrbute ranking
102
102
 
103
103
  plt.figure()
104
104
  markers, stemlines, baseline = plt.stem(
@@ -119,8 +119,8 @@ plt.grid(True, which="both", ls="--", linewidth=0.5)
119
119
  plt.show() # plot the arrtibute ranking in an logplot
120
120
  print("active dimensions: " + str(ar[ar > 1e-2]))
121
121
 
122
- gsis = ANOVAapprox.get_GSI(ads, λ_min)
123
- label = list(ads.U[1:])
122
+ gsis = ads.get_GSI(lam=λ_min)
123
+ label = list(ads.getSetting().U[1:])
124
124
  l = len(label)
125
125
  plt.figure()
126
126
  x_values = np.arange(1, l + 1)
@@ -150,7 +150,9 @@ print(
150
150
  ################################################
151
151
 
152
152
  Umask = np.append(np.array([True]), gsis > 1e-2)
153
- U = [ads.U[i] for i in np.arange(0, len(Umask))[Umask]] # get important subsets
153
+ U = [
154
+ ads.getSetting().U[i] for i in np.arange(0, len(Umask))[Umask]
155
+ ] # get important subsets
154
156
  bws = M / (math.log10(M) * (len(U) - 1)) # calculate frequencies per subset
155
157
  N = [
156
158
  math.floor(bws ** (1 / max(1, len(u))) / 2) * 2 for u in U
@@ -164,7 +166,7 @@ a.approximate(
164
166
  lam=lambdas, max_iter=max_iter, solver="lsqr"
165
167
  ) # do the approximation for all specified regularisation parameters
166
168
 
167
- mse = ANOVAapprox.get_mse(a, X_test, y_test) # get mse error at the test points
169
+ mse = a.get_mse(X=X_test, y=y_test) # get mse error at the test points
168
170
  λ_min = min(
169
171
  mse, key=mse.get
170
172
  ) # get the regularisation parameter which leads to the minimal error
@@ -183,7 +185,7 @@ print("mse = " + str(mse_min))
183
185
  y_eval_anova = a.evaluateANOVAterms(
184
186
  X=X_test, lam=λ_min
185
187
  ) # evaluate all of the ANOVA terms
186
- pos = a.U.index((3,)) # find the index for the subset u=[3]
188
+ pos = a.getSetting().U.index((3,)) # find the index for the subset u=[3]
187
189
  y_eval_anova_3 = y_eval_anova.T[pos]
188
190
 
189
191
  perm = np.argsort(X_test.T[3])
@@ -89,7 +89,7 @@ ads.approximate(lam=lambdas, max_iter=max_iter, solver="lsqr")
89
89
  ## get approximation accuracy ##
90
90
  ################################
91
91
 
92
- # mse = ANOVAapprox.get_mse(ads) # get mse error at the given training points
92
+ # mse = ads.get_mse() # get mse error at the given training points
93
93
  mse = ads.get_mse(X=X_test, y=y_test) # get mse error at the test points
94
94
  λ_min = min(
95
95
  mse, key=mse.get
@@ -81,10 +81,10 @@ print("Total number of used parameters = " + str(len(anova_model.fc[lambdas[0]].
81
81
  #######################
82
82
 
83
83
  ### Do sensitivity analysis ####
84
- gsis = ANOVAapprox.get_GSI(
85
- anova_model, 0.0
84
+ anova_model.get_GSI(
85
+ lam=0.0
86
86
  ) # calculates indices for importance of terms (gsis is vector, with indices belonging to terms in anova_model.U)
87
- gsis_as_dict = ANOVAapprox.get_GSI(anova_model, 0.0, dict=true)
87
+ anova_model.get_GSI(lam=0.0, Dict=true)
88
88
 
89
89
  y_min_calc = 10 ** (np.min(np.log10(gsis)) - 0.5)
90
90
  label = list(anova_model.U[1:])
@@ -113,8 +113,8 @@ plt.show()
113
113
  ################################
114
114
 
115
115
  ### error analysis ###
116
- mse_train = ANOVAapprox.get_mse(anova_model, lam=0.0)
117
- mse_test = ANOVAapprox.get_mse(anova_model, X_test, y_test, lam=0.0)
116
+ mse_train = anova_model.get_mse(lam=0.0)
117
+ mse_test = anova_model.get_mse(X=X_test, y=y_test, lam=0.0)
118
118
 
119
119
  print("MSE on test points: " + str(mse_test))
120
120
 
@@ -122,13 +122,13 @@ print("MSE on test points: " + str(mse_test))
122
122
  ## Approximation with better suited index set ##
123
123
  ################################################
124
124
 
125
- U = ANOVAapprox.get_ActiveSet(anova_model, [0.01, 0.01], lam=0.0)
125
+ U = anova_model.get_ActiveSet(eps=[0.01, 0.01], lam=0.0)
126
126
  print("Found index-set U: " + str(U))
127
- anova_model = ANOVAapprox.approx(
128
- X, y, U=U, N=[i + 2 for i in N], basis=basis
127
+ anova_model = anova_model.approx(
128
+ X=X, y=y, U=U, N=[i + 2 for i in N], basis=basis
129
129
  ) # increase number of paramers in N for the important terms
130
130
  anova_model.approximate(lam=lambdas)
131
131
  print("Total number of used parameters = " + str(len(anova_model.fc[lambdas[0]].vec())))
132
- mse_train = ANOVAapprox.get_mse(anova_model, lam=0.0)
133
- mse_test = ANOVAapprox.get_mse(anova_model, X_test, y_test, lam=0.0)
132
+ mse_train = anova_model.get_mse(lam=0.0)
133
+ mse_test = anova_model.get_mse(X=X_test, y=y_test, lam=0.0)
134
134
  print("MSE on test points after ANOVA truncation: " + str(mse_test))
@@ -1,4 +1,6 @@
1
+ import csv
1
2
  import math
3
+ import os
2
4
  import threading
3
5
  from math import acos, isnan
4
6
 
@@ -188,6 +188,9 @@ class approx:
188
188
 
189
189
  self.X = X
190
190
 
191
+ if X.shape[0] != y.shape[0]:
192
+ raise ValueError("X and y have different lengths.")
193
+
191
194
  setting = approx_setting(
192
195
  parent=self,
193
196
  U=U,
@@ -384,7 +387,7 @@ class approx:
384
387
  B,
385
388
  maxiter,
386
389
  solver,
387
- verbose,
390
+ verbosity,
388
391
  solver_max_iter,
389
392
  solver_weights,
390
393
  solver_verbose,
@@ -399,7 +402,15 @@ class approx:
399
402
  D = dict([(u, tuple([1.0] * len(u))) for u in setting.U])
400
403
  t = dict([(u, tuple([1.0] * len(u))) for u in setting.U])
401
404
 
405
+ if verbosity > 3:
406
+ if not os.path.exists("log"):
407
+ os.mkdir("log")
408
+ with open("log/log.csv", "w", newline="") as csvfile:
409
+ csv.writer(csvfile, delimiter=",").writerow(["it"] + setting.U)
410
+
402
411
  for idx in range(maxiter):
412
+ if verbosity > 0:
413
+ print("===== Iteration ", str(idx + 1), " =====")
403
414
  bw = compute_bandwidth(B, D, t)
404
415
  if setting.N is not None:
405
416
  self.addSetting(setting)
@@ -409,9 +420,16 @@ class approx:
409
420
  setting.N = [bw[i] for i in setting.U]
410
421
  self.addTrafo()
411
422
 
412
- if verbose:
413
- print("bw in iteration", str(idx + 1), "are", str(bw))
414
-
423
+ if verbosity > 0:
424
+ for i in setting.U:
425
+ print("bw in", str(i), ":", bw[i])
426
+ # print("bw in iteration", str(idx + 1), "are", str(bw))
427
+ print()
428
+ if verbosity > 3:
429
+ with open("log/log.csv", "a", newline="") as csvfile:
430
+ csv.writer(csvfile, delimiter=",").writerow(
431
+ ["bw in it" + str(idx + 1)] + [str(bw[i]) for i in setting.U]
432
+ )
415
433
  self.approximate(
416
434
  lam=lam,
417
435
  solver=solver,
@@ -421,16 +439,36 @@ class approx:
421
439
  tol=solver_tol,
422
440
  )
423
441
 
424
- D, t = self.estimate_rates(lam=lam, verbose=verbose)
425
- if verbose:
426
- print(
427
- "estimated rates in iteration",
428
- str(idx + 1),
429
- "are D =",
430
- str(D),
431
- "and t =",
432
- str(t),
433
- )
442
+ D, t = self.estimate_rates(lam=lam, verbosity=verbosity)
443
+ if verbosity > 1:
444
+ for i in setting.U:
445
+ print(
446
+ "estimated rates for",
447
+ str(i),
448
+ ": D = ",
449
+ str(D[i]),
450
+ "and t = ",
451
+ str(t[i]),
452
+ )
453
+ print()
454
+
455
+ # print(
456
+ # "estimated rates in iteration",
457
+ # str(idx + 1),
458
+ # "are D =",
459
+ # str(D),
460
+ # "and t =",
461
+ # str(t),
462
+ # )
463
+ if verbosity > 3:
464
+ with open("log/log.csv", "a", newline="") as csvfile:
465
+ wr = csv.writer(csvfile, delimiter=",")
466
+ wr.writerow(
467
+ ["D in it" + str(idx + 1)] + [str(D[i]) for i in setting.U]
468
+ )
469
+ wr.writerow(
470
+ ["t in it" + str(idx + 1)] + [str(t[i]) for i in setting.U]
471
+ )
434
472
  return D, t
435
473
 
436
474
  def autoapproximate(
@@ -440,7 +478,7 @@ class approx:
440
478
  B=None,
441
479
  maxiter=2,
442
480
  solver="lsqr",
443
- verbose=False,
481
+ verbosity=0,
444
482
  solver_max_iter=50,
445
483
  solver_weights=None,
446
484
  solver_verbose=False,
@@ -462,7 +500,7 @@ class approx:
462
500
  B=B,
463
501
  maxiter=maxiter,
464
502
  solver=solver,
465
- verbose=verbose,
503
+ verbosity=verbosity,
466
504
  solver_max_iter=solver_max_iter,
467
505
  solver_weights=solver_weights,
468
506
  solver_verbose=solver_verbose,
@@ -476,7 +514,7 @@ class approx:
476
514
  B=B,
477
515
  maxiter=maxiter,
478
516
  solver=solver,
479
- verbose=verbose,
517
+ verbosity=verbosity,
480
518
  solver_max_iter=solver_max_iter,
481
519
  solver_weights=solver_weights,
482
520
  solver_verbose=solver_verbose,
@@ -541,10 +579,12 @@ class approx:
541
579
 
542
580
  Xt = transformX(X, setting.basis)
543
581
 
544
- if self.setting[settingnr].basis == "per":
545
- values = np.zeros((Xt.shape[0], len(self.setting[settingnr].U)), "complex")
582
+ if self.getSetting(settingnr).basis == "per":
583
+ values = np.zeros(
584
+ (Xt.shape[0], len(self.getSetting(settingnr).U)), "complex"
585
+ )
546
586
  else:
547
- values = np.zeros((Xt.shape[0], len(self.setting[settingnr].U)), "float")
587
+ values = np.zeros((Xt.shape[0], len(self.getSetting(settingnr).U)), "float")
548
588
 
549
589
  trafo = GroupedTransform(
550
590
  system=gt_systems[setting.basis],
@@ -5,25 +5,30 @@ def getfcu(ghat, u):
5
5
  idx = [s.u for s in ghat.settings].index(u)
6
6
  bws = ghat.settings[idx].bandwidths
7
7
 
8
- #fcu = ghat[u].reshape(bws[::-1] - 1)
9
- #fcu = np.permute_dims(fcu, range(len(bws))[::-1])
8
+ # fcu = ghat[u].reshape(bws[::-1] - 1)
9
+ # fcu = np.permute_dims(fcu, range(len(bws))[::-1])
10
10
  fcu = ghat[u].reshape(bws - 1)
11
11
  fcu = np.permute_dims(fcu, range(len(bws)))
12
-
12
+
13
13
  return fcu
14
14
 
15
15
 
16
- def getaxissum(ghat, u, j):
16
+ def getaxissum(ghat, u, j, system):
17
17
  fcu = getfcu(ghat, u)
18
18
  idx = [s.u for s in ghat.settings].index(u)
19
19
  bws = ghat.settings[idx].bandwidths
20
20
 
21
21
  fcuj = np.sum(abs(fcu) ** 2, axis=tuple([i for i in range(len(u)) if i != j]))
22
22
 
23
- fcuj = (
24
- fcuj[np.mod(range(int(bws[j] / 2), bws[j]), bws[j] - 1)]
25
- + fcuj[range(int(bws[j] / 2) - 1, -1, -1)]
26
- )
23
+ if system == "exp":
24
+ fcuj = (
25
+ fcuj[np.mod(range(int(bws[j] / 2), bws[j]), bws[j] - 1)]
26
+ + fcuj[range(int(bws[j] / 2) - 1, -1, -1)]
27
+ )
28
+ elif system == "cos":
29
+ pass
30
+ else:
31
+ raise ValueError("For this basis is estimate rates not implemented")
27
32
  # fcuj = np.concatenate(fcuj[math.ceil(bws[j]/2):] + [fcuj[0]]) + fcuj[math.ceil(bws[j]/2)-1::-1]
28
33
  return fcuj
29
34
 
@@ -32,7 +37,7 @@ def compute_bandwidth(B, D, t):
32
37
  us = set(D.keys()) - {()}
33
38
  bw = {u: [6] * len(u) for u in us}
34
39
  bw[()] = []
35
-
40
+
36
41
  minfreqs = sum(math.prod((bw[u][j] - 1) for j in range(len(u))) for u in us)
37
42
  if B < minfreqs:
38
43
  raise ValueError(f"Budget too small: {B} < {minfreqs}")
@@ -106,7 +111,7 @@ def most_common_value(data):
106
111
  return t[max_index]
107
112
 
108
113
 
109
- def estimate_rates(self, lam, settingnr=None, verbose=False):
114
+ def estimate_rates(self, lam, settingnr=None, verbosity=0):
110
115
  us = [s.u for s in self.getTrafo(settingnr).settings]
111
116
  nhat = GroupedCoefficients(
112
117
  self.getTrafo(settingnr).settings,
@@ -119,24 +124,27 @@ def estimate_rates(self, lam, settingnr=None, verbose=False):
119
124
  mcl = np.exp(most_common_value(np.log(abs(self.getFc(settingnr)[lam].data))))
120
125
  threshold = 100 * mcl**2
121
126
 
122
- if verbose:
123
- ps = []
127
+ if verbosity > 5:
128
+ if not os.path.exists(os.path.join("log", "figures")):
129
+ os.mkdir(os.path.join("log", "figures"))
130
+ num = 0
131
+
132
+ system = self.getTrafo(settingnr).system
124
133
 
125
134
  for u in us:
126
135
  if len(u) == 0:
127
136
  continue
128
137
 
129
- if verbose:
138
+ if verbosity > 5:
130
139
  fig, ax = plt.subplots()
131
140
  ax.set_xscale("log")
132
141
  ax.set_yscale("log")
133
142
  ax.set_title(str(u))
134
- ps.append(ax)
135
143
 
136
144
  for j in range(len(u)):
137
- axissum = getaxissum(self.getFc(settingnr)[lam], u, j)
145
+ axissum = getaxissum(self.getFc(settingnr)[lam], u, j, system)
138
146
 
139
- axissumnum = getaxissum(nhat, u, j)
147
+ axissumnum = getaxissum(nhat, u, j, system)
140
148
  idx = next(
141
149
  (
142
150
  i
@@ -146,7 +154,7 @@ def estimate_rates(self, lam, settingnr=None, verbose=False):
146
154
  None,
147
155
  )
148
156
 
149
- if verbose:
157
+ if verbosity > 5:
150
158
 
151
159
  y = np.cumsum(axissum[::-1])[::-1]
152
160
  ax.plot(
@@ -166,7 +174,7 @@ def estimate_rates(self, lam, settingnr=None, verbose=False):
166
174
  D[u][j] = Duj
167
175
  t[u][j] = -tuj / 2
168
176
 
169
- if verbose:
177
+ if verbosity > 5:
170
178
  x = np.arange(1, idx + 1)
171
179
  ax.plot(
172
180
  x,
@@ -174,10 +182,18 @@ def estimate_rates(self, lam, settingnr=None, verbose=False):
174
182
  linewidth=2,
175
183
  # color=j
176
184
  )
177
- if verbose:
178
- plt.figure(figsize=(12, 9))
179
- for ax in ps:
180
- plt.sca(ax)
181
- plt.show()
185
+ if verbosity > 5:
186
+ # plt.figure(figsize=(12, 9))
187
+ # for ax in ps:
188
+ # plt.sca(ax)
189
+ fig.savefig(
190
+ os.path.join(
191
+ "log",
192
+ "figures",
193
+ str(num).strip() + "_rates_" + str(u).strip() + ".png",
194
+ )
195
+ )
196
+ num = num + 1
197
+ plt.close(fig)
182
198
 
183
199
  return D, t
File without changes
File without changes
File without changes