# Path: ifcb/data/adc.py
# SCHEMA = {
#     1: SCHEMA_VERSION_1,
#     2: SCHEMA_VERSION_2,
#     SCHEMA_VERSION_1._name: SCHEMA_VERSION_1,
#     SCHEMA_VERSION_2._name: SCHEMA_VERSION_2
# }
# 
# Path: ifcb/data/hdr.py
# TEMPERATURE = 'temperature'
# 
# HUMIDITY = 'humidity'
# 
# Path: ifcb/data/utils.py
# class BaseDictlike(object):
#     """
#     Provides as complete a readonly dict interface as possible,
#     based on anything that implements ``keys`` and ``__getitem__``.
#     when overriding, override ``has_key`` rather than ```__contains__``.
# 
#     Override any method if a more efficient implementation
#     is available.
#     """
#     def keys(self):
#         """
#         Default implementation raises ``NotImplementedError``.
#         This must be overridden for correct behavior.
#         """
#         raise NotImplementedError
#     def __getitem__(self, k):
#         """
#         Default implementation raises ``NotImplementedError``.
#         This must be overridden for correct behavior.
# 
#         :param k: the key
#         :type k: hashable
#         """
#         raise NotImplementedError
#     def __iter__(self):
#         yield from self.keys()
#     def has_key(self, k):
#         """
#         Iterates over keys and returns first key for
#         which equality test passes. This method is
#         called by the ``__contains__`` special method.
# 
#         :param k: the key to test
#         :type k: hashable
#         """
#         for ek in self.keys():
#             if ek == k:
#                 return True
#         return False
#     def __contains__(self, k):
#         return self.has_key(k)
#     def items(self):
#         """
#         Yields item pairs, based on calling keys
#         and then accessing each item.
#         """
#         for k in self.keys():
#             yield k, self[k]
#     def values(self):
#         """
#         Yields all values. Calls ``items``.
#         """
#         for k, v in self.items():
#             yield v
#     def __len__(self):
#         n = 0
#         for k in self.keys():
#             n += 1
#         return n
# 
# Path: ifcb/metrics/ml_analyzed.py
# def compute_ml_analyzed(abin):
#     """returns ml_analyzed, look time, run time"""
#     s = abin.schema
#     if s is SCHEMA_VERSION_1:
#         return compute_ml_analyzed_s1(abin)
#     elif s is SCHEMA_VERSION_2:
#         return compute_ml_analyzed_s2(abin)


from functools import lru_cache
from .adc import SCHEMA
from .hdr import TEMPERATURE, HUMIDITY
from .utils import BaseDictlike
from ..metrics.ml_analyzed import compute_ml_analyzed
        from .hdf import bin2hdf
        from .zip import bin2zip
        from .matlab import bin2mat
    def _get_ml_analyzed(self):
        return compute_ml_analyzed(self)
    @property
    def ml_analyzed(self):
        ma, _, _ = self._get_ml_analyzed()
        return ma
    @property
    def look_time(self):
        _, lt, _ = self._get_ml_analyzed()
        return lt
    @property
    def run_time(self):
        _, _, rt = self._get_ml_analyzed()
        return rt
    @property
    def inhibit_time(self):
        return self.run_time - self.look_time
    @property
    def n_triggers(self):
        try:
            last_row = self.adc.iloc[-1]
        except IndexError: # empty ADC file
            return 0
        return int(last_row[self.schema.TRIGGER])
    @property
    def trigger_rate(self):
        """return trigger rate in triggers / s"""
        return 1.0 * self.n_triggers / self.run_time
    @property
    def temperature(self):

# Path: ifcb/data/adc.py
# SCHEMA = {
#     1: SCHEMA_VERSION_1,
#     2: SCHEMA_VERSION_2,
#     SCHEMA_VERSION_1._name: SCHEMA_VERSION_1,
#     SCHEMA_VERSION_2._name: SCHEMA_VERSION_2
# }
# 
# Path: ifcb/data/hdr.py
# TEMPERATURE = 'temperature'
# 
# HUMIDITY = 'humidity'
# 
# Path: ifcb/data/utils.py
# class BaseDictlike(object):
#     """
#     Provides as complete a readonly dict interface as possible,
#     based on anything that implements ``keys`` and ``__getitem__``.
#     when overriding, override ``has_key`` rather than ```__contains__``.
# 
#     Override any method if a more efficient implementation
#     is available.
#     """
#     def keys(self):
#         """
#         Default implementation raises ``NotImplementedError``.
#         This must be overridden for correct behavior.
#         """
#         raise NotImplementedError
#     def __getitem__(self, k):
#         """
#         Default implementation raises ``NotImplementedError``.
#         This must be overridden for correct behavior.
# 
#         :param k: the key
#         :type k: hashable
#         """
#         raise NotImplementedError
#     def __iter__(self):
#         yield from self.keys()
#     def has_key(self, k):
#         """
#         Iterates over keys and returns first key for
#         which equality test passes. This method is
#         called by the ``__contains__`` special method.
# 
#         :param k: the key to test
#         :type k: hashable
#         """
#         for ek in self.keys():
#             if ek == k:
#                 return True
#         return False
#     def __contains__(self, k):
#         return self.has_key(k)
#     def items(self):
#         """
#         Yields item pairs, based on calling keys
#         and then accessing each item.
#         """
#         for k in self.keys():
#             yield k, self[k]
#     def values(self):
#         """
#         Yields all values. Calls ``items``.
#         """
#         for k, v in self.items():
#             yield v
#     def __len__(self):
#         n = 0
#         for k in self.keys():
#             n += 1
#         return n
# 
# Path: ifcb/metrics/ml_analyzed.py
# def compute_ml_analyzed(abin):
#     """returns ml_analyzed, look time, run time"""
#     s = abin.schema
#     if s is SCHEMA_VERSION_1:
#         return compute_ml_analyzed_s1(abin)
#     elif s is SCHEMA_VERSION_2:
#         return compute_ml_analyzed_s2(abin)


# Path: ifcb/data/bins.py
from functools import lru_cache
from .adc import SCHEMA
from .hdr import TEMPERATURE, HUMIDITY
from .utils import BaseDictlike
from ..metrics.ml_analyzed import compute_ml_analyzed
        from .hdf import bin2hdf
        from .zip import bin2zip
        from .matlab import bin2mat

    def _get_ml_analyzed(self):
        return compute_ml_analyzed(self)
    @property
    def ml_analyzed(self):
        ma, _, _ = self._get_ml_analyzed()
        return ma
    @property
    def look_time(self):
        _, lt, _ = self._get_ml_analyzed()
        return lt
    @property
    def run_time(self):
        _, _, rt = self._get_ml_analyzed()
        return rt
    @property
    def inhibit_time(self):
        return self.run_time - self.look_time
    @property
    def n_triggers(self):
        try:
            last_row = self.adc.iloc[-1]
        except IndexError: # empty ADC file
            return 0
        return int(last_row[self.schema.TRIGGER])
    @property
    def trigger_rate(self):
        """return trigger rate in triggers / s"""
        return 1.0 * self.n_triggers / self.run_time
    @property
    def temperature(self):

        return self.header(TEMPERATURE)