<s> from os . path import abspath <EOL> from io import BytesIO <EOL> import copy <EOL> import numpy <EOL> import unittest <EOL> from mayavi . core . null_engine import NullEngine <EOL> from mayavi . sources . array_source import ArraySource <EOL> from mayavi . modules . outline import Outline <EOL> from mayavi . modules . streamline import Streamline <EOL> class TestStreamline ( unittest . 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 setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> e = NullEngine ( ) <EOL> e . start ( ) <EOL> s = e . new_scene ( ) <EOL> self . e = e <EOL> self . s = s <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> e . add_source ( d ) <EOL> o = Outline ( ) <EOL> e . add_module ( o ) <EOL> st = Streamline ( ) <EOL> e . add_module ( st ) <EOL> widget = st . seed . widget <EOL> widget . set ( radius = <NUM_LIT:1.0> , center = ( - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ) , <EOL> theta_resolution = <NUM_LIT:4> , phi_resolution = <NUM_LIT:4> ) <EOL> st = Streamline ( streamline_type = '<STR_LIT>' ) <EOL> seed = st . seed <EOL> seed . widget = seed . widget_list [ <NUM_LIT:1> ] <EOL> e . add_module ( st ) <EOL> seed . widget . set ( point1 = ( - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ) , point2 = ( - <NUM_LIT> , - <NUM_LIT> , <NUM_LIT> ) ) <EOL> st . ribbon_filter . width = <NUM_LIT> <EOL> st = Streamline ( streamline_type = '<STR_LIT>' ) <EOL> seed = st . seed <EOL> seed . widget = seed . widget_list [ <NUM_LIT:2> ] <EOL> e . add_module ( st ) <EOL> seed . widget . set ( center = ( - <NUM_LIT> , <NUM_LIT> , - <NUM_LIT> ) ) <EOL> st . tube_filter . radius = <NUM_LIT> <EOL> st = Streamline ( streamline_type = '<STR_LIT>' ) <EOL> seed = st . seed <EOL> seed . widget = seed . widget_list [ <NUM_LIT:3> ] <EOL> e . add_module ( st ) <EOL> seed . widget . position = ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> st . tube_filter . radius = <NUM_LIT> <EOL> self . st = st <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> src = s . children [ <NUM_LIT:0> ] <EOL> st = src . children [ <NUM_LIT:0> ] . children [ <NUM_LIT:2> ] <EOL> self . assertEqual ( st . streamline_type , '<STR_LIT>' ) <EOL> self . assertEqual ( st . ribbon_filter . width , <NUM_LIT> ) <EOL> self . assertEqual ( st . seed . widget , st . seed . widget_list [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( numpy . allclose ( st . seed . widget . point1 , <EOL> ( - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ) ) , True ) <EOL> self . assertEqual ( numpy . allclose ( st . seed . widget . point2 , <EOL> ( - <NUM_LIT> , - <NUM_LIT> , <NUM_LIT> ) ) , True ) <EOL> st = src . children [ <NUM_LIT:0> ] . children [ <NUM_LIT:3> ] <EOL> self . assertEqual ( st . streamline_type , '<STR_LIT>' ) <EOL> self . assertEqual ( st . tube_filter . radius , <NUM_LIT> ) <EOL> self . assertEqual ( st . seed . widget , st . seed . widget_list [ <NUM_LIT:2> ] ) <EOL> self . assertEqual ( numpy . allclose ( st . seed . widget . center , <EOL> ( - <NUM_LIT> , <NUM_LIT> , - <NUM_LIT> ) ) , True ) <EOL> st = src . children [ <NUM_LIT:0> ] . children [ <NUM_LIT:4> ] <EOL> self . assertEqual ( st . streamline_type , '<STR_LIT>' ) <EOL> self . assertEqual ( st . tube_filter . radius , <NUM_LIT> ) <EOL> self . assertEqual ( st . seed . widget , st . seed . widget_list [ <NUM_LIT:3> ] ) <EOL> self . assertEqual ( numpy . allclose ( st . seed . widget . position , <EOL> ( - <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) ) , True ) <EOL> def test_streamline ( self ) : <EOL> "<STR_LIT>" <EOL> self . check ( ) <EOL> def test_components_changed ( self ) : <EOL> """<STR_LIT>""" <EOL> st = self . st <EOL> tf = st . tube_filter <EOL> st . tube_filter = tf . __class__ ( ) <EOL> st . tube_filter = tf <EOL> st . ribbon_filter = st . ribbon_filter . __class__ ( ) <EOL> seed = st . seed <EOL> st . seed = seed . __class__ ( ) <EOL> st . seed = seed <EOL> st . actor = st . actor . __class__ ( ) <EOL> tracer = st . stream_tracer <EOL> st . stream_tracer = tracer . __class__ ( ) <EOL> st . stream_tracer = tracer <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> sources = s . children <EOL> s . children = [ ] <EOL> s . children . extend ( sources ) <EOL> self . check ( ) <EOL> sources1 = copy . deepcopy ( sources ) <EOL> s . children [ : ] = sources1 <EOL> self . check ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
