<commit_before>from .simConst import *
from ._sim_cffi import ffi, lib
import numpy as np
import collections


SShapeVizInfo = collections.namedtuple(
    'SShapeVizInfo',
    [
        'vertices',
        'indices',
        'normals',
        'shadingAngle',
        'colors',
        'texture',
        'textureId',
        'textureRes',
        'textureCoords',
        'textureApplyMode',
        'textureOptions',
    ],
)


def _check_return(ret):
    if ret < 0:
        raise RuntimeError(
            'The call failed on the V-REP side. Return value: %d' % ret)


def _check_null_return(val):
    if val == ffi.NULL:
        raise RuntimeError(
            'The call failed on the V-REP side by returning null.')


def _check_set_object_parameter(ret):
    if ret == 0:
        raise RuntimeError(
            'Parameter could not be set (e.g. because the parameterID doesn\'t '
            'exist, or because the specified object doesn\'t correspond to the '
            'correct type)')


def simExtLaunchUIThread(options, scene, pyrep_root):
    lib.simExtLaunchUIThread(
        'PyRep'.encode('ascii'), options, scene.encode('ascii'),
        pyrep_root.encode('ascii'))


def simExtSimThreadInit():
    lib.simExtSimThreadInit()


def simExtCanInitSimThread():
    return bool(lib.simExtCanInitSimThread())


def simExtSimThreadDestroy():
    lib.simExtSimThreadDestroy()


def simExtPostExitRequest():
    lib.simExtPostExitRequest()


def simExtGetExitRequest():
    return bool(lib.simExtGetExitRequest())


def simExtStep(stepIfRunning=True):
    lib.simExtStep(stepIfRunning)


def simStartSimulation():
    lib.simStartSimulation()


def simStopSimulation():
    lib.simStopSimulation()


def simPauseSimulation():
    return lib.simPauseSimulation()


def simQuitSimulator(doNotDisplayMessages):
    lib.simQuitSimulator(doNotDisplayMessages)


def simGetObjectHandle(objectName):
    handle = lib.simGetObjectHandle(objectName.encode('ascii'))
    if handle <= 0:
        raise RuntimeError('Handle %s does not exist.' % objectName)
    return handle


def simGetIkGroupHandle(ikGroupName):
    handle = lib.simGetIkGroupHandle(ikGroupName.encode('ascii'))
    if handle <= 0:
        raise RuntimeError('Ik group does not exist.')
    return handle


def simGetObjectPosition(objectHandle, relativeToObjectHandle):
    position = ffi.new('float[3]')
    lib.simGetObjectPosition(objectHandle, relativeToObjectHandle, position)
    return list(position)


def simGetJointPosition(jointHandle):
    position = ffi.new('float *')
    lib.simGetJointPosition(jointHandle, position)
    return position[0]

<commit_msg>Support handle=0 in simGetObjectHandle for DefaultCamera<commit_after>from .simConst import *
from ._sim_cffi import ffi, lib
import numpy as np
import collections


SShapeVizInfo = collections.namedtuple(
    'SShapeVizInfo',
    [
        'vertices',
        'indices',
        'normals',
        'shadingAngle',
        'colors',
        'texture',
        'textureId',
        'textureRes',
        'textureCoords',
        'textureApplyMode',
        'textureOptions',
    ],
)


def _check_return(ret):
    if ret < 0:
        raise RuntimeError(
            'The call failed on the V-REP side. Return value: %d' % ret)


def _check_null_return(val):
    if val == ffi.NULL:
        raise RuntimeError(
            'The call failed on the V-REP side by returning null.')


def _check_set_object_parameter(ret):
    if ret == 0:
        raise RuntimeError(
            'Parameter could not be set (e.g. because the parameterID doesn\'t '
            'exist, or because the specified object doesn\'t correspond to the '
            'correct type)')


def simExtLaunchUIThread(options, scene, pyrep_root):
    lib.simExtLaunchUIThread(
        'PyRep'.encode('ascii'), options, scene.encode('ascii'),
        pyrep_root.encode('ascii'))


def simExtSimThreadInit():
    lib.simExtSimThreadInit()


def simExtCanInitSimThread():
    return bool(lib.simExtCanInitSimThread())


def simExtSimThreadDestroy():
    lib.simExtSimThreadDestroy()


def simExtPostExitRequest():
    lib.simExtPostExitRequest()


def simExtGetExitRequest():
    return bool(lib.simExtGetExitRequest())


def simExtStep(stepIfRunning=True):
    lib.simExtStep(stepIfRunning)


def simStartSimulation():
    lib.simStartSimulation()


def simStopSimulation():
    lib.simStopSimulation()


def simPauseSimulation():
    return lib.simPauseSimulation()


def simQuitSimulator(doNotDisplayMessages):
    lib.simQuitSimulator(doNotDisplayMessages)


def simGetObjectHandle(objectName):
    handle = lib.simGetObjectHandle(objectName.encode('ascii'))
    if handle < 0:
        raise RuntimeError('Handle %s does not exist.' % objectName)
    return handle


def simGetIkGroupHandle(ikGroupName):
    handle = lib.simGetIkGroupHandle(ikGroupName.encode('ascii'))
    if handle <= 0:
        raise RuntimeError('Ik group does not exist.')
    return handle


def simGetObjectPosition(objectHandle, relativeToObjectHandle):
    position = ffi.new('float[3]')
    lib.simGetObjectPosition(objectHandle, relativeToObjectHandle, position)
    return list(position)


def simGetJointPosition(jointHandle):
    position = ffi.new('float *')
    lib.simGetJointPosition(jointHandle, position)
    return position[0]


{'fraction_non_alphanumeric': 0.10154193305754043, 'fraction_numerical': 0.002444528018051899, 'mean_word_length': 3.4325, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, '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': '4079212', 'n_tokens_mistral': 1646, 'n_tokens_neox': 1578, 'n_words': 371}