Test Failed
Pull Request — master (#862)
by Daniil
03:30
created

examples.plugin_examples.plugin_templates.iterative.testing_iterative_plugin3   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 41
dl 0
loc 88
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A TestingIterativePlugin3.pre_process() 0 2 1
A TestingIterativePlugin3.nOutput_datasets() 0 2 1
A TestingIterativePlugin3.nClone_datasets() 0 2 1
A TestingIterativePlugin3.process_frames() 0 2 1
A TestingIterativePlugin3.__init__() 0 3 1
A TestingIterativePlugin3.setup() 0 35 1
A TestingIterativePlugin3.post_process() 0 4 1
1
# Copyright 2014 Diamond Light Source Ltd.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#     http://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
"""
15
.. module:: testing_iterative_plugin3
16
   :platform: Unix
17
   :synopsis: Iterative plugin example
18
.. moduleauthor:: Nicola Wadeson <[email protected]>
19
"""
20
21
from savu.plugins.utils import register_plugin
22
from savu.plugins.filters.base_filter import BaseFilter
23
from savu.plugins.driver.iterative_plugin import IterativePlugin
24
25
26
@register_plugin
27
class TestingIterativePlugin3(BaseFilter, IterativePlugin):
28
    """
29
    A plugin to test the iterative plugin driver
30
    """
31
32
    def __init__(self):
33
        super(TestingIterativePlugin3, self).\
34
            __init__("TestingIterativePlugin3")
35
36
    def pre_process(self):
37
        self.set_iterations(3)
38
39
    def process_frames(self, data):
40
        return [data[0], data[0]]
41
42
    def post_process(self):
43
        # option here to break out of the iterations
44
        # self.set_processing_complete()
45
        pass
46
47
    def setup(self):
48
        self.exp.log(self.name + " Start")
49
50
        # set up the output dataset that is created by the plugin
51
        in_dataset, out_dataset = self.get_datasets()
52
53
        in_pData, out_pData = self.get_plugin_datasets()
54
        in_pData[0].plugin_data_setup('SINOGRAM', self.get_max_frames())
55
56
        # these are the datasets with names
57
        out_dataset[0].create_dataset(in_dataset[0])
58
        out_dataset[1].create_dataset(in_dataset[0])
59
        # these are the clones
60
        out_dataset[2].create_dataset(out_dataset[0])
61
        out_dataset[3].create_dataset(out_dataset[1])
62
63
        out_pData[0].plugin_data_setup('SINOGRAM', 'single')
64
        out_pData[1].plugin_data_setup('SINOGRAM', 'single')
65
        out_pData[2].plugin_data_setup('SINOGRAM', 'single')
66
        out_pData[3].plugin_data_setup('SINOGRAM', 'single')
67
68
        # try replacing input dataset with the output dataset
69
        dIn = [in_dataset[0]]
70
        dOut = [out_dataset[0], out_dataset[1]]
71
        self.set_iteration_datasets(0, dIn, dOut)
72
73
        dIn = [out_dataset[0], out_dataset[0], out_dataset[1]]
74
        dOut = [out_dataset[2], out_dataset[3]]
75
        self.set_iteration_datasets(1, dIn, dOut)
76
77
        # cloned datasets used as alternating datasets?
78
        self.set_alternating_datasets(out_dataset[0], out_dataset[2])
79
        self.set_alternating_datasets(out_dataset[1], out_dataset[3])
80
81
        self.exp.log(self.name + " End")
82
83
    def nOutput_datasets(self):
84
        return 4
85
86
    def nClone_datasets(self):
87
        return 2
88