<s> from os . path import abspath <EOL> from io import BytesIO <EOL> import copy <EOL> import unittest <EOL> from mayavi . tests import datasets <EOL> from mayavi . core . engine import Engine <EOL> from mayavi . core . null_engine import NullEngine <EOL> from mayavi . sources . vtk_data_source import VTKDataSource <EOL> from mayavi . modules . outline import Outline <EOL> from mayavi . modules . grid_plane import GridPlane <EOL> class TestGridPlane ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> e = NullEngine ( ) <EOL> e . start ( ) <EOL> e . new_scene ( ) <EOL> self . e = e <EOL> sgrid = datasets . generateStructuredGrid ( ) <EOL> src = VTKDataSource ( data = sgrid ) <EOL> e . add_source ( src ) <EOL> o = Outline ( ) <EOL> e . add_module ( o ) <EOL> gp1 = GridPlane ( ) <EOL> e . add_module ( gp1 ) <EOL> gp2 = GridPlane ( ) <EOL> gp2 . grid_plane . axis = '<STR_LIT:y>' <EOL> gp2 . grid_plane . position = <NUM_LIT:16> <EOL> e . add_module ( gp2 ) <EOL> gp3 = GridPlane ( ) <EOL> e . add_module ( gp3 ) <EOL> gp3 . grid_plane . axis = '<STR_LIT:z>' <EOL> gp3 . grid_plane . position = <NUM_LIT:6> <EOL> for gp in ( gp1 , gp2 , gp3 ) : <EOL> gp . actor . property . set ( ambient = <NUM_LIT:1.0> ) <EOL> self . scene = e . current_scene <EOL> return <EOL> def tearDown ( self ) : <EOL> """<STR_LIT>""" <EOL> self . e . stop ( ) <EOL> return <EOL> def check ( self ) : <EOL> """<STR_LIT>""" <EOL> s = self . scene <EOL> mm = s . children [ <NUM_LIT:0> ] . children [ <NUM_LIT:0> ] <EOL> gp1 , gp2 , gp3 = mm . children [ <NUM_LIT:1> : ] <EOL> self . assertEqual ( gp1 . grid_plane . axis , '<STR_LIT:x>' ) <EOL> self . assertEqual ( gp1 . grid_plane . position , <NUM_LIT:0> ) <EOL> self . assertEqual ( gp1 . actor . property . ambient , <NUM_LIT:1.0> ) <EOL> self . assertEqual ( gp2 . grid_plane . axis , '<STR_LIT:y>' ) <EOL> self . assertEqual ( gp2 . grid_plane . position , <NUM_LIT:16> ) <EOL> self . assertEqual ( gp2 . actor . property . ambient , <NUM_LIT:1.0> ) <EOL> self . assertEqual ( gp3 . grid_plane . axis , '<STR_LIT:z>' ) <EOL> self . assertEqual ( gp3 . grid_plane . position , <NUM_LIT:6> ) <EOL> self . assertEqual ( gp3 . actor . property . ambient , <NUM_LIT:1.0> ) <EOL> def test_grid_plane ( self ) : <EOL> "<STR_LIT>" <EOL> self . check ( ) <EOL> def test_save_and_restore ( self ) : <EOL> """<STR_LIT>""" <EOL> engine = self . e <EOL> scene = self . scene <EOL> f = BytesIO ( ) <EOL> f . name = abspath ( '<STR_LIT>' ) <EOL> engine . save_visualization ( f ) <EOL> f . seek ( <NUM_LIT:0> ) <EOL> engine . close_scene ( scene ) <EOL> engine . load_visualization ( f ) <EOL> self . scene = engine . current_scene <EOL> self . check ( ) <EOL> def test_deepcopied ( self ) : <EOL> """<STR_LIT>""" <EOL> s = self . scene <EOL> source = s . children . pop ( ) <EOL> s . children . append ( source ) <EOL> self . check ( ) <EOL> source1 = copy . deepcopy ( source ) <EOL> s . children [ <NUM_LIT:0> ] = source1 <EOL> self . check ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
