Example #1
0
  def testShape(self):
    for pad in (False, True):
      for _ in range(10):
        msg = [np.random.bytes(np.random.randint(20))
               for _ in range(np.random.randint(10))]
        self._RunTest(msg, pad=pad)

      # Zero-element, non-trivial shapes.
      for _ in range(10):
        k = np.random.randint(10)
        msg = np.empty((0, k), dtype=bytes)
        encoded = string_ops.encode_base64(msg, pad=pad)
        decoded = string_ops.decode_base64(encoded)

        with self.cached_session() as sess:
          encoded_value, decoded_value = self.evaluate([encoded, decoded])

        self.assertEqual(encoded_value.shape, msg.shape)
        self.assertEqual(decoded_value.shape, msg.shape)
Example #2
0
  def testShape(self):
    for pad in (False, True):
      for _ in range(10):
        msg = [np.random.bytes(np.random.randint(20))
               for _ in range(np.random.randint(10))]
        self._RunTest(msg, pad=pad)

      # Zero-element, non-trivial shapes.
      for _ in range(10):
        k = np.random.randint(10)
        msg = np.empty((0, k), dtype=bytes)
        encoded = string_ops.encode_base64(msg, pad=pad)
        decoded = string_ops.decode_base64(encoded)

        with self.cached_session() as sess:
          encoded_value, decoded_value = sess.run([encoded, decoded])

        self.assertEqual(encoded_value.shape, msg.shape)
        self.assertEqual(decoded_value.shape, msg.shape)
Example #3
0
 def setUp(self):
   self._msg = array_ops.placeholder(dtype=dtypes.string)
   self._encoded_f = string_ops.encode_base64(self._msg, pad=False)
   self._decoded_f = string_ops.decode_base64(self._encoded_f)
   self._encoded_t = string_ops.encode_base64(self._msg, pad=True)
   self._decoded_t = string_ops.decode_base64(self._encoded_t)
Example #4
0
 def setUp(self):
   self._msg = array_ops.placeholder(dtype=dtypes.string)
   self._encoded_f = string_ops.encode_base64(self._msg, pad=False)
   self._decoded_f = string_ops.decode_base64(self._encoded_f)
   self._encoded_t = string_ops.encode_base64(self._msg, pad=True)
   self._decoded_t = string_ops.decode_base64(self._encoded_t)