<s> from __future__ import absolute_import , division , print_function <EOL> from abc import ABCMeta , abstractproperty , abstractmethod <EOL> import numpy as np <EOL> from glue . external import six <EOL> from glue . core . subset import Subset <EOL> from glue . core . exceptions import IncompatibleAttribute <EOL> from glue . core . layer_artist import MatplotlibLayerArtist , ChangedTrigger <EOL> __all__ = [ '<STR_LIT>' ] <EOL> @ six . add_metaclass ( ABCMeta ) <EOL> class ScatterLayerBase ( object ) : <EOL> xatt = abstractproperty ( ) <EOL> yatt = abstractproperty ( ) <EOL> @ abstractmethod <EOL> def get_data ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class ScatterLayerArtist ( MatplotlibLayerArtist , ScatterLayerBase ) : <EOL> xatt = ChangedTrigger ( ) <EOL> yatt = ChangedTrigger ( ) <EOL> _property_set = MatplotlibLayerArtist . _property_set + [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def __init__ ( self , layer , ax ) : <EOL> super ( ScatterLayerArtist , self ) . __init__ ( layer , ax ) <EOL> self . emphasis = None <EOL> def _recalc ( self ) : <EOL> self . clear ( ) <EOL> assert len ( self . artists ) == <NUM_LIT:0> <EOL> try : <EOL> x = self . layer [ self . xatt ] . ravel ( ) <EOL> y = self . layer [ self . yatt ] . ravel ( ) <EOL> except IncompatibleAttribute as exc : <EOL> self . disable_invalid_attributes ( * exc . args ) <EOL> return False <EOL> self . artists = self . _axes . plot ( x , y ) <EOL> return True <EOL> def update ( self , view = None , transpose = False ) : <EOL> self . _check_subset_state_changed ( ) <EOL> if self . _changed : <EOL> if not self . _recalc ( ) : <EOL> return <EOL> self . _changed = False <EOL> has_emph = False <EOL> if self . emphasis is not None : <EOL> try : <EOL> s = Subset ( self . layer . data ) <EOL> s . subset_state = self . emphasis <EOL> if hasattr ( self . layer , '<STR_LIT>' ) : <EOL> s . subset_state &= self . layer . subset_state <EOL> x = s [ self . xatt ] . ravel ( ) <EOL> y = s [ self . yatt ] . ravel ( ) <EOL> self . artists . extend ( self . _axes . plot ( x , y ) ) <EOL> has_emph = True <EOL> except IncompatibleAttribute : <EOL> pass <EOL> self . _sync_style ( ) <EOL> if has_emph : <EOL> self . artists [ - <NUM_LIT:1> ] . set_mec ( '<STR_LIT>' ) <EOL> self . artists [ - <NUM_LIT:1> ] . set_mew ( <NUM_LIT:2> ) <EOL> self . artists [ - <NUM_LIT:1> ] . set_alpha ( <NUM_LIT:1> ) <EOL> def get_data ( self ) : <EOL> try : <EOL> return self . layer [ self . xatt ] . ravel ( ) , self . layer [ self . yatt ] . ravel ( ) <EOL> except IncompatibleAttribute : <EOL> return np . array ( [ ] ) , np . array ( [ ] ) </s>
