Ejemplo n.º 1
0
    def __init__(self,
                 edgecolor=None,   
                 facecolor=None,
                 linewidth=None,
                 antialiased = None, 
                 fill=1,
                 **kwargs
                 ):
        Artist.__init__(self)

        if edgecolor is None: edgecolor = rcParams['patch.edgecolor']
        if facecolor is None: facecolor = rcParams['patch.facecolor']
        if linewidth is None: linewidth = rcParams['patch.linewidth']
        if antialiased is None: antialiased = rcParams['patch.antialiased']

        self._edgecolor = edgecolor
        self._facecolor = facecolor
        self._linewidth = linewidth
        self._antialiased = antialiased        
        self.fill = fill


        for k,v in kwargs.items():
            func = 'set_' + k            
            if hasattr(self, func):
                func = getattr(self, func)
                func(v)
Ejemplo n.º 2
0
    def __init__(self, x=0, y=0, text='',
                 color='k',
                 verticalalignment='bottom',
                 horizontalalignment='left',
                 fontname='Sans',
                 fontsize=10,
                 fontweight='bold',
                 fontangle='normal',
                 rotation=None,
                 ):
        Artist.__init__(self)
        self._x, self._y = x, y

        self._color = color
        self._text = text
        self._verticalalignment = verticalalignment
        self._horizontalalignment = horizontalalignment
        self._rotation = rotation
        self._fontname = fontname
        self._fontsize = fontsize
        self._fontweight = fontweight
        self._fontangle = fontangle


        self._reset=1
        self._drawn = 0
        self._eraseImg = None
        self._lastXY = 0,0
def find_or_create_artist(name):
    artists_names = [artist._name for artist in Artist._all]
    if name in artists_names:
        return Artist.find_by_name(name)
    else:
        artist = Artist(name)
        return artist
Ejemplo n.º 4
0
    def __init__(self, ax, loc=None, bbox=None):

        Artist.__init__(self)

        if is_string_like(loc) and loc not in self.codes:
            warnings.warn(
                "Unrecognized location %s. Falling back on "
                "bottom; valid locations are\n%s\t" % (loc, "\n\t".join(self.codes.iterkeys()))
            )
            loc = "bottom"
        if is_string_like(loc):
            loc = self.codes.get(loc, 1)
        self.set_figure(ax.figure)
        self._axes = ax
        self._loc = loc
        self._bbox = bbox

        # use axes coords
        self.set_transform(ax.transAxes)

        self._texts = []
        self._cells = {}
        self._autoRows = []
        self._autoColumns = []
        self._autoFontsize = True

        self._cachedRenderer = None
Ejemplo n.º 5
0
    def __init__(self,
                 edgecolor=None,   
                 facecolor=None,
                 linewidth=None,
                 antialiased = None,
                 fill=1,
                 **kwargs
                 ):
        Artist.__init__(self)

        if edgecolor is None: edgecolor = rcParams['patch.edgecolor']
        if facecolor is None: facecolor = rcParams['patch.facecolor']
        if linewidth is None: linewidth = rcParams['patch.linewidth']
        if antialiased is None: antialiased = rcParams['patch.antialiased']

        self._edgecolor = edgecolor
        self._facecolor = facecolor
        self._linewidth = linewidth
        self._antialiased = antialiased        
        self.fill = fill

        # set up some abbreviations for easier interactive use
        for func, abbrev in self._aliases:
            self.__dict__['set_%s'%abbrev] = getattr(self, 'set_%s'%func)
            self.__dict__['get_%s'%abbrev] = getattr(self, 'get_%s'%func)

        for k,v in kwargs.items():
            func = 'set_' + k            
            if hasattr(self, func):
                func = getattr(self, func)
                func(v)
Ejemplo n.º 6
0
    def __init__(self,
                 edgecolor=None,
                 facecolor=None,
                 linewidth=None,
                 antialiased=None,
                 hatch=None,
                 fill=1,
                 xunits=None,
                 yunits=None,
                 **kwargs):
        Artist.__init__(self)

        if edgecolor is None: edgecolor = rcParams['patch.edgecolor']
        if facecolor is None: facecolor = rcParams['patch.facecolor']
        if linewidth is None: linewidth = rcParams['patch.linewidth']
        if antialiased is None: antialiased = rcParams['patch.antialiased']

        self._edgecolor = edgecolor
        self._facecolor = facecolor
        self._linewidth = linewidth
        self._antialiased = antialiased
        self._hatch = hatch
        self.fill = fill
        self._xunits = xunits
        self._yunits = yunits
        self._xunits_id, self._yunits_id = None, None

        if len(kwargs): setp(self, **kwargs)
Ejemplo n.º 7
0
    def __init__(self, 
                 x=0, y=0, text='',
                 color=None,          # defaults to rc params
                 verticalalignment='bottom',
                 horizontalalignment='left',
                 multialignment=None,
                 fontproperties=None, # defaults to FontProperties()
                 rotation=None,
                 ):

        Artist.__init__(self)
        self.cached = {}
        self._x, self._y = x, y

        if color is None: color = rcParams['text.color']
        if fontproperties is None: fontproperties=FontProperties()

        self._color = color
        self._text = text
        self._verticalalignment = verticalalignment
        self._horizontalalignment = horizontalalignment
        self._multialignment = multialignment

        
        
        self._rotation = rotation
        self._fontproperties = fontproperties
Ejemplo n.º 8
0
    def __init__(
        self,
        edgecolor=None,
        facecolor=None,
        linewidth=None,
        antialiased=None,
        hatch=None,
        fill=1,
        xunits=None,
        yunits=None,
        **kwargs
    ):
        Artist.__init__(self)

        if edgecolor is None:
            edgecolor = rcParams["patch.edgecolor"]
        if facecolor is None:
            facecolor = rcParams["patch.facecolor"]
        if linewidth is None:
            linewidth = rcParams["patch.linewidth"]
        if antialiased is None:
            antialiased = rcParams["patch.antialiased"]

        self._edgecolor = edgecolor
        self._facecolor = facecolor
        self._linewidth = linewidth
        self._antialiased = antialiased
        self._hatch = hatch
        self.fill = fill
        self._xunits = xunits
        self._yunits = yunits
        self._xunits_id, self._yunits_id = None, None

        if len(kwargs):
            setp(self, **kwargs)
Ejemplo n.º 9
0
    def __init__(self, ax,
                 cmap = None,
                 norm = None,
                 aspect=None,
                 interpolation=None,
                 origin=None,
                 extent=None,
                 ):

        """
        aspect, interpolation and cmap default to their rc setting

        cmap is a cm colormap instance
        norm is a colors.normalize instance to map luminance to 0-1

        extent is a data xmin, xmax, ymin, ymax for making image plots
        registered with data plots.  Default is the image dimensions
        in pixels
        
        """
        Artist.__init__(self)        
        cm.ScalarMappable.__init__(self, norm, cmap)

        if origin is None: origin = rcParams['image.origin']
        self.origin = origin
        self._extent = extent      

        # map interpolation strings to module constants
        self._interpd = {
            'bicubic'     : _image.BICUBIC,
            'bilinear'    : _image.BILINEAR,
            'blackman100' : _image.BLACKMAN100,
            'blackman256' : _image.BLACKMAN256,
            'blackman64'  : _image.BLACKMAN64,
            'nearest'     : _image.NEAREST,
            'sinc144'     : _image.SINC144,
            'sinc256'     : _image.SINC256,
            'sinc64'      : _image.SINC64,
            'spline16'    : _image.SPLINE16,
            'spline36'    : _image.SPLINE36,       
        }

        # map aspect ratio strings to module constants
        self._aspectd = {
            'free'     : _image.ASPECT_FREE,
            'preserve' : _image.ASPECT_PRESERVE,
        }

        # reverse interp dict
        self._interpdr = dict([ (v,k) for k,v in self._interpd.items()])

        # reverse aspect dict
        self._aspectdr = dict([ (v,k) for k,v in self._aspectd.items()])

        if aspect is None: aspect = rcParams['image.aspect']
        if interpolation is None: interpolation = rcParams['image.interpolation']        
        
        self.set_interpolation(interpolation)
        self.set_aspect( aspect)
        self.axes = ax
Ejemplo n.º 10
0
    def __init__(self, axes):
        """
        Init the axis with the parent Axes instance
        """
        Artist.__init__(self)
        self.set_figure(axes.figure)

        self.axes = axes

        self.set_major_locator(AutoLocator())
        self.set_minor_locator(NullLocator())

        self.set_major_formatter(ScalarFormatter())
        self.set_minor_formatter(NullFormatter())

        # whether the grids are on
        self._gridOnMajor = rcParams['axes.grid']
        self._gridOnMinor = False

        self.label = self._get_label()
        self._set_artist_props(self.label)

        # build a few default ticks; grow as necessary later; only
        # define 1 so properties set on ticks will be copied as they
        # grow
        self.majorTicks = [self._get_tick(major=True) for i in range(1)]
        self.minorTicks = [self._get_tick(major=False) for i in range(1)]
Ejemplo n.º 11
0
    def __init__(self, ax, loc=None, bbox=None):

        Artist.__init__(self)

        if is_string_like(loc) and loc not in self.codes:
            warnings.warn('Unrecognized location %s. Falling back on '
                          'bottom; valid locations are\n%s\t' %
                          (loc, '\n\t'.join(self.codes.iterkeys())))
            loc = 'bottom'
        if is_string_like(loc):
            loc = self.codes.get(loc, 1)
        self.set_figure(ax.figure)
        self._axes = ax
        self._loc = loc
        self._bbox = bbox

        # use axes coords
        self.set_transform(ax.transAxes)

        self._texts = []
        self._cells = {}
        self._autoRows = []
        self._autoColumns = []
        self._autoFontsize = True

        self.set_clip_on(False)

        self._cachedRenderer = None
Ejemplo n.º 12
0
def main(args):
    model = ArtistVGG19(shape=(args.height, args.width, 3),
                        verbose=args.verbose)
    config = ArtistConfig(
        contest_path=os.path.join(args.content_path, args.content_img),
        content_layers=[2, 7, 12, 21, 30],
        content_layer_weights=[1 / 5., 1 / 5., 1 / 5., 1 / 5., 1 / 5.],
        style_path=os.path.join(args.style_path, args.style_img),
        style_layers=[23],
        style_layer_weights=[1],
        size=(args.height, args.width),
        alpha=args.alpha,
        beta=args.beta,
        gamma=args.gamma,
        lr=args.lr,
        n_iter=args.n_iter,
        noise_rate=args.noise_rate,
        optimizer='adam',
        debug=args.debug,
        verbose=args.verbose)

    artist = Artist(model=model)
    img = artist.transform(config=config)

    save_img(os.path.join('result', args.img_name + '.jpg'), img)

    plt.imshow(img)
    plt.show()
Ejemplo n.º 13
0
    def __init__(self,
                 edgecolor=None,
                 facecolor=None,
                 linewidth=None,
                 antialiased=None,
                 fill=1,
                 **kwargs):
        Artist.__init__(self)

        if edgecolor is None: edgecolor = rcParams['patch.edgecolor']
        if facecolor is None: facecolor = rcParams['patch.facecolor']
        if linewidth is None: linewidth = rcParams['patch.linewidth']
        if antialiased is None: antialiased = rcParams['patch.antialiased']

        self._edgecolor = edgecolor
        self._facecolor = facecolor
        self._linewidth = linewidth
        self._antialiased = antialiased
        self.fill = fill

        # set up some abbreviations for easier interactive use
        for func, abbrev in self._aliases:
            self.__dict__['set_%s' % abbrev] = getattr(self, 'set_%s' % func)
            self.__dict__['get_%s' % abbrev] = getattr(self, 'get_%s' % func)

        for k, v in kwargs.items():
            func = 'set_' + k
            if hasattr(self, func):
                func = getattr(self, func)
                func(v)
Ejemplo n.º 14
0
    def setDB(self):


        mydb = mysql.connector.connect(
                     host="localhost",
                     user="******",
                     passwd="1110235361",
                     database="priotuli"
         )
        mycursor = mydb.cursor()
        mycursor.execute("SELECT name, password, usertype FROM user")
        myresult = mycursor.fetchall()
        print(myresult)
        mycursor.close()
        mydb.close()

        name = self.uname.text()
        pwd = self.passw.text()
        print(name, " ", pwd)
        for row in myresult:
            #print(row[2])
            if name == row[0] and pwd == row[1]:
                if row[2] == "normal":
                    print("noraml")
                    self.normalUser = QtWidgets.QMainWindow()
                    self.ui = Normal()
                    self.ui.setupUi(self.normalUser)
                    self.normalUser.show()
                if row[2] == "artist":
                    print("artist")
                    self.artistWindow = QtWidgets.QMainWindow()
                    self.ui = Artist()
                    self.ui.setupUi(self.artistWindow)
                    self.artistWindow.show()
Ejemplo n.º 15
0
    def __init__(self, axes):
        """
        Init the axis with the parent Axes instance
        """
        Artist.__init__(self)
        self.set_figure(axes.figure)
        
        self.axes = axes

        self.set_major_locator( AutoLocator() )
        self.set_minor_locator( NullLocator() )

        self.set_major_formatter( ScalarFormatter() )
        self.set_minor_formatter( NullFormatter() )
        
        # whether the grids are on
        self._gridOnMajor = rcParams['axes.grid']  
        self._gridOnMinor = False

        self.label = self._get_label()
        self._set_artist_props(self.label)

        # build a few default ticks; grow as necessary later; only
        # define 1 so properties set on ticks will be copied as they
        # grow
        self.majorTicks = [self._get_tick(major=True)  for i in range(1)]
        self.minorTicks = [self._get_tick(major=False) for i in range(1)]       
Ejemplo n.º 16
0
    def __init__(
            self,
            figsize=None,  # defaults to rc figure.figsize
            dpi=None,  # defaults to rc figure.dpi
            facecolor=None,  # defaults to rc figure.facecolor
            edgecolor=None,  # defaults to rc figure.edgecolor
            linewidth=1.0,  # the default linewidth of the frame
            frameon=True,  # whether or not to draw the figure frame
            subplotpars=None,  # default to rc
    ):
        """
        figsize is a w,h tuple in inches
        dpi is dots per inch
        subplotpars is a SubplotParams instance, defaults to rc
        """
        Artist.__init__(self)
        #self.set_figure(self)
        self._axstack = Stack()  # maintain the current axes
        self._axobservers = []
        self._seen = {}  # axes args we've seen

        if figsize is None: figsize = rcParams['figure.figsize']
        if dpi is None: dpi = rcParams['figure.dpi']
        if facecolor is None: facecolor = rcParams['figure.facecolor']
        if edgecolor is None: edgecolor = rcParams['figure.edgecolor']

        self._unit_conversions = {}

        self.dpi = Value(dpi)
        self.figwidth = Value(figsize[0])
        self.figheight = Value(figsize[1])
        self.ll = Point(Value(0), Value(0))
        self.ur = Point(self.figwidth * self.dpi, self.figheight * self.dpi)
        self.bbox = Bbox(self.ll, self.ur)

        self.frameon = frameon

        self.transFigure = get_bbox_transform(unit_bbox(), self.bbox)

        self.figurePatch = Rectangle(
            xy=(0, 0),
            width=1,
            height=1,
            facecolor=facecolor,
            edgecolor=edgecolor,
            linewidth=linewidth,
        )
        self._set_artist_props(self.figurePatch)

        self._hold = rcParams['axes.hold']
        self.canvas = None

        if subplotpars is None:
            subplotpars = SubplotParams()

        self.subplotpars = subplotpars

        self.clf()

        self._cachedRenderer = None
Ejemplo n.º 17
0
    def setProps(self, props={}, **kwprops):
        """
        If font is given as a string or a dict, convert it into a Font object.
        If rotation is a string representing a number, convert it.

        Then call Artist.setProps.
        """

        # A property might be defined in both props and kwprops,
        # so do all of this twice
        for d in (props, kwprops):
            if 'font' in d.keys():
                currentFont = Font()
                if 'font' in self.props().keys():
                    currentFont = self.props('font')

                if isinstance(d['font'], str):
                    currentFont.setFamily(d['font'])
                    d['font'] = currentFont
                elif isinstance(d['font'], dict):
                    currentFont.setProps(d['font'])
                    d['font'] = currentFont

            if 'rotation' in d.keys():
                try:
                    d['rotation'] = float(d['rotation'])
                except ValueError:
                    pass

        Artist.setProps(self, props, **kwprops)
Ejemplo n.º 18
0
    def __init__(self, 
                 x=0, y=0, text='',
                 color=None,          # defaults to rc params
                 verticalalignment='bottom',
                 horizontalalignment='left',
                 multialignment=None,
                 fontproperties=None, # defaults to FontProperties()
                 rotation=None,
                 ):

        Artist.__init__(self)
        if not is_string_like(text):
            raise TypeError('text must be a string type')
        self.cached = {}
        self._x, self._y = x, y

        if color is None: color = rcParams['text.color']
        if fontproperties is None: fontproperties=FontProperties()

        self._color = color
        self.set_text(text)
        self._verticalalignment = verticalalignment
        self._horizontalalignment = horizontalalignment
        self._multialignment = multialignment        
        self._rotation = rotation
        self._fontproperties = fontproperties
        self._bbox = None
        self._renderer = None        
Ejemplo n.º 19
0
    def __init__(self, axes, pickradius=15):
        """
        Init the axis with the parent Axes instance
        """
        Artist.__init__(self)
        self.set_figure(axes.figure)

        self.axes = axes
        self.major = Ticker()
        self.minor = Ticker()
        self.callbacks = CallbackRegistry(('units', 'units finalize'))

        #class dummy:
        #    locator = None
        #    formatter = None
        #self.major = dummy()
        #self.minor = dummy()

        self.label = self._get_label()
        self.offsetText = self._get_offset_text()
        self.majorTicks = []
        self.minorTicks = []
        self.pickradius = pickradius

        self.cla()
Ejemplo n.º 20
0
    def __init__(self, axes, loc, label,
                 size   = None,  # points
                 gridOn = None, # defaults to axes.grid
                 tick1On = True,
                 tick2On = True,
                 label1On = True,
                 label2On = False,
                 major = True,
                 ):
        """
        bbox is the Bound2D bounding box in display coords of the Axes
        loc is the tick location in data coords
        size is the tick size in relative, axes coords
        """
        Artist.__init__(self)

        if gridOn is None: gridOn = rcParams['axes.grid']

        self.set_figure(axes.figure)
        self.axes = axes

        name = self.__name__.lower()
        if size is None:
            if major:
                size = rcParams['%s.major.size'%name]
                pad = rcParams['%s.major.pad'%name]
            else:
                size = rcParams['%s.minor.size'%name]
                pad = rcParams['%s.minor.pad'%name]

        self._tickdir = rcParams['%s.direction'%name]
        if self._tickdir == 'in':
            self._xtickmarkers = (TICKUP, TICKDOWN)
            self._ytickmarkers = (TICKRIGHT, TICKLEFT)
            self._pad = Value(pad)
        else:
            self._xtickmarkers = (TICKDOWN, TICKUP)
            self._ytickmarkers = (TICKLEFT, TICKRIGHT)
            self._pad = Value(pad + size)

        self._loc = loc
        self._size = size

        self._padPixels = self.figure.dpi*self._pad*Value(1/72.0)


        self.tick1line = self._get_tick1line(loc)
        self.tick2line = self._get_tick2line(loc)
        self.gridline = self._get_gridline(loc)

        self.label1 = self._get_text1(loc)
        self.label = self.label1  # legacy name
        self.label2 = self._get_text2(loc)

        self.gridOn = gridOn
        self.tick1On = tick1On
        self.tick2On = tick2On
        self.label1On = label1On
        self.label2On = label2On
Ejemplo n.º 21
0
    def __init__(self, axes, loc, label,
                 size   = None,  # points
                 gridOn = None, # defaults to axes.grid
                 tick1On = True,
                 tick2On = True,
                 label1On = True,
                 label2On = False,
                 major = True,
                 ):
        """
        bbox is the Bound2D bounding box in display coords of the Axes
        loc is the tick location in data coords
        size is the tick size in relative, axes coords
        """
        Artist.__init__(self)

        if gridOn is None: gridOn = rcParams['axes.grid']

        self.set_figure(axes.figure)
        self.axes = axes

        name = self.__name__.lower()
        if size is None:
            if major:
                size = rcParams['%s.major.size'%name]
                pad = rcParams['%s.major.pad'%name]
            else:
                size = rcParams['%s.minor.size'%name]
                pad = rcParams['%s.minor.pad'%name]

        self._tickdir = rcParams['%s.direction'%name]
        if self._tickdir == 'in':
            self._xtickmarkers = (TICKUP, TICKDOWN)
            self._ytickmarkers = (TICKRIGHT, TICKLEFT)
            self._pad = Value(pad)
        else:
            self._xtickmarkers = (TICKDOWN, TICKUP)
            self._ytickmarkers = (TICKLEFT, TICKRIGHT)
            self._pad = Value(pad + size)

        self._loc = loc
        self._size = size

        self._padPixels = self.figure.dpi*self._pad*Value(1/72.0)


        self.tick1line = self._get_tick1line(loc)
        self.tick2line = self._get_tick2line(loc)
        self.gridline = self._get_gridline(loc)

        self.label1 = self._get_text1(loc)
        self.label = self.label1  # legacy name
        self.label2 = self._get_text2(loc)

        self.gridOn = gridOn
        self.tick1On = tick1On
        self.tick2On = tick2On
        self.label1On = label1On
        self.label2On = label2On
Ejemplo n.º 22
0
    def __init__(self,
                 figsize   = None,  # defaults to rc figure.figsize
                 dpi       = None,  # defaults to rc figure.dpi
                 facecolor = None,  # defaults to rc figure.facecolor
                 edgecolor = None,  # defaults to rc figure.edgecolor
                 linewidth = 1.0,   # the default linewidth of the frame
                 frameon = True,    # whether or not to draw the figure frame
                 subplotpars = None, # default to rc
                 ):
        """
        figsize is a w,h tuple in inches
        dpi is dots per inch
        subplotpars is a SubplotParams instance, defaults to rc
        """
        Artist.__init__(self)
        #self.set_figure(self)
        self._axstack = Stack()  # maintain the current axes
        self._axobservers = []
        self._seen = {}          # axes args we've seen

        if figsize is None  : figsize   = rcParams['figure.figsize']
        if dpi is None      : dpi       = rcParams['figure.dpi']
        if facecolor is None: facecolor = rcParams['figure.facecolor']
        if edgecolor is None: edgecolor = rcParams['figure.edgecolor']

        self._unit_conversions = {}

        self.dpi = Value(dpi)
        self.figwidth = Value(figsize[0])
        self.figheight = Value(figsize[1])
        self.ll = Point( Value(0), Value(0) )
        self.ur = Point( self.figwidth*self.dpi,
                         self.figheight*self.dpi )
        self.bbox = Bbox(self.ll, self.ur)

        self.frameon = frameon

        self.transFigure = get_bbox_transform( unit_bbox(), self.bbox)



        self.figurePatch = Rectangle(
            xy=(0,0), width=1, height=1,
            facecolor=facecolor, edgecolor=edgecolor,
            linewidth=linewidth,
            )
        self._set_artist_props(self.figurePatch)

        self._hold = rcParams['axes.hold']
        self.canvas = None

        if subplotpars is None:
            subplotpars = SubplotParams()

        self.subplotpars = subplotpars

        self.clf()

        self._cachedRenderer = None
Ejemplo n.º 23
0
    def set_drawing_area(self, da):
        "Update the drawing area the widget renders into"

        if self._drawingArea == da: return 
        #print 'Setting da for', self._text
        Artist.set_drawing_area(self, da)

        self._state_change()
Ejemplo n.º 24
0
    def set_transform(self, t):
        """
        set the Transformation instance used by this artist

        ACCEPTS: a matplotlib.transforms.Transform instance
        """
        Artist.set_transform(self, t)
        self._invalid = True
Ejemplo n.º 25
0
 def test_to_and_from_str_with_albums(self):
     artist = Artist('artist name', 'country')
     first_album = Album('first album title', 2020)
     first_album.add(Song('first song title'))
     first_album.add(Song('second song title'))
     second_album = Album('second album title', 2021)
     second_album.add(Song('third song title'))
     assert Artist.from_string(str(artist)) == artist
def add_artist(art):
    # you don't need with con. THe insert_art method will handle the db connection
    art_1 = Artist( 1, 'L. S.', 'Lowry')
    art_2 = Artist(2,'Claude', 'Monet' )
    art_3 = Artist(3,'Vincent Van', 'Gogh')
    insert_art(art_1)
    insert_art(art_2)
    insert_art(art_3)
Ejemplo n.º 27
0
 def set_axes(self, ax):
     Artist.set_axes(self, ax)
     if ax.xaxis is not None:
         self._xcid = ax.xaxis.callbacks.connect('units',
                                                 self.recache_always)
     if ax.yaxis is not None:
         self._ycid = ax.yaxis.callbacks.connect('units',
                                                 self.recache_always)
Ejemplo n.º 28
0
 def set_axes(self, ax):
     Artist.set_axes(self, ax)
     if ax.xaxis is not None:
         self._xcid = ax.xaxis.callbacks.connect('units',
                                                 self.recache_always)
     if ax.yaxis is not None:
         self._ycid = ax.yaxis.callbacks.connect('units',
                                                 self.recache_always)
Ejemplo n.º 29
0
 def get_artist(self, id):
     print(f'calling Spotify to get artist with id of {id}')
     spotify_artist = self.sp.artist(id)
     artist = Artist()
     artist.id = spotify_artist['id']
     artist.name = spotify_artist['name']
     artist.genres = spotify_artist['genres']
     return artist
Ejemplo n.º 30
0
 def update_from(self, other):
     Artist.update_from(self, other)
     self.set_edgecolor(other.get_edgecolor())
     self.set_facecolor(other.get_facecolor())
     self.set_fill(other.get_fill())
     self.set_linewidth(other.get_linewidth())
     self.set_transform(other.get_transform())
     self.set_figure(other.get_figure())
     self.set_alpha(other.get_alpha())
Ejemplo n.º 31
0
    def set_alpha(self, alpha):

        try:
            float(alpha)
        except TypeError:
            raise TypeError("alpha must be a float")
        else:
            Artist.set_alpha(self, alpha)
            self._colors = [(r, g, b, alpha) for r, g, b, a in self._colors]
Ejemplo n.º 32
0
    def set_alpha(self, alpha):
        """
        Set the alpha value used for blending - not supported on
        all backends

        ACCEPTS: float
        """
        Artist.set_alpha(self, alpha)
        self._imcache = None
Ejemplo n.º 33
0
def sjson(s):
    sim=s.get()
    if sim is None:
        sim=Artist(key=s)
    similar={"name":sim.getName(),
             "logo":sim.getImage(),
             "mbid":sim.key.id()
            }
    return similar    
Ejemplo n.º 34
0
def getlogo(key):
    artist=key.get()
    if artist is None:
        artist=Artist(key=key)
    try:
        logo=images.get_serving_url(artist.getLogo())
    except:
        return ""
    return logo
Ejemplo n.º 35
0
    def set_alpha(self, alpha):
        """
        Set the alpha value used for blending - not supported on
        all backends

        ACCEPTS: float
        """
        Artist.set_alpha(self, alpha)
        self._imcache = None
Ejemplo n.º 36
0
def getSimilar(key):
    artist=key.get()
    if artist is None:
        artist=Artist(key=key)
    similars=[]
    for s in artist.getSimilars():
        similar=sjson(s)
        similars.append(similar)
    return similars
Ejemplo n.º 37
0
 def update_from(self, other):
     'Copy properties from t to self'
     Artist.update_from(self, other)
     self._color = other._color
     self._multialignment = other._multialignment        
     self._verticalalignment = other._verticalalignment
     self._horizontalalignment = other._horizontalalignment
     self._fontproperties = other._fontproperties.copy()
     self._rotation = other._rotation
Ejemplo n.º 38
0
    def set_alpha(self, alpha):

        try:
            float(alpha)
        except TypeError:
            raise TypeError('alpha must be a float')
        else:
            Artist.set_alpha(self, alpha)
            self._colors = [(r, g, b, alpha) for r, g, b, a in self._colors]
Ejemplo n.º 39
0
 def update_from(self, other):
     Artist.update_from(self, other)
     self.set_edgecolor(other.get_edgecolor())
     self.set_facecolor(other.get_facecolor())
     self.set_fill(other.get_fill())
     self.set_linewidth(other.get_linewidth())
     self.set_transform(other.get_transform())
     self.set_figure(other.get_figure())
     self.set_alpha(other.get_alpha())
Ejemplo n.º 40
0
def add_artist(art):
    with conn:

        art_1 = Artist(1, 'L. S.', 'Lowry')
        art_2 = Artist(2, 'Claude', 'Monet')
        art_3 = Artist(3, 'Vincent Van', 'Gogh')
        insert_art(art_1)
        insert_art(art_2)
        insert_art(art_3)
Ejemplo n.º 41
0
    def test_only_available_artist_artworks_are_returned(self):
        # List of artists with unique IDs
        example_artist_list = [
            Artist('John', '*****@*****.**', 1),
            Artist('Gary', '*****@*****.**', 3),
            Artist('Paula', '*****@*****.**', 5)
        ]

        # add each to db
        for artist in example_artist_list:
            artwork_store._add_artist(artist)

        # list of artworks with availability statuses of True or False
        example_artwork_list = [
            Artwork('Pigeon Scape', 150, 1, True),
            Artwork('Tarnished Hallow', 75, 1, False),
            Artwork('Bog Keeper', 140, 1, True),
            Artwork('Dance Rush', 20, 1, True),
            Artwork('Patchwork Sammy', 85, 5, True),
            Artwork('Basked Valley', 560, 3, False),
            Artwork('Patchwork Sammy', 85, 4, True),
            Artwork('Baked Patty', 1600, 3, False)
        ]

        # add each artwork to db
        for art in example_artwork_list:
            artwork_store._add_artwork(art)

        # returned artworks with True status of availability based on given Artowrk ID foreign key to Artist ID primary key
        actual_available_artwork_id_1_list = artwork.get_all_artist_available_artwork(
            1)
        actual_available_artwork_id_3_list = artwork.get_all_artist_available_artwork(
            3)
        actual_available_artwork_id_5_list = artwork.get_all_artist_available_artwork(
            5)

        # what is expected from db when ran based on provided Artwork IDs
        expected_available_artwork_id_1_list = [
            Artwork('Pigeon Scape', 150, 1, True),
            Artwork('Bog Keeper', 140, 1, True),
            Artwork('Dance Rush', 20, 1, True)
        ]

        expected_available_artwork_id_3_list = []

        expected_available_artwork_id_5_list = [
            Artwork('Patchwork Sammy', 85, 5, True)
        ]

        # Checks that list of tuples are equivalent to each other
        self.assertListEqual(expected_available_artwork_id_1_list,
                             actual_available_artwork_id_1_list)
        self.assertListEqual(expected_available_artwork_id_3_list,
                             actual_available_artwork_id_3_list)
        self.assertEqual(expected_available_artwork_id_5_list,
                         actual_available_artwork_id_5_list)
Ejemplo n.º 42
0
 def __init__(
         self,
         figsize=None,  # defaults to rc figure.figsize
         dpi=None,  # defaults to rc figure.dpi
         facecolor=None,  # defaults to rc figure.facecolor
         edgecolor=None,  # defaults to rc figure.edgecolor
         linewidth=1.0,  # the default linewidth of the frame
         frameon=True,  # whether or not to draw the figure frame
         subplotpars=None,  # default to rc
 ):
     """
     *figsize*
         w,h tuple in inches
     *dpi*
         dots per inch
     *facecolor*
         the figure patch facecolor; defaults to rc ``figure.facecolor``
     *edgecolor*
         the figure patch edge color; defaults to rc ``figure.edgecolor``
     *linewidth*
         the figure patch edge linewidth; the default linewidth of the frame
     *frameon*
         if False, suppress drawing the figure frame
     *subplotpars*
         a :class:`SubplotParams` instance, defaults to rc
     """
     Artist.__init__(self)
     self.callbacks = cbook.CallbackRegistry(('dpi_changed', ))
     if figsize is None: figsize = rcParams['figure.figsize']
     if dpi is None: dpi = rcParams['figure.dpi']
     if facecolor is None: facecolor = rcParams['figure.facecolor']
     if edgecolor is None: edgecolor = rcParams['figure.edgecolor']
     self.dpi_scale_trans = Affine2D()
     self.dpi = dpi
     self.bbox_inches = Bbox.from_bounds(0, 0, *figsize)
     self.bbox = TransformedBbox(self.bbox_inches, self.dpi_scale_trans)
     self.frameon = frameon
     self.transFigure = BboxTransformTo(self.bbox)
     self.patch = self.figurePatch = Rectangle(
         xy=(0, 0),
         width=1,
         height=1,
         facecolor=facecolor,
         edgecolor=edgecolor,
         linewidth=linewidth,
     )
     self._set_artist_props(self.patch)
     self._hold = rcParams['axes.hold']
     self.canvas = None
     if subplotpars is None:
         subplotpars = SubplotParams()
     self.subplotpars = subplotpars
     self._axstack = Stack()  # maintain the current axes
     self.axes = []
     self.clf()
     self._cachedRenderer = None
Ejemplo n.º 43
0
    def __init__(
        self, ax, cmap=None, norm=None, interpolation=None, origin=None, extent=None, filternorm=1, filterrad=4.0
    ):

        """
        interpolation and cmap default to their rc settings

        cmap is a cm colormap instance
        norm is a colors.normalize instance to map luminance to 0-1

        extent is a data xmin, xmax, ymin, ymax for making image plots
        registered with data plots.  Default is the image dimensions
        in pixels

        """
        Artist.__init__(self)
        cm.ScalarMappable.__init__(self, norm, cmap)

        if origin is None:
            origin = rcParams["image.origin"]
        self.origin = origin
        self._extent = extent
        self.set_filternorm(filternorm)
        self.set_filterrad(filterrad)

        # map interpolation strings to module constants
        self._interpd = {
            "nearest": _image.NEAREST,
            "bilinear": _image.BILINEAR,
            "bicubic": _image.BICUBIC,
            "spline16": _image.SPLINE16,
            "spline36": _image.SPLINE36,
            "hanning": _image.HANNING,
            "hamming": _image.HAMMING,
            "hermite": _image.HERMITE,
            "kaiser": _image.KAISER,
            "quadric": _image.QUADRIC,
            "catrom": _image.CATROM,
            "gaussian": _image.GAUSSIAN,
            "bessel": _image.BESSEL,
            "mitchell": _image.MITCHELL,
            "sinc": _image.SINC,
            "lanczos": _image.LANCZOS,
            "blackman": _image.BLACKMAN,
        }

        # reverse interp dict
        self._interpdr = dict([(v, k) for k, v in self._interpd.items()])

        if interpolation is None:
            interpolation = rcParams["image.interpolation"]

        self.set_interpolation(interpolation)
        self.axes = ax

        self._imcache = None
Ejemplo n.º 44
0
    def __init__(self, canvas, size=5, **kwprops):
        # A SyntaxError or TypeError will be received if the user tries to
        # supply the size as an arg AND a kwarg. So we don't have to worry
        # about a size property being set in Marker.__init__.

        Artist.__init__(self, canvas, **kwprops)

        self.setOrigin()
        self.setPosition()
        self.setSize(size)
Ejemplo n.º 45
0
    def __init__(self, canvas, size=5, **kwprops):
        # A SyntaxError or TypeError will be received if the user tries to
        # supply the size as an arg AND a kwarg. So we don't have to worry
        # about a size property being set in Marker.__init__.

        Artist.__init__(self, canvas, **kwprops)

        self.setOrigin()
        self.setPosition()
        self.setSize(size)
Ejemplo n.º 46
0
    def __init__(
            self,
            figsize=None,  # defaults to rc figure.figsize
            dpi=None,  # defaults to rc figure.dpi
            facecolor=None,  # defaults to rc figure.facecolor
            edgecolor=None,  # defaults to rc figure.edgecolor
            linewidth=1.0,  # the default linewidth of the frame
            frameon=True,  # whether or not to draw the figure frame
            subplotpars=None,  # default to rc
    ):
        """
        figsize is a w,h tuple in inches
        dpi is dots per inch
        subplotpars is a SubplotParams instance, defaults to rc
        """
        Artist.__init__(self)

        if figsize is None: figsize = rcParams['figure.figsize']
        if dpi is None: dpi = rcParams['figure.dpi']
        if facecolor is None: facecolor = rcParams['figure.facecolor']
        if edgecolor is None: edgecolor = rcParams['figure.edgecolor']

        self._dpi_scale_trans = Affine2D()
        self.dpi = dpi
        self.bbox_inches = Bbox.from_bounds(0, 0, *figsize)
        self.bbox = TransformedBbox(self.bbox_inches, self._dpi_scale_trans)

        self.frameon = frameon

        self.transFigure = BboxTransformTo(self.bbox)

        self.figurePatch = Rectangle(
            xy=(0, 0),
            width=1,
            height=1,
            facecolor=facecolor,
            edgecolor=edgecolor,
            linewidth=linewidth,
        )
        self._set_artist_props(self.figurePatch)

        self._hold = rcParams['axes.hold']
        self.canvas = None

        if subplotpars is None:
            subplotpars = SubplotParams()

        self.subplotpars = subplotpars

        self._axstack = Stack()  # maintain the current axes
        self.axes = []
        self.clf()

        self._cachedRenderer = None
        self._autoLayout = rcParams['figure.autolayout']
Ejemplo n.º 47
0
    def __init__(self,
                 edgeColor=ColorDispatcher().get('k'),
                 faceColor=ColorDispatcher().get('b'),
                 fill=1,
                 ):

        Artist.__init__(self)
        self._edgecolor = edgeColor
        self._facecolor = faceColor
        self.fill = fill
        self._linewidth=1
Ejemplo n.º 48
0
    def __init__(self, figure, canvas):
        """
        **Constructor**

        figure
            The figure to draw the plot on.
        canvas
            The canvas that the figure uses.
        """
        self._figure = figure
        Artist.__init__(self, canvas)
Ejemplo n.º 49
0
 def update_from(self, other):
     "Copy properties from other to self"
     Artist.update_from(self, other)
     self._color = other._color
     self._multialignment = other._multialignment
     self._verticalalignment = other._verticalalignment
     self._horizontalalignment = other._horizontalalignment
     self._fontproperties = other._fontproperties.copy()
     self._rotation = other._rotation
     self._picker = other._picker
     self._linespacing = other._linespacing
Ejemplo n.º 50
0
    def set_alpha(self, alpha):
        """
Set the alpha tranpancies of the collection.  Alpha can be a float, in
which case it is applied to the entire collection, or a sequence of floats

ACCEPTS: float or sequence of floats"""

        try: float(alpha)
        except TypeError: raise TypeError('alpha must be a float')
        else:
            Artist.set_alpha(self, alpha)
            self._colors = [(r,g,b,alpha) for r,g,b,a in self._colors]
Ejemplo n.º 51
0
    def __init__(
        self,
        axes,
        loc,
        label,
        size=None,  # points
        gridOn=None,  # defaults to axes.grid
        tick1On=True,
        tick2On=True,
        label1On=True,
        label2On=False,
        major=True,
    ):
        """
        bbox is the Bound2D bounding box in display coords of the Axes
        loc is the tick location in data coords
        size is the tick size in relative, axes coords
        """
        Artist.__init__(self)

        if gridOn is None:
            gridOn = rcParams["axes.grid"]

        self.set_figure(axes.figure)
        self.axes = axes

        if size is None:
            if major:
                size = rcParams["tick.major.size"]
                pad = rcParams["tick.major.pad"]
            else:
                size = rcParams["tick.minor.size"]
                pad = rcParams["tick.minor.pad"]

        self._loc = loc
        self._size = size
        self._pad = Value(pad)
        self._padPixels = self.figure.dpi * self._pad * Value(1 / 72.0)

        self.tick1line = self._get_tick1line(loc)
        self.tick2line = self._get_tick2line(loc)
        self.gridline = self._get_gridline(loc)

        self.label1 = self._get_text1(loc)
        self.label = self.label1  # legacy name
        self.label2 = self._get_text2(loc)

        self.gridOn = gridOn
        self.tick1On = tick1On
        self.tick2On = tick2On
        self.label1On = label1On
        self.label2On = label2On