Skip to content

Commit c20899d

Browse files
committed
Merge branch 'temporal-shenanigans' of github.com:CITCOM-project/CausalTestingFramework into temporal-shenanigans
2 parents 6ceef1a + fbfe76a commit c20899d

File tree

6 files changed

+46
-44
lines changed

6 files changed

+46
-44
lines changed

.github/workflows/ci-tests-drafts.yaml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,22 @@ jobs:
1515
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
1616
python-version: ["3.9", "3.10", "3.11", "3.12"]
1717
steps:
18-
- uses: actions/checkout@v2
19-
- name: Set up Python using Miniconda
20-
uses: conda-incubator/setup-miniconda@v2
21-
with:
22-
auto-update-conda: true
23-
python-version: ${{ matrix.python-version }}
24-
- name: Install package and dependencies
25-
run: |
26-
python --version
18+
- uses: actions/checkout@v4
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
2726
pip install -e .
2827
pip install -e .[test]
2928
pip install pytest pytest-cov
30-
shell: bash -l {0}
31-
- name: Test with pytest
32-
run: |
33-
pytest --cov=causal_testing --cov-report=xml
34-
shell: bash -l {0}
35-
- name: "Upload coverage to Codecov"
36-
uses: codecov/codecov-action@v2
37-
with:
38-
fail_ci_if_error: true
39-
token: ${{ secrets.CODECOV_TOKEN }}
29+
- name: Test with pytest
30+
run: |
31+
pytest --cov=causal_testing --cov-report=xml
32+
- name: "Upload coverage to Codecov"
33+
uses: codecov/codecov-action@v2
34+
with:
35+
fail_ci_if_error: true
36+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/ci-tests.yaml

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,23 @@ jobs:
2020
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
2121
python-version: ["3.9", "3.10", "3.11", "3.12"]
2222
steps:
23-
- uses: actions/checkout@v2
24-
- name: Set up Python using Miniconda
25-
uses: conda-incubator/setup-miniconda@v2
26-
with:
27-
auto-update-conda: true
28-
python-version: ${{ matrix.python-version }}
29-
- name: Install package and dependencies
30-
run: |
23+
- uses: actions/checkout@v4
24+
- name: Set up Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
- name: Install dependencies
29+
run: |
3130
python --version
31+
python -m pip install --upgrade pip
3232
pip install -e .
3333
pip install -e .[test]
3434
pip install pytest pytest-cov
35-
shell: bash -l {0}
36-
- name: Test with pytest
37-
run: |
38-
pytest --cov=causal_testing --cov-report=xml
39-
shell: bash -l {0}
40-
- name: "Upload coverage to Codecov"
41-
uses: codecov/codecov-action@v2
42-
with:
43-
fail_ci_if_error: true
44-
token: ${{ secrets.CODECOV_TOKEN }}
35+
- name: Test with pytest
36+
run: |
37+
pytest --cov=causal_testing --cov-report=xml
38+
- name: "Upload coverage to Codecov"
39+
uses: codecov/codecov-action@v2
40+
with:
41+
fail_ci_if_error: true
42+
token: ${{ secrets.CODECOV_TOKEN }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ system-under-test that is expected to cause a change to some output(s).
2525
## Installation
2626

2727
### Requirements
28-
- Python 3.9 and 3.10 only.
28+
- Python 3.9, 3.10, 3.11 and 3.12
2929

3030
- Microsoft Visual C++ 14.0+ (Windows only).
3131

causal_testing/surrogate/causal_surrogate_assisted.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
from abc import ABC, abstractmethod
44
from dataclasses import dataclass
55
from typing import Callable
6-
6+
import pandas as pd
77
from causal_testing.data_collection.data_collector import ObservationalDataCollector
88
from causal_testing.specification.causal_specification import CausalSpecification
99
from causal_testing.testing.base_test_case import BaseTestCase
1010
from causal_testing.testing.estimators import CubicSplineRegressionEstimator
1111

12-
1312
@dataclass
1413
class SimulationResult:
1514
"""Data class holding the data and result metadata of a simulation"""
@@ -18,6 +17,11 @@ class SimulationResult:
1817
fault: bool
1918
relationship: str
2019

20+
def to_dataframe(self) -> pd.DataFrame:
21+
"""Convert the simulation result data to a pandas DataFrame"""
22+
data_as_lists = {k: v if isinstance(v, list) else [v] for k,v in self.data.items()}
23+
return pd.DataFrame(data_as_lists)
24+
2125

2226
class SearchAlgorithm(ABC): # pylint: disable=too-few-public-methods
2327
"""Class to be inherited with the search algorithm consisting of a search function and the fitness function of the
@@ -87,14 +91,14 @@ def execute(
8791

8892
self.simulator.startup()
8993
test_result = self.simulator.run_with_config(candidate_test_case)
94+
test_result_df = test_result.to_dataframe()
9095
self.simulator.shutdown()
9196

9297
if custom_data_aggregator is not None:
9398
if data_collector.data is not None:
9499
data_collector.data = custom_data_aggregator(data_collector.data, test_result.data)
95100
else:
96-
data_collector.data = data_collector.data.append(test_result.data, ignore_index=True)
97-
101+
data_collector.data = pd.concat([data_collector.data, test_result_df], ignore_index=True)
98102
if test_result.fault:
99103
print(
100104
f"Fault found between {surrogate.treatment} causing {surrogate.outcome}. Contradiction with "

docs/source/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Getting started
33

44
Requirements
55
---------------
6-
* Python 3.9 and 3.10 only.
6+
* Python 3.9, 3.10, 3.11 and 3.12
77
* `Microsoft Visual C++ <https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist>`_ 14.0+ (Windows only).
88

99

tests/surrogate_tests/test_causal_surrogate_assisted.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,7 @@ def shutdown(self):
231231
pass
232232

233233
def data_double_aggregator(data, new_data):
234-
return data.append(new_data, ignore_index=True).append(new_data, ignore_index=True)
234+
"""Previously used data.append(new_data), however, pandas version >2 requires pd.concat() since append is now a private method.
235+
Converting new_data to a pd.DataFrame is required to use pd.concat(). """
236+
new_data = pd.DataFrame([new_data])
237+
return pd.concat([data, new_data, new_data], ignore_index=True)

0 commit comments

Comments
 (0)