def test_doas_matrix_benchmark(benchmark):
    model = DOASModel.from_dict({
        'initial_concentration': {
            'j1': {
                'compartments': ['s1', 's2'],
                'parameters': ['j.1', 'j.0']
            },
        },
        'oscillation': {
            'osc1': {
                'frequency': 'osc.freq',
                'rate': 'osc.rate'
            },
            'osc2': {
                'frequency': 'osc.freq',
                'rate': 'osc.rate'
            }
        },
        'megacomplex': {
            'm1': {
                'oscillation': ['osc1', 'osc2'],
            }
        },
        'irf': {
            'irf1': {
                'type': 'gaussian',
                'center': ['irf.center'],
                'width': ['irf.width']
            },
        },
        'dataset': {
            'dataset1': {
                'initial_concentration': 'j1',
                'megacomplex': ['m1'],
                'irf': 'irf1',
            }
        }
    })
    parameter = ParameterGroup.from_dict({
        'j': [
            ['1', 1, {
                'vary': False
            }],
            ['0', 0, {
                'vary': False
            }],
        ],
        'osc': [
            ['freq', 16],
            ['rate', 0.3],
        ],
        'irf': [['center', 0.5], ['width', 0.3]],
    })
    time = np.arange(0, 6, 0.001)
    dataset = model.dataset['dataset1'].fill(model, parameter)

    benchmark(calculate_doas_matrix, dataset, 0, time)
Example #2
0
def test_doas_matrix_benchmark(benchmark):
    model = DOASModel.from_dict({
        'initial_concentration': {
            'j1': {
                'compartments': ['s1', 's2'],
                'parameters': ['j.1', 'j.0']
            },
        },
        'oscillation': {
            'osc1': {'frequency': 'osc.freq', 'rate': 'osc.rate'},
            'osc2': {'frequency': 'osc.freq', 'rate': 'osc.rate'}
        },
        'megacomplex': {
            'm1': {
                'oscillation': ['osc1', 'osc2'],
            }
        },
        'irf': {
            'irf1': {'type': 'gaussian', 'center': ['irf.center'], 'width': ['irf.width']},
        },
        'dataset': {
            'dataset1': {
                'initial_concentration': 'j1',
                'megacomplex': ['m1'],
                'irf': 'irf1',
            }
        }
    })
    parameter = ParameterGroup.from_dict({
        'j': [
            ['1', 1, {'vary': False}],
            ['0', 0, {'vary': False}],
        ],
        'osc': [
            ['freq', 16],
            ['rate', 0.3],
        ],
        'irf': [['center', 0.5], ['width', 0.3]],
    })
    time = np.arange(0, 6, 0.001)
    dataset = model.dataset['dataset1'].fill(model, parameter)

    benchmark(calculate_doas_matrix, dataset, time, 0)
Example #3
0
class OneOscillationWithIrf:
    sim_model = DOASModel.from_dict({
        "oscillation": {
            "osc1": {
                "frequency": "osc.freq",
                "rate": "osc.rate"
            }
        },
        "megacomplex": {
            "m1": {
                "oscillation": ["osc1"]
            }
        },
        "shape": {
            "sh1": {
                "type": "gaussian",
                "amplitude": "shape.amps.1",
                "location": "shape.locs.1",
                "width": "shape.width.1",
            },
        },
        "irf": {
            "irf1": {
                "type": "gaussian",
                "center": "irf.center",
                "width": "irf.width"
            },
        },
        "dataset": {
            "dataset1": {
                "megacomplex": ["m1"],
                "shape": {
                    "osc1": "sh1"
                },
                "irf": "irf1",
            }
        },
    })

    model = DOASModel.from_dict({
        "oscillation": {
            "osc1": {
                "frequency": "osc.freq",
                "rate": "osc.rate"
            }
        },
        "megacomplex": {
            "m1": {
                "oscillation": ["osc1"]
            }
        },
        "irf": {
            "irf1": {
                "type": "gaussian",
                "center": "irf.center",
                "width": "irf.width"
            },
        },
        "dataset": {
            "dataset1": {
                "megacomplex": ["m1"],
                "irf": "irf1",
            }
        },
    })

    wanted_parameter = ParameterGroup.from_dict({
        "osc": [
            ["freq", 25],
            ["rate", 0.1],
        ],
        "shape": {
            "amps": [7],
            "locs": [5],
            "width": [4]
        },
        "irf": [["center", 0.3], ["width", 0.1]],
    })

    parameter = ParameterGroup.from_dict({
        "osc": [
            ["freq", 25],
            ["rate", 0.1],
        ],
        "irf": [["center", 0.3], ["width", 0.1]],
    })

    time = np.arange(0, 3, 0.01)
    spectral = np.arange(0, 10)
    axis = {"time": time, "spectral": spectral}

    wanted_clp = ["osc1_cos", "osc1_sin"]
    wanted_shape = (300, 2)
Example #4
0
class OneOscillationWithSequentialModel:
    sim_model = DOASModel.from_dict({
        "initial_concentration": {
            "j1": {
                "compartments": ["s1", "s2"],
                "parameters": ["j.1", "j.0"]
            },
        },
        "k_matrix": {
            "k1": {
                "matrix": {
                    ("s2", "s1"): "kinetic.1",
                    ("s2", "s2"): "kinetic.2",
                }
            }
        },
        "oscillation": {
            "osc1": {
                "frequency": "osc.freq",
                "rate": "osc.rate"
            }
        },
        "megacomplex": {
            "m1": {
                "k_matrix": ["k1"],
                "oscillation": ["osc1"],
            }
        },
        "shape": {
            "sh1": {
                "type": "gaussian",
                "amplitude": "shape.amps.1",
                "location": "shape.locs.1",
                "width": "shape.width.1",
            },
            "sh2": {
                "type": "gaussian",
                "amplitude": "shape.amps.2",
                "location": "shape.locs.2",
                "width": "shape.width.2",
            },
            "sh3": {
                "type": "gaussian",
                "amplitude": "shape.amps.3",
                "location": "shape.locs.3",
                "width": "shape.width.3",
            },
        },
        "irf": {
            "irf1": {
                "type": "gaussian",
                "center": "irf.center",
                "width": "irf.width"
            },
        },
        "dataset": {
            "dataset1": {
                "initial_concentration": "j1",
                "megacomplex": ["m1"],
                "shape": {
                    "osc1": "sh1",
                    "s1": "sh2",
                    "s2": "sh3",
                },
                "irf": "irf1",
            }
        },
    })

    model = DOASModel.from_dict({
        "initial_concentration": {
            "j1": {
                "compartments": ["s1", "s2"],
                "parameters": ["j.1", "j.0"]
            },
        },
        "k_matrix": {
            "k1": {
                "matrix": {
                    ("s2", "s1"): "kinetic.1",
                    ("s2", "s2"): "kinetic.2",
                }
            }
        },
        "oscillation": {
            "osc1": {
                "frequency": "osc.freq",
                "rate": "osc.rate"
            }
        },
        "megacomplex": {
            "m1": {
                "k_matrix": ["k1"],
                "oscillation": ["osc1"],
            }
        },
        "irf": {
            "irf1": {
                "type": "gaussian",
                "center": "irf.center",
                "width": "irf.width"
            },
        },
        "dataset": {
            "dataset1": {
                "initial_concentration": "j1",
                "megacomplex": ["m1"],
                "irf": "irf1",
            }
        },
    })

    wanted_parameter = ParameterGroup.from_dict({
        "j": [
            ["1", 1, {
                "vary": False,
                "non-negative": False
            }],
            ["0", 0, {
                "vary": False,
                "non-negative": False
            }],
        ],
        "kinetic": [
            ["1", 0.2],
            ["2", 0.01],
        ],
        "osc": [
            ["freq", 25],
            ["rate", 0.1],
        ],
        "shape": {
            "amps": [0.07, 2, 4],
            "locs": [5, 2, 8],
            "width": [4, 2, 3]
        },
        "irf": [["center", 0.3], ["width", 0.1]],
    })

    parameter = ParameterGroup.from_dict({
        "j": [
            ["1", 1, {
                "vary": False,
                "non-negative": False
            }],
            ["0", 0, {
                "vary": False,
                "non-negative": False
            }],
        ],
        "kinetic": [
            ["1", 0.2],
            ["2", 0.01],
        ],
        "osc": [
            ["freq", 25],
            ["rate", 0.1],
        ],
        "irf": [["center", 0.3], ["width", 0.1]],
    })

    time = np.arange(-1, 5, 0.01)
    spectral = np.arange(0, 10)
    axis = {"time": time, "spectral": spectral}

    wanted_clp = ["osc1_cos", "osc1_sin", "s1", "s2"]
    wanted_shape = (600, 4)
class OneOscillation():
    sim_model = DOASModel.from_dict({
        'oscillation': {
            'osc1': {
                'frequency': 'osc.freq',
                'rate': 'osc.rate'
            }
        },
        'megacomplex': {
            'm1': {
                'oscillation': ['osc1']
            }
        },
        'shape': {
            'sh1': {
                'type': "gaussian",
                'amplitude': "shape.amps.1",
                'location': "shape.locs.1",
                'width': "shape.width.1",
            },
        },
        'dataset': {
            'dataset1': {
                'megacomplex': ['m1'],
                'shape': {
                    'osc1': 'sh1'
                }
            }
        }
    })

    model = DOASModel.from_dict({
        'oscillation': {
            'osc1': {
                'frequency': 'osc.freq',
                'rate': 'osc.rate'
            }
        },
        'megacomplex': {
            'm1': {
                'oscillation': ['osc1']
            }
        },
        'dataset': {
            'dataset1': {
                'megacomplex': ['m1']
            }
        }
    })

    wanted_parameter = ParameterGroup.from_dict({
        'osc': [
            ['freq', 25.5],
            ['rate', 0.1],
        ],
        'shape': {
            'amps': [7],
            'locs': [5],
            'width': [4]
        },
    })

    parameter = ParameterGroup.from_dict({
        'osc': [
            ['freq', 20],
            ['rate', 0.3],
        ],
    })

    time = np.arange(0, 3, 0.01)
    spectral = np.arange(0, 10)
    axis = {'time': time, 'spectral': spectral}

    wanted_clp = ['osc1_cos', 'osc1_sin']
    wanted_shape = (300, 2)
class OneOscillationWithSequentialModel():
    sim_model = DOASModel.from_dict({
        'initial_concentration': {
            'j1': {
                'compartments': ['s1', 's2'],
                'parameters': ['j.1', 'j.0']
            },
        },
        'k_matrix': {
            "k1": {
                'matrix': {
                    ("s2", "s1"): 'kinetic.1',
                    ("s2", "s2"): 'kinetic.2',
                }
            }
        },
        'oscillation': {
            'osc1': {
                'frequency': 'osc.freq',
                'rate': 'osc.rate'
            }
        },
        'megacomplex': {
            'm1': {
                'k_matrix': ['k1'],
                'oscillation': ['osc1'],
            }
        },
        'shape': {
            'sh1': {
                'type': "gaussian",
                'amplitude': "shape.amps.1",
                'location': "shape.locs.1",
                'width': "shape.width.1",
            },
            'sh2': {
                'type': "gaussian",
                'amplitude': "shape.amps.2",
                'location': "shape.locs.2",
                'width': "shape.width.2",
            },
            'sh3': {
                'type': "gaussian",
                'amplitude': "shape.amps.3",
                'location': "shape.locs.3",
                'width': "shape.width.3",
            },
        },
        'irf': {
            'irf1': {
                'type': 'gaussian',
                'center': 'irf.center',
                'width': 'irf.width'
            },
        },
        'dataset': {
            'dataset1': {
                'initial_concentration': 'j1',
                'megacomplex': ['m1'],
                'shape': {
                    'osc1': 'sh1',
                    's1': 'sh2',
                    's2': 'sh3',
                },
                'irf': 'irf1',
            }
        }
    })

    model = DOASModel.from_dict({
        'initial_concentration': {
            'j1': {
                'compartments': ['s1', 's2'],
                'parameters': ['j.1', 'j.0']
            },
        },
        'k_matrix': {
            "k1": {
                'matrix': {
                    ("s2", "s1"): 'kinetic.1',
                    ("s2", "s2"): 'kinetic.2',
                }
            }
        },
        'oscillation': {
            'osc1': {
                'frequency': 'osc.freq',
                'rate': 'osc.rate'
            }
        },
        'megacomplex': {
            'm1': {
                'k_matrix': ['k1'],
                'oscillation': ['osc1'],
            }
        },
        'irf': {
            'irf1': {
                'type': 'gaussian',
                'center': 'irf.center',
                'width': 'irf.width'
            },
        },
        'dataset': {
            'dataset1': {
                'initial_concentration': 'j1',
                'megacomplex': ['m1'],
                'irf': 'irf1',
            }
        }
    })

    wanted_parameter = ParameterGroup.from_dict({
        'j': [
            ['1', 1, {
                'vary': False,
                'non-negative': False
            }],
            ['0', 0, {
                'vary': False,
                'non-negative': False
            }],
        ],
        'kinetic': [
            ["1", 0.2],
            ["2", 0.01],
        ],
        'osc': [
            ['freq', 25],
            ['rate', 0.1],
        ],
        'shape': {
            'amps': [0.07, 2, 4],
            'locs': [5, 2, 8],
            'width': [4, 2, 3]
        },
        'irf': [['center', 0.3], ['width', 0.1]],
    })

    parameter = ParameterGroup.from_dict({
        'j': [
            ['1', 1, {
                'vary': False,
                'non-negative': False
            }],
            ['0', 0, {
                'vary': False,
                'non-negative': False
            }],
        ],
        'kinetic': [
            ["1", 0.2],
            ["2", 0.01],
        ],
        'osc': [
            ['freq', 25],
            ['rate', 0.1],
        ],
        'irf': [['center', 0.3], ['width', 0.1]],
    })

    time = np.arange(-1, 5, 0.01)
    spectral = np.arange(0, 10)
    axis = {'time': time, 'spectral': spectral}

    wanted_clp = ['osc1_cos', 'osc1_sin', 's1', 's2']
    wanted_shape = (600, 4)