How to use the sciunit.Model function in sciunit

To help you get started, we’ve selected a few sciunit 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 scidash / sciunit / sciunit / unit_test / core_tests.py View on Github external
def test_get_model_state(self):
        from sciunit import Model
        
        m = Model()
        state = m.__getstate__()
        self.assertEqual(m.__dict__,state)
github openworm / ChannelWorm / tests / SCU_Models.py View on Github external
import sciunit
import SCU_Capabilities

class IonChannelModel(sciunit.Model, capabilities.Generates_IV_Curve,
        capabilities.Receives_Current, capabilities.Generates_Membrane_Potential):
        """A generic ion channel model."""

        def __init__(self, name=None, iv_curve=None, current=None, voltage=None):
            super(IonChannelModel, self).__init__(name=name)

        def generate_iv_curve(self):
            return self.iv_curve

        def receive_current(self):
            #Not clear what this should return
            pass

        def generate_membrane_potential(self):
            #Not clear what this should return
            pass
github openworm / ChannelWorm / tests / hello_model.py View on Github external
if self.score == True:
            return 'Pass'
        elif self.score == False:
            return 'Fail'
        else:
            return 'N/A'

# create a Capability
class ReturnsNumber(sciunit.Capability):
    """ This Model returns a real number. """

    def return_num(self):
        raise NotImplementedError("Must return a real number.")

# create a Model that has the above Capability
class RandomSample(sciunit.Model, ReturnsNumber):
    """ Generates a random number between 1 and 10. """

    def __init__(self):
        self.return_num()

    def return_num(self):
        return random.randint(1, 3)

# create a class of Test
class SingleNumberTest(sciunit.Test):
    """Tests that a single a single predicted number is equal to an observed one."""
    def __init__(self, observation=None, name=None):
        sciunit.Test.__init__(self, observation, name)

    required_capabilities = ReturnsNumber,
github scidash / sciunit / sciunit / unit_test / error_tests.py View on Github external
def test_error_types(self):
        from sciunit.errors import CapabilityError, BadParameterValueError,\
                                   PredictionError, InvalidScoreError
        from sciunit import Model, Capability

        CapabilityError(Model(),Capability)
        PredictionError(Model(),'foo')
        InvalidScoreError()
        BadParameterValueError('x',3)
github scidash / sciunit / sciunit / unit_test / model_tests.py View on Github external
def test_get_model_state(self):
        from sciunit import Model

        m = Model()
        state = m.__getstate__()
        self.assertEqual(m.__dict__, state)
github scidash / sciunit / sciunit / capabilities.py View on Github external
def unimplemented(self, message=''):
        """Raise a `CapabilityNotImplementedError` with details."""
        from sciunit import Model
        capabilities = [obj for obj in self.__class__.mro() if issubclass(obj, Capability) and not issubclass(obj, Model)]
        model = self if isinstance(self, Model) else None
        capability = None if not capabilities else capabilities[0]
        print(model, capability)
        raise CapabilityNotImplementedError(model, capability, message)