Example #1
0
from cryptle.metric.base import Timeseries, MemoryTS
import scipy.stats as sp

import cryptle.logging as logging

logger = logging.getLogger(__name__)


class Skewness(Timeseries):
    """Timeseries for calculating the skewness of the upstream.

    Args
    ----
    lookback : int
        The lookback period for sampling upstream timeseries values.
    name : str, optional
        To be used by :meth:`__repr__` method for debugging

    """
    def __repr__(self):
        return self.name

    def __init__(self, ts, lookback, name='skewness'):
        self.name = f'{name}{lookback}'
        super().__init__(ts)
        logger.debug('Obj: {}. Initialized the parent Timeseries of Skewness.',
                     type(self))
        self._lookback = lookback
        self._ts = ts
        self._cache = []
Example #2
0
import logging
import cryptle.logging as clogging

logger = logging.getLogger('test')
clogger = clogging.getLogger('ctest')

# Previous root logger changes would affect the logger in this run - consider
# encapulation such as fixture in test_logging.


def test_naive(caplog):
    logger.error('testing pytest capturing for standard library')
    if not caplog.records:
        assert False
    for record in caplog.records:
        assert record.name == 'test'
        assert record.message == 'testing pytest capturing for standard library'
        assert record.module == 'test_pytest_capture'


def test_cryptle_logging_capture(caplog):
    clogger.error('testing pytest capturing for cryptle logging')
    if not caplog.records:
        assert False
    for record in caplog.records:
        assert record.name == 'ctest'
        assert record.message == 'testing pytest capturing for cryptle logging'
        assert record.module == 'test_pytest_capture'