Skip to content

Commit fc5131d

Browse files
committed
minor change in CondTestCases to assert that the original structure of the python tests works too (with session is not needed due to use of PythonTest.evaluate()
1 parent 1c8aa4a commit fc5131d

1 file changed

Lines changed: 22 additions & 28 deletions

File tree

‎test/TensorFlowNET.UnitTest/control_flow_ops_test/CondTestCases.cs‎

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public void testCondTrue_ConstOnly()
1919
with(tf.Session(graph), sess =>
2020
{
2121
var x = tf.constant(2, name: "x");
22-
var y = tf.constant(5, name: "y");
22+
var y = tf.constant(5, name: "y");
2323

24-
var z = control_flow_ops.cond(tf.less(x, y),
25-
() => tf.constant(22, name: "t22"),
24+
var z = control_flow_ops.cond(tf.less(x, y),
25+
() => tf.constant(22, name: "t22"),
2626
() => tf.constant(55, name: "f55"));
2727

2828
int result = z.eval(sess);
@@ -40,8 +40,8 @@ public void testCondFalse_ConstOnly()
4040
var x = tf.constant(2, name: "x");
4141
var y = tf.constant(1, name: "y");
4242

43-
var z = control_flow_ops.cond(tf.less(x, y),
44-
() => tf.constant(22, name: "t22"),
43+
var z = control_flow_ops.cond(tf.less(x, y),
44+
() => tf.constant(22, name: "t22"),
4545
() => tf.constant(11, name: "f11"));
4646

4747
int result = z.eval(sess);
@@ -52,42 +52,36 @@ public void testCondFalse_ConstOnly()
5252
[TestMethod]
5353
public void testCondTrue()
5454
{
55-
var graph = tf.Graph().as_default();
55+
tf.Graph().as_default();
5656

57-
with(tf.Session(graph), sess =>
58-
{
59-
var x = tf.constant(2, name: "x");
60-
var y = tf.constant(5, name: "y");
57+
var x = tf.constant(2, name: "x");
58+
var y = tf.constant(5, name: "y");
6159

62-
var z = control_flow_ops.cond(tf.less(x, y),
63-
() => tf.multiply(x, 17),
64-
() => tf.add(y, 23));
60+
var z = control_flow_ops.cond(tf.less(x, y),
61+
() => tf.multiply(x, 17),
62+
() => tf.add(y, 23));
6563

66-
int result = z.eval(sess);
67-
assertEquals(result, 34);
68-
});
64+
var result = evaluate<int>(z);
65+
assertEquals(result, 34);
6966
}
7067

7168
[TestMethod]
7269
public void testCondFalse()
7370
{
74-
var graph = tf.Graph().as_default();
71+
tf.Graph().as_default();
7572

76-
with(tf.Session(graph), sess =>
77-
{
78-
var x = tf.constant(2);
79-
var y = tf.constant(1);
73+
var x = tf.constant(2);
74+
var y = tf.constant(1);
8075

81-
var z = control_flow_ops.cond(tf.less(x, y),
82-
() => tf.multiply(x, 17),
83-
() => tf.add(y, 23));
76+
var z = control_flow_ops.cond(tf.less(x, y),
77+
() => tf.multiply(x, 17),
78+
() => tf.add(y, 23));
8479

85-
int result = z.eval(sess);
86-
assertEquals(result, 24);
87-
});
80+
var result = evaluate<int>(z);
81+
assertEquals(result, 24);
8882
}
8983

90-
// NOTE: all other test python test cases of this class are either not needed due to strong typing or dest a deprecated api
84+
// NOTE: all other python test cases of this class are either not needed due to strong typing or test a deprecated api
9185

9286
}
9387
}

0 commit comments

Comments
 (0)