# Path: hylaa/util.py
# class Freezable():
#     'a class where you can freeze the fields (prevent new fields from being created)'
# 
#     _frozen = False
# 
#     def freeze_attrs(self):
#         'prevents any new attributes from being created in the object'
#         self._frozen = True
# 
#     def __setattr__(self, key, value):
#         if self._frozen and not hasattr(self, key):
#             raise TypeError("{} does not contain attribute '{}' (object was frozen)".format(self, key))
# 
#         object.__setattr__(self, key, value)
# 
# Path: hylaa/settings.py
# class PlotSettings(Freezable): # pylint: disable=too-few-public-methods,too-many-instance-attributes
#     'plot settings container'
# 
#     PLOT_NONE = 0 # don't plot (safety checking only; for performance measurement)
#     PLOT_LIVE = 1 # plot the computation live as we're computing
#     PLOT_INTERACTIVE = 2 # live plotting with pauses and buttons upon certain events
#     PLOT_IMAGE = 3 # save the image plot to a file
#     PLOT_VIDEO = 4 # save a video to a file
# 
#     def __init__(self):
#         self.plot_mode = PlotSettings.PLOT_NONE
#         
#         self.store_plot_result = False # store the reachable plot data inside the computation result object?
# 
#         self.filename = None # filename to print data to for certain plot modes
# 
#         self.plot_size = (8, 8) # inches
# 
#         # these settings can be lists, in which case we'll make multiple plots
#         self.xdim_dir = 0 # plotting x dimension number, direction (np.array), None (time), or dict: mode_name -> dir
#         self.ydim_dir = 1 # plotting y dimension number, direction (np.array), None (time), or dict: mode_name -> dir
#         self.label = LabelSettings() # plot title, axis labels, font sizes, ect.
#         self.extra_collections = None # list of extra animation collections
# 
#         self.num_angles = 512 # how many evenly-spaced angles to put into plot_vecs
# 
#         self.draw_stride = 1 # draw every n frames (good to inscrease if number of steps is large)
#         
#         self.reachable_poly_width = 2 # width of reachable polygon outlines
#         self.extend_plot_range_ratio = 0.1 # extend plot axis range 10% at a time
# 
#         self.sim_line_color = 'black' # simulation line color
#         self.sim_line_width = 0.2 # width of simulation lines
# 
#         self.grid = True
#         self.grid_xtics = None # override default xtics value, for example np.linspace(0.0, 5.0, 1.0)
#         self.grid_ytics = None # override default ytics value, for example np.linspace(0.0, 5.0, 1.0)
# 
#         self.use_markers_for_small = True # draw markers when the reachable set is tiny instead of (invisible) polygons
# 
#         self.show_counterexample = True # draw concrete counter-example in the last frame?
# 
#         self.interactive_skip_count = 0 # when using PLOT_INTERACTIVE, auto-click 'next' this many times
# 
#         self.video_fps = 40
#         self.video_extra_frames = 40 # extra frames at the end of a video so it doesn't end so abruptly
#         self.video_pause_frames = 20 # frames to render in video whenever a 'pause' occurs
#         self.video_show_frame = True # show the frame counter?
# 
#         # function which returns the Writer with the desired settings used to create a video, used for video export
#         def make_video_writer():
#             'returns the Writer to create a video for export'
# 
#             writer_class = animation.writers['ffmpeg']
#             return writer_class(fps=self.video_fps, metadata=dict(artist='Me'), bitrate=1800)
# 
#         self.make_video_writer_func = make_video_writer
# 
#         self.freeze_attrs()


import matplotlib.pyplot as plt
from hylaa.util import Freezable
from hylaa.settings import PlotSettings
    def create_plot(self):
        'create the plot'

        if isinstance(self.settings.xdim_dir, list):
            assert isinstance(self.settings.ydim_dir, list)
            assert len(self.settings.xdim_dir) == len(self.settings.ydim_dir)
        else:
            self.settings.xdim_dir = [self.settings.xdim_dir]
            self.settings.ydim_dir = [self.settings.ydim_dir]

        self.num_subplots = len(self.settings.xdim_dir)

        if not self.settings.plot_mode in [PlotSettings.PLOT_NONE]:
            self.fig, axes_list = plt.subplots(nrows=self.num_subplots, ncols=1, figsize=self.settings.plot_size, \
                                                    squeeze=False)

            self.axes_list = []
            
            for row in axes_list:
                for axes in row:
                    self.axes_list.append(axes)

            if not isinstance(self.settings.label, list):
                self.settings.label = [self.settings.label]

            # only use title for the first subplot the first plot
            title = self.settings.label[0].title
            title = title if title is not None else self.ha.name
            self.axes_list[0].set_title(title, fontsize=self.settings.label[0].title_size)


# Path: hylaa/util.py
# class Freezable():
#     'a class where you can freeze the fields (prevent new fields from being created)'
# 
#     _frozen = False
# 
#     def freeze_attrs(self):
#         'prevents any new attributes from being created in the object'
#         self._frozen = True
# 
#     def __setattr__(self, key, value):
#         if self._frozen and not hasattr(self, key):
#             raise TypeError("{} does not contain attribute '{}' (object was frozen)".format(self, key))
# 
#         object.__setattr__(self, key, value)
# 
# Path: hylaa/settings.py
# class PlotSettings(Freezable): # pylint: disable=too-few-public-methods,too-many-instance-attributes
#     'plot settings container'
# 
#     PLOT_NONE = 0 # don't plot (safety checking only; for performance measurement)
#     PLOT_LIVE = 1 # plot the computation live as we're computing
#     PLOT_INTERACTIVE = 2 # live plotting with pauses and buttons upon certain events
#     PLOT_IMAGE = 3 # save the image plot to a file
#     PLOT_VIDEO = 4 # save a video to a file
# 
#     def __init__(self):
#         self.plot_mode = PlotSettings.PLOT_NONE
#         
#         self.store_plot_result = False # store the reachable plot data inside the computation result object?
# 
#         self.filename = None # filename to print data to for certain plot modes
# 
#         self.plot_size = (8, 8) # inches
# 
#         # these settings can be lists, in which case we'll make multiple plots
#         self.xdim_dir = 0 # plotting x dimension number, direction (np.array), None (time), or dict: mode_name -> dir
#         self.ydim_dir = 1 # plotting y dimension number, direction (np.array), None (time), or dict: mode_name -> dir
#         self.label = LabelSettings() # plot title, axis labels, font sizes, ect.
#         self.extra_collections = None # list of extra animation collections
# 
#         self.num_angles = 512 # how many evenly-spaced angles to put into plot_vecs
# 
#         self.draw_stride = 1 # draw every n frames (good to inscrease if number of steps is large)
#         
#         self.reachable_poly_width = 2 # width of reachable polygon outlines
#         self.extend_plot_range_ratio = 0.1 # extend plot axis range 10% at a time
# 
#         self.sim_line_color = 'black' # simulation line color
#         self.sim_line_width = 0.2 # width of simulation lines
# 
#         self.grid = True
#         self.grid_xtics = None # override default xtics value, for example np.linspace(0.0, 5.0, 1.0)
#         self.grid_ytics = None # override default ytics value, for example np.linspace(0.0, 5.0, 1.0)
# 
#         self.use_markers_for_small = True # draw markers when the reachable set is tiny instead of (invisible) polygons
# 
#         self.show_counterexample = True # draw concrete counter-example in the last frame?
# 
#         self.interactive_skip_count = 0 # when using PLOT_INTERACTIVE, auto-click 'next' this many times
# 
#         self.video_fps = 40
#         self.video_extra_frames = 40 # extra frames at the end of a video so it doesn't end so abruptly
#         self.video_pause_frames = 20 # frames to render in video whenever a 'pause' occurs
#         self.video_show_frame = True # show the frame counter?
# 
#         # function which returns the Writer with the desired settings used to create a video, used for video export
#         def make_video_writer():
#             'returns the Writer to create a video for export'
# 
#             writer_class = animation.writers['ffmpeg']
#             return writer_class(fps=self.video_fps, metadata=dict(artist='Me'), bitrate=1800)
# 
#         self.make_video_writer_func = make_video_writer
# 
#         self.freeze_attrs()


# Path: hylaa/simulation.py
import matplotlib.pyplot as plt
from hylaa.util import Freezable
from hylaa.settings import PlotSettings

    def create_plot(self):
        'create the plot'

        if isinstance(self.settings.xdim_dir, list):
            assert isinstance(self.settings.ydim_dir, list)
            assert len(self.settings.xdim_dir) == len(self.settings.ydim_dir)
        else:
            self.settings.xdim_dir = [self.settings.xdim_dir]
            self.settings.ydim_dir = [self.settings.ydim_dir]

        self.num_subplots = len(self.settings.xdim_dir)

        if not self.settings.plot_mode in [PlotSettings.PLOT_NONE]:
            self.fig, axes_list = plt.subplots(nrows=self.num_subplots, ncols=1, figsize=self.settings.plot_size, \
                                                    squeeze=False)

            self.axes_list = []
            
            for row in axes_list:
                for axes in row:
                    self.axes_list.append(axes)

            if not isinstance(self.settings.label, list):
                self.settings.label = [self.settings.label]

            # only use title for the first subplot the first plot
            title = self.settings.label[0].title
            title = title if title is not None else self.ha.name
            self.axes_list[0].set_title(title, fontsize=self.settings.label[0].title_size)


            if self.settings.video_show_frame and self.settings.plot_mode == PlotSettings.PLOT_VIDEO: