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 rotation 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 rotated. In case of trans-
             formations, a transformation is returned that consists of this
             rotation applied AFTER the given translation. In case of a unit cell,
             a unit cell with rotated cell vectors 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, call; 41, call; 42, parenthesized_expression; 43, identifier:columns; 44, call; 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, attribute; 63, argument_list; 64, identifier:isinstance; 65, argument_list; 66, boolean_operator; 67, attribute; 68, argument_list; 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, call; 81, call; 82, identifier:isinstance; 83, argument_list; 84, call; 85, integer:2; 86, attribute; 87, integer:0; 88, identifier:np; 89, identifier:dot; 90, attribute; 91, identifier:x; 92, identifier:x; 93, attribute; 94, comparison_operator:x.shape == (3, ); 95, parenthesized_expression; 96, identifier:np; 97, identifier:dot; 98, identifier:x; 99, call; 100, identifier:Complete; 101, argument_list; 102, identifier:Complete; 103, argument_list; 104, identifier:Rotation; 105, argument_list; 106, identifier:UnitCell; 107, argument_list; 108, identifier:ValueError; 109, argument_list; 110, identifier:x; 111, attribute; 112, identifier:len; 113, argument_list; 114, identifier:x; 115, identifier:shape; 116, identifier:self; 117, identifier:r; 118, identifier:np; 119, identifier:ndarray; 120, attribute; 121, tuple; 122, boolean_operator; 123, attribute; 124, argument_list; 125, call; 126, call; 127, attribute; 128, call; 129, call; 130, call; 131, attribute; 132, binary_operator:"Can not apply this rotation to %s" % x; 133, identifier:np; 134, identifier:ndarray; 135, attribute; 136, identifier:x; 137, identifier:shape; 138, integer:3; 139, comparison_operator:len(x.shape) == 2; 140, comparison_operator:x.shape[1] == 3; 141, attribute; 142, identifier:transpose; 143, attribute; 144, argument_list; 145, attribute; 146, argument_list; 147, identifier:self; 148, identifier:r; 149, attribute; 150, argument_list; 151, attribute; 152, argument_list; 153, attribute; 154, argument_list; 155, identifier:x; 156, identifier:active; 157, string:"Can not apply this rotation to %s"; 158, identifier:x; 159, identifier:x; 160, identifier:shape; 161, call; 162, integer:2; 163, subscript; 164, integer:3; 165, identifier:self; 166, identifier:r; 167, identifier:np; 168, identifier:dot; 169, attribute; 170, attribute; 171, identifier:np; 172, identifier:dot; 173, attribute; 174, attribute; 175, identifier:np; 176, identifier:dot; 177, attribute; 178, attribute; 179, identifier:np; 180, identifier:dot; 181, attribute; 182, attribute; 183, identifier:np; 184, identifier:dot; 185, attribute; 186, attribute; 187, identifier:len; 188, argument_list; 189, attribute; 190, integer:1; 191, identifier:self; 192, identifier:r; 193, identifier:x; 194, identifier:r; 195, identifier:self; 196, identifier:r; 197, identifier:x; 198, identifier:t; 199, identifier:self; 200, identifier:r; 201, identifier:x; 202, identifier:t; 203, identifier:self; 204, identifier:r; 205, identifier:x; 206, identifier:r; 207, identifier:self; 208, identifier:r; 209, identifier:x; 210, identifier:matrix; 211, attribute; 212, identifier:x; 213, identifier:shape; 214, identifier:x; 215, identifier:shape
code: def apply_to(self, x, columns=False):
          """Apply this rotation 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 rotated. In case of trans-
             formations, a transformation is returned that consists of this
             rotation applied AFTER the given translation. In case of a unit cell,
             a unit cell with rotated cell vectors 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 np.dot(self.r, x)
          if isinstance(x, np.ndarray) and (x.shape == (3, ) or (len(x.shape) == 2 and x.shape[1] == 3)) and not columns:
              return np.dot(x, self.r.transpose())
          elif isinstance(x, Complete):
              return Complete(np.dot(self.r, x.r), np.dot(self.r, x.t))
          elif isinstance(x, Translation):
              return Complete(self.r, np.dot(self.r, x.t))
          elif isinstance(x, Rotation):
              return Rotation(np.dot(self.r, x.r))
          elif isinstance(x, UnitCell):
              return UnitCell(np.dot(self.r, x.matrix), x.active)
          else:
              raise ValueError("Can not apply this rotation to %s" % x)