def setUp(self): # Default model self.df_wrong = pd.DataFrame(data={"z": [0.0, 1.0]}) # 2D identity model with permuted df inputs domain_2d = gr.Domain(bounds={"x0": [-1.0, +1.0], "x1": [0.0, 1.0]}) marginals = {} marginals["x0"] = gr.MarginalNamed(d_name="uniform", d_param={ "loc": -1, "scale": 2 }) marginals["x1"] = gr.MarginalNamed( sign=-1, d_name="uniform", d_param={ "loc": 0, "scale": 1 }, ) self.model_2d = gr.Model( functions=[ gr.Function(lambda x: [x[0], x[1]], ["x0", "x1"], ["y0", "y1"], "test", 0), ], domain=domain_2d, density=gr.Density(marginals=marginals), ) self.df_2d = pd.DataFrame(data={"x1": [0.0], "x0": [+1.0]}) self.res_2d = self.model_2d.evaluate_df(self.df_2d) self.df_median_in = pd.DataFrame({"x0": [0.5], "x1": [0.5]}) self.df_median_out = pd.DataFrame({"x0": [0.0], "x1": [0.5]}) self.model_3d = gr.Model( functions=[ gr.Function(lambda x: x[0] + x[1] + x[2], ["x", "y", "z"], ["f"], "test", 0) ], density=gr.Density(marginals=marginals), ) ## Timing check self.model_slow = gr.Model(functions=[ gr.Function(lambda x: x, ["x0"], ["y0"], "f0", 1), gr.Function(lambda x: x, ["x0"], ["y1"], "f1", 1), ])
def setUp(self): # 2D identity model with permuted df inputs domain_2d = gr.Domain(bounds={"x": [-1.0, +1], "y": [0.0, 1.0]}) marginals = {} marginals["x"] = gr.MarginalNamed( d_name="uniform", d_param={"loc": -1, "scale": 2} ) marginals["y"] = gr.MarginalNamed( sign=-1, d_name="uniform", d_param={"loc": 0, "scale": 1} ) self.model_2d = gr.Model( functions=[ gr.Function(lambda x: [x[0], x[1]], ["x", "y"], ["f", "g"], "test", 0) ], domain=domain_2d, density=gr.Density( marginals=marginals, copula=gr.CopulaIndependence(var_rand=["x"]) ), ) ## Correct results self.df_2d_nominal = pd.DataFrame( data={"x": [0.0], "y": [0.5], "f": [0.0], "g": [0.5]} ) self.df_2d_grad = pd.DataFrame( data={"Df_Dx": [1.0], "Dg_Dx": [0.0], "Df_Dy": [0.0], "Dg_Dy": [1.0]} ) self.df_2d_qe = pd.DataFrame( data={"x": [0.0], "y": [0.1], "f": [0.0], "g": [0.1]} )
def setUp(self): self.fcn = gr.Function(lambda x: x, ["x"], ["x"], "test", 0) self.fcn_vec = gr.FunctionVectorized(lambda df: df, ["x"], ["x"], "test", 0) self.df = pd.DataFrame({"x": [0]}) self.df_wrong = pd.DataFrame({"z": [0]})