예제 #1
0
 def test_range_tensor(self):
     with self.cached_session() as sess:
         r = py_builtins.range_(constant_op.constant(3))
         self.assertAllEqual(self.evaluate(r), [0, 1, 2])
         r = py_builtins.range_(1, constant_op.constant(3))
         self.assertAllEqual(self.evaluate(r), [1, 2])
         r = py_builtins.range_(2, 0, constant_op.constant(-1))
         self.assertAllEqual(self.evaluate(r), [2, 1])
예제 #2
0
 def test_range_tensor(self):
   with self.test_session() as sess:
     r = py_builtins.range_(constant_op.constant(3))
     self.assertAllEqual(sess.run(r), [0, 1, 2])
     r = py_builtins.range_(1, constant_op.constant(3))
     self.assertAllEqual(sess.run(r), [1, 2])
     r = py_builtins.range_(2, 0, constant_op.constant(-1))
     self.assertAllEqual(sess.run(r), [2, 1])
예제 #3
0
 def test_range_tensor_empty_range(self):
     with self.session() as sess:
         r = py_builtins.range_(constant_op.constant(-3))
         self.assertAllEqual(self.evaluate(r), [])
         r = py_builtins.range_(5, constant_op.constant(2))
         self.assertAllEqual(self.evaluate(r), [])
예제 #4
0
 def test_range(self):
     self.assertListEqual(list(py_builtins.range_(3)), [0, 1, 2])
     self.assertListEqual(list(py_builtins.range_(1, 3)), [1, 2])
     self.assertListEqual(list(py_builtins.range_(2, 0, -1)), [2, 1])
예제 #5
0
 def test_range(self):
   self.assertListEqual(list(py_builtins.range_(3)), [0, 1, 2])
   self.assertListEqual(list(py_builtins.range_(1, 3)), [1, 2])
   self.assertListEqual(list(py_builtins.range_(2, 0, -1)), [2, 1])
 def test_range_tensor_empty_range(self):
   with self.session() as sess:
     r = py_builtins.range_(constant_op.constant(-3))
     self.assertAllEqual(sess.run(r), [])
     r = py_builtins.range_(5, constant_op.constant(2))
     self.assertAllEqual(sess.run(r), [])