@@ -1463,10 +1463,10 @@ class AssertShapesTest(test.TestCase):
14631463 def test_raise_static_shape_mismatch (self ):
14641464 x = array_ops .ones ([3 , 2 ], name = "x" )
14651465 y = array_ops .ones ([2 , 3 ], name = "y" )
1466- shapes = {
1467- x : ("N" , "Q" ),
1468- y : ("N" , "D" ),
1469- }
1466+ shapes = [
1467+ ( x , ("N" , "Q" ) ),
1468+ ( y , ("N" , "D" ) ),
1469+ ]
14701470 regex = (r"Specified by tensor .* dimension 0. "
14711471 r"Tensor .* dimension 0 must have size 3. "
14721472 r"Received size 2" )
@@ -1476,10 +1476,10 @@ def test_raise_dynamic_shape_mismatch(self):
14761476 with ops .Graph ().as_default ():
14771477 x = array_ops .placeholder (dtypes .float32 , [None , 2 ], name = "x" )
14781478 y = array_ops .placeholder (dtypes .float32 , [None , 3 ], name = "y" )
1479- shapes = {
1480- x : ("N" , "Q" ),
1481- y : ("N" , "D" ),
1482- }
1479+ shapes = [
1480+ ( x , ("N" , "Q" ) ),
1481+ ( y , ("N" , "D" ) ),
1482+ ]
14831483 regex = (r"\[Specified by tensor x.* dimension 0\] "
14841484 r"\[Tensor y.* dimension\] \[0\] \[must have size\] \[3\]" )
14851485 feed_dict = {x : np .ones ([3 , 2 ]), y : np .ones ([2 , 3 ])}
@@ -1489,10 +1489,10 @@ def test_raise_dynamic_shape_mismatch(self):
14891489 def test_raise_static_shape_explicit_mismatch (self ):
14901490 x = array_ops .ones ([3 , 2 ], name = "x" )
14911491 y = array_ops .ones ([2 , 3 ], name = "y" )
1492- shapes = {
1493- x : (3 , "Q" ),
1494- y : (3 , "D" ),
1495- }
1492+ shapes = [
1493+ ( x , (3 , "Q" ) ),
1494+ ( y , (3 , "D" ) ),
1495+ ]
14961496 regex = (r"Specified explicitly. "
14971497 r"Tensor .* dimension 0 must have size 3. "
14981498 r"Received size 2" )
@@ -1502,21 +1502,21 @@ def test_raise_static_shape_explicit_mismatch(self):
15021502 def test_rank_zero_rank_one_size_one_equivalence (self ):
15031503 rank_one_size_one = array_ops .ones ([1 ], name = "rank_one_size_one" )
15041504 rank_zero = array_ops .constant (5 , name = "rank_zero" )
1505- check_ops .assert_shapes ({
1506- rank_one_size_one : ( ),
1507- rank_zero : ( ),
1508- } )
1509- check_ops .assert_shapes ({
1510- rank_one_size_one : (1 ,),
1511- rank_zero : (1 ,),
1512- } )
1505+ check_ops .assert_shapes ([
1506+ ( rank_one_size_one , () ),
1507+ ( rank_zero , () ),
1508+ ] )
1509+ check_ops .assert_shapes ([
1510+ ( rank_one_size_one , (1 ,) ),
1511+ ( rank_zero , (1 ,) ),
1512+ ] )
15131513
15141514 @test_util .run_in_graph_and_eager_modes
15151515 def test_raise_static_rank_1_size_not_1_mismatch_scalar (self ):
15161516 x = array_ops .constant ([2 , 2 ], name = "x" )
1517- shapes = {
1518- x : ( ),
1519- }
1517+ shapes = [
1518+ ( x , () ),
1519+ ]
15201520 regex = (r"Specified explicitly. "
15211521 r"Tensor .* dimension 0 must have size 1. "
15221522 r"Received size 2" )
@@ -1525,9 +1525,9 @@ def test_raise_static_rank_1_size_not_1_mismatch_scalar(self):
15251525 @test_util .run_in_graph_and_eager_modes
15261526 def test_raise_static_scalar_mismatch_rank_1_size_not_1 (self ):
15271527 x = array_ops .constant (2 , name = "x" )
1528- shapes = {
1529- x : (2 ,),
1530- }
1528+ shapes = [
1529+ ( x , (2 ,) ),
1530+ ]
15311531 regex = (r"Specified explicitly. "
15321532 r"Tensor .* dimension 0 must have size 2. "
15331533 r"Received size 1" )
@@ -1537,7 +1537,7 @@ def test_raise_static_scalar_mismatch_rank_1_size_not_1(self):
15371537 def test_scalar_implies_size_one (self ):
15381538 scalar = array_ops .constant (5 , name = "rank_zero" )
15391539 x = array_ops .ones ([2 , 2 ], name = "x" )
1540- shapes = { scalar : ("a" ,), x : ("a" , 2 )}
1540+ shapes = [( scalar , ("a" ,)), ( x , ("a" , 2 ))]
15411541 regex = (r"Specified by tensor .* dimension 0. "
15421542 r"Tensor .* dimension 0 must have size 1. "
15431543 r"Received size 2" )
@@ -1546,7 +1546,7 @@ def test_scalar_implies_size_one(self):
15461546 @test_util .run_in_graph_and_eager_modes
15471547 def test_raise_not_iterable (self ):
15481548 x = array_ops .constant ([1 , 2 ], name = "x" )
1549- shapes = { x : 2 }
1549+ shapes = [( x , 2 )]
15501550 regex = (r"Tensor .*. "
15511551 r"Specified shape must be an iterable. "
15521552 r"An iterable has the attribute `__iter__` or `__getitem__`. "
@@ -1557,10 +1557,10 @@ def test_raise_dynamic_shape_explicit_mismatch(self):
15571557 with ops .Graph ().as_default ():
15581558 x = array_ops .placeholder (dtypes .float32 , [None , 2 ], name = "xa" )
15591559 y = array_ops .placeholder (dtypes .float32 , [None , 3 ], name = "y" )
1560- shapes = {
1561- x : (3 , "Q" ),
1562- y : (3 , "D" ),
1563- }
1560+ shapes = [
1561+ ( x , (3 , "Q" ) ),
1562+ ( y , (3 , "D" ) ),
1563+ ]
15641564 regex = (r"\[Specified explicitly\] "
15651565 r"\[Tensor y.* dimension\] \[0\] \[must have size\] \[3\]" )
15661566 feed_dict = {x : np .ones ([3 , 2 ]), y : np .ones ([2 , 3 ])}
@@ -1569,7 +1569,7 @@ def test_raise_dynamic_shape_explicit_mismatch(self):
15691569 @test_util .run_in_graph_and_eager_modes
15701570 def test_no_op_when_specified_as_unknown (self ):
15711571 x = array_ops .constant ([1 , 1 ], name = "x" )
1572- assertion = check_ops .assert_shapes ({ x : None } )
1572+ assertion = check_ops .assert_shapes ([( x , None )] )
15731573 with ops .control_dependencies ([assertion ]):
15741574 out = array_ops .identity (x )
15751575 self .evaluate (out )
@@ -1616,7 +1616,7 @@ def test_raises_dynamic_incorrect_rank(self):
16161616 for shape in rank_two_shapes :
16171617 regex = r"Tensor .* must have rank\] \[2\]"
16181618 self .raises_dynamic_error (
1619- shapes = { x : shape } , regex = regex , feed_dict = {x : x_value })
1619+ shapes = [( x , shape )] , regex = regex , feed_dict = {x : x_value })
16201620
16211621 @test_util .run_in_graph_and_eager_modes
16221622 def test_correctly_matching (self ):
@@ -1626,25 +1626,25 @@ def test_correctly_matching(self):
16261626 x = array_ops .ones ([1 , 2 , 3 ], name = "x" )
16271627 y = array_ops .ones ([3 , 1 , 2 ], name = "y" )
16281628 z = array_ops .ones ([2 , 3 , 1 ], name = "z" )
1629- assertion = check_ops .assert_shapes ({
1630- x : ("a" , "b" , "c" ),
1631- y : ("c" , "a" , "b" ),
1632- z : ("b" , "c" , "a" ),
1633- v : ("a" , "b" ),
1634- w : ("c" ,),
1635- u : "a"
1636- } )
1629+ assertion = check_ops .assert_shapes ([
1630+ ( x , ("a" , "b" , "c" ) ),
1631+ ( y , ("c" , "a" , "b" ) ),
1632+ ( z , ("b" , "c" , "a" ) ),
1633+ ( v , ("a" , "b" ) ),
1634+ ( w , ("c" ,) ),
1635+ ( u , "a" )
1636+ ] )
16371637 with ops .control_dependencies ([assertion ]):
16381638 out = array_ops .identity (x )
16391639 self .evaluate (out )
1640- assertion = check_ops .assert_shapes ({
1641- x : (1 , "b" , "c" ),
1642- y : ("c" , "a" , 2 ),
1643- z : ("b" , 3 , "a" ),
1644- v : ("a" , 2 ),
1645- w : (3 ,),
1646- u : ( )
1647- } )
1640+ assertion = check_ops .assert_shapes ([
1641+ ( x , (1 , "b" , "c" ) ),
1642+ ( y , ("c" , "a" , 2 ) ),
1643+ ( z , ("b" , 3 , "a" ) ),
1644+ ( v , ("a" , 2 ) ),
1645+ ( w , (3 ,) ),
1646+ ( u , () )
1647+ ] )
16481648 with ops .control_dependencies ([assertion ]):
16491649 out = array_ops .identity (x )
16501650 self .evaluate (out )
@@ -1653,10 +1653,10 @@ def test_correctly_matching(self):
16531653 def test_variable_length_symbols (self ):
16541654 x = array_ops .ones ([4 , 1 ], name = "x" )
16551655 y = array_ops .ones ([4 , 2 ], name = "y" )
1656- assertion = check_ops .assert_shapes ({
1657- x : ("num_observations" , "input_dim" ),
1658- y : ("num_observations" , "output_dim" ),
1659- } )
1656+ assertion = check_ops .assert_shapes ([
1657+ ( x , ("num_observations" , "input_dim" ) ),
1658+ ( y , ("num_observations" , "output_dim" ) ),
1659+ ] )
16601660 with ops .control_dependencies ([assertion ]):
16611661 out = array_ops .identity (x )
16621662 self .evaluate (out )
@@ -1665,22 +1665,22 @@ def test_variable_length_symbols(self):
16651665 def test_raise_implicit_mismatch_using_iterable_alternatives (self ):
16661666 x = array_ops .ones ([2 , 2 ], name = "x" )
16671667 y = array_ops .ones ([1 , 3 ], name = "y" )
1668- styles = [{
1669- x : ("A" , "B" ),
1670- y : ("A" , "C" ),
1671- }, {
1672- x : "AB" ,
1673- y : "AC"
1674- }, {
1675- x : ["A" , "B" ],
1676- y : ["A" , "C" ],
1677- }, {
1678- x : np .array (["A" , "B" ]),
1679- y : np .array (["A" , "C" ])
1680- }, {
1681- x : ("A" , "B" ),
1682- y : "AC"
1683- } ]
1668+ styles = [[
1669+ ( x , ("A" , "B" ) ),
1670+ ( y , ("A" , "C" ) ),
1671+ ], [
1672+ ( x , "AB" ) ,
1673+ ( y , "AC" )
1674+ ], [
1675+ ( x , ["A" , "B" ]) ,
1676+ ( y , ["A" , "C" ]) ,
1677+ ], [
1678+ ( x , np .array (["A" , "B" ]) ),
1679+ ( y , np .array (["A" , "C" ]) )
1680+ ], [
1681+ ( x , ("A" , "B" ) ),
1682+ ( y , "AC" )
1683+ ] ]
16841684 for shapes in styles :
16851685 self .raises_static_error (
16861686 shapes = shapes ,
@@ -1692,22 +1692,22 @@ def test_raise_implicit_mismatch_using_iterable_alternatives(self):
16921692 def test_raise_explicit_mismatch_using_iterable_alternatives (self ):
16931693 x = array_ops .ones ([2 , 2 ], name = "x" )
16941694 y = array_ops .ones ([1 , 3 ], name = "y" )
1695- styles = [{
1696- x : (2 , 2 ),
1697- y : (2 , 3 ),
1698- }, {
1699- x : "22" ,
1700- y : "23"
1701- }, {
1702- x : [2 , 2 ],
1703- y : [2 , 3 ],
1704- }, {
1705- x : np .array ([2 , 2 ]),
1706- y : np .array ([2 , 3 ])
1707- }, {
1708- x : (2 , 2 ),
1709- y : "23"
1710- } ]
1695+ styles = [[
1696+ ( x , (2 , 2 ) ),
1697+ ( y , (2 , 3 ) ),
1698+ ], [
1699+ ( x , "22" ) ,
1700+ ( y , "23" )
1701+ ], [
1702+ ( x , [2 , 2 ]) ,
1703+ ( y , [2 , 3 ]) ,
1704+ ], [
1705+ ( x , np .array ([2 , 2 ]) ),
1706+ ( y , np .array ([2 , 3 ]) )
1707+ ], [
1708+ ( x , (2 , 2 ) ),
1709+ ( y , "23" )
1710+ ] ]
17111711 for shapes in styles :
17121712 self .raises_static_error (
17131713 shapes = shapes ,
@@ -1720,16 +1720,16 @@ def test_dim_size_specified_as_unknown(self):
17201720 x = array_ops .ones ([1 , 2 , 3 ], name = "x" )
17211721 y = array_ops .ones ([2 , 1 ], name = "y" )
17221722 a1 = check_ops .assert_shapes ({
1723- x : (None , 2 , None ),
1724- y : (None , 1 ),
1723+ ( x , (None , 2 , None ) ),
1724+ ( y , (None , 1 ) ),
17251725 })
17261726 a2 = check_ops .assert_shapes ({
1727- x : ("." , 2 , "." ),
1728- y : ("." , 1 ),
1727+ ( x , ("." , 2 , "." ) ),
1728+ ( y , ("." , 1 ) ),
17291729 })
17301730 a3 = check_ops .assert_shapes ({
1731- x : ".2." ,
1732- y : ".1" ,
1731+ ( x , ".2." ) ,
1732+ ( y , ".1" ) ,
17331733 })
17341734 with ops .control_dependencies ([a1 , a2 , a3 ]):
17351735 out = array_ops .identity (x )
@@ -1739,14 +1739,14 @@ def test_dim_size_specified_as_unknown(self):
17391739 def test_raise_static_shape_explicit_mismatch_innermost_dims (self ):
17401740 x = array_ops .ones ([3 , 2 ], name = "x" )
17411741 y = array_ops .ones ([2 , 3 ], name = "y" )
1742- s1 = {
1743- x : (3 , "Q" ),
1744- y : (Ellipsis , 3 , "D" ),
1745- }
1746- s2 = {
1747- x : "3Q" ,
1748- y : "*3D" ,
1749- }
1742+ s1 = [
1743+ ( x , (3 , "Q" ) ),
1744+ ( y , (Ellipsis , 3 , "D" ) ),
1745+ ]
1746+ s2 = [
1747+ ( x , "3Q" ) ,
1748+ ( y , "*3D" ) ,
1749+ ]
17501750 regex = (r"Specified explicitly. "
17511751 r"Tensor .* dimension -2 must have size 3. "
17521752 r"Received size 2" )
@@ -1757,27 +1757,27 @@ def test_raise_static_shape_explicit_mismatch_innermost_dims(self):
17571757 def test_correctly_matching_innermost_dims (self ):
17581758 x = array_ops .ones ([1 , 2 , 3 , 2 ], name = "x" )
17591759 y = array_ops .ones ([2 , 3 , 3 ], name = "y" )
1760- a1 = check_ops .assert_shapes ({
1761- x : (Ellipsis , "N" , "Q" ),
1762- y : (Ellipsis , "N" , "D" ),
1763- } )
1764- a2 = check_ops .assert_shapes ({
1765- x : "*NQ" ,
1766- y : "*ND" ,
1767- } )
1760+ a1 = check_ops .assert_shapes ([
1761+ ( x , (Ellipsis , "N" , "Q" ) ),
1762+ ( y , (Ellipsis , "N" , "D" ) ),
1763+ ] )
1764+ a2 = check_ops .assert_shapes ([
1765+ ( x , "*NQ" ) ,
1766+ ( y , "*ND" ) ,
1767+ ] )
17681768 with ops .control_dependencies ([a1 , a2 ]):
17691769 out = array_ops .identity (x )
17701770 self .evaluate (out )
17711771
17721772 @test_util .run_in_graph_and_eager_modes
17731773 def test_raise_variable_num_outer_dims_prefix_misuse (self ):
17741774 x = array_ops .ones ([1 , 2 ], name = "x" )
1775- s1 = {
1776- x : ("N" , Ellipsis , "Q" ),
1777- }
1778- s2 = {
1779- x : "N*Q" ,
1780- }
1775+ s1 = [
1776+ ( x , ("N" , Ellipsis , "Q" ) ),
1777+ ]
1778+ s2 = [
1779+ ( x , "N*Q" ) ,
1780+ ]
17811781 regex = (r"Tensor .* specified shape index .*. "
17821782 r"Symbol `...` or `\*` for a variable number of "
17831783 r"unspecified dimensions is only allowed as the first entry" )
@@ -1786,7 +1786,7 @@ def test_raise_variable_num_outer_dims_prefix_misuse(self):
17861786
17871787 @test_util .run_in_graph_and_eager_modes
17881788 def test_empty_shapes_dict_no_op (self ):
1789- assertion = check_ops .assert_shapes ({} )
1789+ assertion = check_ops .assert_shapes ([] )
17901790 with ops .control_dependencies ([assertion ]):
17911791 out = array_ops .identity (0 )
17921792 self .evaluate (out )
0 commit comments