text
stringlengths
1
93.6k
self.draw()
def blit(self, bbox=None):
'''If bbox is None, blit the entire canvas to the widget. Otherwise
blit only the area defined by the bbox.
'''
self.blitbox = bbox
filetypes = FigureCanvasBase.filetypes.copy()
filetypes['png'] = 'Portable Network Graphics'
def print_png(self, filename, *args, **kwargs):
'''Call the widget function to make a png of the widget.
'''
fig = FigureCanvasAgg(self.figure)
FigureCanvasAgg.draw(fig)
l, b, w, h = self.figure.bbox.bounds
texture = Texture.create(size=(w, h))
texture.blit_buffer(bytes(fig.get_renderer().buffer_rgba()),
colorfmt='rgba', bufferfmt='ubyte')
texture.flip_vertical()
img = Image(texture)
img.save(filename)
def get_default_filetype(self):
return 'png'
def new_timer(self, *args, **kwargs):
"""
Creates a new backend-specific subclass of :class:`backend_bases.Timer`.
This is useful for getting periodic events through the backend's native
event loop. Implemented only for backends with GUIs.
optional arguments:
*interval*
Timer interval in milliseconds
*callbacks*
Sequence of (func, args, kwargs) where func(*args, **kwargs) will
be executed by the timer every *interval*.
"""
return TimerKivy(*args, **kwargs)
class FigureManagerKivy(FigureManagerBase):
'''The FigureManager main function is to instantiate the backend navigation
toolbar and to call show to instantiate the App.
'''
def __init__(self, canvas, num):
super(FigureManagerKivy, self).__init__(canvas, num)
self.canvas = canvas
self.toolbar = self._get_toolbar()
def show(self):
pass
def get_window_title(self):
return Window.title
def set_window_title(self, title):
Window.title = title
def resize(self, w, h):
if (w > 0) and (h > 0):
Window.size = w, h
def _get_toolbar(self):
if rcParams['toolbar'] == 'toolbar2':
toolbar = NavigationToolbar2Kivy(self.canvas)
else:
toolbar = None
return toolbar
'''Now just provide the standard names that backend.__init__ is expecting
'''
FigureCanvas = FigureCanvasKivy
FigureManager = FigureManagerKivy
NavigationToolbar = NavigationToolbar2Kivy
# <FILESEP>
import argparse
import os.path
import random
import time
import numpy as np
import torch
from loa_agent import LOAAgent
parser = argparse.ArgumentParser(description='Train LOA')
parser.add_argument('--difficulty_level',
type=str, help='Difficulty level of the TWC game',
default='easy', choices=['easy', 'medium', 'hard'])
parser.add_argument('--sem_parser_mode',
type=str, help='Which mode to use for ablation',
default='both',
choices=['both', 'verbnet', 'propbank', 'none'])