Skip to content

Commit 73769b5

Browse files
Ignore notebooks.
1 parent ff9aec6 commit 73769b5

File tree

9 files changed

+1248
-24
lines changed

9 files changed

+1248
-24
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ docs_template/scripts/latex/*.png
4343

4444
# data
4545
*.sav
46+
47+
# notebooks
48+
work_maren/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ $ pytest
7171
```
7272

7373
It is important to run `pytask` and then `pytest`, such that the tests for the plots
74-
work.
74+
work. (It is normal that tests take up to 3 minutes to run)
7575

7676
If you encounter any issues, refer to the sections **"Preparing your system"** and
7777
**"How to get started on a second machine"** in this

inst/WORDLIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"base-usuario-20-enusc-2023.sav"
2+
https://www.dropbox.com/scl/fo/0oe4pz0epdx9az31s43rt/ACFL6YD4UZk6tIym7caipMU?rlkey=ds6wtw5ehatssgrkuqq29coeu&st=yw25julf&dl=0
23
fo
34
aa
45
aA

src/project_mbb/analysis/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def regression_perception_info(enusc_clean):
2727
def _set_category_values(enusc_clean):
2828
"""Encodes categorical values for perception and information source."""
2929
_fail_if_invalid_categories_perception(enusc_clean, perception_change_mapping)
30-
_fail_if_invalid_categories_source(enusc_clean, info_sources_mapping)
30+
_fail_if_invalid_categories_source(enusc_clean)
3131

3232
enusc_model_pre = pd.DataFrame()
3333
enusc_model_pre["crime_increase_perception_commune"] = enusc_clean[

src/project_mbb/data_management/clean_enusc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def clean_enusc(raw_enusc):
2828
"""
2929
enusc_filtered = _filter_enusc(raw_enusc, relevant_var)
3030
enusc_renamed = _rename_enusc(enusc_filtered, rename_mapping)
31-
enusc_mapped = _map_categories(enusc_renamed)
31+
enusc_mapped = _map_categories(enusc_renamed, map_category)
3232
enusc_filled = _fill_missing(enusc_mapped)
3333
enusc_dtypes = _set_data_types_not_mapped_var(enusc_filled)
3434
return enusc_dtypes

src/project_mbb/final/task_plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ def task_plot_perception(
2323
None (plots saved to path)
2424
"""
2525
enusc_clean = pd.read_pickle(enusc_clean)
26-
plot_crime_perception(enusc_clean)
26+
plot_crime_perception(enusc_clean, products)

tests/data_management/test_data_mgt_enusc.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
categories,
1414
floats,
1515
integers,
16+
map_category,
1617
relevant_var,
1718
rename_mapping,
1819
security_levels_mapping,
@@ -77,7 +78,7 @@ def test_rename_enusc(enusc_raw):
7778
def test_value_presence(enusc_raw_short, column, expected_value):
7879
enusc_filtered = _filter_enusc(enusc_raw_short, relevant_var)
7980
enusc_renamed = _rename_enusc(enusc_filtered, rename_mapping)
80-
enusc_category = _map_categories(enusc_renamed)
81+
enusc_category = _map_categories(enusc_renamed, map_category)
8182

8283
assert (
8384
expected_value in enusc_category[column].values
@@ -91,7 +92,7 @@ def test_value_presence(enusc_raw_short, column, expected_value):
9192
def test_column_is_categorical(enusc_raw_short, column):
9293
enusc_filtered = _filter_enusc(enusc_raw_short, relevant_var)
9394
enusc_renamed = _rename_enusc(enusc_filtered, rename_mapping)
94-
enusc_category = _map_categories(enusc_renamed)
95+
enusc_category = _map_categories(enusc_renamed, map_category)
9596

9697
assert isinstance(
9798
enusc_category[column].dtype, pd.CategoricalDtype
@@ -109,7 +110,7 @@ def test_value_presence_continued(enusc_raw_short, column, values_dict):
109110
errors = []
110111
enusc_filtered = _filter_enusc(enusc_raw_short, relevant_var)
111112
enusc_renamed = _rename_enusc(enusc_filtered, rename_mapping)
112-
enusc_category = _map_categories(enusc_renamed)
113+
enusc_category = _map_categories(enusc_renamed, map_category)
113114

114115
for value in enusc_category[column]:
115116
if pd.isna(value): # Skip missing values
@@ -125,14 +126,14 @@ def test_value_presence_continued(enusc_raw_short, column, values_dict):
125126
def test_fail_age_not_categorical(enusc_raw_short):
126127
enusc_filtered = _filter_enusc(enusc_raw_short, relevant_var)
127128
enusc_renamed = _rename_enusc(enusc_filtered, rename_mapping)
128-
enusc_category = _map_categories(enusc_renamed)
129+
enusc_category = _map_categories(enusc_renamed, map_category)
129130
assert isinstance(enusc_category["age"].dtype, pd.CategoricalDtype)
130131

131132

132133
def test_amount_of_missing(enusc_raw_short):
133134
enusc_filtered = _filter_enusc(enusc_raw_short, relevant_var)
134135
enusc_renamed = _rename_enusc(enusc_filtered, rename_mapping)
135-
enusc_category = _map_categories(enusc_renamed)
136+
enusc_category = _map_categories(enusc_renamed, map_category)
136137
enusc_filled = _fill_missing(enusc_category)
137138

138139
errors = []
@@ -168,7 +169,7 @@ def test_set_data_types_not_mapped_var(enusc_raw_short, column, expected_dtype):
168169
errors = []
169170
enusc_filtered = _filter_enusc(enusc_raw_short, relevant_var)
170171
enusc_renamed = _rename_enusc(enusc_filtered, rename_mapping)
171-
enusc_category = _map_categories(enusc_renamed)
172+
enusc_category = _map_categories(enusc_renamed, map_category)
172173
enusc_filled = _fill_missing(enusc_category)
173174
enusc_dtypes = _set_data_types_not_mapped_var(enusc_filled)
174175

@@ -202,7 +203,7 @@ def test_fail_set_data_types_not_mapped_var(
202203
errors = []
203204
enusc_filtered = _filter_enusc(enusc_raw_short, relevant_var)
204205
enusc_renamed = _rename_enusc(enusc_filtered, rename_mapping)
205-
enusc_category = _map_categories(enusc_renamed)
206+
enusc_category = _map_categories(enusc_renamed, map_category)
206207
enusc_filled = _fill_missing(enusc_category)
207208
enusc_dtypes = _set_data_types_not_mapped_var(enusc_filled)
208209

to_dos.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)