<commit_before>import numpy as np

import roslib; roslib.load_manifest('hrl_generic_arms')
import rospy
from geometry_msgs.msg import PoseStamped, Pose, Point, Quaternion
import tf.transformations as tf_trans

class PoseConverter:
    @staticmethod
    def _make_generic(args):
        if type(args[0]) == str:
            frame_id = args[0]
            header, homo_mat, rot_quat = PoseConverter._make_generic(args[1:])
            if header is None:
                header = [0, rospy.Time.now(), '']
            header[2] = frame_id
            return header, homo_mat, rot_quat

        if len(args) == 1:
            if type(args[0]) == Pose:
                homo_mat, rot_quat = PoseConverter._extract_pose_msg(args[0])
                return None, homo_mat, rot_quat

            elif type(args[0]) == PoseStamped:
                homo_mat, rot_quat = PoseConverter._extract_pose_msg(args[0].pose)
                seq = args[0].header.seq
                stamp = args[0].header.stamp
                frame_id = args[0].header.frame_id
                return [seq, stamp, frame_id], homo_mat, rot_quat

            elif type(args[0]) == np.core.matrix and np.shape(args[0]) == (4, 4):
                return None, args[0], tf_trans.quaternion_from_matrix(args[0])

            elif (type(args[0]) == tuple or type(args[0]) == list) and len(args[0]) == 2:
                header, homo_mat, rot_quat = PoseConverter._make_generic_pos_rot(args[0][0], args[0][1])
                if homo_mat is not None:
                    return header, homo_mat, rot_quat

        elif len(args) == 2:
            header, homo_mat, rot_quat = PoseConverter._make_generic_pos_rot(args[0], args[1])
            if homo_mat is not None:
                return header, homo_mat, rot_quat

            elif ((type(args[0]) == list or type(args[0]) == tuple) and len(args[0]) == 3 and
                  (type(args[1]) == list or type(args[1]) == tuple) and len(args[1]) == 4):
                homo_mat = np.mat(quaternion_matrix(args[1]))
                homo_mat[:3,3] = np.mat(args[0]).T
                return None, homo_mat, args[1]

        assert False, "Unknown pose type"

    @staticmethod
    def _make_generic_pos_rot(pos, rot):
        if (type(pos) == np.core.matrix and type(rot) == np.core.matrix and
            np.shape(pos) == (3, 1) and np.shape(rot) == (3, 3)):
            homo_mat = np.mat(np.eye(4))
            homo_mat[:3,3] = pos
            homo_mat[:3,:3] = rot
            return None, homo_mat, tf_trans.quaternion_from_matrix(homo_mat)
        return None, None, None

    @staticmethod<commit_msg>Fixed pose_converter for special cases<commit_after>import numpy as np

import roslib; roslib.load_manifest('hrl_generic_arms')
import rospy
from geometry_msgs.msg import PoseStamped, Pose, Point, Quaternion
import tf.transformations as tf_trans

class PoseConverter:
    @staticmethod
    def _make_generic(args):
        if type(args[0]) == str:
            frame_id = args[0]
            header, homo_mat, rot_quat = PoseConverter._make_generic(args[1:])
            if header is None:
                header = [0, rospy.Time.now(), '']
            header[2] = frame_id
            return header, homo_mat, rot_quat

        if len(args) == 1:
            if type(args[0]) == Pose:
                homo_mat, rot_quat = PoseConverter._extract_pose_msg(args[0])
                return None, homo_mat, rot_quat

            elif type(args[0]) == PoseStamped:
                homo_mat, rot_quat = PoseConverter._extract_pose_msg(args[0].pose)
                seq = args[0].header.seq
                stamp = args[0].header.stamp
                frame_id = args[0].header.frame_id
                return [seq, stamp, frame_id], homo_mat, rot_quat

            elif type(args[0]) == np.core.matrix and np.shape(args[0]) == (4, 4):
                return None, args[0], tf_trans.quaternion_from_matrix(args[0])

            elif (type(args[0]) == tuple or type(args[0]) == list) and len(args[0]) == 2:
                header, homo_mat, rot_quat = PoseConverter._make_generic_pos_rot(args[0][0], args[0][1])
                if homo_mat is not None:
                    return header, homo_mat, rot_quat

        elif len(args) == 2:
            header, homo_mat, rot_quat = PoseConverter._make_generic_pos_rot(args[0], args[1])
            if homo_mat is not None:
                return header, homo_mat, rot_quat

            elif ((type(args[0]) == list or type(args[0]) == tuple or 
                   type(args[0]) == np.core.matrix or type(args[0]) == np.ndarray) and 
                  len(args[0]) == 3 and
                  (type(args[1]) == list or type(args[1]) == tuple or
                   type(args[1]) == np.core.matrix or type(args[1]) == np.ndarray) and 
                  len(args[1]) == 4):
                if len(np.shape(args[0])) > 1 and np.shape(args[0])[1] == 1:
                    pos = args[0]
                else:
                    pos = np.mat(args[0]).T
                homo_mat = np.mat(tf_trans.quaternion_matrix(args[1]))
                homo_mat[:3,3] = pos
                return None, homo_mat, args[1]

        assert False, "Unknown pose type"

    @staticmethod
    def _make_generic_pos_rot(pos, rot):
        if (type(pos) == np.core.matrix and type(rot) == np.core.matrix and
            np.shape(pos) == (3, 1) and np.shape(rot) == (3, 3)):
            homo_mat = np.mat(np.eye(4))
            homo_mat[:3,3] = pos
            homo_mat[:3,:3] = rot
            return None, homo_mat, tf_trans.quaternion_from_matrix(homo_mat)
        return None, None, None

    @staticmethod
{'fraction_non_alphanumeric': 0.12646536412078152, 'fraction_numerical': 0.02024866785079929, 'mean_word_length': 2.060326086956522, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '421027', 'n_tokens_mistral': 1924, 'n_tokens_neox': 1840, 'n_words': 412}