File: _variable.pyx

package info (click to toggle)
orange3 3.40.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,908 kB
  • sloc: python: 162,745; ansic: 622; makefile: 322; sh: 93; cpp: 77
file content (25 lines) | stat: -rw-r--r-- 636 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#cython: embedsignature=True
#cython: language_level=3

import cython

@cython.boundscheck(False)
@cython.wraparound(False)
def val_from_str_add_cont(self, s):
    if s in self.unknown_str:
        return self.Unknown
    val = float(s)
    cdef int i
    cdef int ndec
    cdef str s1
    cdef int nd
    cdef int ad = self.adjust_decimals
    if ad and isinstance(s, str):
        nd = self._number_of_decimals
        s1 = s.strip()
        i = s1.find(".")
        ndec = len(s1) - i - 1 if i > 0 else 0
        if ndec > nd or ad == 2:
            self.number_of_decimals = ndec
            self.adjust_decimals = 1
    return val