Repository: soda-inria/hazardous

Issue:
make_synthetic_competing_weibull function returns error with default parameters
The dataset generating function [make_synthetic_competing_weibull](https://github.com/soda-inria/hazardous/blob/main/hazardous/data/_competing_weibull.py#L35) with default parameters (when `return_X_y=False`):
```python
make_synthetic_competing_weibull()
```
outputs the following error:
```python-traceback
[...]
--> 104 return Bunch(data=frame[X.columns], target=X[y.columns], frame=frame)
[...]
KeyError: "None of [Index(['event', 'duration'], dtype='object')] are in the [columns]"
```

Hints from issue comments:
@jovan-stojanovic: Sorry, didn't see it was WIP in #25 

Solution patch:
diff --git a/hazardous/data/_competing_weibull.py b/hazardous/data/_competing_weibull.py
index 2b15f9c..1a5f6b9 100644
--- a/hazardous/data/_competing_weibull.py
+++ b/hazardous/data/_competing_weibull.py
@@ -101,4 +101,4 @@ def make_synthetic_competing_weibull(
         return X, y
 
     frame = pd.concat([X, y], axis=1)
-    return Bunch(data=frame[X.columns], target=X[y.columns], frame=frame)
+    return Bunch(data=frame[X.columns], target=frame[y.columns], frame=frame)


Test patch:
diff --git a/hazardous/data/tests/test_competing_weibull.py b/hazardous/data/tests/test_competing_weibull.py
index 594dbe3..1dd4dd0 100644
--- a/hazardous/data/tests/test_competing_weibull.py
+++ b/hazardous/data/tests/test_competing_weibull.py
@@ -1,4 +1,5 @@
 import pytest
+from numpy.testing import assert_array_equal
 from sklearn.dummy import DummyClassifier, DummyRegressor
 from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
 from sklearn.model_selection import cross_val_score
@@ -121,3 +122,22 @@ def test_competing_weibull_with_censoring(seed):
     # Check that high scale censoring keeps approximate balance between events:
     event_counts = y_high_scale.query("event != 0")["event"].value_counts().sort_index()
     assert event_counts.max() < 2 * event_counts.min(), event_counts
+
+
+@pytest.mark.parametrize("seed", range(3))
+def test_make_synthetic_competing_weibull_return(seed):
+    n_samples = 1000
+    df = make_synthetic_competing_weibull(
+        n_events=3,
+        n_samples=n_samples,
+        return_X_y=False,
+        random_state=seed,
+    )
+    X, y = make_synthetic_competing_weibull(
+        n_events=3,
+        n_samples=n_samples,
+        return_X_y=True,
+        random_state=seed,
+    )
+    assert_array_equal(df["data"], X)
+    assert_array_equal(df["target"], y)