Ejemplo n.º 1
0
 def test_new_name(self):
     rename_axis_lt = ops.rename_axis(self.original_lt, 'channel', 'foo')
     expected_axes = [(name if name != 'channel' else 'foo', axis.value)
                      for name, axis in self.original_lt.axes.items()]
     expected_lt = core.LabeledTensor(self.original_lt.tensor,
                                      expected_axes)
     self.assertLabeledTensorsEqual(rename_axis_lt, expected_lt)
Ejemplo n.º 2
0
 def test_invalid_input(self):
     with self.assertRaisesRegexp(ValueError, 'not contained in the set'):
         ops.rename_axis(self.original_lt, 'foo', 'bar')
Ejemplo n.º 3
0
 def test_identity(self):
     rename_axis_lt = ops.rename_axis(self.original_lt, 'channel',
                                      'channel')
     self.assertLabeledTensorsEqual(rename_axis_lt, self.original_lt)
Ejemplo n.º 4
0
 def test_name(self):
     rename_axis_lt = ops.rename_axis(self.original_lt, 'channel', 'foo')
     self.assertIn('lt_rename_axis', rename_axis_lt.name)
Ejemplo n.º 5
0
 def test_invalid_input(self):
   with self.assertRaisesRegexp(ValueError, 'not contained in the set'):
     ops.rename_axis(self.original_lt, 'foo', 'bar')
Ejemplo n.º 6
0
 def test_new_name(self):
   rename_axis_lt = ops.rename_axis(self.original_lt, 'channel', 'foo')
   expected_axes = [(name if name != 'channel' else 'foo', axis.value)
                    for name, axis in self.original_lt.axes.items()]
   expected_lt = core.LabeledTensor(self.original_lt.tensor, expected_axes)
   self.assertLabeledTensorsEqual(rename_axis_lt, expected_lt)
Ejemplo n.º 7
0
 def test_identity(self):
   rename_axis_lt = ops.rename_axis(self.original_lt, 'channel', 'channel')
   self.assertLabeledTensorsEqual(rename_axis_lt, self.original_lt)
Ejemplo n.º 8
0
 def test_name(self):
   rename_axis_lt = ops.rename_axis(self.original_lt, 'channel', 'foo')
   self.assertIn('lt_rename_axis', rename_axis_lt.name)