# Path: metrology/instruments/derive.py
# class Derive(Meter):
#     """
#     A derive is like a meter but accepts an absolute counter as input.
# 
#       derive = Metrology.derive('network.io')
#       derive.mark()
#       derive.count
# 
#     """
#     def __init__(self, average_class=EWMA):
#         self.last = AtomicLong(0)
#         super(Derive, self).__init__(average_class)
# 
#     def mark(self, value=1):
#         """Record an event with the derive.
# 
#         :param value: counter value to record
#         """
#         last = self.last.get_and_set(value)
#         if last <= value:
#             value = value - last
#         super(Derive, self).mark(value)


from unittest import TestCase
from metrology.instruments.derive import Derive



class DeriveTest(TestCase):
    def setUp(self):
        self.derive = Derive()

    def test_derive(self):
        self.derive.mark()
        self.assertEqual(1, self.derive.count)

    def test_blank_derive(self):

# Path: metrology/instruments/derive.py
# class Derive(Meter):
#     """
#     A derive is like a meter but accepts an absolute counter as input.
# 
#       derive = Metrology.derive('network.io')
#       derive.mark()
#       derive.count
# 
#     """
#     def __init__(self, average_class=EWMA):
#         self.last = AtomicLong(0)
#         super(Derive, self).__init__(average_class)
# 
#     def mark(self, value=1):
#         """Record an event with the derive.
# 
#         :param value: counter value to record
#         """
#         last = self.last.get_and_set(value)
#         if last <= value:
#             value = value - last
#         super(Derive, self).mark(value)


# Path: tests/instruments/test_derive.py
from unittest import TestCase
from metrology.instruments.derive import Derive




class DeriveTest(TestCase):
    def setUp(self):
        self.derive = Derive()

    def test_derive(self):
        self.derive.mark()
        self.assertEqual(1, self.derive.count)

    def test_blank_derive(self):

        self.assertEqual(0, self.derive.count)