Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RSE 23 Group Assignment Shervud Pitawanik Franz
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Niklas Franz
RSE 23 Group Assignment Shervud Pitawanik Franz
Commits
8ec76555
Commit
8ec76555
authored
1 year ago
by
Sortofamudkip
Browse files
Options
Downloads
Patches
Plain Diff
bool param checks
parent
0cdb625d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test_dataset.py
+43
-0
43 additions, 0 deletions
src/test_dataset.py
with
43 additions
and
0 deletions
src/test_dataset.py
+
43
−
0
View file @
8ec76555
...
@@ -6,6 +6,7 @@ from Dataset import Dataset
...
@@ -6,6 +6,7 @@ from Dataset import Dataset
import
pandas
as
pd
import
pandas
as
pd
from
pathlib
import
Path
from
pathlib
import
Path
import
pytest
import
pytest
import
numpy
as
np
this_file_dir
=
Path
(
__file__
).
parent
this_file_dir
=
Path
(
__file__
).
parent
...
@@ -68,3 +69,45 @@ def test_get_sorted_columns(the_dataset: Dataset):
...
@@ -68,3 +69,45 @@ def test_get_sorted_columns(the_dataset: Dataset):
"""
Tests Dataset.get_sorted_column().
"""
"""
Tests Dataset.get_sorted_column().
"""
sorted_GAD1
=
the_dataset
.
get_sorted_column
(
"
GAD_T
"
)
sorted_GAD1
=
the_dataset
.
get_sorted_column
(
"
GAD_T
"
)
assert
sorted_GAD1
.
iloc
[
0
]
<=
sorted_GAD1
.
iloc
[
-
1
]
assert
sorted_GAD1
.
iloc
[
0
]
<=
sorted_GAD1
.
iloc
[
-
1
]
@pytest.mark.parametrize
(
"
param
"
,
[
np
.
array
([
1
,
2
,
3
]),
"
123
"
,
3
,
0.1
,
[],
np
,
pd
,
True
,
None
],
)
def
test_catch_non_dataframe
(
the_dataset
:
Dataset
,
param
):
"""
Tests that functions that take pd.DataFrame correctly
catch incorrect input data types.
"""
with
pytest
.
raises
(
ValueError
):
the_dataset
.
preprocess_dataset
(
param
)
the_dataset
.
get_is_competitive_col
(
param
)
the_dataset
.
_drop_unnecessary_columns
(
param
)
the_dataset
.
remove_nonaccepting_rows
(
param
)
the_dataset
.
preprocess_whyplay
(
param
)
the_dataset
.
get_combined_anxiety_score
(
param
)
the_dataset
.
get_is_narcissist_col
(
param
)
@pytest.mark.parametrize
(
"
param
"
,
[
"
true
"
,
"
false
"
,
"
True
"
,
"
False
"
],
)
def
test_catch_non_bool
(
the_dataset
:
Dataset
,
param
):
"""
Tests that the dataframe is preprocessed correctly.
"""
dataframe
=
the_dataset
.
get_dataframe
()
columns_set
=
set
(
dataframe
.
columns
)
with
pytest
.
raises
(
ValueError
):
the_dataset
.
get_category_counts
(
"
GAD_T
"
,
param
)
the_dataset
.
get_sorted_column
(
"
GAD_T
"
,
param
)
@pytest.mark.parametrize
(
"
param
"
,
[
True
,
False
,
None
],
)
def
test_bool_or_none_params
(
the_dataset
:
Dataset
,
param
):
"""
Tests that the dataframe is preprocessed correctly.
"""
dataframe
=
the_dataset
.
get_dataframe
()
columns_set
=
set
(
dataframe
.
columns
)
the_dataset
.
get_category_counts
(
"
GAD_T
"
,
param
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment