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
Merge requests
!12
"...git@gitup.uni-potsdam.de:dostoll/hpc-benchmark-game.git" did not exist on "71b7b57270774d96afd414506f71d3632cbb8800"
Merge "Write tests" branch into master
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Merge "Write tests" branch into master
18-write-tests
into
master
Overview
0
Commits
6
Pipelines
0
Changes
1
Merged
Wishyut (Jake Pita)
requested to merge
18-write-tests
into
master
1 year ago
Overview
0
Commits
6
Pipelines
0
Changes
1
Expand
Closes
#18 (closed)
0
0
Merge request reports
Viewing commit
d20de04f
Prev
Next
Show latest version
1 file
+
26
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
d20de04f
added/modified tests to get 100% Dataset.py code coverage
· d20de04f
Sortofamudkip
authored
1 year ago
src/test_plotter.py
+
112
−
3
Options
from
pathlib
import
Path
from
Dataset
import
Dataset
import
src.
Dataset
from
Plotter
import
Plotter
import
pandas
as
pd
import
pytest
import
matplotlib.pyplot
as
plt
this_file_dir
=
Path
(
__file__
).
parent
@pytest.fixture
def
the_plotter
()
->
src
.
Dataset
.
Dataset
:
dataset
=
src
.
Dataset
.
Dataset
(
str
(
this_file_dir
/
"
../data/GamingStudy_data.csv
"
)
)
plotter
=
Plotter
(
dataset
)
return
plotter
def
test_load_plotter
():
"""
Tests that the Plotter class can be loaded.
"""
dataset
=
Dataset
(
str
(
this_file_dir
/
"
../data/GamingStudy_data.csv
"
))
dataset
=
src
.
Dataset
.
Dataset
(
str
(
this_file_dir
/
"
../data/GamingStudy_data.csv
"
)
)
plotter
=
Plotter
(
dataset
)
assert
type
(
plotter
.
df
)
==
pd
.
DataFrame
assert
type
(
plotter
.
ds
)
==
Dataset
assert
type
(
plotter
.
ds
)
==
src
.
Dataset
.
Dataset
def
test_catch_colname_not_in_df
(
the_plotter
:
Plotter
):
"""
Tests that functions that take colname correctly
catch colnames not in dataset.
"""
with
pytest
.
raises
(
KeyError
):
the_plotter
.
distribution_plot
(
"
GAAAD_T
"
)
def
test_catch_target_not_string
(
the_plotter
:
Plotter
):
"""
Tests that functions that take target correctly
catch non strings.
"""
with
pytest
.
raises
(
ValueError
):
the_plotter
.
distribution_plot
(
True
)
with
pytest
.
raises
(
ValueError
):
the_plotter
.
plot_categorical_bar_chart
(
True
,
"
GAD_T
"
)
with
pytest
.
raises
(
ValueError
):
the_plotter
.
plot_categorical_bar_chart
(
"
GAD_T
"
,
True
)
with
pytest
.
raises
(
ValueError
):
the_plotter
.
plot_categorical_bar_chart
(
"
GAD_TT
"
,
"
GAD_T
"
)
with
pytest
.
raises
(
ValueError
):
the_plotter
.
plot_categorical_bar_chart
(
"
GAD_T
"
,
"
GAD_TT
"
)
with
pytest
.
raises
(
ValueError
):
the_plotter
.
plot_categorical_histplot
(
True
,
"
GAD_T
"
)
with
pytest
.
raises
(
ValueError
):
the_plotter
.
plot_categorical_histplot
(
"
GAD_T
"
,
True
)
with
pytest
.
raises
(
ValueError
):
the_plotter
.
plot_categorical_histplot
(
"
GAD_TT
"
,
"
GAD_T
"
)
with
pytest
.
raises
(
ValueError
):
the_plotter
.
plot_categorical_histplot
(
"
GAD_T
"
,
"
GAD_TT
"
)
with
pytest
.
raises
(
ValueError
):
the_plotter
.
plot_scatterplot
(
True
,
"
GAD_T
"
)
with
pytest
.
raises
(
ValueError
):
the_plotter
.
plot_scatterplot
(
"
GAD_T
"
,
True
)
with
pytest
.
raises
(
ValueError
):
the_plotter
.
plot_scatterplot
(
"
GAD_TT
"
,
"
GAD_T
"
)
with
pytest
.
raises
(
ValueError
):
the_plotter
.
plot_scatterplot
(
"
GAD_T
"
,
"
GAD_TT
"
)
@pytest.mark.parametrize
(
"
param
"
,
[
True
,
None
,
"
notdict
"
,
6.4
,
pd
,
(
1
,),
src
.
Dataset
.
Dataset
],
)
def
test_catch_styling_params_not_dict
(
the_plotter
:
Plotter
,
param
):
"""
Tests that functions that take styling_params correctly
catch non dictionaries.
"""
with
pytest
.
raises
(
ValueError
):
the_plotter
.
plot_categorical_bar_chart
(
"
GAD_T
"
,
"
GAD_T
"
,
param
)
with
pytest
.
raises
(
ValueError
):
the_plotter
.
plot_categorical_histplot
(
"
GAD_T
"
,
"
GAD_T
"
,
param
)
with
pytest
.
raises
(
ValueError
):
the_plotter
.
plot_scatterplot
(
"
GAD_T
"
,
"
GAD_T
"
,
param
)
with
pytest
.
raises
(
ValueError
):
the_plotter
.
distribution_plot
(
"
GAD_T
"
,
param
)
def
test_catch_plotter_init_not_Dataset
():
"""
Tests that the Plotter
'
s init actually takes a src.Dataset.Dataset.
"""
with
pytest
.
raises
(
ValueError
):
p
=
Plotter
(
"
not-a-src.Dataset.Dataset
"
)
def
test_customize_plot
(
the_plotter
:
Plotter
):
fig
,
ax
=
plt
.
subplots
()
the_plotter
.
customize_plot
(
fig
,
ax
,
{
"
title
"
:
"
a
"
})
assert
True
def
test_distribution_plot
(
the_plotter
:
Plotter
):
the_plotter
.
distribution_plot
(
"
GAD_T
"
)
assert
True
def
test_plot_categorical_bar_chart
(
the_plotter
:
Plotter
):
the_plotter
.
plot_categorical_bar_chart
(
"
GAD_T
"
,
"
SWL_T
"
)
assert
True
def
test_plot_categorical_boxplot
(
the_plotter
:
Plotter
):
the_plotter
.
plot_categorical_boxplot
(
"
whyplay
"
,
"
SWL_T
"
)
assert
True
def
test_plot_categorical_histplot
(
the_plotter
:
Plotter
):
the_plotter
.
plot_categorical_histplot
(
"
whyplay
"
,
"
SWL_T
"
)
assert
True
def
test_plot_scatterplot
(
the_plotter
:
Plotter
):
the_plotter
.
plot_scatterplot
(
"
GAD_T
"
,
"
SWL_T
"
)
assert
True
Loading