<s> from os . path import abspath <EOL> from io import BytesIO <EOL> import copy <EOL> import unittest <EOL> import numpy <EOL> from mayavi . core . null_engine import NullEngine <EOL> from mayavi . sources . vtk_xml_file_reader import VTKXMLFileReader <EOL> from mayavi . modules . outline import Outline <EOL> from mayavi . modules . contour_grid_plane import ContourGridPlane <EOL> from mayavi . modules . scalar_cut_plane import ScalarCutPlane <EOL> from mayavi . tests . common import get_example_data <EOL> class TestVTKXMLReader ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> e = NullEngine ( ) <EOL> e . start ( ) <EOL> e . new_scene ( ) <EOL> self . e = e <EOL> r = VTKXMLFileReader ( ) <EOL> r . initialize ( get_example_data ( '<STR_LIT>' ) ) <EOL> e . add_source ( r ) <EOL> o = Outline ( ) <EOL> e . add_module ( o ) <EOL> cgp1 = ContourGridPlane ( ) <EOL> e . add_module ( cgp1 ) <EOL> cgp1 . grid_plane . position = <NUM_LIT:1> <EOL> cgp2 = ContourGridPlane ( ) <EOL> cgp2 . contour . filled_contours = True <EOL> cgp2 . grid_plane . axis = '<STR_LIT:y>' <EOL> cgp2 . grid_plane . position = <NUM_LIT:1> <EOL> e . add_module ( cgp2 ) <EOL> cp = ScalarCutPlane ( ) <EOL> e . add_module ( cp ) <EOL> ip = cp . implicit_plane <EOL> ip . normal = <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> <EOL> ip . origin = <NUM_LIT:0.5> , <NUM_LIT:0.5> , <NUM_LIT:1.0> <EOL> ip . widget . origin = <NUM_LIT:0.5> , <NUM_LIT:0.5> , <NUM_LIT:1.0> <EOL> ip . widget . enabled = False <EOL> self . scene = e . current_scene <EOL> self . cgp2 = cgp2 <EOL> self . cp = cp <EOL> return <EOL> def tearDown ( self ) : <EOL> """<STR_LIT>""" <EOL> self . e . stop ( ) <EOL> return <EOL> def check ( self ) : <EOL> """<STR_LIT>""" <EOL> scene = self . scene <EOL> src = scene . children [ <NUM_LIT:0> ] <EOL> mm = src . children [ <NUM_LIT:0> ] <EOL> cgp1 = mm . children [ <NUM_LIT:1> ] <EOL> self . assertEqual ( cgp1 . grid_plane . position , <NUM_LIT:1> ) <EOL> cgp2 = mm . children [ <NUM_LIT:2> ] <EOL> self . assertEqual ( cgp2 . contour . filled_contours , True ) <EOL> self . assertEqual ( cgp2 . grid_plane . axis , '<STR_LIT:y>' ) <EOL> self . assertEqual ( cgp2 . grid_plane . position , <NUM_LIT:1> ) <EOL> cp = mm . children [ <NUM_LIT:3> ] <EOL> ip = cp . implicit_plane <EOL> self . assertAlmostEqual ( numpy . sum ( ip . normal - ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ) ) , <NUM_LIT> ) <EOL> self . assertAlmostEqual ( numpy . sum ( ip . origin - ( <NUM_LIT:0.5> , <NUM_LIT:0.5> , <NUM_LIT:1.0> ) ) , <NUM_LIT:0.0> ) <EOL> self . assertEqual ( ip . widget . enabled , False ) <EOL> def test_vtk_xml_reader ( 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> cp = source . children [ <NUM_LIT:0> ] . children [ - <NUM_LIT:1> ] <EOL> cp . implicit_plane . widget . enabled = False <EOL> self . check ( ) <EOL> source1 = copy . deepcopy ( source ) <EOL> s . children [ <NUM_LIT:0> ] = source1 <EOL> cp = source1 . children [ <NUM_LIT:0> ] . children [ - <NUM_LIT:1> ] <EOL> cp . implicit_plane . widget . enabled = False <EOL> self . check ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
