Skip to content

Commit 31efbfe

Browse files
add command line args + codacy
1 parent 122f68d commit 31efbfe

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

causal_testing/json_front/json_class.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,13 @@ def get_args() -> argparse.Namespace:
232232
"-f", help="if included, the script will stop if a test fails", action="store_true")
233233
parser.add_argument(
234234
"--log_path", help="Specify a directory to change the location of the log file", default=".")
235+
parser.add_argument(
236+
"--data_path", help="Specify path to file containing runtime data", required=True
237+
)
238+
parser.add_argument(
239+
"--dag_path", help="Specify path to file containing the DAG, normally a .dot file", required=True
240+
)
241+
parser.add_argument(
242+
"--json_path", help="Specify path to file containing JSON tests, normally a .json file", required=True
243+
)
235244
return parser.parse_args()

examples/poisson/run_causal_tests.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
import logging
22
import numpy as np
33
import pandas as pd
44
import scipy
@@ -10,10 +10,6 @@
1010
from causal_testing.testing.estimators import Estimator
1111
from causal_testing.specification.scenario import Scenario
1212
from causal_testing.specification.variable import Input, Output, Meta
13-
import logging
14-
data_path = "data.csv"
15-
dag_path = "dag.dot"
16-
json_path = "causal_tests.json"
1713

1814

1915
class WidthHeightEstimator(LinearRegressionEstimator):
@@ -147,10 +143,9 @@ def logger_setup():
147143
"LinearRegressionEstimator": LinearRegressionEstimator,
148144
}
149145

150-
151146
# Create input structure required to create a modelling scenario
152-
modelling_inputs = [Input(i['name'], i['type'], distributions[i['distribution']]) for i in inputs] +\
153-
[Output(i['name'], i['type']) for i in outputs] +\
147+
modelling_inputs = [Input(i['name'], i['type'], distributions[i['distribution']]) for i in inputs] + \
148+
[Output(i['name'], i['type']) for i in outputs] + \
154149
[Meta(i['name'], i['type'], populates[i['populate']]) for i in metas] if metas else list()
155150

156151
# Create modelling scenario to access z3 variable mirrors
@@ -181,9 +176,9 @@ def add_modelling_assumptions(self, estimation_model: Estimator):
181176

182177
if __name__ == "__main__":
183178
args = MyJsonUtility.get_args()
184-
185179
json_utility = MyJsonUtility(args.log_path) # Create an instance of the extended JsonUtility class
186-
json_utility.set_path(json_path, dag_path, data_path) # Set the path to the data.csv, dag.dot and causal_tests.json file
180+
json_utility.set_path(args.json_path, args.dag_path,
181+
args.data_path) # Set the path to the data.csv, dag.dot and causal_tests.json file
187182

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

0 commit comments

Comments
 (0)