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

examples.plugin_examples.plugin_templates.iterative.testing_iterative_plugin2   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 34
dl 0
loc 77
rs 10
c 0
b 0
f 0
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A TestingIterativePlugin2.nOutput_datasets() 0 2 1
A TestingIterativePlugin2.nClone_datasets() 0 2 1
A TestingIterativePlugin2.pre_process() 0 2 1
A TestingIterativePlugin2.setup() 0 20 1
A TestingIterativePlugin2.process_frames() 0 4 2
A TestingIterativePlugin2.post_process() 0 4 1
A TestingIterativePlugin2.__init__() 0 3 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_plugin2
16
   :platform: Unix
17
   :synopsis: Iterative plugin example
18
.. moduleauthor:: Nicola Wadeson <[email protected]>
19
"""
20
21
import numpy as np
22
23
from savu.plugins.utils import register_plugin
24
from savu.plugins.filters.base_filter import BaseFilter
25
from savu.plugins.driver.iterative_plugin import IterativePlugin
26
27
28
@register_plugin
29
class TestingIterativePlugin2(BaseFilter, IterativePlugin):
30
    """
31
    A plugin to test the iterative plugin driver
32
    """
33
34
    def __init__(self):
35
        super(TestingIterativePlugin2, self).\
36
            __init__("TestingIterativePlugin2")
37
38
    def pre_process(self):
39
        self.set_iterations(3)
40
41
    def process_frames(self, data):
42
        if self.get_iteration() == 0:
43
            return data[0]
44
        return data[0]
45
46
    def post_process(self):
47
        # option here to break out of the iterations
48
        # self.set_processing_complete()
49
        pass
50
51
    def setup(self):
52
        self.exp.log(self.name + " Start")
53
54
        # set up the output dataset that is created by the plugin
55
        in_dataset, out_dataset = self.get_datasets()
56
57
        in_pData, out_pData = self.get_plugin_datasets()
58
        in_pData[0].plugin_data_setup('SINOGRAM', 'single')
59
60
        out_dataset[0].create_dataset(in_dataset[0])
61
        self.clone_dataset(out_dataset[1], out_dataset[0])
62
63
        out_pData[0].plugin_data_setup('SINOGRAM', 'single')
64
        out_pData[1].plugin_data_setup('SINOGRAM', 'single')
65
66
        # try replacing input dataset with the output dataset
67
        self.set_iteration_datasets(0, [in_dataset[0]], [out_dataset[0]])
68
        self.set_iteration_datasets(1, [out_dataset[0]], [out_dataset[1]])
69
70
        self.exp.log(self.name + " End")
71
72
    def nOutput_datasets(self):
73
        return 2
74
75
    def nClone_datasets(self):
76
        return 1
77