pyANOVAapprox 2.0.2__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.2 → pyanovaapprox-2.0.3}/PKG-INFO +1 -1
  2. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/pyproject.toml +1 -1
  3. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/simpleTest/exampleNonPeriodic.py +3 -1
  4. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/simpleTest/exampleWavelet.py +1 -1
  5. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/src/pyANOVAapprox/approx.py +33 -18
  6. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/src/pyANOVAapprox/bandwidth.py +23 -17
  7. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/.github/workflows/ci.yml +0 -0
  8. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/.github/workflows/documentation.yml +0 -0
  9. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/.github/workflows/format.yml +0 -0
  10. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/.github/workflows/release.yml +0 -0
  11. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/.gitignore +0 -0
  12. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/LICENSE +0 -0
  13. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/README.md +0 -0
  14. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/docs/Makefile +0 -0
  15. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/docs/source/Analysis.rst +0 -0
  16. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/docs/source/Approximation.rst +0 -0
  17. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/docs/source/Errors.rst +0 -0
  18. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/docs/source/conf.py +0 -0
  19. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/docs/source/index.rst +0 -0
  20. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/simpleTest/TestFunctionPeriodic.py +0 -0
  21. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/simpleTest/exampleAutoapproximate.py +0 -0
  22. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/simpleTest/exampleCheb.py +0 -0
  23. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/simpleTest/exampleClassification.py +0 -0
  24. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/simpleTest/examplePeriodic.py +0 -0
  25. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/src/pyANOVAapprox/__init__.py +2 -2
  26. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/src/pyANOVAapprox/analysis.py +0 -0
  27. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/src/pyANOVAapprox/errors.py +0 -0
  28. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/src/pyANOVAapprox/fista.py +0 -0
  29. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/src/pyANOVAapprox/trafos.py +0 -0
  30. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/tests/TestFunctionCheb.py +0 -0
  31. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/tests/TestFunctionPeriodic.py +0 -0
  32. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/tests/cheb_fista.py +0 -0
  33. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/tests/cheb_lsqr.py +0 -0
  34. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/tests/per_fista.py +0 -0
  35. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/tests/per_lsqr.py +0 -0
  36. {pyanovaapprox-2.0.2 → pyanovaapprox-2.0.3}/tests/run_tests.py +0 -0
  37. {pyanovaapprox-2.0.2 → 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.2
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.2"
7
+ version = "2.0.3"
8
8
  authors = [
9
9
  { name="Felix Wirth", email="fwi012001@gmail.com" },
10
10
  ]
@@ -150,7 +150,9 @@ print(
150
150
  ################################################
151
151
 
152
152
  Umask = np.append(np.array([True]), gsis > 1e-2)
153
- U = [ads.getSetting().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
@@ -82,7 +82,7 @@ print("Total number of used parameters = " + str(len(anova_model.fc[lambdas[0]].
82
82
 
83
83
  ### Do sensitivity analysis ####
84
84
  anova_model.get_GSI(
85
- lam=0.0
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
87
  anova_model.get_GSI(lam=0.0, Dict=true)
88
88
 
@@ -187,7 +187,7 @@ class approx:
187
187
  ):
188
188
 
189
189
  self.X = X
190
-
190
+
191
191
  if X.shape[0] != y.shape[0]:
192
192
  raise ValueError("X and y have different lengths.")
193
193
 
@@ -401,12 +401,12 @@ class approx:
401
401
 
402
402
  D = dict([(u, tuple([1.0] * len(u))) for u in setting.U])
403
403
  t = dict([(u, tuple([1.0] * len(u))) for u in setting.U])
404
-
405
- if verbosity>3:
404
+
405
+ if verbosity > 3:
406
406
  if not os.path.exists("log"):
407
407
  os.mkdir("log")
408
- with open('log/log.csv', 'w', newline='') as csvfile:
409
- csv.writer(csvfile, delimiter=',').writerow(["it"] + setting.U)
408
+ with open("log/log.csv", "w", newline="") as csvfile:
409
+ csv.writer(csvfile, delimiter=",").writerow(["it"] + setting.U)
410
410
 
411
411
  for idx in range(maxiter):
412
412
  if verbosity > 0:
@@ -423,11 +423,13 @@ class approx:
423
423
  if verbosity > 0:
424
424
  for i in setting.U:
425
425
  print("bw in", str(i), ":", bw[i])
426
- #print("bw in iteration", str(idx + 1), "are", str(bw))
426
+ # print("bw in iteration", str(idx + 1), "are", str(bw))
427
427
  print()
428
428
  if verbosity > 3:
429
- with open('log/log.csv', 'a', newline='') as csvfile:
430
- csv.writer(csvfile, delimiter=',').writerow(["bw in it"+str(idx+1)] + [str(bw[i]) for i in setting.U])
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
+ )
431
433
  self.approximate(
432
434
  lam=lam,
433
435
  solver=solver,
@@ -440,22 +442,33 @@ class approx:
440
442
  D, t = self.estimate_rates(lam=lam, verbosity=verbosity)
441
443
  if verbosity > 1:
442
444
  for i in setting.U:
443
- print("estimated rates for", str(i), ": D = ", str(D[i]), "and t = ", str(t[i]) )
445
+ print(
446
+ "estimated rates for",
447
+ str(i),
448
+ ": D = ",
449
+ str(D[i]),
450
+ "and t = ",
451
+ str(t[i]),
452
+ )
444
453
  print()
445
-
446
- #print(
454
+
455
+ # print(
447
456
  # "estimated rates in iteration",
448
457
  # str(idx + 1),
449
458
  # "are D =",
450
459
  # str(D),
451
460
  # "and t =",
452
461
  # str(t),
453
- #)
462
+ # )
454
463
  if verbosity > 3:
455
- with open('log/log.csv', 'a', newline='') as csvfile:
456
- wr = csv.writer(csvfile, delimiter=',')
457
- wr.writerow(["D in it"+str(idx+1)] + [str(D[i]) for i in setting.U])
458
- wr.writerow(["t in it"+str(idx+1)] + [str(t[i]) for i in setting.U])
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
+ )
459
472
  return D, t
460
473
 
461
474
  def autoapproximate(
@@ -567,9 +580,11 @@ class approx:
567
580
  Xt = transformX(X, setting.basis)
568
581
 
569
582
  if self.getSetting(settingnr).basis == "per":
570
- values = np.zeros((Xt.shape[0], len(self.setting[settingnr].U)), "complex")
583
+ values = np.zeros(
584
+ (Xt.shape[0], len(self.getSetting(settingnr).U)), "complex"
585
+ )
571
586
  else:
572
- 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")
573
588
 
574
589
  trafo = GroupedTransform(
575
590
  system=gt_systems[setting.basis],
@@ -5,11 +5,11 @@ 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
 
@@ -37,7 +37,7 @@ def compute_bandwidth(B, D, t):
37
37
  us = set(D.keys()) - {()}
38
38
  bw = {u: [6] * len(u) for u in us}
39
39
  bw[()] = []
40
-
40
+
41
41
  minfreqs = sum(math.prod((bw[u][j] - 1) for j in range(len(u))) for u in us)
42
42
  if B < minfreqs:
43
43
  raise ValueError(f"Budget too small: {B} < {minfreqs}")
@@ -123,19 +123,19 @@ def estimate_rates(self, lam, settingnr=None, verbosity=0):
123
123
 
124
124
  mcl = np.exp(most_common_value(np.log(abs(self.getFc(settingnr)[lam].data))))
125
125
  threshold = 100 * mcl**2
126
-
127
- if verbosity>5:
128
- if not os.path.exists(os.path.join("log","figures")):
129
- os.mkdir(os.path.join("log","figures"))
126
+
127
+ if verbosity > 5:
128
+ if not os.path.exists(os.path.join("log", "figures")):
129
+ os.mkdir(os.path.join("log", "figures"))
130
130
  num = 0
131
-
131
+
132
132
  system = self.getTrafo(settingnr).system
133
133
 
134
134
  for u in us:
135
135
  if len(u) == 0:
136
136
  continue
137
137
 
138
- if verbosity>5:
138
+ if verbosity > 5:
139
139
  fig, ax = plt.subplots()
140
140
  ax.set_xscale("log")
141
141
  ax.set_yscale("log")
@@ -154,7 +154,7 @@ def estimate_rates(self, lam, settingnr=None, verbosity=0):
154
154
  None,
155
155
  )
156
156
 
157
- if verbosity>5:
157
+ if verbosity > 5:
158
158
 
159
159
  y = np.cumsum(axissum[::-1])[::-1]
160
160
  ax.plot(
@@ -174,7 +174,7 @@ def estimate_rates(self, lam, settingnr=None, verbosity=0):
174
174
  D[u][j] = Duj
175
175
  t[u][j] = -tuj / 2
176
176
 
177
- if verbosity>5:
177
+ if verbosity > 5:
178
178
  x = np.arange(1, idx + 1)
179
179
  ax.plot(
180
180
  x,
@@ -182,12 +182,18 @@ def estimate_rates(self, lam, settingnr=None, verbosity=0):
182
182
  linewidth=2,
183
183
  # color=j
184
184
  )
185
- if verbosity>5:
186
- #plt.figure(figsize=(12, 9))
187
- #for ax in ps:
185
+ if verbosity > 5:
186
+ # plt.figure(figsize=(12, 9))
187
+ # for ax in ps:
188
188
  # plt.sca(ax)
189
- fig.savefig(os.path.join("log","figures", str(num).strip()+ "_rates_" + str(u).strip() + ".png"))
189
+ fig.savefig(
190
+ os.path.join(
191
+ "log",
192
+ "figures",
193
+ str(num).strip() + "_rates_" + str(u).strip() + ".png",
194
+ )
195
+ )
190
196
  num = num + 1
191
- plt.close(fig)
197
+ plt.close(fig)
192
198
 
193
199
  return D, t
File without changes
File without changes
File without changes
@@ -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
 
@@ -8,8 +10,6 @@ from pyGroupedTransforms import *
8
10
  from scipy.optimize import bisect
9
11
  from scipy.sparse.linalg import lsqr
10
12
  from scipy.special import erf
11
- import csv
12
- import os
13
13
 
14
14
  # from sklearn.metrics import roc_auc_score
15
15