Skip to content

Commit

Permalink
Undoing expansion definition. Modifying deepcopy
Browse files Browse the repository at this point in the history
  • Loading branch information
danielandresarcones committed Sep 16, 2024
1 parent a960824 commit b3ea4f5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions docs/examples/bias.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,7 @@ class LinearModel(ForwardModelBase):
def __init__(self, name):
super().__init__(name)
self.pce_order = 1
self.bias_dist = chaospy.Normal(0.0, 1.0)

# generate the polynomial chaos expansion
self.expansion = chaospy.generate_expansion(self.pce_order, self.bias_dist)


def interface(self):
self.parameters = ["a", "b"]
self.input_sensors = Sensor("x")
Expand All @@ -116,6 +112,10 @@ def response(self, inp: dict) -> dict:

# define the distribution for the bias term
b_dist = chaospy.Normal(0.0, b)

# generate the polynomial chaos expansion
expansion = chaospy.generate_expansion(self.pce_order, bias_dist)

# generate quadrature nodes and weights
sparse_quads = chaospy.generate_quadrature(
self.pce_order, b_dist, rule="Gaussian"
Expand All @@ -127,7 +127,7 @@ def response(self, inp: dict) -> dict:

# fit the polynomial chaos expansion
fitted_sparse = chaospy.fit_quadrature(
self.expansion, sparse_quads[0], sparse_quads[1], sparse_evals
expansion, sparse_quads[0], sparse_quads[1], sparse_evals
)
return {"y": fitted_sparse, "dist": b_dist}

Expand Down
2 changes: 1 addition & 1 deletion probeye/inference/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(
):

# attributes from arguments
self.problem = cp.deepcopy(problem)
self.problem = cp.copy(problem)
self.show_progress = show_progress
self.seed = seed

Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/inference/bias/test_likelihood_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ def __init__(self, name):
super().__init__(name)

self.pce_order = 1
self.b_dist = chaospy.Normal(0.0, 1.0)
self.expansion = chaospy.generate_expansion(self.pce_order, self.b_dist)

def interface(self):
self.parameters = ["a", "b"]
Expand All @@ -49,6 +47,8 @@ def response(self, inp: dict) -> dict:

# define the distribution for the bias term
b_dist = chaospy.Normal(0.0, b)
expansion = chaospy.generate_expansion(self.pce_order, b_dist)

# generate quadrature nodes and weights
sparse_quads = chaospy.generate_quadrature(
self.pce_order, b_dist, rule="Gaussian"
Expand All @@ -59,7 +59,7 @@ def response(self, inp: dict) -> dict:
)
# fit the polynomial chaos expansion
fitted_sparse = chaospy.fit_quadrature(
self.expansion, sparse_quads[0], sparse_quads[1], sparse_evals
expansion, sparse_quads[0], sparse_quads[1], sparse_evals
)
return {"y": fitted_sparse, "dist": b_dist}

Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/inference/bias/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ def __init__(self, name):
super().__init__(name)

self.pce_order = 1
self.b_dist = chaospy.Normal(0.0, 1.0)
self.expansion = chaospy.generate_expansion(self.pce_order, self.b_dist)

def interface(self):
self.parameters = ["a", "b"]
Expand All @@ -45,6 +43,8 @@ def response(self, inp: dict) -> dict:

# define the distribution for the bias term
b_dist = chaospy.Normal(0.0, b)
expansion = chaospy.generate_expansion(self.pce_order, b_dist)

# generate quadrature nodes and weights
sparse_quads = chaospy.generate_quadrature(
self.pce_order, b_dist, rule="Gaussian"
Expand All @@ -55,7 +55,7 @@ def response(self, inp: dict) -> dict:
)
# fit the polynomial chaos expansion
fitted_sparse = chaospy.fit_quadrature(
self.expansion, sparse_quads[0], sparse_quads[1], sparse_evals
expansion, sparse_quads[0], sparse_quads[1], sparse_evals
)
return {"y": fitted_sparse, "dist": b_dist}

Expand Down

0 comments on commit b3ea4f5

Please sign in to comment.