<s> """<STR_LIT>""" <EOL> from numpy import sqrt <EOL> from numpy . random import random <EOL> from traits . api import HasTraits , Property , Array , Font <EOL> from traitsui . api import View , Item , TabularEditor <EOL> from traitsui . tabular_adapter import TabularAdapter <EOL> class ArrayAdapter ( TabularAdapter ) : <EOL> columns = [ ( '<STR_LIT:i>' , '<STR_LIT:index>' ) , ( '<STR_LIT:x>' , <NUM_LIT:0> ) , ( '<STR_LIT:y>' , <NUM_LIT:1> ) , ( '<STR_LIT:z>' , <NUM_LIT:2> ) ] <EOL> alignment = '<STR_LIT:right>' <EOL> format = '<STR_LIT>' <EOL> index_text = Property <EOL> index_image = Property <EOL> def _get_index_text ( self ) : <EOL> return str ( self . row ) <EOL> def _get_index_image ( self ) : <EOL> x , y , z = self . item <EOL> if sqrt ( ( x - <NUM_LIT:0.5> ) ** <NUM_LIT:2> + ( y - <NUM_LIT:0.5> ) ** <NUM_LIT:2> + ( z - <NUM_LIT:0.5> ) ** <NUM_LIT:2> ) <= <NUM_LIT> : <EOL> return '<STR_LIT>' <EOL> return None <EOL> class ShowArray ( HasTraits ) : <EOL> data = Array <EOL> view = View ( <EOL> Item ( '<STR_LIT:data>' , <EOL> show_label = False , <EOL> style = '<STR_LIT>' , <EOL> editor = TabularEditor ( adapter = ArrayAdapter ( ) ) <EOL> ) , <EOL> title = '<STR_LIT>' , <EOL> width = <NUM_LIT> , <EOL> height = <NUM_LIT> , <EOL> resizable = True <EOL> ) <EOL> demo = ShowArray ( data = random ( ( <NUM_LIT> , <NUM_LIT:3> ) ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> demo . configure_traits ( ) </s>
