This works for both SV and MV scalar fields
969139
private void updateScalarReplaceValue(String currentValue, String newValue) {
        m_dbTran.addScalarValueColumn(m_tableDef, m_dbObj.getObjectID(), m_fieldName, newValue);
        Set<String> currTermSet = tokenize(Utils.isEmpty(currentValue) ? "" : currentValue);
        Set<String> newTermSet = tokenize(newValue);
        for (String term : currTermSet) {
            if (!newTermSet.remove(term)) {
                unindexTerm(term);
            }
        }
        indexTerms(newTermSet);
        addFieldTermReferences(newTermSet);
        if (Utils.isEmpty(currentValue)) {
            addFieldReference();
        }
    }
315770
private void addSVScalar() {
        String fieldValue = m_dbObj.getFieldValue(m_fieldName);
        m_dbTran.addScalarValueColumn(m_tableDef, m_dbObj.getObjectID(), m_fieldName, fieldValue);
        addTermColumns(fieldValue);
    }
217466
public static Mapping<Float> floatv(Constraint... constraints) {
        return new FieldMapping(
                InputMode.SINGLE,
                mkSimpleConverter(s ->
                    isEmptyStr(s) ? 0.0f : Float.parseFloat(s)
                ), new MappingMeta(MAPPING_FLOAT, Float.class)
            ).constraint(checking(Float::parseFloat, "error.float", true))
                .constraint(constraints);
        }
1249619
static float vDistSqr(float[] v1, float[] v2) {
        float dx = v2[0] - v1[0];
        float dy = v2[1] - v1[1];
        float dz = v2[2] - v1[2];
        return dx * dx + dy * dy + dz * dz;
    }
1130774
def concatenate_fields(fields, dim):
    ''
    if len(fields) == 0:
        raise ValueError('fields cannot be an empty list')
    
    if len(set((f.name, f.shape, f.dtype) for f in fields)) != 1:
        raise ValueError('fields should have homogeneous name, shape and dtype')
    tpl = fields[0]
    attr = InstanceAttribute(tpl.name, shape=tpl.shape, dtype=tpl.dtype, 
                             dim=dim, alias=None)
    
    attr.value = np.array([f.value for f in fields], dtype=tpl.dtype)
    return attr
466367
def p_common_scalar_magic_func(p):
    ''
    p[0] = ast.MagicConstant(p[1].upper(), None, lineno=p.lineno(1))
686709
def unpack_scalar(cls, dataset, data):
        
        if len(data) != 1:
            return data
        key = list(data.keys())[0]

        if len(data[key]) == 1 and key in dataset.vdims:
            scalar = data[key][0]
            return scalar.compute() if hasattr(scalar, 'compute') else scalar
        return data
686318
def encode_mv(vals):
    """'"""
    s = ""
    for val in vals:
        val = val.replace('$', '$$')
        if len(s) > 0:
            s += ';'
        s += '$' + val + '$'

    return s
45849
def _lookup_generic_scalar(self,
                               obj,
                               as_of_date,
                               country_code,
                               matches,
                               missing):
        
        result = self._lookup_generic_scalar_helper(
            obj, as_of_date, country_code,
        )
        if result is not None:
            matches.append(result)
        else:
            missing.append(obj)
341570
def update_fields(u, u_old, v_old, a_old):
    """"""

    # Get vectors (references)
    u_vec, u0_vec  = u.vector(), u_old.vector()
    v0_vec, a0_vec = v_old.vector(), a_old.vector()

    # use update functions using vector arguments
    a_vec = update_a(u_vec, u0_vec, v0_vec, a0_vec, ufl=False)
    v_vec = update_v(a_vec, u0_vec, v0_vec, a0_vec, ufl=False)

    # Update (u_old <- u)
    v_old.vector()[:], a_old.vector()[:] = v_vec, a_vec
    u_old.vector()[:] = u.vector()
1008156
def set_active_scalar(self, name, preference='cell'):
        """"""
        _, field = get_scalar(self, name, preference=preference, info=True)
        if field == POINT_DATA_FIELD:
            self.GetPointData().SetActiveScalars(name)
        elif field == CELL_DATA_FIELD:
            self.GetCellData().SetActiveScalars(name)
        else:
            raise RuntimeError('Data field ({}) not useable'.format(field))
        self._active_scalar_info = [field, name]
407140
function addMiter (v, coordCurr, normPrev, normNext, miter_len_sq, isBeginning, context) {
    var miterVec = createMiterVec(normPrev, normNext);

    //  Miter limit: if miter join is too sharp, convert to bevel instead
    if (Vector.lengthSq(miterVec) > miter_len_sq) {
        addJoin(JOIN_TYPE.bevel, v, coordCurr, normPrev, normNext, isBeginning, context);
    }
    else {
        addVertex(coordCurr, miterVec, miterVec, 1, v, context, 1);
        addVertex(coordCurr, miterVec, miterVec, 0, v, context, -1);
        if (!isBeginning) {
            indexPairs(1, context);
        }
    }
}
1332388
def _scalar_to_vector(self, m):
        
        if not isinstance(m.y0, numbers.Number):
            return m
        else:
            m = copy.deepcopy(m)
            t0 = 0.0
            if isinstance(m.y0, numbers.Integral):
                numtype = np.float64
            else:
                numtype = type(m.y0)
            y0_orig = m.y0
            m.y0 = np.array([m.y0], dtype=numtype)
            def make_vector_fn(fn):
                def newfn(y, t):
                    return np.array([fn(y[0], t)], dtype=numtype)
                newfn.__name__ = fn.__name__
                return newfn
            def make_matrix_fn(fn):
                def newfn(y, t):
                    return np.array([[fn(y[0], t)]], dtype=numtype)
                newfn.__name__ = fn.__name__
                return newfn
            def make_coupling_fn(fn):
                def newfn(source_y, target_y, weight):
                    return np.array([fn(source_y[0], target_y[0], weight)])
                newfn.__name__ = fn.__name__
                return newfn
            if isinstance(m.f(y0_orig, t0), numbers.Number):
                m.f = make_vector_fn(m.f)
            if hasattr(m, 'G') and isinstance(m.G(y0_orig,t0), numbers.Number):
                m.G = make_matrix_fn(m.G)
            if (hasattr(m, 'coupling') and
                    isinstance(m.coupling(y0_orig, y0_orig, 0.5),
                               numbers.Number)):
                m.coupling = make_coupling_fn(m.coupling)
            return m
416122
def _scalar_binary_op(self, other, binop, result):
        '''
        
        '''
        template = 'map({arr}, |z: {type}| z {binop} {other}{suffix})'
        weld_type = result._weld_type.__str__()
        result.weldobj.weld_code = template.format(arr = result.weldobj.weld_code,
                                                  type =  weld_type,
                                                  binop = binop,
                                                  other = str(other),
                                                  suffix = DTYPE_SUFFIXES[weld_type])
        return result
266015
def add_scalar(self, name, value, step):
        """"""
        self.writer.add_scalar(name, value, step)
355510
public SDVariable sub(String varName, double scalar) {
        val result = sameDiff.f().sub(this, scalar);
        return sameDiff.updateVariableNameAndReference(result, varName);
    }
689297
def combine_mv_and_lv(mv, lv):
    

    combined = {
        c: pd.concat([mv[c], lv[c]], axis=0) for c in list(lv.keys())
    }

    combined['Transformer'] = mv['Transformer']

    return combined