コード例 #1
0
    def test_bool_ops_vector(self):
        """Test Logical Operations: Vector"""

        thermal_zone_id = 0
        # The equation returns a vector mask
        parser = Parser(trappy.Run())
        eqn = "(trappy.thermal.ThermalGovernor:current_temperature > 77000)\
                & (trappy.pid_controller.PIDController:output > 2500)"
        mask = parser.solve(eqn)
        self.assertEquals(len(parser.ref(mask.dropna()[0])), 0)
コード例 #2
0
    def test_bool_ops_vector(self):
        """Test Logical Operations: Vector"""

        thermal_zone_id = 0
        # The equation returns a vector mask
        parser = Parser(trappy.FTrace())
        eqn = "(trappy.thermal.ThermalGovernor:current_temperature > 77000)\
                & (trappy.pid_controller.PIDController:output > 2500)"
        mask = parser.solve(eqn)
        self.assertEquals(len(parser.ref(mask.dropna()[0])), 0)
コード例 #3
0
ファイル: Analyzer.py プロジェクト: jrjang/bart
class Analyzer(object):

    """
    :param data: TRAPpy Run Object
    :type data: :mod:`trappy.run.Run`

    :param config: A dictionary of variables, classes
        and functions that can be used in the statements
    :type config: dict
    """

    def __init__(self, data, config, topology=None):
        self._parser = Parser(data, config, topology)

    def assertStatement(self, statement, select=None):
        """Solve the statement for a boolean result

        :param statement: A string representing a valid
            :mod:`trappy.stats.grammar` statement
        :type statement: str

        :param select: If the result represents a boolean
            mask and the data was derived from a TRAPpy event
            with a pivot value. The :code:`select` can be
            used to select a particular pivot value
        :type select: :mod:`pandas.DataFrame` column
        """

        result = self.getStatement(statement, select=select)

        # pylint: disable=no-member
        if not (isinstance(result, bool) or isinstance(result, np.bool_)):
            warnings.warn(
                "solution of {} is not an instance of bool".format(statement))
        return result
        # pylint: enable=no-member

    def getStatement(self, statement, reference=False, select=None):
        """Evaluate the statement"""

        result = self._parser.solve(statement)

        # pylint: disable=no-member
        if np.isscalar(result):
            return result
        # pylint: enable=no-member

        if select is not None and len(result):
            result = result[select]
            if reference:
                result = self._parser.ref(result)

        return result
コード例 #4
0
class Analyzer(object):
    """
    :param data: TRAPpy Run Object
    :type data: :mod:`trappy.run.Run`

    :param config: A dictionary of variables, classes
        and functions that can be used in the statements
    :type config: dict
    """
    def __init__(self, data, config, topology=None):
        self._parser = Parser(data, config, topology)

    def assertStatement(self, statement, select=None):
        """Solve the statement for a boolean result

        :param statement: A string representing a valid
            :mod:`trappy.stats.grammar` statement
        :type statement: str

        :param select: If the result represents a boolean
            mask and the data was derived from a TRAPpy event
            with a pivot value. The :code:`select` can be
            used to select a particular pivot value
        :type select: :mod:`pandas.DataFrame` column
        """

        result = self.getStatement(statement, select=select)

        # pylint: disable=no-member
        if not (isinstance(result, bool) or isinstance(result, np.bool_)):
            warnings.warn(
                "solution of {} is not an instance of bool".format(statement))
        return result
        # pylint: enable=no-member

    def getStatement(self, statement, reference=False, select=None):
        """Evaluate the statement"""

        result = self._parser.solve(statement)

        # pylint: disable=no-member
        if np.isscalar(result):
            return result
        # pylint: enable=no-member

        if select is not None and len(result):
            result = result[select]
            if reference:
                result = self._parser.ref(result)

        return result
コード例 #5
0
ファイル: Analyzer.py プロジェクト: sinkap/bart
class Analyzer(object):

    """
        Args:
            data (trappy.Run): A trappy.Run instance
            config (dict): A dictionary of variables, classes
                and functions that can be used in the statements
    """

    def __init__(self, data, config, topology=None):
        self._parser = Parser(data, config, topology)

    def assertStatement(self, statement, select=None):
        """Solve the statement for a boolean result"""

        result = self.getStatement(statement, select=select)

        # pylint: disable=no-member
        if not (isinstance(result, bool) or isinstance(result, np.bool_)):
            warnings.warn(
                "solution of {} is not an instance of bool".format(statement))
        return result
        # pylint: enable=no-member

    def getStatement(self, statement, reference=False, select=None):
        """Evaluate the statement"""

        result = self._parser.solve(statement)

        # pylint: disable=no-member
        if np.isscalar(result):
            return result
        # pylint: enable=no-member

        if select is not None and len(result):
            result = result[select]
            if reference:
                result = self._parser.ref(result)

        return result
コード例 #6
0
class Analyzer(object):
    """
        Args:
            data (trappy.Run): A trappy.Run instance
            config (dict): A dictionary of variables, classes
                and functions that can be used in the statements
    """
    def __init__(self, data, config, topology=None):
        self._parser = Parser(data, config, topology)

    def assertStatement(self, statement, select=None):
        """Solve the statement for a boolean result"""

        result = self.getStatement(statement, select=select)

        # pylint: disable=no-member
        if not (isinstance(result, bool) or isinstance(result, np.bool_)):
            warnings.warn(
                "solution of {} is not an instance of bool".format(statement))
        return result
        # pylint: enable=no-member

    def getStatement(self, statement, reference=False, select=None):
        """Evaluate the statement"""

        result = self._parser.solve(statement)

        # pylint: disable=no-member
        if np.isscalar(result):
            return result
        # pylint: enable=no-member

        if select is not None and len(result):
            result = result[select]
            if reference:
                result = self._parser.ref(result)

        return result