a helper function to return the conversion type based on user 
           preference and input recipe.

           Parameters
           ==========
           convert_to: a string either docker or singularity (default None)
170827
def _get_conversion_type(self, convert_to=None):
        '''

        '''
        acceptable = ['singularity', 'docker']

        # Default is to convert to opposite kind
        conversion = "singularity"
        if self.name == "singularity":
            conversion = "docker"

        # Unless the user asks for a specific type
        if convert_to is not None and convert_to in acceptable:
            conversion = convert_to
        return conversion
387359
def get_converter(self, parameter):
        """"""
        if parameter not in self._converters:
            param = self.get_parameter(parameter)
            try:
                scale = float(param['Scale'])
            except KeyError:
                scale = 1

            def convert(value):
                # easy_scale = float(param['EasyScale'])
                # easy_scale_multiplier = float(param['EasyScaleMultiplier'])
                return value * scale

            return convert
78370
def value_convert(self, value, value_type):
        
        CONVERSION_OPTIONS = {
            "str": str,
            "int": int,
            "float": float,
            # Treat booleans specially
            "bool": (lambda val: val.lower() in ("true", "1")),
            # Auto-guess the type
            "auto": self.make_value,
        }

        try:
            return CONVERSION_OPTIONS[value_type](value)
        except (TypeError, ValueError):
            self.notify_user("Bad type conversion")
            return None
1207142
def to_python(self, value):
        '''
        
        '''
        try:
            if value is None and self._default is not None:
                return self.default
            self._check_required(value)
            if not isinstance(value, self._python_type):
                value = self._import(value)
            return value
        except ValueError as ex:
            raise ValueError(ex, self._errors['to_python'])
115242
def python_type_to_dtype(python_type: type) -> Optional[tf.DType]:
    ''''''
    dtype = None
    if python_type == float:
        dtype = tf.float32
    elif python_type == int:
        dtype = tf.int32
    elif python_type == bool:
        dtype = tf.bool
    return dtype
1242706
def _get_convert_method(self):
        
        for type_, method in self._map.items():
            if type(self.value) is bool and type_ is not bool:
                continue
            if isinstance(self.value, type_):
                return method
        if is_sql_instance(self.value):
            return self._raw
        return self._undefined
1089546
def convert(self):
        
        cname = str(self.config["wrapper"])
        self._output = classes.from_commandline(self._input, classname=cname)
        return None
275147
def convert(self, type_from, type_to, data):
        
        try:
            return self.compose(type_to, self.parse(type_from, data))
        except Exception as e:
            raise ValueError(
                "Couldn't convert '{from_}' to '{to}'. Possibly "
                "because the parser of '{from_}' generates a "
                "data structure incompatible with the composer "
                "of '{to}'. This is the original error: \n\n"
                "{error}: {message}".format(from_=type_from, to=type_to,
                                            error=e.__class__.__name__,
                                            message=e.message))
919307
def convert(dbus_obj):
    
    _isinstance = partial(isinstance, dbus_obj)
    ConvertType = namedtuple('ConvertType', 'pytype dbustypes')

    pyint = ConvertType(int, (dbus.Byte, dbus.Int16, dbus.Int32, dbus.Int64,
                              dbus.UInt16, dbus.UInt32, dbus.UInt64))
    pybool = ConvertType(bool, (dbus.Boolean, ))
    pyfloat = ConvertType(float, (dbus.Double, ))
    pylist = ConvertType(lambda _obj: list(map(convert, dbus_obj)),
                         (dbus.Array, ))
    pytuple = ConvertType(lambda _obj: tuple(map(convert, dbus_obj)),
                          (dbus.Struct, ))
    types_str = (dbus.ObjectPath, dbus.Signature, dbus.String)
    if not PY3:
        types_str += (dbus.UTF8String,)
    pystr = ConvertType(str if PY3 else unicode, types_str)

    pydict = ConvertType(
        lambda _obj: dict(zip(map(convert, dbus_obj.keys()),
                              map(convert, dbus_obj.values())
                              )
                          ),
        (dbus.Dictionary, )
    )

    for conv in (pyint, pybool, pyfloat, pylist, pytuple, pystr, pydict):
        if any(map(_isinstance, conv.dbustypes)):
            return conv.pytype(dbus_obj)
    else:
        return dbus_obj
1103593
def to_python(self,value):
        
        if value==self.emptyValue or value in EMPTY_VALUES:
            return self.emptyValue

        try:
            value=self.coerce(value)
        except(ValueError,TypeError,ValidationError):
            raise ValidationError(self.error_messages['invalid_choice']%{'value':value})

        return value
339035
def convert(self, value):
        """"""
        try:
            return convert_to_format(value, self._format)
        except (ValueError, TypeError):
            return value
138346
def _convert_types(self, a):
        
        # No conversion for scalar type
        if a.dtype != 'object':
            return a, None

        # We can't infer the type of an empty array, so just
        # assume strings
        if len(a) == 0:
            return a.astype('U1'), None

        # Compute a mask of missing values. Replace NaNs and Nones with
        # empty strings so that type inference has a chance.
        mask = pd.isnull(a)
        if mask.sum() > 0:
            a = a.copy()
            np.putmask(a, mask, '')
        else:
            mask = None

        if infer_dtype(a, skipna=False) == 'mixed':
            # assume its a string, otherwise raise an error
            try:
                a = np.array([s.encode('ascii') for s in a])
                a = a.astype('O')
            except:
                raise ValueError("Column of type 'mixed' cannot be converted to string")

        type_ = infer_dtype(a, skipna=False)
        if type_ in ['unicode', 'string']:
            max_len = max_len_string_array(a)
            return a.astype('U{:d}'.format(max_len)), mask
        else:
            raise ValueError('Cannot store arrays with {} dtype'.format(type_))
974681
def _convert_option(self):
        '''
        
        '''
        data_endian = 'little'
        if (self._encoding == 1 or self._encoding == 2 or self._encoding == 5 or
            self._encoding == 7 or self._encoding == 9 or self._encoding == 11 or
                self._encoding == 12 or self._encoding == 18):
            data_endian = 'big'
        if sys.byteorder == 'little' and data_endian == 'big':
            # big->little
            order = '>'
        elif sys.byteorder == 'big' and data_endian == 'little':
            # little->big
            order = '<'
        else:
            # no conversion
            order = '='

        return order
406044
def convert(self, expr):
        
        if type(expr) is BV:
            if expr.op == "BVV":
                cached_obj = self._object_cache.get(expr._cache_key, None)
                if cached_obj is None:
                    cached_obj = self.BVV(*expr.args)
                    self._object_cache[expr._cache_key] = cached_obj
                return cached_obj
        if type(expr) is Bool and expr.op == "BoolV":
            return expr.args[0]
        return super().convert(expr)
946472
def get_default_collection_converters(conversion_finder: ConversionFinder) -> List[Union[Converter[Any, dict], Converter[dict, Any]]]:
    
    return [ConverterFunction(from_type=List, to_type=Set, conversion_method=list_to_set, custom_name='list_to_set',
                              function_args={'conversion_finder': conversion_finder}),
            ConverterFunction(from_type=List, to_type=Tuple, conversion_method=list_to_tuple,
                              custom_name='list_to_tuple', function_args={'conversion_finder': conversion_finder})]
646675
def to(target, options = {})
      conversion = conversions[source || detect(object, false), detect(target)]
      conversion.call(object, options)
    end
215512
def convert(self, value, _type):
        
        return self.type_convertors.get(_type, lambda x: x)(value)