<s> """<STR_LIT>""" <EOL> from __future__ import ( absolute_import , division , print_function , <EOL> unicode_literals ) <EOL> import six <EOL> import os <EOL> import unittest <EOL> import nose <EOL> import numpy as np <EOL> from numpy . testing import ( assert_equal , assert_almost_equal , assert_allclose ) <EOL> import pims <EOL> path , _ = os . path . split ( os . path . abspath ( __file__ ) ) <EOL> path = os . path . join ( path , '<STR_LIT:data>' ) <EOL> def _skip_if_no_bioformats ( ) : <EOL> if not pims . bioformats . available ( ) : <EOL> raise nose . SkipTest ( '<STR_LIT>' ) <EOL> def assert_image_equal ( actual , expected ) : <EOL> if np . issubdtype ( actual . dtype , np . integer ) : <EOL> assert_equal ( actual , expected ) <EOL> else : <EOL> if np . issubdtype ( expected . dtype , np . integer ) : <EOL> expected = expected / float ( np . iinfo ( expected . dtype ) . max ) <EOL> assert_allclose ( actual , expected , atol = <NUM_LIT:1> / <NUM_LIT> ) <EOL> class _image_single ( object ) : <EOL> def check_skip ( self ) : <EOL> pass <EOL> def test_bool ( self ) : <EOL> self . check_skip ( ) <EOL> pass <EOL> def test_open ( self ) : <EOL> self . v . close ( ) <EOL> self . v = pims . open ( self . filename ) <EOL> def test_integer_attributes ( self ) : <EOL> self . check_skip ( ) <EOL> assert_equal ( len ( self . v . frame_shape ) , len ( self . expected_shape ) ) <EOL> self . assertTrue ( isinstance ( self . v . frame_shape [ <NUM_LIT:0> ] , six . integer_types ) ) <EOL> self . assertTrue ( isinstance ( self . v . frame_shape [ <NUM_LIT:1> ] , six . integer_types ) ) <EOL> self . assertTrue ( isinstance ( len ( self . v ) , six . integer_types ) ) <EOL> def test_shape ( self ) : <EOL> self . check_skip ( ) <EOL> assert_equal ( self . v . frame_shape , self . expected_shape ) <EOL> def test_count ( self ) : <EOL> self . check_skip ( ) <EOL> assert_equal ( len ( self . v ) , self . expected_len ) <EOL> def test_repr ( self ) : <EOL> self . check_skip ( ) <EOL> repr ( self . v ) <EOL> class _image_series ( _image_single ) : <EOL> def test_iterator ( self ) : <EOL> self . check_skip ( ) <EOL> iter ( self . v ) <EOL> def test_getting_slice ( self ) : <EOL> self . check_skip ( ) <EOL> tmp = list ( self . v [ <NUM_LIT:0> : <NUM_LIT:2> ] ) <EOL> frame0 , frame1 = tmp <EOL> def test_getting_single_frame ( self ) : <EOL> self . v [ <NUM_LIT:0> ] <EOL> self . v [ <NUM_LIT:0> ] <EOL> self . v [ <NUM_LIT:1> ] <EOL> self . v [ <NUM_LIT:1> ] <EOL> def test_getting_list ( self ) : <EOL> self . check_skip ( ) <EOL> list ( self . v [ [ <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:1> ] ] ) <EOL> def test_frame_number_present ( self ) : <EOL> self . check_skip ( ) <EOL> for frame_no in [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> ] : <EOL> self . assertTrue ( hasattr ( self . v [ frame_no ] , '<STR_LIT>' ) ) <EOL> not_none = self . v [ frame_no ] . frame_no is not None <EOL> self . assertTrue ( not_none ) <EOL> def test_frame_number_accurate ( self ) : <EOL> self . check_skip ( ) <EOL> for frame_no in [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> ] : <EOL> self . assertEqual ( self . v [ frame_no ] . frame_no , frame_no ) <EOL> def test_simple_negative_index ( self ) : <EOL> self . check_skip ( ) <EOL> self . v [ - <NUM_LIT:1> ] <EOL> list ( self . v [ [ <NUM_LIT:0> , - <NUM_LIT:1> ] ] ) <EOL> class _image_stack ( object ) : <EOL> def check_skip ( self ) : <EOL> pass <EOL> def test_getting_stack ( self ) : <EOL> self . check_skip ( ) <EOL> assert_equal ( self . v [ <NUM_LIT:0> ] . shape [ - <NUM_LIT:3> ] , self . expected_Z ) <EOL> def test_sizeZ ( self ) : <EOL> self . check_skip ( ) <EOL> assert_equal ( self . v . sizes [ '<STR_LIT:z>' ] , self . expected_Z ) <EOL> class _image_multichannel ( object ) : <EOL> def check_skip ( self ) : <EOL> pass <EOL> def test_change_channel ( self ) : <EOL> self . check_skip ( ) <EOL> self . v . bundle_axes = '<STR_LIT>' <EOL> channel0 , channel1 = self . v [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , self . v [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] <EOL> self . v . bundle_axes = '<STR_LIT>' <EOL> self . v . default_coords [ '<STR_LIT:c>' ] = <NUM_LIT:0> <EOL> assert_image_equal ( self . v [ <NUM_LIT:0> ] , channel0 ) <EOL> self . v . default_coords [ '<STR_LIT:c>' ] = <NUM_LIT:1> <EOL> assert_image_equal ( self . v [ <NUM_LIT:0> ] , channel1 ) <EOL> def test_sizeC ( self ) : <EOL> self . check_skip ( ) <EOL> assert_equal ( self . v . sizes [ '<STR_LIT:c>' ] , self . expected_C ) <EOL> class TestBioformatsTiff ( _image_series , unittest . TestCase ) : <EOL> def check_skip ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> def setUp ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> self . filename = os . path . join ( path , '<STR_LIT>' ) <EOL> self . frame0 = np . load ( os . path . join ( path , '<STR_LIT>' ) ) <EOL> self . frame1 = np . load ( os . path . join ( path , '<STR_LIT>' ) ) <EOL> self . klass = pims . Bioformats <EOL> self . kwargs = { '<STR_LIT>' : False } <EOL> self . v = self . klass ( self . filename , ** self . kwargs ) <EOL> self . expected_shape = ( <NUM_LIT> , <NUM_LIT> ) <EOL> self . expected_len = <NUM_LIT:5> <EOL> def test_getting_single_frame ( self ) : <EOL> self . check_skip ( ) <EOL> assert_image_equal ( self . v [ <NUM_LIT:0> ] , self . frame0 ) <EOL> assert_image_equal ( self . v [ <NUM_LIT:1> ] , self . frame1 ) <EOL> def tearDown ( self ) : <EOL> self . v . close ( ) <EOL> class TestBioformatsND2 ( _image_series , _image_multichannel , unittest . TestCase ) : <EOL> def check_skip ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> def setUp ( self ) : <EOL> self . filename = os . path . join ( path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . check_skip ( ) <EOL> self . klass = pims . Bioformats <EOL> self . kwargs = { '<STR_LIT>' : False } <EOL> self . v = self . klass ( self . filename , ** self . kwargs ) <EOL> self . expected_shape = ( <NUM_LIT:10> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . expected_len = <NUM_LIT:3> <EOL> self . expected_Z = <NUM_LIT:10> <EOL> self . expected_C = <NUM_LIT:2> <EOL> def tearDown ( self ) : <EOL> self . v . close ( ) <EOL> class TestBioformatsMOV ( _image_series , unittest . TestCase ) : <EOL> def check_skip ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> if not os . path . isfile ( self . filename ) : <EOL> raise nose . SkipTest ( '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> self . filename = os . path . join ( path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . check_skip ( ) <EOL> self . klass = pims . Bioformats <EOL> self . kwargs = { '<STR_LIT>' : False } <EOL> self . v = self . klass ( self . filename , ** self . kwargs ) <EOL> self . expected_shape = ( <NUM_LIT> , <NUM_LIT> ) <EOL> self . expected_len = <NUM_LIT> <EOL> self . expected_C = <NUM_LIT:3> <EOL> def tearDown ( self ) : <EOL> self . v . close ( ) <EOL> class TestBioformatsIPW ( _image_series , _image_stack , _image_multichannel , <EOL> unittest . TestCase ) : <EOL> def check_skip ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> if not os . path . isfile ( self . filename ) : <EOL> raise nose . SkipTest ( '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> self . filename = os . path . join ( path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . check_skip ( ) <EOL> self . klass = pims . Bioformats <EOL> self . kwargs = { '<STR_LIT>' : False } <EOL> self . v = self . klass ( self . filename , ** self . kwargs ) <EOL> self . expected_shape = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . expected_len = <NUM_LIT:7> <EOL> self . expected_C = <NUM_LIT:2> <EOL> self . expected_Z = <NUM_LIT> <EOL> def tearDown ( self ) : <EOL> self . v . close ( ) <EOL> class TestBioformatsDM3 ( _image_single , unittest . TestCase ) : <EOL> def check_skip ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> if not os . path . isfile ( self . filename ) : <EOL> raise nose . SkipTest ( '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> self . filename = os . path . join ( path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . check_skip ( ) <EOL> self . klass = pims . Bioformats <EOL> self . kwargs = { '<STR_LIT>' : False } <EOL> self . v = self . klass ( self . filename , ** self . kwargs ) <EOL> self . expected_shape = ( <NUM_LIT> , <NUM_LIT> ) <EOL> self . expected_len = <NUM_LIT:1> <EOL> def tearDown ( self ) : <EOL> self . v . close ( ) <EOL> class TestBioformatsLSM ( _image_series , _image_stack , _image_multichannel , <EOL> unittest . TestCase ) : <EOL> def check_skip ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> if not os . path . isfile ( self . filename ) : <EOL> raise nose . SkipTest ( '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> self . filename = os . path . join ( path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . check_skip ( ) <EOL> self . klass = pims . Bioformats <EOL> self . kwargs = { '<STR_LIT>' : False } <EOL> self . v = self . klass ( self . filename , ** self . kwargs ) <EOL> self . expected_shape = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . expected_len = <NUM_LIT> <EOL> self . expected_C = <NUM_LIT:2> <EOL> self . expected_Z = <NUM_LIT> <EOL> def tearDown ( self ) : <EOL> self . v . close ( ) <EOL> class TestBioformatsAndorTiff ( _image_series , _image_stack , _image_multichannel , <EOL> unittest . TestCase ) : <EOL> def check_skip ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> if not os . path . isfile ( self . filename ) : <EOL> raise nose . SkipTest ( '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> self . filename = os . path . join ( path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . check_skip ( ) <EOL> self . klass = pims . Bioformats <EOL> self . kwargs = { '<STR_LIT>' : False } <EOL> self . v = self . klass ( self . filename , ** self . kwargs ) <EOL> self . expected_shape = ( <NUM_LIT:4> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . expected_len = <NUM_LIT:5> <EOL> self . expected_C = <NUM_LIT:2> <EOL> self . expected_Z = <NUM_LIT:4> <EOL> def tearDown ( self ) : <EOL> self . v . close ( ) <EOL> class TestBioformatsOlympusTiff ( _image_series , _image_stack , unittest . TestCase ) : <EOL> def check_skip ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> if not os . path . isfile ( self . filename ) : <EOL> raise nose . SkipTest ( '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> self . filename = os . path . join ( path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . check_skip ( ) <EOL> self . klass = pims . Bioformats <EOL> self . kwargs = { '<STR_LIT>' : False } <EOL> self . v = self . klass ( self . filename , ** self . kwargs ) <EOL> self . expected_shape = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . expected_len = <NUM_LIT:16> <EOL> self . expected_Z = <NUM_LIT> <EOL> def tearDown ( self ) : <EOL> self . v . close ( ) <EOL> class TestBioformatsLIFseries1 ( _image_single , _image_stack , _image_multichannel , <EOL> unittest . TestCase ) : <EOL> def check_skip ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> if not os . path . isfile ( self . filename ) : <EOL> raise nose . SkipTest ( '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> self . filename = os . path . join ( path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . check_skip ( ) <EOL> self . klass = pims . Bioformats <EOL> self . kwargs = { '<STR_LIT>' : False , '<STR_LIT>' : <NUM_LIT:0> } <EOL> self . v = self . klass ( self . filename , ** self . kwargs ) <EOL> self . expected_shape = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . expected_len = <NUM_LIT:1> <EOL> self . expected_C = <NUM_LIT:4> <EOL> self . expected_Z = <NUM_LIT> <EOL> def test_count_series ( self ) : <EOL> assert_equal ( self . v . size_series , <NUM_LIT:2> ) <EOL> def test_switch_series ( self ) : <EOL> self . v . series = <NUM_LIT:1> <EOL> assert_equal ( self . v . sizes [ '<STR_LIT:z>' ] , <NUM_LIT> ) <EOL> def tearDown ( self ) : <EOL> self . v . close ( ) <EOL> class TestBioformatsLIFseries2 ( _image_single , _image_stack , _image_multichannel , <EOL> unittest . TestCase ) : <EOL> def check_skip ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> if not os . path . isfile ( self . filename ) : <EOL> raise nose . SkipTest ( '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> self . filename = os . path . join ( path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . check_skip ( ) <EOL> self . klass = pims . Bioformats <EOL> self . kwargs = { '<STR_LIT>' : False , '<STR_LIT>' : <NUM_LIT:1> } <EOL> self . v = self . klass ( self . filename , ** self . kwargs ) <EOL> self . expected_shape = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . expected_len = <NUM_LIT:1> <EOL> self . expected_C = <NUM_LIT:4> <EOL> self . expected_Z = <NUM_LIT> <EOL> def tearDown ( self ) : <EOL> self . v . close ( ) <EOL> class TestBioformatsIPL ( _image_single , unittest . TestCase ) : <EOL> def check_skip ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> if not os . path . isfile ( self . filename ) : <EOL> raise nose . SkipTest ( '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> self . filename = os . path . join ( path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . check_skip ( ) <EOL> self . klass = pims . Bioformats <EOL> self . kwargs = { '<STR_LIT>' : False } <EOL> self . v = self . klass ( self . filename , ** self . kwargs ) <EOL> self . expected_shape = ( <NUM_LIT> , <NUM_LIT> ) <EOL> self . expected_len = <NUM_LIT:1> <EOL> def tearDown ( self ) : <EOL> self . v . close ( ) <EOL> class TestBioformatsSEQ ( _image_single , _image_stack , unittest . TestCase ) : <EOL> def check_skip ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> if not os . path . isfile ( self . filename ) : <EOL> raise nose . SkipTest ( '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> self . filename = os . path . join ( path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . check_skip ( ) <EOL> self . klass = pims . Bioformats <EOL> self . kwargs = { '<STR_LIT>' : False } <EOL> self . v = self . klass ( self . filename , ** self . kwargs ) <EOL> self . expected_shape = ( <NUM_LIT:30> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . expected_len = <NUM_LIT:1> <EOL> self . expected_Z = <NUM_LIT:30> <EOL> def tearDown ( self ) : <EOL> self . v . close ( ) <EOL> class TestBioformatsLEI ( _image_single , _image_stack , unittest . TestCase ) : <EOL> def check_skip ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> if not os . path . isfile ( self . filename ) : <EOL> raise nose . SkipTest ( '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> self . filename = os . path . join ( path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . check_skip ( ) <EOL> self . klass = pims . Bioformats <EOL> self . kwargs = { '<STR_LIT>' : False } <EOL> self . v = self . klass ( self . filename , ** self . kwargs ) <EOL> self . expected_shape = ( <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . expected_len = <NUM_LIT:1> <EOL> self . expected_Z = <NUM_LIT:3> <EOL> def tearDown ( self ) : <EOL> self . v . close ( ) <EOL> class TestBioformatsICS ( _image_single , unittest . TestCase ) : <EOL> def check_skip ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> if not os . path . isfile ( self . filename ) : <EOL> raise nose . SkipTest ( '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> self . filename = os . path . join ( path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . check_skip ( ) <EOL> self . klass = pims . Bioformats <EOL> self . kwargs = { '<STR_LIT>' : False } <EOL> self . v = self . klass ( self . filename , ** self . kwargs ) <EOL> self . expected_shape = ( <NUM_LIT> , <NUM_LIT> ) <EOL> self . expected_len = <NUM_LIT:1> <EOL> def tearDown ( self ) : <EOL> self . v . close ( ) <EOL> class TestBioformatsZPO ( _image_stack , _image_multichannel , unittest . TestCase ) : <EOL> def check_skip ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> if not os . path . isfile ( self . filename ) : <EOL> raise nose . SkipTest ( '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> self . filename = os . path . join ( path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . check_skip ( ) <EOL> self . klass = pims . Bioformats <EOL> self . kwargs = { '<STR_LIT>' : False } <EOL> self . v = self . klass ( self . filename , ** self . kwargs ) <EOL> self . expected_shape = ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . expected_C = <NUM_LIT:3> <EOL> self . expected_Z = <NUM_LIT> <EOL> def tearDown ( self ) : <EOL> self . v . close ( ) <EOL> class TestBioformatsMetadataND2 ( unittest . TestCase ) : <EOL> def check_skip ( self ) : <EOL> _skip_if_no_bioformats ( ) <EOL> def setUp ( self ) : <EOL> self . filename = os . path . join ( path , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . check_skip ( ) <EOL> self . klass = pims . Bioformats <EOL> def tearDown ( self ) : <EOL> self . v . close ( ) <EOL> def test_metadataretrieve ( self ) : <EOL> self . v = self . klass ( self . filename , meta = True ) <EOL> self . v . bundle_axes = '<STR_LIT>' <EOL> assert_equal ( self . v . metadata . ChannelCount ( <NUM_LIT:0> ) , <NUM_LIT:2> ) <EOL> assert_equal ( self . v . metadata . ChannelName ( <NUM_LIT:0> , <NUM_LIT:0> ) , '<STR_LIT>' ) <EOL> assert_almost_equal ( self . v . metadata . PixelsPhysicalSizeX ( <NUM_LIT:0> ) , <EOL> <NUM_LIT> ) <EOL> assert_almost_equal ( self . v . calibration , <NUM_LIT> ) <EOL> assert_almost_equal ( self . v [ <NUM_LIT:0> ] . metadata [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> assert_equal ( self . v [ <NUM_LIT:0> ] . metadata [ '<STR_LIT:t>' ] , <NUM_LIT:0> ) <EOL> del self . v . frame_metadata [ '<STR_LIT>' ] <EOL> assert '<STR_LIT>' not in self . v [ <NUM_LIT:0> ] . metadata <EOL> self . v . frame_metadata [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> assert '<STR_LIT>' in self . v [ <NUM_LIT:0> ] . metadata <EOL> assert_allclose ( self . v [ <NUM_LIT:0> ] . metadata [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> atol = <NUM_LIT> ) <EOL> def test_metadata_raw ( self ) : <EOL> self . v = self . klass ( self . filename , meta = False ) <EOL> metadata = self . v . get_metadata_raw ( '<STR_LIT>' ) <EOL> assert_equal ( metadata [ '<STR_LIT>' ] , '<STR_LIT:2>' ) <EOL> assert_equal ( metadata [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> assert_equal ( metadata [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_metadata_tags ( self ) : <EOL> self . v = self . klass ( self . filename , meta = True ) <EOL> fields = self . v . metadata . fields <EOL> assert '<STR_LIT>' in fields <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> nose . runmodule ( argv = [ __file__ , '<STR_LIT>' ] , <EOL> exit = False ) </s>
