Exemplo n.º 1
0
 def sanity_fuzzyMatchExample(self):
   """
     Check example for fuzzyMatch
   """
   from PyAstronomy import pyaC
   
   wordList = ["one", "two", "three", "four", "o-ne"]
   
   r = pyaC.fuzzyMatch("One", wordList)
   print("Exact match: {em:}, close match(es): {cm:}".format(**r))
   
   r = pyaC.fuzzyMatch("One", wordList, cutoff=0.4)
   print("Exact match: {em:}, close match(es): {cm:}".format(**r))
   
   r = pyaC.fuzzyMatch("One", wordList, caseSensitive=False)
   print("Exact match: {em:}, close match(es): {cm:}".format(**r))
Exemplo n.º 2
0
    def selectByPlanetName(self, planetName, caseSensitive=False):
        """
        Get entry by planet name.

        Parameters
        ----------
        planetName : string
            The name of the planet (includes planet letter,
            e.g., "corot-2 b"
        caseSensitive : boolean, optional
            If False (default), the search will be case-insensitive.

        Returns
        -------
        Data entry : dictionary
            A dictionary with a key for every data column holding
            the associated value from the data table.
        """
        pnames = [name.decode("utf8") for name in self.data.pl_name]
        r = pyaC.fuzzyMatch(planetName, pnames,
                            caseSensitive=caseSensitive, raises=True)
        result = {}
        for c in six.itervalues(self._columns):
            result[c[0]] = self.data[c[0]][r["index"]]
        return result
Exemplo n.º 3
0
    def selectByPlanetName(self, planetName, toScreen=True, caseSensitive=False):
        """
        Get entry by planet name.

        Parameters
        ----------
        planetName : string
            The name of the planet (includes planet letter,
            e.g., "corot-2 b"
        caseSensitive : boolean, optional
            If False (default), the search will be case-insensitive.
        toScreen : boolean, optional
            If True (default), the information on the system is printed
            to screen in human-readable format.

        Returns
        -------
        Data entry : dictionary
            A dictionary with a key for every data column holding
            the associated value from the data table.
        """
        names = [n for n in self.vot["name"]]
        r = pyaC.fuzzyMatch(planetName, names,
                            caseSensitive=caseSensitive, raises=True)
        result = {cn: self.vot[r["index"]][cn] for cn in self.vot.colnames}
        if toScreen:
            self._printHRInfo(result)

        return result
Exemplo n.º 4
0
    def selectByPlanetName(self, planetName, caseSensitive=False):
        """
        Get entry by planet name.

        Parameters
        ----------
        planetName : string
            The name of the planet (includes planet letter,
            e.g., "corot-2 b"
        caseSensitive : boolean, optional
            If False (default), the search will be case-insensitive.

        Returns
        -------
        Data entry : dictionary
            A dictionary with a key for every data column holding
            the associated value from the data table.
        """
        if hasattr(self.data.pl_name[0], "decode"):
            pnames = [name.decode("utf8") for name in self.data.pl_name]
        else:
            pnames = self.data.pl_name
        r = pyaC.fuzzyMatch(planetName,
                            pnames,
                            caseSensitive=caseSensitive,
                            raises=True)
        result = {}
        for c in six.itervalues(self._columns):
            result[c[0]] = self.data[c[0]][r["index"]]
        return result