An object to ease multi-line scalar values
340754
function MultiLine( type , fold , applicable , options ) {
	this.type = type ;
	this.fold = !! fold ;
	this.applicable = !! applicable ;
	this.options = options ;
	this.lines = [] ;
}
1183773
def read_multiline (value):
    """"""
    for line in value.splitlines():
        line = line.strip()
        if not line or line.startswith('#'):
            continue
        yield line
83034
def simplify_scalar(self, func=sympy.simplify):
        
        return SLH(
            self.S.simplify_scalar(func=func),
            self.L.simplify_scalar(func=func),
            self.H.simplify_scalar(func=func))
645370
def _in_multi_line(self, line):
        """"""

        # we are only looking for explicitly joined lines here, not
        # implicit ones (i.e. brackets, braces etc.).  this is just to
        # guard against the possibility of modifying the space inside of
        # a literal multiline string with unfortunately placed
        # whitespace

        current_state = (self.backslashed or self.triplequoted)

        if re.search(r"\\$", line):
            self.backslashed = True
        else:
            self.backslashed = False

        triples = len(re.findall(r"\"\"\"|\'\'\'", line))
        if triples == 1 or triples % 2 != 0:
            self.triplequoted = not self.triplequoted

        return current_state
914743
def squeeze(attrs, inputs, proto_obj):
    """"""
    new_attrs = translation_utils._fix_attribute_names(attrs,
                                                       {'axes' : 'axis'})
    return 'squeeze', new_attrs, inputs
365357
def linesubst(line, variables):
    
    # trivial no substitution early detection:
    if '{{' not in line and '\\' not in line:
        return line
    st = NORM
    out = ""
    curvar = ""
    for c in line:
        if st is NORM:
            if c == '{':
                st = ONE
            elif c == '\\':
                st = LIT
            else:
                out += c
        elif st is LIT:
            out += c
            st = NORM
        elif st is ONE:
            if c == '{':
                st = TWO
            elif c == '\\':
                out += '{'
                st = LIT
            else:
                out += '{' + c
                st = NORM
        elif st is TWO:
            if c == '\\':
                st = TLIT
            elif c == '}':
                st = TERM
            else:
                curvar += c
        elif st is TLIT:
            curvar += c
            st = TWO
        elif st is TERM:
            if c == '}':
                if curvar not in variables:
                    LOG.warning("Unknown variable %r detected, will just be replaced by an empty string", curvar)
                else:
                    LOG.debug("Substitution of {{%s}} by %r", curvar, variables[curvar])

                    value = variables[curvar]
                    if isinstance(value, (float, int, long)):
                        value = str(value)

                    out += value
                curvar = ''
                st = NORM
            elif c == '\\':
                curvar += '}'
                st = TLIT
            else:
                curvar += '}' + c
                st = TWO
    if st is not NORM:
        LOG.warning("st is not NORM at end of line: " + line)
        LOG.warning("returned substitution: " + out)
    return out
189781
def scalarDecorator(func):
    """"""
    @wraps(func)
    def scalar_wrapper(*args,**kwargs):
        if nu.array(args[0]).shape == ():
            scalarOut= True
            newargs= ()
            for ii in range(len(args)):
                newargs= newargs+(nu.array([args[ii]]),)
            args= newargs
        else:
            scalarOut= False
        result= func(*args,**kwargs)
        if scalarOut:
            out= ()
            for ii in range(result.shape[1]):
                out= out+(result[0,ii],)
            return out
        else:
            return result
    return scalar_wrapper
101401
def process_line(self, line):
        ""
        cleaned = []
        columns = line.split(self.indel)
        # Populate indices if not defined
        if not self.indices:
            self.indices = range(len(columns))
        for i in self.indices:
            # Support turning an in col into multiple out cols
            out = self.process_column(i, columns[i])
            if isinstance(out, (list, tuple)):
                cleaned.extend(out)
            else:
                cleaned.append(out)
        return self.outdel.join(cleaned) + '\n'
520765
def scalarVectorDecorator(func):
    """"""
    @wraps(func)
    def scalar_wrapper(*args,**kwargs):
        if numpy.array(args[1]).shape == () \
                and numpy.array(args[2]).shape == (): #only if both R and z are scalars
            scalarOut= True
            args= (args[0],numpy.array([args[1]]),numpy.array([args[2]]))
        elif numpy.array(args[1]).shape == () \
                and not numpy.array(args[2]).shape == (): #R scalar, z vector
            scalarOut= False
            args= (args[0],args[1]*numpy.ones_like(args[2]),args[2])
        elif not numpy.array(args[1]).shape == () \
                and numpy.array(args[2]).shape == (): #R vector, z scalar
            scalarOut= False
            args= (args[0],args[1],args[2]*numpy.ones_like(args[1]))
        else:
            scalarOut= False
        result= func(*args,**kwargs)
        if scalarOut:
            return result[0]
        else:
            return result
    return scalar_wrapper
741430
def scale_values(numbers, num_lines=1, minimum=None, maximum=None):
    ""

    # find min/max values, ignoring Nones
    filtered = [n for n in numbers if n is not None]
    min_ = min(filtered) if minimum is None else minimum
    max_ = max(filtered) if maximum is None else maximum
    dv = max_ - min_

    # clamp
    numbers = [max(min(n, max_), min_) if n is not None else None for n in numbers]

    if dv == 0:
        values = [4 * num_lines if x is not None else None for x in numbers]
    elif dv > 0:
        num_blocks = len(blocks) - 1

        min_index = 1.
        max_index = num_lines * num_blocks

        values = [
            ((max_index - min_index) * (x - min_)) / dv + min_index
            if not x is None else None for x in numbers
        ]

        values = [round(v) or 1 if not v is None else None for v in values]
    return values
1132811
def p_static_scalar(p):
    ''''''
    if len(p) == 2:
        p[0] = p[1]
    elif len(p) == 3:
        p[0] = ''
    else:
        p[0] = p[2].decode('string_escape')
186129
def unpack_scalar(cls, dataset, data):
        
        if (len(data.data_vars) == 1 and
            len(data[dataset.vdims[0].name].shape) == 0):
            return data[dataset.vdims[0].name].item()
        return data
427348
def mul(x, y, context=None):
    
    return _apply_function_in_current_context(
        BigFloat,
        mpfr.mpfr_mul,
        (
            BigFloat._implicit_convert(x),
            BigFloat._implicit_convert(y),
        ),
        context,
    )
381549
def _possibly_convert_objects(values):
    
    return np.asarray(pd.Series(values.ravel())).reshape(values.shape)
750972
def _values(self):
        """"""
        if self.interpolate:
            return [
                val[0] for serie in self.series for val in serie.interpolated
            ]
        else:
            return super(Line, self)._values
1332242
def get_scalar(self, name, preference='cell', info=False):
        
        return get_scalar(self, name, preference=preference, info=info)
556254
def convert_to_scalars(cls, ops, kwargs):
    """"""
    from qnet.algebra.core.scalar_algebra import Scalar, ScalarValue
    scalar_ops = []
    for op in ops:
        if not isinstance(op, Scalar):
            scalar_ops.append(ScalarValue(op))
        else:
            scalar_ops.append(op)
    return scalar_ops, kwargs