How to use the swat.utils.compat.float64 function in swat

To help you get started, we’ve selected a few swat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sassoftware / python-swat / swat / cas / datamsghandlers.py View on Github external
errorcheck(self._sw_databuffer.setInt64(row, offset + (i * 8),
                                   int64(transformer(get(value, i, 0)))),
                                   self._sw_databuffer)
                else:
                    errorcheck(self._sw_databuffer.setInt64(row, offset,
                                                            int64(transformer(value))),
                               self._sw_databuffer)
            else:
                if length > 8:
                    for i in range(int64(length / 8)):
                        errorcheck(self._sw_databuffer.setDouble(row, offset + (i * 8),
                                   float64(transformer(get(value, i, np.nan)))),
                                   self._sw_databuffer)
                else:
                    errorcheck(self._sw_databuffer.setDouble(row, offset,
                               float64(transformer(value))),
                               self._sw_databuffer)
github sassoftware / python-swat / swat / formatter.py View on Github external
def _generic_format(self, value, sasfmt=None, width=12):
        ''' Generic formatter for when tkefmt isn't available '''
        out = None

        if isinstance(value, float64_types):
            if np.isnan(value) or value is None:
                out = a2u(str(value))
            elif sasfmt and re.match(r'^[df]?\d*\.\d*$', sasfmt, flags=re.I):
                out = self._format_numeric(value, sasfmt, width=width)
            elif sasfmt and re.match(r'^(nl)?(comma|mny|mny|dollar|euro)\d*\.\d*$', sasfmt, flags=re.I):
                out = self._format_numeric(value, sasfmt, width=width, commas=True)
            else:
                out = a2u(str(float64(value)))
        elif isinstance(value, int64_types):
            if sasfmt and re.match(r'^[df]?\d*\.\d*$', sasfmt):
                out = self._format_numeric(value, sasfmt, width=width)
            elif sasfmt and re.match(r'^(nl)?(comma|mny|dollar|euro)\d*\.\d*$', sasfmt, flags=re.I):
                out = self._format_numeric(value, sasfmt, width=width, commas=True)
            else:
                out = a2u(str(int64(value)))
        elif isinstance(value, int32_types):
            try:
                if sasfmt and re.match(r'^[df]?\d*\.\d*$', sasfmt, flags=re.I):
                    out = self._format_numeric(int32(value), sasfmt, width=width)
                elif sasfmt and re.match(r'^(nl)(comma|mny|dollar|euro)\d*\.\d*$', sasfmt, flags=re.I):
                    out = self._format_numeric(value, sasfmt, width=width, commas=True)
                else:
                    out = a2u(str(int32(value)))
            except OverflowError:
github sassoftware / python-swat / swat / cas / dbapi.py View on Github external
if isinstance(item, text_types):
                values[i] = "'%s'" % item.replace("'", "''")
            elif isinstance(item, binary_types):
                values[i] = b"'%s'" % item.replace("'", "''")
            elif isinstance(item, datetime.datetime):
                values[i] = "'%s'dt" % item.strftime('%d%b%Y:%H:%M:%S')
            elif isinstance(item, datetime.date):
                values[i] = "'%s'd" % item.strftime('%d%b%Y')
            elif isinstance(item, datetime.time):
                values[i] = "'%s't" % item.strftime('%H:%M:%S')
            elif isinstance(item, int32_types):
                values[i] = '%s' % int32(item)
            elif isinstance(item, int64_types):
                values[i] = '%s' % int64(item)
            elif isinstance(item, float64_types):
                values[i] = '%s' % float64(item)
            elif item is True:
                values[i] = '1'
            elif item is False:
                values[i] = '0'
            else:
                raise TypeError('Unrecognized data type: %s' % item)
        if keys:
            return dict(zip(keys, values))
        return tuple(values)
github sassoftware / python-swat / swat / cas / rest / table.py View on Github external
def _attr2python(attr):
    ''' Convert an attribute to a Python object '''
    atype = attr['type']
    value = attr['value']
    if atype in ['double', 'float']:
        if value is None:
            return np.nan
        return float64(value)
    elif atype in ['int32', 'int']:
        return int32(value)
    elif atype == 'int64':
        return int64(value)
    elif atype == 'date':
        return cas2python_date(value)
    elif atype == 'time':
        return cas2python_time(value)
    elif atype == 'datetime':
        return cas2python_datetime(value)
    return value
github sassoftware / python-swat / swat / cas / rest / value.py View on Github external
def getDouble(self):
        ''' Get the value as a double '''
        return float64(self._value)
github sassoftware / python-swat / swat / cas / connection.py View on Github external
raise SWATError('%s is not a valid boolean value' % value)
                elif typ == 'string':
                    if isinstance(value, (binary_types, text_types)):
                        errorcheck(self._sw_connection.setStringOption(name, a2n(value)),
                                   self._sw_connection)
                    else:
                        errorcheck(self._sw_connection.setStringOption(name, value),
                                   self._sw_connection)
                elif typ == 'int32':
                    errorcheck(self._sw_connection.setInt32Option(name, int32(value)),
                               self._sw_connection)
                elif typ == 'int64':
                    errorcheck(self._sw_connection.setInt64Option(name, int64(value)),
                               self._sw_connection)
                elif typ == 'double':
                    errorcheck(self._sw_connection.setDoubleOption(name, float64(value)),
                               self._sw_connection)
            except TypeError:
                raise SWATError('%s is not the correct type' % value)
        return True
github sassoftware / python-swat / swat / cas / transformers.py View on Github external
i = i + 1
        elif isinstance(item, binary_types):
            errorcheck(_sw_values.setString(i, key, a2n(item, 'utf-8')),
                       _sw_values)
            i = i + 1
        elif isinstance(item, int64_types):
            errorcheck(_sw_values.setInt64(i, key, int64(item)), _sw_values)
            i = i + 1
        elif isinstance(item, int32_types):
            if item > MAX_INT32 or item < MIN_INT32:
                errorcheck(_sw_values.setInt64(i, key, int64(item)), _sw_values)
            else:
                errorcheck(_sw_values.setInt32(i, key, int32(item)), _sw_values)
            i = i + 1
        elif isinstance(item, float64_types):
            errorcheck(_sw_values.setDouble(i, key, float64(item)), _sw_values)
            i = i + 1
        elif item is nil:
            errorcheck(_sw_values.setNil(i, key), _sw_values)
            i = i + 1
        elif isinstance(item, items_types):
            _sw_sublist = errorcheck(_sw_values.createListAt(
                                     i, key, len(item)), _sw_values)
            j = 0
            for v in item:
                j = set_list_value(_sw_sublist, j, None, v)
            i = i + 1
        elif isinstance(item, (dict_types, ParamManager)):
            if isinstance(item, ParamManager):
                item = item.to_params()
            _sw_sublist = errorcheck(_sw_values.createListAt(
                                     i, key, len(item)), _sw_values)