def test_constructor_shape(self): """Test construction of shape of tensor""" ranks = ["M", "K"] name = "ME" t1 = Tensor(rank_ids=ranks, name=name) self.assertEqual(t1.getName(), name) t2 = Tensor(rank_ids=ranks) t2.setName(name) self.assertEqual(t2.getName(), name)
def __init__(self, *tensors): """__init__""" # # Set up logging # self.logger = logging.getLogger('fibertree.graphics.spacetime_canvas') # # Structures to hold infomation about each tracked tensor # self.tensors = [] self.spacetime = [] self.highlights = [] for tensor in tensors: # # Append each tensor being tracked, conditionally # unwraping it if it is a Payload object # self.tensors.append(Payload.get(tensor)) # # Create a "spacetime" tensor to hold the spacetime # information for this tracked tensor # if isinstance(tensor, Tensor): assert tensor.getShape() != [], "No support for 0-D tensors" spacetime = Tensor(rank_ids=["T"] + tensor.getRankIds()) spacetime.setName(tensor.getName()) spacetime.setColor(tensor.getColor()) else: assert tensor.getDepth() == 1, "Only 1-D fibers are supported" spacetime = Tensor(rank_ids=["T", "S"]) # # Append the "spacetime" tensor to hold this tracked # tensor's spacetime information # self.spacetime.append(spacetime) # # Append an empty highlight object to hold the highlighting # information for this tracked tensor # self.highlights.append({}) self.frame_num = 0