Skip to content

Commit ca157db

Browse files
committed
Fix failing tests
1 parent 7c106e2 commit ca157db

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

docs/source/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
author = 'John D. Jakeman'
2929

3030
# The full version, including alpha/beta/rc tags
31-
release = '1.0.2'
31+
release = '1.0.3'
3232

3333

3434
# -- General configuration ---------------------------------------------------

pyapprox/benchmarks/multifidelity_benchmarks.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ def _get_covariance_matrix(self) -> np.ndarray:
7373
for fi, mi in zip(self._flat_funs, means):
7474
jj = 0
7575
for fj, mj in zip(self._flat_funs, means):
76-
cov[ii, jj] = ((fi(quad_xx)-mi)*(fj(quad_xx)-mj)).dot(quad_ww)
76+
cov[ii, jj] = (
77+
(fi(quad_xx)-mi)*(fj(quad_xx)-mj)).dot(quad_ww).item()
7778
jj += 1
7879
ii += 1
7980
return cov
@@ -151,7 +152,7 @@ def covariance_of_centered_values_kronker_product(self) -> np.ndarray:
151152
quad_cov = self._V_fun(
152153
jj1, kk1, ll1, jj2, kk2, ll2,
153154
means, flat_covs, xx).dot(ww)
154-
est_cov[cnt1, cnt2] = quad_cov
155+
est_cov[cnt1, cnt2] = quad_cov.item()
155156
cnt2 += 1
156157
cnt1 += 1
157158
return np.array(est_cov)
@@ -177,7 +178,7 @@ def covariance_of_mean_and_variance_estimators(self) -> np.ndarray:
177178
for ll in range(self.nqoi):
178179
quad_cov = self._B_fun(
179180
ii, jj, kk, ll, means, flat_covs, xx).dot(ww)
180-
est_cov[ii, cnt] = quad_cov
181+
est_cov[ii, cnt] = quad_cov.item()
181182
cnt += 1
182183
return np.array(est_cov)
183184

pyapprox/interface/tests/test_wrappers.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ def test_work_tracking_model(self):
100100
timer_model, max_eval_concurrency, base_model=base_model,
101101
assert_omp=False)
102102
# pool_model = timer_model
103-
model = WorkTrackingModel(pool_model, base_model)
103+
model = WorkTrackingModel(
104+
pool_model, base_model, enforce_timer_model=False)
104105

105106
samples = np.random.normal(0, 1, (nvars, nsamples))
106107
values = model(samples)
@@ -109,9 +110,6 @@ def test_work_tracking_model(self):
109110
assert np.allclose(values, exact_values)
110111
values, grads = model(samples, return_grad=True)
111112
assert np.allclose(values, exact_values)
112-
print(grads)
113-
print(np.vstack(grads))
114-
print(exact_grads)
115113
assert np.allclose(np.vstack(grads), exact_grads)
116114

117115
def test_pool_model(self):

pyapprox/multifidelity/acv.py

+1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ def __init__(self, stat, costs, opt_criteria=None):
192192
self._npartitions = 1
193193

194194
def _check_cov(self, cov, costs):
195+
costs = np.atleast_1d(costs)
195196
if costs.ndim != 1:
196197
raise ValueError("costs is not a 1D iterable")
197198
nmodels = len(costs)

pyapprox/multifidelity/tests/test_multioutput_monte_carlo.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,10 @@ def test_best_model_subset_estimator(self):
495495
target_cost = 10
496496
est._save_candidate_estimators = True
497497
np.set_printoptions(linewidth=1000)
498-
print(cov, "C###")
499498
est.allocate_samples(target_cost, {"verbosity": 1, "nprocs": 1})
500499

501500
criteria = np.array(
502-
[e._optimized_criteria for e in est._candidate_estimators])
501+
[e[0]._optimized_criteria for e in est._candidate_estimators])
503502
assert np.allclose(criteria.min(), est._optimized_criteria)
504503

505504
ntrials, max_eval_concurrency = int(1e3), 1

pyapprox/surrogates/interp/tests/test_sparse_grid.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,8 @@ def test_online_cost_function(self):
15761576
# function of polynomial model that just fixes cost for each level of
15771577
# the multilevel model
15781578
timer_model = base_model
1579-
model = WorkTrackingModel(timer_model, base_model, 1)
1579+
model = WorkTrackingModel(
1580+
timer_model, base_model, 1, enforce_timer_model=False)
15801581

15811582
ranges = [2*(-1)**(ii+1) for ii in range(2*num_vars)]
15821583
canonical_ranges = [(-1)**(ii+1) for ii in range(2*num_vars)]

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def no_cythonize(extensions, **_ignore):
3333

3434
setuptools.setup(
3535
name="pyapprox",
36-
version="1.0.2",
36+
version="1.0.3",
3737
author="John D. Jakeman",
3838
author_email="[email protected]",
3939
description="High-dimensional function approximation and estimation",
@@ -97,7 +97,7 @@ def no_cythonize(extensions, **_ignore):
9797

9898
# To test pyapprox on test.pypi use the following.
9999
# Note the use of extra-index-url
100-
# python -m pip install --extra-index-url=https://test.pypi.org/simple/ pyapprox==1.0.2
100+
# python -m pip install --extra-index-url=https://test.pypi.org/simple/ pyapprox==1.0.3
101101

102102
# To build wheel locally use
103103
# python -m build

0 commit comments

Comments
 (0)