docstr: Tests that CausalEstimator objects can be consistently retrieved from CausalEstimate and CausalModel objects.
docstr_tok: ["Tests","that","CausalEstimator","objects","can","be","consistently","retrieved","from","CausalEstimate","and","CausalModel","objects","."]
code: def test_causal_estimator_cache(self):
      """
      Tests that CausalEstimator objects can be consistently retrieved from CausalEstimate and CausalModel objects.
      """
      beta = 10
      num_samples = 100
      num_treatments = 1
      num_common_causes = 5
      data = dowhy.datasets.linear_dataset(
          beta=beta,
          num_common_causes=num_common_causes,
          num_samples=num_samples,
          num_treatments=num_treatments,
          treatment_is_binary=True,
      )
  
      model = CausalModel(
          data=data["df"],
          treatment=data["treatment_name"],
          outcome=data["outcome_name"],
          graph=data["gml_graph"],
          proceed_when_unidentifiable=True,
          test_significance=None,
      )
  
      identified_estimand = model.identify_effect(
          proceed_when_unidentifiable=True
      )
      methods = [
          "backdoor.linear_regression",
          "backdoor.propensity_score_matching",
      ]
      estimates = []
      estimates.append(
          model.estimate_effect(
              identified_estimand,
              method_name=methods[0],
              control_value=0,
              treatment_value=1,
          )
      )
      estimates.append(
          model.estimate_effect(
              identified_estimand,
              method_name=methods[1],
              control_value=0,
              treatment_value=1,
          )
      )
  
      # Default == operator tests if same object. If same object, don't need to check type.
      assert (estimates[0].estimator) == model.get_estimator(methods[0])
      assert (estimates[1].estimator) == model.get_estimator(methods[1])
      assert (estimates[0].estimator) != model.get_estimator(methods[1])
  
imports: import networkx
  import pandas
  import pytest
  from flaky import flaky
  from pytest import mark
  from sklearn import linear_model
  import dowhy
  import dowhy.datasets
  from dowhy import CausalModel
  from dowhy.causal_graph import CausalGraph
  from dowhy.gcm import ProbabilisticCausalModel, StructuralCausalModel
  from dowhy.utils.graph_operations import daggity_to_dot
label_desc: Use image node_id 13 for calling the TestCausalModel obj's underlying member method code with example usage: obj.test_causal_estimator_cache() without return types