nodes: 0, module; 1, function_definition; 2, function_name:apply_to; 3, parameters; 4, block; 5, identifier:self; 6, identifier:x; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, if_statement; 11, identifier:columns; 12, False; 13, comment:"""Apply this translation to the given object
  
             The argument can be several sorts of objects:
  
             * ``np.array`` with shape (3, )
             * ``np.array`` with shape (N, 3)
             * ``np.array`` with shape (3, N), use ``columns=True``
             * ``Translation``
             * ``Rotation``
             * ``Complete``
             * ``UnitCell``
  
             In case of arrays, the 3D vectors are translated. In case of trans-
             formations, a new transformation is returned that consists of this
             translation applied AFTER the given translation. In case of a unit
             cell, the original object is returned.
  
             This method is equivalent to ``self*x``.
          """; 14, boolean_operator; 15, block; 16, boolean_operator; 17, block; 18, elif_clause; 19, elif_clause; 20, elif_clause; 21, elif_clause; 22, else_clause; 23, boolean_operator; 24, identifier:columns; 25, return_statement; 26, boolean_operator; 27, not_operator; 28, return_statement; 29, call; 30, block; 31, call; 32, block; 33, call; 34, block; 35, call; 36, block; 37, block; 38, boolean_operator; 39, comparison_operator:x.shape[0] == 3; 40, binary_operator:x + self.t.reshape((3,1)); 41, call; 42, parenthesized_expression; 43, identifier:columns; 44, binary_operator:x + self.t; 45, identifier:isinstance; 46, argument_list; 47, return_statement; 48, identifier:isinstance; 49, argument_list; 50, return_statement; 51, identifier:isinstance; 52, argument_list; 53, return_statement; 54, identifier:isinstance; 55, argument_list; 56, return_statement; 57, raise_statement; 58, call; 59, comparison_operator:len(x.shape) == 2; 60, subscript; 61, integer:3; 62, identifier:x; 63, call; 64, identifier:isinstance; 65, argument_list; 66, boolean_operator; 67, identifier:x; 68, attribute; 69, identifier:x; 70, identifier:Complete; 71, call; 72, identifier:x; 73, identifier:Translation; 74, call; 75, identifier:x; 76, identifier:Rotation; 77, call; 78, identifier:x; 79, identifier:UnitCell; 80, identifier:x; 81, call; 82, identifier:isinstance; 83, argument_list; 84, call; 85, integer:2; 86, attribute; 87, integer:0; 88, attribute; 89, argument_list; 90, identifier:x; 91, attribute; 92, comparison_operator:x.shape == (3, ); 93, parenthesized_expression; 94, identifier:self; 95, identifier:t; 96, identifier:Complete; 97, argument_list; 98, identifier:Translation; 99, argument_list; 100, identifier:Complete; 101, argument_list; 102, identifier:ValueError; 103, argument_list; 104, identifier:x; 105, attribute; 106, identifier:len; 107, argument_list; 108, identifier:x; 109, identifier:shape; 110, attribute; 111, identifier:reshape; 112, tuple; 113, identifier:np; 114, identifier:ndarray; 115, attribute; 116, tuple; 117, boolean_operator; 118, attribute; 119, binary_operator:x.t + self.t; 120, binary_operator:x.t + self.t; 121, attribute; 122, attribute; 123, binary_operator:"Can not apply this translation to %s" % x; 124, identifier:np; 125, identifier:ndarray; 126, attribute; 127, identifier:self; 128, identifier:t; 129, integer:3; 130, integer:1; 131, identifier:x; 132, identifier:shape; 133, integer:3; 134, comparison_operator:len(x.shape) == 2; 135, comparison_operator:x.shape[1] == 3; 136, identifier:x; 137, identifier:r; 138, attribute; 139, attribute; 140, attribute; 141, attribute; 142, identifier:x; 143, identifier:r; 144, identifier:self; 145, identifier:t; 146, string:"Can not apply this translation to %s"; 147, identifier:x; 148, identifier:x; 149, identifier:shape; 150, call; 151, integer:2; 152, subscript; 153, integer:3; 154, identifier:x; 155, identifier:t; 156, identifier:self; 157, identifier:t; 158, identifier:x; 159, identifier:t; 160, identifier:self; 161, identifier:t; 162, identifier:len; 163, argument_list; 164, attribute; 165, integer:1; 166, attribute; 167, identifier:x; 168, identifier:shape; 169, identifier:x; 170, identifier:shape
code: def apply_to(self, x, columns=False):
          """Apply this translation to the given object
  
             The argument can be several sorts of objects:
  
             * ``np.array`` with shape (3, )
             * ``np.array`` with shape (N, 3)
             * ``np.array`` with shape (3, N), use ``columns=True``
             * ``Translation``
             * ``Rotation``
             * ``Complete``
             * ``UnitCell``
  
             In case of arrays, the 3D vectors are translated. In case of trans-
             formations, a new transformation is returned that consists of this
             translation applied AFTER the given translation. In case of a unit
             cell, the original object is returned.
  
             This method is equivalent to ``self*x``.
          """
          if isinstance(x, np.ndarray) and len(x.shape) == 2 and x.shape[0] == 3 and columns:
              return x + self.t.reshape((3,1))
          if isinstance(x, np.ndarray) and (x.shape == (3, ) or (len(x.shape) == 2 and x.shape[1] == 3)) and not columns:
              return x + self.t
          elif isinstance(x, Complete):
              return Complete(x.r, x.t + self.t)
          elif isinstance(x, Translation):
              return Translation(x.t + self.t)
          elif isinstance(x, Rotation):
              return Complete(x.r, self.t)
          elif isinstance(x, UnitCell):
              return x
          else:
              raise ValueError("Can not apply this translation to %s" % x)