Skip to content

Commit f5871b9

Browse files
change path method
1 parent fd070db commit f5871b9

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

causal_testing/json_front/json_class.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,20 @@ def __init__(self):
4646
self.modelling_scenario = None
4747
self.causal_specification = None
4848

49-
def set_path(self, directory_path: Path):
49+
def set_path(self, json_path: str, dag_path: str, data_path: str):
5050
"""
5151
Takes a path of the directory containing all scenario specific files and creates individual paths for each file
52-
:param directory_path: pathlib.Path pointing towards directory containing all scenario specific user code and files
52+
:param json_path: string path representation to .json file containing test specifications
53+
:param dag_path: string path representation to the .dot file containing the Causal DAG
54+
:param data_path: string path representation to the data file
5355
:returns:
54-
- json_path - path to causal_tests.json
55-
- dag_path - path to dag.dot
56-
- data_path - path to scenario data, expected in data.csv
56+
- json_path -
57+
- dag_path -
58+
- data_path -
5759
"""
58-
self.json_path = directory_path.joinpath("causal_tests.json")
59-
self.dag_path = directory_path.joinpath("dag.dot")
60-
self.data_path = directory_path.joinpath("data.csv")
60+
self.json_path = Path(json_path)
61+
self.dag_path = Path(dag_path)
62+
self.data_path = Path(data_path)
6163

6264
def set_variables(self, inputs: dict, outputs: dict, metas: dict, distributions: dict, populates: dict):
6365
""" Populate the Causal Variables

examples/poisson/causal_test_setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
from causal_testing.specification.scenario import Scenario
1414
from causal_testing.specification.variable import Input, Output, Meta
1515

16+
data_path = "data.csv"
17+
dag_path = "dag.dot"
18+
json_path = "causal_tests.json"
19+
20+
1621
class WidthHeightEstimator(LinearRegressionEstimator):
1722
"""
1823
Extension of LinearRegressionEstimator class to include scenario specific user code
@@ -104,8 +109,6 @@ def get_args() -> argparse.Namespace:
104109
description="A script for parsing json config files for the Causal Testing Framework")
105110
parser.add_argument("-f", help="if included, the script will stop if a test fails",
106111
action="store_true")
107-
parser.add_argument("--directory_path", help="path to the json file containing the causal tests",
108-
default="causal_tests.json", type=Path)
109112
return parser.parse_args()
110113

111114

@@ -188,7 +191,7 @@ def add_modelling_assumptions(self, estimation_model: Estimator):
188191
args = get_args()
189192

190193
json_utility = MyJsonUtility() # Create an instance of the extended JsonUtility class
191-
json_utility.set_path(args.directory_path) # Set the path to the data.csv, dag.dot and causal_tests.json file
194+
json_utility.set_path(json_path, dag_path, data_path) # Set the path to the data.csv, dag.dot and causal_tests.json file
192195

193196
# Load the Causal Variables into the JsonUtility class ready to be used in the tests
194197
json_utility.set_variables(inputs, outputs, metas, distributions, populates)

0 commit comments

Comments
 (0)