Calculate the kerning data for this location and add it to this instance.
        
        *   instanceLocation:   Location object
        *   source: dict of {sourcename: (source, sourceLocation)}
486628
def addKerning(self, instanceLocation=None, sources=None):
        
        items = []
        kerningObject = self.font.kerning
        kerningMasters = []
        if instanceLocation is None:
            instanceLocation = self.locationObject

        if sources is None:
            # kerning has no special requests, add the default sources
            sources = self.sources
        for sourceName, (source, sourceLocation) in sources.items():
            if sourceName in self.muted['kerning']:
                # kerning in this master was muted, so do not add.
                if self.verbose and self.logger:
                    self.logger.info("\tMuting kerning data for %s", instanceLocation)
                continue
            if len(source.kerning.keys())>0:
                items.append((sourceLocation, MathKerning(source.kerning, source.groups)))
        if items:
            m = None
            try:
                bias, m = buildMutator(items, axes=self.axes)
            except:
                if self.logger:
                    self.logger.exception("\tError processing kerning data. %s", items)
                return
            instanceObject = m.makeInstance(instanceLocation)
            if self.roundGeometry:
                instanceObject.round()
            instanceObject.extractKerning(self.font)
1363878
def ref_context_from_geoloc(geoloc):
    """"""
    text = geoloc.get('text')
    geoid = geoloc.get('geoID')
    rc = RefContext(name=text, db_refs={'GEOID': geoid})
    return rc
799903
def _calculateGlyph(self, targetGlyphObject, instanceLocationObject, glyphMasters):
        
        sources = None
        items = []

        for item in glyphMasters:
            locationObject = item['location']
            fontObject = item['font']
            glyphName = item['glyphName']
            if not glyphName in fontObject:
                continue
            glyphObject = MathGlyph(fontObject[glyphName])
            items.append((locationObject, glyphObject))
        bias, m = buildMutator(items, axes=self.axes)
        instanceObject = m.makeInstance(instanceLocationObject)
        if self.roundGeometry:
            try:
                instanceObject = instanceObject.round()
            except AttributeError:
                if self.verbose and self.logger:
                    self.logger.info("MathGlyph object missing round() method.")


        try:
            instanceObject.extractGlyph(targetGlyphObject, onlyGeometry=True)
        except TypeError:
            # this causes ruled glyphs to end up in the wrong glyphname
            # but defcon2 objects don't support it
            pPen = targetGlyphObject.getPointPen()
            targetGlyphObject.clear()
            instanceObject.drawPoints(pPen)
            targetGlyphObject.width = instanceObject.width
1333665
def getLearnableLocationRepresentation(self):
    
    learnableCells = np.array([], dtype="uint32")

    totalPrevCells = 0
    for module in self.L6aModules:
      learnableCells = np.append(learnableCells,
                                 module.getLearnableCells() + totalPrevCells)
      totalPrevCells += module.numberOfCells()

    return learnableCells
1348821
def convert_source_location(self, source_reading, reference_reading):
        
        offset_x, offset_y = reference_reading.get_coordinate_offset(source_reading)
        focus = source_reading.x + offset_x, source_reading.y + offset_y
        return focus
889011
def setLocation(self, location):
        
        if not location or not isinstance(location, Location):
            raise ValueError("setLocation expected a Location object")
        self.x = location.x
        self.y = location.y
        return self
899164
def to_unit_cell(self, in_place=False):
        
        frac_coords = np.mod(self.frac_coords, 1)
        if in_place:
            self.frac_coords = frac_coords
        else:
            return PeriodicSite(self.species, frac_coords, self.lattice,
                                properties=self.properties)
812152
@Nonnull
    public BugInstance addSourceLine(MethodDescriptor methodDescriptor, Location location) {
        try {
            IAnalysisCache analysisCache = Global.getAnalysisCache();
            ClassContext classContext = analysisCache.getClassAnalysis(ClassContext.class, methodDescriptor.getClassDescriptor());
            Method method = analysisCache.getMethodAnalysis(Method.class, methodDescriptor);
            return addSourceLine(classContext, method, location);
        } catch (CheckedAnalysisException e) {
            return addSourceLine(SourceLineAnnotation.createReallyUnknown(methodDescriptor.getClassDescriptor()
                    .toDottedClassName()));
        }
    }
28339
def has_kerning_info(ttFont):
  """"""
  if "GPOS" not in ttFont:
    return False

  if not ttFont["GPOS"].table.LookupList:
    return False

  for lookup in ttFont["GPOS"].table.LookupList.Lookup:
    if lookup.LookupType == 2:  # type 2 = Pair Adjustment
      return True
    elif lookup.LookupType == 9:  # type 9 = Extension subtable
      for ext in lookup.SubTable:
        if ext.ExtensionLookupType == 2:  # type 2 = Pair Adjustment
          return True
471326
def readKerningElement(self, kerningElement, instanceObject):
        
        kerningLocation = self.locationFromElement(kerningElement)
        instanceObject.addKerning(kerningLocation)
204722
public static double getNormalizedEditDistance(
      String source, String target, boolean caseSensitive) {

    if (isEmptyOrWhitespace(source) && isEmptyOrWhitespace(target)) {
      return 0.0;
    }

    return (double) getEditDistance(source, target, caseSensitive)
        / (double) getWorstCaseEditDistance(source.length(), target.length());
  }
1000615
int computeMethodInfoSize() {
    // If this method_info must be copied from an existing one, the size computation is trivial.
    if (sourceOffset != 0) {
      // sourceLength excludes the first 6 bytes for access_flags, name_index and descriptor_index.
      return 6 + sourceLength;
    }
    // 2 bytes each for access_flags, name_index, descriptor_index and attributes_count.
    int size = 8;
    // For ease of reference, we use here the same attribute order as in Section 4.7 of the JVMS.
    if (code.length > 0) {
      if (code.length > 65535) {
        throw new IndexOutOfBoundsException("Method code too large!");
      }
      symbolTable.addConstantUtf8(Constants.CODE);
      // The Code attribute has 6 header bytes, plus 2, 2, 4 and 2 bytes respectively for max_stack,
      // max_locals, code_length and attributes_count, plus the bytecode and the exception table.
      size += 16 + code.length + Handler.getExceptionTableSize(firstHandler);
      if (stackMapTableEntries != null) {
        boolean useStackMapTable = symbolTable.getMajorVersion() >= Opcodes.V1_6;
        symbolTable.addConstantUtf8(useStackMapTable ? Constants.STACK_MAP_TABLE : "StackMap");
        // 6 header bytes and 2 bytes for number_of_entries.
        size += 8 + stackMapTableEntries.length;
      }
      if (lineNumberTable != null) {
        symbolTable.addConstantUtf8(Constants.LINE_NUMBER_TABLE);
        // 6 header bytes and 2 bytes for line_number_table_length.
        size += 8 + lineNumberTable.length;
      }
      if (localVariableTable != null) {
        symbolTable.addConstantUtf8(Constants.LOCAL_VARIABLE_TABLE);
        // 6 header bytes and 2 bytes for local_variable_table_length.
        size += 8 + localVariableTable.length;
      }
      if (localVariableTypeTable != null) {
        symbolTable.addConstantUtf8(Constants.LOCAL_VARIABLE_TYPE_TABLE);
        // 6 header bytes and 2 bytes for local_variable_type_table_length.
        size += 8 + localVariableTypeTable.length;
      }
      if (firstCodeAttribute != null) {
        size +=
            firstCodeAttribute.computeAttributesSize(
                symbolTable, code.data, code.length, maxStack, maxLocals);
      }
    }
    if (numberOfExceptions > 0) {
      symbolTable.addConstantUtf8(Constants.EXCEPTIONS);
      size += 8 + 2 * numberOfExceptions;
    }
    boolean useSyntheticAttribute = symbolTable.getMajorVersion() < Opcodes.V1_5;
    if ((accessFlags & Opcodes.ACC_SYNTHETIC) != 0 && useSyntheticAttribute) {
      symbolTable.addConstantUtf8(Constants.SYNTHETIC);
      size += 6;
    }
    if (signatureIndex != 0) {
      symbolTable.addConstantUtf8(Constants.SIGNATURE);
      size += 8;
    }
    if ((accessFlags & Opcodes.ACC_DEPRECATED) != 0) {
      symbolTable.addConstantUtf8(Constants.DEPRECATED);
      size += 6;
    }
    if (defaultValue != null) {
      symbolTable.addConstantUtf8(Constants.ANNOTATION_DEFAULT);
      size += 6 + defaultValue.length;
    }
    if (parameters != null) {
      symbolTable.addConstantUtf8(Constants.METHOD_PARAMETERS);
      // 6 header bytes and 1 byte for parameters_count.
      size += 7 + parameters.length;
    }
    if (firstAttribute != null) {
      size += firstAttribute.computeAttributesSize(symbolTable);
    }
    return size;
  }
1315762
def update_source_hashes(self, instance):
        
        self.init_instance(instance)
        instance._ik['source_hashes'] = dict(
            (attname, hash(getattr(instance, attname)))
            for attname in self.get_source_fields(instance))
        return instance._ik['source_hashes']
1232410
def mergeDictionaries(sourceDictionary, destinationDictionary):
        
        log = Logger()
        varNamePattern = re.compile(r"^((__((ENV)|(FILE))__[A-Z]{3,})|(__((ENV)|(FILE))))__(?P<name>.*)$")
        varTypePattern = re.compile(r"^__((ENV)|(FILE))__(?P<type>[A-Z]{3,})__(.*)$")

        for key, value in sourceDictionary.items():
            # ignoring comments
            if key == "//":
                continue

            if isinstance(value, dict):
                # get node or create one
                node = destinationDictionary.setdefault(key, {})
                Config.mergeDictionaries(value, node)
            elif isinstance(value, str) and (value.startswith("__ENV__") or value.startswith("__FILE__")):
                # extracting environment variable name
                nameMatch = varNamePattern.match(value)
                if nameMatch is None:
                    log.warn("Invalid environmental variable specified: {name}", name=value)
                    continue
                envVariableName = nameMatch.group("name")

                # checking if environment variable is set
                if envVariableName not in os.environ:
                    log.warn("No environment variable {name} is set.", name=envVariableName)
                    continue

                if value.startswith("__ENV__"): # checking if value is set in the environment variable
                    # checking if variable has a defined cast type
                    typeMatch = varTypePattern.match(value)
                    if typeMatch is not None:
                        envVariableType = typeMatch.group("type")

                        # casting value to the specified type
                        if envVariableType == "STR":
                            destinationDictionary[key] = str(os.environ[envVariableName])
                        elif envVariableType == "BOOL":
                            if os.environ[envVariableName] == "1":
                                destinationDictionary[key] = True
                            elif os.environ[envVariableName] == "0":
                                destinationDictionary[key] = False
                        elif envVariableType == "INT":
                            destinationDictionary[key] = int(os.environ[envVariableName])
                        elif envVariableType == "FLOAT":
                            destinationDictionary[key] = float(os.environ[envVariableName])
                        elif envVariableType == "JSON":
                            try:
                                destinationDictionary[key] = json.loads(os.environ[envVariableName])
                            except Exception:
                                log.warn(
                                    "Environment variable {name} contains an invalid JSON value.",
                                    name=envVariableName
                                )
                        else:
                            log.warn(
                                "Unsupported type {type} specified for variable {name}.",
                                name=envVariableName,
                                type=envVariableType
                            )
                            continue
                    else:
                        destinationDictionary[key] = os.environ[envVariableName]
                elif value.startswith("__FILE__"): # checking if value is set in a file
                    filePath = os.environ[envVariableName]

                    # checking if file exists
                    if not os.path.isfile(filePath):
                        log.warn(
                            "File {filePath} does not exist.",
                            filePath=filePath,
                        )
                        continue

                    # checking if file can be read
                    if not os.access(filePath, os.R_OK):
                        log.warn(
                            "File {filePath} cannot be read.",
                            filePath=filePath,
                        )
                        continue

                    # load file contents
                    filePointer = open(filePath, "r")
                    destinationDictionary[key] = filePointer.read().strip()
                    filePointer.close()
            elif isinstance(value, str) and value.startswith("__FILE__"):
                pass
            else:
                destinationDictionary[key] = value

        return destinationDictionary
1255367
private static DataSource lookupDS(String dsJndiLocation) {
        DataSource ds;
        try {
            InitialContext ctx = new InitialContext();
            ds = (DataSource) ctx.lookup(dsJndiLocation);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        if (ds == null) {
            throw new RuntimeException("Datasource not found: " + dsJndiLocation); //$NON-NLS-1$
        }
        return ds;
    }
1118166
def location
      st = Position.new(0, 0)
      en = Position.from_offset(code, code.length)
      range = Range.new(st, en)
      Location.new(filename, range)
    end
362189
def globalize_indentation(src):
    
    lines = src.splitlines()
    indent = len(lines[0]) - len(lines[0].strip(' '))
    func_src = ''
    for ii, l in enumerate(src.splitlines()):
        line = l[indent:]
        func_src += line + '\n'
    return func_src