How to use the agate.utils.memoize function in agate

To help you get started, we’ve selected a few agate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wireservice / agate / agate / analysis.py View on Github external
    @memoize
    def _root(self):
        """
        Returns the root node of this Analysis' trace. (It may be itself.)
        """
        return self._trace()[0]
github wireservice / agate / agate / mapped_sequence.py View on Github external
    @memoize
    def dict(self):
        """
        Retrieve the contents of this sequence as an
        :class:`collections.OrderedDict`.
        """
        if self.keys() is None:
            raise KeyError

        return OrderedDict(self.items())
github wireservice / agate / agate / columns / number.py View on Github external
    @memoize
    def sum(self):
        """
        Compute the values in this column.

        Should be invoked via the :class:`.Sum` aggregation.
        """
        return sum(self.get_data_without_nulls())
github wireservice / agate / agate / analysis.py View on Github external
    @memoize
    def _cache_path(self):
        """
        Get the full cache path for the current fingerprint.
        """
        return os.path.join(self._cache_dir, '%s.cache' % self._fingerprint())
github wireservice / agate / agate / columns.py View on Github external
    @memoize
    def values_without_nulls(self):
        """
        Get the values in this column with any null values removed.
        """
        return tuple(d for d in self.values() if d is not None)
github wireservice / agate / agate / analysis.py View on Github external
    @memoize
    def _trace(self):
        """
        Returns the sequence of Analysis instances that lead to this one.
        """
        if self._parent:
            return self._parent._trace() + [self]

        return [self]
github wireservice / agate / agate / columns.py View on Github external
    @memoize
    def values_distinct(self):
        """
        Get the distinct values in this column, as a tuple.
        """
        return tuple(set(self.values()))
github wireservice / agate / agate / columns / number.py View on Github external
    @memoize
    def quartiles(self):
        """
        Compute quartiles for this column of data.

        :returns: :class:`Quartiles`.
        :raises: :exc:`.NullCalculationError`
        """
        return Quartiles(self.percentiles())
github wireservice / agate / agate / columns.py View on Github external
    @memoize
    def values(self):
        """
        Get the values in this column, as a tuple.
        """
        return tuple(row[self._index] for row in self._rows)
github wireservice / agate / agate / columns.py View on Github external
    @memoize
    def values_without_nulls_sorted(self):
        """
        Get the values in this column with any null values removed and sorted.
        """
        return sorted(self.values_without_nulls(), key=null_handler)