Create an X10 device from a feature definition.
170239
def create_x10(plm, housecode, unitcode, feature):
    """"""
    from insteonplm.devices.ipdb import IPDB
    ipdb = IPDB()
    product = ipdb.x10(feature)
    deviceclass = product.deviceclass
    device = None
    if deviceclass:
        device = deviceclass(plm, housecode, unitcode)
    return device
794921
def compile(self, X, verbose=False):
        
        if self.feature >= X.shape[1]:
            raise ValueError('term requires feature {}, '\
                             'but X has only {} dimensions'\
                             .format(self.feature, X.shape[1]))

        self.edge_knots_ = gen_edge_knots(X[:, self.feature],
                                          self.dtype,
                                          verbose=verbose)
        return self
444903
def vgcreate(vgname, devices, **kwargs):
    '''
    
    '''
    if not vgname or not devices:
        return 'Error: vgname and device(s) are both required'
    if isinstance(devices, six.string_types):
        devices = devices.split(',')

    cmd = ['vgcreate', vgname]
    for device in devices:
        cmd.append(device)
    valid = ('clustered', 'maxlogicalvolumes', 'maxphysicalvolumes',
             'vgmetadatacopies', 'metadatacopies', 'physicalextentsize')
    for var in kwargs:
        if kwargs[var] and var in valid:
            cmd.append('--{0}'.format(var))
            cmd.append(kwargs[var])
    out = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
    vgdata = vgdisplay(vgname)
    vgdata['Output from vgcreate'] = out[0].strip()
    return vgdata
165655
def dev_setup():
    ''''''

    # check first if NiftyPET was already installed and use the choice of GPU
    path_resources = path_niftypet_local()
    # if so, import the resources and get the constants
    if os.path.isfile(os.path.join(path_resources,'resources.py')):
        sys.path.append(path_resources)
        try:
            import resources
        except ImportError as ie:
            print '----------------------------'
            print 'e> Import Error: NiftyPET''s resources file <resources.py> could not be imported.  It should be in ''~/.niftypet/resources.py'' but likely it does not exists.'
            print '----------------------------'
    else:
        print 'e> resources file not found/installed.'
        return None

    # get all constants and check if device is already chosen
    Cnt = resources.get_setup()
    if 'CCARCH' in Cnt and 'DEVID' in Cnt:
        print 'i> using this CUDA architecture(s):', Cnt['CCARCH']
        return Cnt['CCARCH']

    # get the current locations
    path_current = os.path.dirname( os.path.realpath(__file__) )
    path_resins = os.path.join(path_current, 'resources')
    path_dinf = os.path.join(path_current, 'niftypet')
    path_dinf = os.path.join(path_dinf, 'nimpa')
    path_dinf = os.path.join(path_dinf, 'dinf')
    # temporary installation location for identifying the CUDA devices
    path_tmp_dinf = os.path.join(path_resins,'dinf')
    # if the folder 'path_tmp_dinf' exists, delete it
    if os.path.isdir(path_tmp_dinf):
        shutil.rmtree(path_tmp_dinf)
    # copy the device_info module to the resources folder within the installation package
    shutil.copytree( path_dinf, path_tmp_dinf)
    # create a build using cmake
    if platform.system()=='Windows':
        path_tmp_build = os.path.join(path_tmp_dinf, 'build')
    elif platform.system() in ['Linux', 'Darwin']:
        path_tmp_build = os.path.join(path_tmp_dinf, 'build')
    else:
        print 'w> the operating system {} is not supported for GPU'.format(platform.system())
        return ''
        
    os.makedirs(path_tmp_build)
    os.chdir(path_tmp_build)
    if platform.system()=='Windows':
        subprocess.call(
            ['cmake', '../', '-DPYTHON_INCLUDE_DIRS='+pyhdr,
             '-DPYTHON_PREFIX_PATH='+prefix, '-G', Cnt['MSVC_VRSN']]
        )
        subprocess.call(['cmake', '--build', './', '--config', 'Release'])
        path_tmp_build = os.path.join(path_tmp_build, 'Release')

    elif platform.system() in ['Linux', 'Darwin']:
        subprocess.call(
            ['cmake', '../', '-DPYTHON_INCLUDE_DIRS='+pyhdr,
             '-DPYTHON_PREFIX_PATH='+prefix]
        )
        subprocess.call(['cmake', '--build', './'])
    else:
        print 'e> This operating systems {} is not supported!'.format(platform.system())
        return ''
    
    # imoprt the new module for device properties
    sys.path.insert(0, path_tmp_build)
    try:
        import dinf
    except ImportError:
        print 'e> could not compile a CUDA C file--assuming no CUDA installation.'
        return ''
    
    # get the list of installed CUDA devices
    Ldev = dinf.dev_info(0)
    # extract the compute capability as a single number 
    cclist = [int(str(e[2])+str(e[3])) for e in Ldev]
    # get the list of supported CUDA devices (with minimum compute capability)
    spprtd = [str(cc) for cc in cclist if cc>=mincc]
    ccstr = ''
    if spprtd:
        # best for the default CUDA device
        i = [int(s) for s in spprtd]
        devid = i.index(max(i))
        #-----------------------------------------------------------------------------------
        # form return list of compute capability numbers for which the software will be compiled
        
        for cc in spprtd:
            ccstr += '-gencode=arch=compute_'+cc+',code=compute_'+cc+';'
        #-----------------------------------------------------------------------------------
    else:
        devid = None

    # remove the temporary path
    sys.path.remove(path_tmp_build)
    # delete the build once the info about the GPUs has been obtained
    os.chdir(path_current)
    shutil.rmtree(path_tmp_dinf, ignore_errors=True)

    # passing this setting to resources.py
    fpth = os.path.join(path_resources,'resources.py') #resource_filename(__name__, 'resources/resources.py')
    f = open(fpth, 'r')
    rsrc = f.read()
    f.close()
    # get the region of keeping in synch with Python
    i0 = rsrc.find('### start GPU properties ###')
    i1 = rsrc.find('### end GPU properties ###')
    # list of constants which will be kept in sych from Python
    cnt_list = ['DEV_ID', 'CC_ARCH']
    val_list = [str(devid), '\''+ccstr+'\'']
    # update the resource.py file
    strNew = '### start GPU properties ###\n'
    for i in range(len(cnt_list)):
        strNew += cnt_list[i]+' = '+val_list[i] + '\n'
    rsrcNew = rsrc[:i0] + strNew + rsrc[i1:] 
    f = open(fpth, 'w')
    f.write(rsrcNew)
    f.close()

    return ccstr
144207
def create_platform(platform):
    '''
    
    '''
    nb_platform = get_('dcim', 'platforms', slug=slugify(platform))
    if nb_platform:
        return False
    else:
        payload = {'name': platform, 'slug': slugify(platform)}
        plat = _add('dcim', 'platforms', payload)
        if plat:
            return {'dcim': {'platforms': payload}}
        else:
            return False
1096609
def _generate_feature_labels(self, X):
        '''
        
        '''
        Xt, Xc = get_ts_data_parts(X)

        ftr_sizes = self._check_features(self.features, Xt[0:3])
        f_labels = []

        # calculated features
        for key in ftr_sizes:
            for i in range(ftr_sizes[key]):
                f_labels += [key + '_' + str(i)]

        # contextual features
        if Xc is not None:
            Ns = len(np.atleast_1d(Xc[0]))
            s_labels = ["context_" + str(i) for i in range(Ns)]
            f_labels += s_labels

        return f_labels
703544
def create_vnic_spec(device):
        
        nic_spec = vim.vm.device.VirtualDeviceSpec()
        nic_spec.operation = vim.vm.device.VirtualDeviceSpec.Operation.edit
        nic_spec.device = device
        return nic_spec
778699
def custom_build(inputs, is_training, keep_prob):
  """"""
  outputs = snt.Conv2D(output_channels=32, kernel_shape=4, stride=2)(inputs)
  outputs = snt.BatchNorm()(outputs, is_training=is_training)
  outputs = tf.nn.relu(outputs)
  outputs = snt.Conv2D(output_channels=64, kernel_shape=4, stride=2)(outputs)
  outputs = snt.BatchNorm()(outputs, is_training=is_training)
  outputs = tf.nn.relu(outputs)
  outputs = snt.BatchFlatten()(outputs)
  outputs = tf.nn.dropout(outputs, keep_prob=keep_prob)
  outputs = snt.Linear(output_size=10)(outputs)
  return outputs
315289
def create_uinput_device(mapping):
    """"""
    if mapping not in _mappings:
        raise DeviceError("Unknown device mapping: {0}".format(mapping))

    try:
        mapping = _mappings[mapping]
        device = UInputDevice(mapping)
    except UInputError as err:
        raise DeviceError(err)

    return device
340308
def create_device_from_category(self, plm, addr, cat, subcat,
                                    product_key=0x00):
        """"""
        saved_device = self._saved_devices.get(Address(addr).id, {})
        cat = saved_device.get('cat', cat)
        subcat = saved_device.get('subcat', subcat)
        product_key = saved_device.get('product_key', product_key)

        device_override = self._overrides.get(Address(addr).id, {})
        cat = device_override.get('cat', cat)
        subcat = device_override.get('subcat', subcat)
        product_key = device_override.get('firmware', product_key)
        product_key = device_override.get('product_key', product_key)

        return insteonplm.devices.create(plm, addr, cat, subcat, product_key)
1123086
def generate(env):
    """"""
    for t in SCons.Tool.tool_list(env['PLATFORM'], env):
        SCons.Tool.Tool(t)(env)
582333
def include_feature(self, name):
        """'"""

        if self.feature_is_included(name) == 0:
            descr = self.features[name].description
            raise DistutilsOptionError(
                descr + " is required, but was excluded or is not available"
            )
        self.features[name].include_in(self)
        self._set_feature(name, 1)
1113554
def create_fc_template(self, out_path, out_name):
        """"""
        fields = self.fields
        objectIdField = self.objectIdField
        geomType = self.geometryType
        wkid = self.parentLayer.spatialReference['wkid']
        return create_feature_class(out_path,
                                    out_name,
                                    geomType,
                                    wkid,
                                    fields,
                                    objectIdField)
1298697
def register_model(ctx, model, type, trait,
                   manufacturer, product_name, description):
    
    session, api_url, project_id = build_client_from_context(ctx)
    model_base_url = '/'.join([api_url, 'deviceModels'])
    model_url = '/'.join([model_base_url, model])
    payload = {
        'device_model_id': model,
        'project_id': project_id,
        'device_type': 'action.devices.types.' + type,
    }
    if trait:
        payload['traits'] = trait
    if manufacturer:
        payload.setdefault('manifest', {})['manufacturer'] = manufacturer
    if product_name:
        payload.setdefault('manifest', {})['productName'] = product_name
    if description:
        payload.setdefault('manifest', {})['deviceDescription'] = description
    logging.debug(json.dumps(payload))
    r = session.get(model_url)
    logging.debug(r.text)
    if r.status_code == 200:
        click.echo('Updating existing device model: %s' % model)
        r = session.put(model_url, data=json.dumps(payload))
    elif r.status_code in (400, 403, 404):
        click.echo('Creating new device model')
        r = session.post(model_base_url, data=json.dumps(payload))
    else:
        raise failed_request_exception('Failed to check existing device model',
                                       r)
    if r.status_code != 200:
        raise failed_request_exception('Failed to register model', r)
    click.echo('Model %s successfully registered' % model)
573011
def create_xz(archive, compression, cmd, verbosity, interactive, filenames):
    """"""
    return _create(archive, compression, cmd, 'xz', verbosity, filenames)
1229329
def createDeviceObjects(self, interface_id):
        """"""
        global WORKING
        WORKING = True
        remote = interface_id.split('-')[-1]
        LOG.debug(
            "RPCFunctions.createDeviceObjects: iterating interface_id = %s" % (remote, ))
        # First create parent object
        for dev in self._devices_raw[remote]:
            if not dev['PARENT']:
                if dev['ADDRESS'] not in self.devices_all[remote]:
                    try:
                        if dev['TYPE'] in devicetypes.SUPPORTED:
                            deviceObject = devicetypes.SUPPORTED[dev['TYPE']](
                                dev, self._proxies[interface_id], self.resolveparamsets)
                            LOG.debug("RPCFunctions.createDeviceObjects: created %s  as SUPPORTED device for %s" % (
                                dev['ADDRESS'], dev['TYPE']))
                        else:
                            deviceObject = devicetypes.UNSUPPORTED(
                                dev, self._proxies[interface_id], self.resolveparamsets)
                            LOG.debug("RPCFunctions.createDeviceObjects: created %s  as UNSUPPORTED device for %s" % (
                                dev['ADDRESS'], dev['TYPE']))
                        LOG.debug(
                            "RPCFunctions.createDeviceObjects: adding to self.devices_all")
                        self.devices_all[remote][dev['ADDRESS']] = deviceObject
                        LOG.debug(
                            "RPCFunctions.createDeviceObjects: adding to self.devices")
                        self.devices[remote][dev['ADDRESS']] = deviceObject
                    except Exception as err:
                        LOG.critical(
                            "RPCFunctions.createDeviceObjects: Parent: %s", str(err))
        # Then create all children for parent
        for dev in self._devices_raw[remote]:
            if dev['PARENT']:
                try:
                    if dev['ADDRESS'] not in self.devices_all[remote]:
                        deviceObject = HMChannel(
                            dev, self._proxies[interface_id], self.resolveparamsets)
                        self.devices_all[remote][dev['ADDRESS']] = deviceObject
                        self.devices[remote][dev['PARENT']].CHANNELS[
                            dev['INDEX']] = deviceObject
                except Exception as err:
                    LOG.critical(
                        "RPCFunctions.createDeviceObjects: Child: %s", str(err))
        if self.devices_all[remote] and self.remotes[remote].get('resolvenames', False):
            self.addDeviceNames(remote)
        WORKING = False
        if self.systemcallback:
            self.systemcallback('createDeviceObjects')
        return True
332932
def populate_device(dev):
        
        try:
            tgt = PackTargets._generate_pack_target_class(dev)
            if tgt is None:
                return
            part = dev.part_number.lower()
            LOG.debug("Loading target '%s' from CMSIS-Pack", part)

            # Make sure there isn't a duplicate target name.
            if part not in TARGET:
                TARGET[part] = tgt
        except (MalformedCmsisPackError, FileNotFoundError_) as err:
            LOG.warning(err)