Skip to content
Snippets Groups Projects
Commit 25824cce authored by nugget's avatar nugget
Browse files

Move PlotOptions class out of TagPlot into its own module.

parent b8e75ae6
No related branches found
No related tags found
2 merge requests!12v.0.1 for alpha release,!8First OOP implementation of tagplot.py.
Test0.tiff

5.67 MiB | W: | H:

Test0.tiff

486 KiB | W: | H:

Test0.tiff
Test0.tiff
Test0.tiff
Test0.tiff
  • 2-up
  • Swipe
  • Onion skin
Test1.tiff

5.67 MiB | W: | H:

Test1.tiff

486 KiB | W: | H:

Test1.tiff
Test1.tiff
Test1.tiff
Test1.tiff
  • 2-up
  • Swipe
  • Onion skin
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Contains the PlotOption class."""
class PlotOptions:
"""
Container objects which include all plot options provided by plotid.
Methods
-------
__init__figs : figure object
Figure that will be tagged.
prefix : str
Prefix that is placed before the ID.
id_method : int
Method that decides which method is used to generate the ID.
rotation : int
Rotation angle for the ID.
position : tuple
Relative position of the ID on the plot (x,y).
"""
def __init__(self, figs, prefix, id_method, rotation, position):
self.figs = figs
self.prefix = prefix
self.id_method = id_method
self.rotation = rotation
self.position = position
......@@ -9,6 +9,7 @@ Functions:
import matplotlib
import matplotlib.pyplot as plt
import create_id
from plotoptions import PlotOptions
def tagplot_matplotlib(plotid_object):
......@@ -19,6 +20,10 @@ def tagplot_matplotlib(plotid_object):
as Tag (Property of figure).
TagPlot can tag multiple figures at once
"""
# Check if plotid_object is a valid instance of PlotOptions
if not isinstance(plotid_object, PlotOptions):
raise TypeError('The given options container is not an instance'
'of PlotOptions.')
# Check if figs is a valid figure or a list of valid figures
if isinstance(plotid_object.figs, matplotlib.figure.Figure):
pass
......
......@@ -52,6 +52,10 @@ class Test_tagplot_matplotlib(unittest.TestCase):
with self.assertRaises(TypeError):
tagplot_matplotlib(options)
def test_mpl_plotoptions(self):
with self.assertRaises(TypeError):
tagplot_matplotlib('wrong_object')
if __name__ == '__main__':
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment