<s> """<STR_LIT>""" <EOL> from os . path import abspath <EOL> from io import BytesIO <EOL> import copy <EOL> import numpy <EOL> from traits . api import TraitError <EOL> from common import TestCase <EOL> class TestGlyph ( TestCase ) : <EOL> def make_data ( self ) : <EOL> """<STR_LIT>""" <EOL> s = numpy . arange ( <NUM_LIT:0.0> , <NUM_LIT> , <NUM_LIT> ) <EOL> s = numpy . reshape ( s , ( <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> ) ) <EOL> s = numpy . transpose ( s ) <EOL> v = numpy . zeros ( <NUM_LIT> , '<STR_LIT:d>' ) <EOL> v [ <NUM_LIT:1> : : <NUM_LIT:3> ] = <NUM_LIT:1.0> <EOL> v = numpy . reshape ( v , ( <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:10> , <NUM_LIT:3> ) ) <EOL> return s , v <EOL> def set_view ( self , s ) : <EOL> """<STR_LIT>""" <EOL> s . scene . z_plus_view ( ) <EOL> c = s . scene . camera <EOL> c . azimuth ( - <NUM_LIT:30> ) <EOL> c . elevation ( <NUM_LIT:20> ) <EOL> s . render ( ) <EOL> def check ( self ) : <EOL> script = self . script <EOL> s = script . engine . current_scene <EOL> src = s . children [ <NUM_LIT:0> ] <EOL> g = src . children [ <NUM_LIT:0> ] . children [ <NUM_LIT:1> ] <EOL> assert g . glyph . glyph_source . glyph_position == '<STR_LIT>' <EOL> assert g . glyph . glyph . vector_mode == '<STR_LIT>' <EOL> assert g . glyph . glyph . scale_factor == <NUM_LIT:0.5> <EOL> assert g . actor . property . line_width == <NUM_LIT:1.0> <EOL> v = src . children [ <NUM_LIT:0> ] . children [ <NUM_LIT:2> ] <EOL> glyph = v . glyph <EOL> gs = glyph . glyph_source <EOL> assert gs . glyph_position == '<STR_LIT>' <EOL> assert gs . glyph_source == gs . glyph_list [ <NUM_LIT:1> ] <EOL> assert numpy . allclose ( v . implicit_plane . normal , ( <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ) ) <EOL> v = src . children [ <NUM_LIT:0> ] . children [ <NUM_LIT:3> ] <EOL> glyph = v . glyph <EOL> gs = glyph . glyph_source <EOL> assert gs . glyph_source == gs . glyph_list [ <NUM_LIT:2> ] <EOL> assert gs . glyph_position == '<STR_LIT>' <EOL> assert numpy . allclose ( v . implicit_plane . normal , ( <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ) ) <EOL> def test ( self ) : <EOL> self . main ( ) <EOL> def do ( self ) : <EOL> script = self . script <EOL> from mayavi . sources . array_source import ArraySource <EOL> from mayavi . modules . outline import Outline <EOL> from mayavi . modules . glyph import Glyph <EOL> from mayavi . modules . vector_cut_plane import VectorCutPlane <EOL> s = self . new_scene ( ) <EOL> d = ArraySource ( ) <EOL> sc , vec = self . make_data ( ) <EOL> d . origin = ( - <NUM_LIT:5> , - <NUM_LIT:5> , - <NUM_LIT:5> ) <EOL> d . scalar_data = sc <EOL> d . vector_data = vec <EOL> script . add_source ( d ) <EOL> o = Outline ( ) <EOL> script . add_module ( o ) <EOL> g = Glyph ( ) <EOL> script . add_module ( g ) <EOL> g . glyph . glyph_source . glyph_position = '<STR_LIT>' <EOL> g . glyph . glyph . vector_mode = '<STR_LIT>' <EOL> g . glyph . glyph . scale_factor = <NUM_LIT:0.5> <EOL> g . actor . property . line_width = <NUM_LIT:1.0> <EOL> v = VectorCutPlane ( ) <EOL> glyph = v . glyph <EOL> gs = glyph . glyph_source <EOL> gs . glyph_position = '<STR_LIT>' <EOL> gs . glyph_source = gs . glyph_list [ <NUM_LIT:1> ] <EOL> script . add_module ( v ) <EOL> v . implicit_plane . set ( normal = ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> ) , origin = ( <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:0> ) ) <EOL> v = VectorCutPlane ( ) <EOL> glyph = v . glyph <EOL> gs = glyph . glyph_source <EOL> gs . glyph_source = gs . glyph_list [ <NUM_LIT:2> ] <EOL> gs . glyph_position = '<STR_LIT>' <EOL> script . add_module ( v ) <EOL> v . implicit_plane . set ( normal = ( <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:0> ) , origin = ( <NUM_LIT:0> , - <NUM_LIT:2> , <NUM_LIT:0> ) ) <EOL> self . set_view ( s ) <EOL> self . check ( ) <EOL> g . actor = g . actor . __class__ ( ) <EOL> glyph = g . glyph <EOL> g . glyph = glyph . __class__ ( ) <EOL> g . glyph = glyph <EOL> glyph = v . glyph <EOL> v . glyph = glyph . __class__ ( ) <EOL> v . glyph = glyph <EOL> v . actor = v . actor . __class__ ( ) <EOL> v . cutter = v . cutter . __class__ ( ) <EOL> ip = v . implicit_plane <EOL> v . implicit_plane = ip . __class__ ( ) <EOL> v . implicit_plane = ip <EOL> s . render ( ) <EOL> self . check ( ) <EOL> f = BytesIO ( ) <EOL> f . name = abspath ( '<STR_LIT>' ) <EOL> script . save_visualization ( f ) <EOL> f . seek ( <NUM_LIT:0> ) <EOL> engine = script . engine <EOL> engine . close_scene ( s ) <EOL> script . load_visualization ( f ) <EOL> s = engine . current_scene <EOL> self . set_view ( s ) <EOL> self . check ( ) <EOL> sources = s . children <EOL> s . children = [ ] <EOL> s . children . extend ( sources ) <EOL> self . set_view ( s ) <EOL> self . check ( ) <EOL> sources1 = copy . deepcopy ( sources ) <EOL> s . children [ : ] = sources <EOL> self . set_view ( s ) <EOL> self . check ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> t = TestGlyph ( ) <EOL> t . test ( ) </s>
