Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
plotID_python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
plotID
plotID_python
Commits
198d707d
Commit
198d707d
authored
2 years ago
by
nugget
Browse files
Options
Downloads
Patches
Plain Diff
Move input validation into PlotOption class.
parent
a4b89e4b
No related branches found
No related tags found
3 merge requests
!12
v.0.1 for alpha release
,
!11
Draft: Merge version0.1 changes into dev
,
!10
Version0.1
Pipeline
#734413
passed
2 years ago
Stage: linting
Stage: testing
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plotoptions.py
+40
-1
40 additions, 1 deletion
plotoptions.py
tagplot.py
+1
-17
1 addition, 17 deletions
tagplot.py
with
41 additions
and
18 deletions
plotoptions.py
+
40
−
1
View file @
198d707d
...
...
@@ -9,7 +9,12 @@ class PlotOptions:
Methods
-------
__init__figs : figure object
__init__
validate_input: Check if input is correct type.
Attributes
----------
figs : figure object
Figure that will be tagged.
prefix : str
Prefix that is placed before the ID.
...
...
@@ -28,3 +33,37 @@ class PlotOptions:
self
.
id_method
=
id_method
self
.
rotation
=
rotation
self
.
position
=
position
def
validate_input
(
self
):
"""
Validate if input for PlotOptions is correct type.
Raises
------
TypeError
TypeError is thrown if one of the attributes is not the correct
type.
Returns
-------
0, if all checks succeeded.
"""
# %% Validate inputs
if
isinstance
(
self
.
prefix
,
str
):
pass
else
:
raise
TypeError
(
"
Prefix is not a string.
"
)
if
isinstance
(
self
.
figs
,
list
):
pass
else
:
raise
TypeError
(
"
Figures are not a list.
"
)
# TODO: Change id_method key from integer to (more meaningful) string.
try
:
self
.
id_method
=
int
(
self
.
id_method
)
except
ValueError
:
raise
TypeError
(
'
The chosen ID id_method is not an integer.
'
)
return
0
This diff is collapsed.
Click to expand it.
tagplot.py
+
1
−
17
View file @
198d707d
...
...
@@ -48,23 +48,6 @@ def tagplot(figs, engine, prefix='', id_method=1, location='east'):
figures were given. The first list contains the tagged figures.
The second list contains the corresponding IDs as strings.
"""
# %% Validate inputs
if
isinstance
(
prefix
,
str
):
pass
else
:
raise
TypeError
(
"
Prefix is not a string.
"
)
if
isinstance
(
figs
,
list
):
pass
else
:
raise
TypeError
(
"
Figures are not a list.
"
)
# TODO: Change id_method key from integer to (more meaningful) string.
try
:
id_method
=
int
(
id_method
)
except
ValueError
:
raise
TypeError
(
'
The chosen ID id_method is not an integer.
'
)
if
isinstance
(
location
,
str
):
pass
else
:
...
...
@@ -99,6 +82,7 @@ def tagplot(figs, engine, prefix='', id_method=1, location='east'):
option_container
=
PlotOptions
(
figs
,
prefix
,
id_method
,
rotation
,
position
)
option_container
.
validate_input
()
match
engine
:
case
'
matplotlib
'
|
'
pyplot
'
:
...
...
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