You are a helpful assistant generating synthetic data that captures *System 1* and *System 2* thinking, *creativity*, and *metacognitive reflection*. Follow these steps in sequence, using tags [sys1] and [end sys1] for *System 1* sections and [sys2] and [end sys2] for *System 2* sections.

1. *Identify System 1 and System 2 Thinking Requirements:*
   - Carefully read the text.
   - Identify parts of the text that require quick, straightforward responses (*System 1*). Mark these sections with [sys1] and [end sys1].
   - Identify parts that require in-depth, reflective thinking (*System 2*), marked with [sys2] and [end sys2].

2. *Apply Step-by-Step Problem Solving with Creativity and Metacognitive Reflection for System 2 Sections:*

   *2.1 Understand the Problem:*
   - Objective: Fully comprehend the issue, constraints, and relevant context.
   - Reflection: "What do I understand about this issue? What might I be overlooking?"
   - Creative Perspective: Seek hidden patterns or possibilities that could reveal deeper insights or innovative connections.

   *2.2 Analyze the Information:*
   - Objective: Break down the problem logically.
   - Reflection: "Am I considering all factors? Are there any assumptions that need challenging?"
   - Creative Perspective: Explore unique patterns or overlooked relationships in the data that could add depth to the analysis.

   *2.3 Generate Hypotheses:*
   - Objective: Propose at least 10 hypotheses, each with a Confidence Score (0.0 to 1.0) and Creative Score (0.0 to 1.0), reflecting originality, surprise, and utility.
   - Reflection: "Have I explored all possible explanations or approaches, both conventional and unconventional?"
   - Creative Perspective: Consider novel angles that might provide unexpected insights.

   *2.4 Anticipate Future Steps and Obstacles:*
   - Objective: Make predictions, accounting for potential outcomes and obstacles.
   - Reflection: "What challenges might I face? Is my plan flexible for different scenarios?"
   - Creative Perspective: Visualize unforeseen outcomes and adapt plans to make use of them effectively.

   *2.5 Evaluate Hypotheses:*
   - Objective: Assess hypotheses based on feasibility, risk, and potential impact.
   - Evaluation: Refine Confidence and Creative Scores as needed.
   - Reflection: "Am I unbiased in my assessment? Which options fit best with the overall objectives?"
   - Creative Perspective: Identify hidden opportunities or overlooked details in each hypothesis.

   *2.6 Select the Best Hypothesis:*
   - Objective: Choose the most promising, strategic hypothesis.
   - Reflection: "Why does this hypothesis stand out? How does it uniquely address the issue?"
   - Creative Perspective: Consider any underutilized potential in the selected approach.

   *2.7 Implement the Hypothesis:*
   - Objective: Outline actionable steps for testing the hypothesis.
   - Reflection: "Is this plan practical? What resources or preparation are required?"
   - Creative Perspective: Refine steps to maximize effectiveness and yield unexpected benefits.

   *2.8 Monitor and Review Progress:*
   - Objective: Review progress, noting areas for improvement.
   - Reflection: "What’s working well? What could be improved?"
   - Creative Perspective: Look for emerging patterns that could refine future approaches.

   *2.9 Reflect and Capture Insights:*
   - Objective: Summarize lessons learned and insights gained for future reference.
   - Reflection: "What new understanding has emerged from this process?"
   - Creative Perspective: Identify innovative insights or patterns that could be applied to similar challenges.

3. *Generate Text Output with Interleaved System 1 and System 2 Responses:*
   - Use the tags [sys1] and [sys2] throughout.
   - Aim for a lengthier, detailed response. Combine both direct, straightforward *System 1* insights and reflective, deeply analytical *System 2* segments to capture a blend of quick observations and thoughtful analysis.

---

### *Example Input Text:*

You are tasked with analyzing a sudden shift in customer preferences in a tech market. There has been a noticeable decline in demand for physical devices, with customers increasingly interested in digital-only options. The challenge is to understand this shift, generate hypotheses for why it might be occurring, and explore potential strategies for adapting to this new trend.

---

### *Processed Output with System 1 and System 2 Thinking:*

The tech market is experiencing a shift in customer demand, moving away from physical devices toward digital-only options.

[sys1]
Customer demand has shifted from physical devices to digital-only options.
We need to understand why this change is happening and find strategies to address it.
Key factors may include cost, convenience, and technological trends.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The goal is to understand the underlying reasons for the shift in demand from physical devices to digital-only options, then develop a strategy to adapt.

*Reflection:* 
"I understand that preferences are changing, but what might be driving this? Is it primarily cost, or are there other factors such as convenience or sustainability?"

*Creative Perspective:* 
"Could there be a larger trend in digital minimalism or a preference for eco-friendly solutions that we’re missing? What unseen motivations might explain this shift?"

**2.2 Analyze the Information:**
There are multiple possible factors driving this shift, from economic influences to cultural shifts. It’s essential to isolate each factor and understand its impact.

*Reflection:* 
"Am I fully considering the various economic and social influences? Could there be a technological factor, like better internet speeds, that makes digital-only products more accessible?"

*Creative Perspective:* 
"Are there patterns or trends in other markets that could shed light on this shift? Could this be part of a larger trend toward virtual experiences?"

**2.3 Generate Hypotheses:**
1. Customers prefer digital options due to lower costs. (Confidence: 0.8, Creative: 0.4)
2. There’s a growing trend toward minimalism and reduced physical clutter. (Confidence: 0.7, Creative: 0.7)
3. Digital products offer greater flexibility and ease of use. (Confidence: 0.6, Creative: 0.6)
4. Environmental concerns are pushing consumers away from physical goods. (Confidence: 0.6, Creative: 0.8)
5. Advances in tech make digital-only options more functional. (Confidence: 0.8, Creative: 0.5)
6. Pandemic-era remote work increased demand for digital solutions. (Confidence: 0.7, Creative: 0.6)
7. Media coverage of the environmental impact of physical devices affects preferences. (Confidence: 0.5, Creative: 0.7)
8. There’s an increase in global digital literacy, expanding market access. (Confidence: 0.6, Creative: 0.6)
9. Customers view digital as more convenient and scalable for future needs. (Confidence: 0.7, Creative: 0.5)
10. Younger consumers prefer the aesthetics and convenience of digital products. (Confidence: 0.6, Creative: 0.6)

*Reflection:* 
"Have I considered all possible influences? Are there any surprising factors that could explain this shift?"

*Creative Perspective:* 
"Could specific social trends, like the rise of influencer culture or digital-first lifestyles, be influencing customer choices?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Anticipate possible challenges, such as resistance from segments still preferring physical products.

*Reflection:* 
"What market obstacles might we face if we shift our focus to digital-only? Are there sub-segments that still prioritize physical products?"

*Creative Perspective:* 
"Could expanding digital options help us reach a more global audience? Are there emerging trends that we could leverage in our strategy?"

[end sys2]

[sys1]
To address this shift, consider a strategy that incorporates both digital-only offerings and educational campaigns about the benefits of digital solutions.
Use insights from customer feedback and current trends to guide product development.
Focus on flexibility and adaptation to cater to different customer segments.
[end sys1]


# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright &copy; 2018 ISIS Rutherford Appleton Laboratory UKRI,
#   NScD Oak Ridge National Laboratory, European Spallation Source,
#   Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
import unittest

from mantid.kernel import *
from mantid.api import *
from mantid.simpleapi import *
from testhelpers import (assertRaisesNothing, create_algorithm)


class ReflectometrySliceEventWorkspaceTest(unittest.TestCase):
    def setUp(self):
        self.__class__._input_ws = self._create_test_workspace()
        self.__class__._input_ws_group = self._create_test_workspace_group()
        self.__class__._monitor_ws = self._create_monitor_workspace()
        self.__class__._monitor_ws_group = self._create_monitor_workspace_group()
        self._default_args = {
            'InputWorkspace' : 'input_ws',
            'MonitorWorkspace' : 'monitor_ws',
            'OutputWorkspace': 'output',
            'UseNewFilterAlgorithm': True
        }

    def tearDown(self):
        mtd.clear()

    def test_missing_input_workspace(self):
        self._assert_run_algorithm_throws()

    def test_missing_monitors(self):
        self._assert_run_algorithm_throws({'InputWorkspace' : 'input_ws'})

    def test_missing_output_ws(self):
        self._assert_run_algorithm_throws({'InputWorkspace' : 'input_ws',
                                           'MonitorWorkspace' : 'monitor_ws'})

    def test_default_inputs_return_single_slice(self):
        output = self._assert_run_algorithm_succeeds(self._default_args)
        self._check_slices(output, ["output_0_4200"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[14, 16, 8])

    def test_default_inputs_return_single_slice_FilterByTime(self):
        args = self._default_args
        args['UseNewFilterAlgorithm'] = False
        output = self._assert_run_algorithm_succeeds(args)
        self._check_slices(output, ["output_0_3600.0"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[14, 16, 8])

    def test_setting_time_interval(self):
        args = self._default_args
        args['TimeInterval'] = 600
        output = self._assert_run_algorithm_succeeds(args)
        self._check_slices(output, ["output_0_600", "output_600_1200", "output_1200_1800",
                                    "output_1800_2400", "output_2400_3000", "output_3000_3600",
                                    "output_3600_4200"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[2, 6, 1])
        self._check_y(output, child=1, spec=3, expected_bins=101, expected_values=[2, 3, 2])
        self._check_y(output, child=2, spec=3, expected_bins=101, expected_values=[0, 3, 0])
        self._check_y(output, child=3, spec=3, expected_bins=101, expected_values=[4, 2, 2])
        self._check_y(output, child=4, spec=3, expected_bins=101, expected_values=[4, 1, 2])
        self._check_y(output, child=5, spec=3, expected_bins=101, expected_values=[2, 1, 1])
        self._check_y(output, child=6, spec=3, expected_bins=101, expected_values=[0, 0, 0])

    def test_setting_time_interval_FilterByTime(self):
        args = self._default_args
        args['TimeInterval'] = 600
        args['UseNewFilterAlgorithm'] = False
        output = self._assert_run_algorithm_succeeds(args)
        self._check_slices(output, ["output_0_600.0", "output_600.0_1200.0", "output_1200.0_1800.0",
                                    "output_1800.0_2400.0", "output_2400.0_3000.0", "output_3000.0_3600.0"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[2, 6, 1])
        self._check_y(output, child=1, spec=3, expected_bins=101, expected_values=[2, 3, 2])
        self._check_y(output, child=2, spec=3, expected_bins=101, expected_values=[0, 3, 0])
        self._check_y(output, child=3, spec=3, expected_bins=101, expected_values=[4, 2, 2])
        self._check_y(output, child=4, spec=3, expected_bins=101, expected_values=[4, 1, 2])
        self._check_y(output, child=5, spec=3, expected_bins=101, expected_values=[2, 1, 1])

    def test_setting_time_interval_and_limits(self):
        args = self._default_args
        args['TimeInterval'] = 600
        args['StartTime'] = '1800'
        args['StopTime'] = '3300'
        output = self._assert_run_algorithm_succeeds(args)
        self._check_slices(output, ["output_1800_2400", "output_2400_3000", "output_3000_3300"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[4, 2, 2])
        self._check_y(output, child=1, spec=3, expected_bins=101, expected_values=[4, 1, 2])
        self._check_y(output, child=2, spec=3, expected_bins=101, expected_values=[1, 1, 0])

    def test_setting_time_interval_and_limits_FilterByTime(self):
        args = self._default_args
        args['TimeInterval'] = 600
        args['StartTime'] = '1800'
        args['StopTime'] = '3300'
        args['UseNewFilterAlgorithm'] = False
        output = self._assert_run_algorithm_succeeds(args)
        # This filters up to 3600, which looks less correct than the new algorithm which cuts
        # off at the requested 3300
        self._check_slices(output, ["output_1800_2400.0", "output_2400.0_3000.0", "output_3000.0_3600.0"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[4, 2, 2])
        self._check_y(output, child=1, spec=3, expected_bins=101, expected_values=[4, 1, 2])
        self._check_y(output, child=2, spec=3, expected_bins=101, expected_values=[2, 1, 1])

    def test_setting_multiple_time_intervals(self):
        args = self._default_args
        args['TimeInterval'] = '600, 1200'
        args['StopTime'] = '3600'
        output = self._assert_run_algorithm_succeeds(args)
        self._check_slices(output, ["output_0_600", "output_600_1800", "output_1800_2400", "output_2400_3600"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[2, 6, 1])
        self._check_y(output, child=1, spec=3, expected_bins=101, expected_values=[2, 6, 2])
        self._check_y(output, child=2, spec=3, expected_bins=101, expected_values=[4, 2, 2])
        self._check_y(output, child=3, spec=3, expected_bins=101, expected_values=[6, 2, 3])

    def test_setting_multiple_time_intervals_is_not_implemented_for_FilterByTime(self):
        args = self._default_args
        args['TimeInterval'] = '600, 1200'
        args['StopTime'] = '3600'
        args['UseNewFilterAlgorithm'] = False
        output = self._assert_run_algorithm_fails(args)

    def test_setting_log_interval_without_log_name_produces_single_slice(self):
        args = self._default_args
        args['LogValueInterval'] = 600
        output = self._assert_run_algorithm_succeeds(args)
        self._check_slices(output, ["output_0_4200"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[14, 16, 8])

    def test_setting_log_interval_without_log_name_produces_single_slice_FilterByLogValue(self):
        args = self._default_args
        args['LogValueInterval'] = 600
        args['UseNewFilterAlgorithm'] = False
        output = self._assert_run_algorithm_succeeds(args)
        self._check_slices(output, ["output_0_3600.0"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[14, 16, 8])

    def test_setting_log_interval(self):
        args = self._default_args
        args['LogName'] = 'proton_charge'
        args['LogValueInterval'] = 20
        output = self._assert_run_algorithm_succeeds(args)
        # Note that default tolerance is half the interval, so we slice +/-10 either side.
        # Also note that empty slices are not included in the output.
        self._check_slices(output, ["output_Log.proton_charge.From.10.To.30.Value-change-direction:both",
                                    "output_Log.proton_charge.From.70.To.90.Value-change-direction:both",
                                    "output_Log.proton_charge.From.90.To.110.Value-change-direction:both"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[4, 1, 2])
        self._check_y(output, child=1, spec=3, expected_bins=101, expected_values=[4, 5, 2])
        self._check_y(output, child=2, spec=3, expected_bins=101, expected_values=[6, 10, 4])

    def test_setting_log_tolerance(self):
        args = self._default_args
        args['LogName'] = 'proton_charge'
        args['LogValueInterval'] = 20
        # Set tolerance to zero to give similar behaviour to FilterByLogValue, although
        # note that empty slices are not output so we have fewer workspaces.
        args['LogValueTolerance'] = 0
        output = self._assert_run_algorithm_succeeds(args)
        self._check_slices(output, ["output_Log.proton_charge.From.0.To.20.Value-change-direction:both",
                                    "output_Log.proton_charge.From.80.To.100.Value-change-direction:both"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[4, 1, 2])
        self._check_y(output, child=1, spec=3, expected_bins=101, expected_values=[4, 5, 2])

    def test_setting_log_interval_FilterByLogValue(self):
        args = self._default_args
        args['LogName'] = 'proton_charge'
        args['LogValueInterval'] = 20
        args['MinimumLogValue'] = 0
        args['MaximumLogValue'] = 100
        args['UseNewFilterAlgorithm'] = False
        output = self._assert_run_algorithm_succeeds(args)
        self._check_slices(output, ["output_0.0_20.0", "output_20.0_40.0", "output_40.0_60.0",
                                    "output_60.0_80.0", "output_80.0_100.0"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[0, 0, 0])
        self._check_y(output, child=1, spec=3, expected_bins=101, expected_values=[0, 0, 0])
        self._check_y(output, child=2, spec=3, expected_bins=101, expected_values=[0, 0, 0])
        self._check_y(output, child=3, spec=3, expected_bins=101, expected_values=[0, 3, 0])
        self._check_y(output, child=4, spec=3, expected_bins=101, expected_values=[4, 12, 3])

    def test_setting_log_without_interval_produces_single_slice(self):
        args = self._default_args
        args['LogName'] = 'proton_charge'
        output = self._assert_run_algorithm_succeeds(args)
        self._check_slices(output, ["output_Log.proton_charge.From.0.To.100.Value-change-direction:both"])
        # Note that the min/max log value are 0->100 (taken from the sample logs) but this is
        # exclusive of values at 100 so excludes quite a few counts
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[8, 6, 4])

    def test_setting_log_limits_without_interval_produces_single_slice(self):
        args = self._default_args
        args['LogName'] = 'proton_charge'
        args['MinimumLogValue'] = 0
        args['MaximumLogValue'] = 101
        output = self._assert_run_algorithm_succeeds(args)
        # We set the max to be over 100 to be inclusive of the values up to 100 so this includes all
        # of the counts from the input workspace
        self._check_slices(output, ["output_Log.proton_charge.From.0.To.101.Value-change-direction:both"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[14, 16, 8])

    def test_setting_log_limits_without_interval_produces_single_slice_FilterByLogValue(self):
        args = self._default_args
        args['LogName'] = 'proton_charge'
        args['MinimumLogValue'] = 0
        args['MaximumLogValue'] = 101
        args['UseNewFilterAlgorithm'] = False
        output = self._assert_run_algorithm_succeeds(args)
        self._check_slices(output, ["output_0.0_101.0"])
        # These values don't seem right - I think they should contain all the counts from the
        # input workspace, i.e. [14, 16, 8]. Adding this test though to confirm the current
        # behaviour so we can check against it if we fix this in future. We may be phasing this
        # algorithm out though so this is not currently a high priority.
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[12, 15, 7])

    def test_setting_log_interval_and_limits(self):
        args = self._default_args
        args['LogName'] = 'proton_charge'
        args['LogValueInterval'] = 20
        args['MinimumLogValue'] = '75'
        args['MaximumLogValue'] = '110'
        output = self._assert_run_algorithm_succeeds(args)
        self._check_slices(output, ["output_Log.proton_charge.From.65.To.85.Value-change-direction:both",
                                    "output_Log.proton_charge.From.85.To.105.Value-change-direction:both"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[4, 5, 2])
        self._check_y(output, child=1, spec=3, expected_bins=101, expected_values=[6, 10, 4])

    def test_setting_log_interval_and_limits_FilterByLogValue(self):
        args = self._default_args
        args['LogName'] = 'proton_charge'
        args['LogValueInterval'] = 20
        args['MinimumLogValue'] = '75'
        args['MaximumLogValue'] = '110'
        args['UseNewFilterAlgorithm'] = False
        output = self._assert_run_algorithm_succeeds(args)
        self._check_slices(output, ["output_75.0_95.0", "output_95.0_115.0"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[0, 3, 0])
        self._check_y(output, child=1, spec=3, expected_bins=101, expected_values=[2, 6, 1])

    def test_when_input_is_a_workspace_group(self):
        args = self._default_args
        args['TimeInterval'] = 600
        args['InputWorkspace'] = 'input_ws_group'
        group = self._assert_run_algorithm_succeeds(args)
        self.assertEqual(group.getNumberOfEntries(), 3)
        output = group[0]
        self._check_slices(output, ["ws1_monitor_ws_output_0_600",
                                    "ws1_monitor_ws_output_600_1200",
                                    "ws1_monitor_ws_output_1200_1800",
                                    "ws1_monitor_ws_output_1800_2400",
                                    "ws1_monitor_ws_output_2400_3000",
                                    "ws1_monitor_ws_output_3000_3600",
                                    "ws1_monitor_ws_output_3600_4200"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[2, 6, 1])
        self._check_y(output, child=1, spec=3, expected_bins=101, expected_values=[2, 3, 2])
        self._check_y(output, child=2, spec=3, expected_bins=101, expected_values=[0, 3, 0])
        self._check_y(output, child=3, spec=3, expected_bins=101, expected_values=[4, 2, 2])
        self._check_y(output, child=4, spec=3, expected_bins=101, expected_values=[4, 1, 2])
        self._check_y(output, child=5, spec=3, expected_bins=101, expected_values=[2, 1, 1])
        self._check_y(output, child=6, spec=3, expected_bins=101, expected_values=[0, 0, 0])

    def test_when_input_is_a_workspace_group_FilterByTime(self):
        args = self._default_args
        args['TimeInterval'] = 600
        args['InputWorkspace'] = 'input_ws_group'
        args['UseNewFilterAlgorithm'] = False
        group = self._assert_run_algorithm_succeeds(args)
        self.assertEqual(group.getNumberOfEntries(), 3)
        output = group[0]
        self._check_slices(output, ["ws1_monitor_ws_output_0_600.0",
                                    "ws1_monitor_ws_output_600.0_1200.0",
                                    "ws1_monitor_ws_output_1200.0_1800.0",
                                    "ws1_monitor_ws_output_1800.0_2400.0",
                                    "ws1_monitor_ws_output_2400.0_3000.0",
                                    "ws1_monitor_ws_output_3000.0_3600.0"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[2, 6, 1])
        self._check_y(output, child=1, spec=3, expected_bins=101, expected_values=[2, 3, 2])
        self._check_y(output, child=2, spec=3, expected_bins=101, expected_values=[0, 3, 0])
        self._check_y(output, child=3, spec=3, expected_bins=101, expected_values=[4, 2, 2])
        self._check_y(output, child=4, spec=3, expected_bins=101, expected_values=[4, 1, 2])
        self._check_y(output, child=5, spec=3, expected_bins=101, expected_values=[2, 1, 1])

    def test_when_input_and_monitors_are_both_workspace_groups(self):
        args = self._default_args
        args['TimeInterval'] = 600
        args['InputWorkspace'] = 'input_ws_group'
        args['MonitorWorkspace'] = 'monitor_ws_group'
        group = self._assert_run_algorithm_succeeds(args)
        self.assertEqual(group.getNumberOfEntries(), 3)
        output = group[0]
        self._check_slices(output, ["ws1_mon1_output_0_600",
                                    "ws1_mon1_output_600_1200",
                                    "ws1_mon1_output_1200_1800",
                                    "ws1_mon1_output_1800_2400",
                                    "ws1_mon1_output_2400_3000",
                                    "ws1_mon1_output_3000_3600",
                                    "ws1_mon1_output_3600_4200"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[2, 6, 1])
        self._check_y(output, child=1, spec=3, expected_bins=101, expected_values=[2, 3, 2])
        self._check_y(output, child=2, spec=3, expected_bins=101, expected_values=[0, 3, 0])
        self._check_y(output, child=3, spec=3, expected_bins=101, expected_values=[4, 2, 2])
        self._check_y(output, child=4, spec=3, expected_bins=101, expected_values=[4, 1, 2])
        self._check_y(output, child=5, spec=3, expected_bins=101, expected_values=[2, 1, 1])
        self._check_y(output, child=6, spec=3, expected_bins=101, expected_values=[0, 0, 0])

    def test_when_input_and_monitors_are_both_workspace_groups_FilterByTime(self):
        args = self._default_args
        args['TimeInterval'] = 600
        args['InputWorkspace'] = 'input_ws_group'
        args['MonitorWorkspace'] = 'monitor_ws_group'
        args['UseNewFilterAlgorithm'] = False
        group = self._assert_run_algorithm_succeeds(args)
        self.assertEqual(group.getNumberOfEntries(), 3)
        output = group[0]
        self._check_slices(output, ["ws1_mon1_output_0_600.0",
                                    "ws1_mon1_output_600.0_1200.0",
                                    "ws1_mon1_output_1200.0_1800.0",
                                    "ws1_mon1_output_1800.0_2400.0",
                                    "ws1_mon1_output_2400.0_3000.0",
                                    "ws1_mon1_output_3000.0_3600.0"])
        self._check_y(output, child=0, spec=3, expected_bins=101, expected_values=[2, 6, 1])
        self._check_y(output, child=1, spec=3, expected_bins=101, expected_values=[2, 3, 2])
        self._check_y(output, child=2, spec=3, expected_bins=101, expected_values=[0, 3, 0])
        self._check_y(output, child=3, spec=3, expected_bins=101, expected_values=[4, 2, 2])
        self._check_y(output, child=4, spec=3, expected_bins=101, expected_values=[4, 1, 2])
        self._check_y(output, child=5, spec=3, expected_bins=101, expected_values=[2, 1, 1])

    def test_fails_when_input_groups_are_different_sizes(self):
        group = self._create_monitor_workspace_group_with_two_members()
        args = self._default_args
        args['TimeInterval'] = 600
        args['InputWorkspace'] = 'input_ws_group'
        args['MonitorWorkspace'] = 'test_monitor_ws_group'
        self._assert_run_algorithm_fails(args)
        mtd.remove('test_monitor_ws_group')

    def _create_test_workspace(self):
        input_ws = CreateSampleWorkspace("Event",BankPixelWidth=1, BinWidth=20000)
        AddTimeSeriesLog(input_ws, Name="proton_charge", Time="2010-01-01T00:00:00", Value=100)
        AddTimeSeriesLog(input_ws, Name="proton_charge", Time="2010-01-01T00:10:00", Value=100)
        AddTimeSeriesLog(input_ws, Name="proton_charge", Time="2010-01-01T00:20:00", Value=80)
        AddTimeSeriesLog(input_ws, Name="proton_charge", Time="2010-01-01T00:30:00", Value=80)
        AddTimeSeriesLog(input_ws, Name="proton_charge", Time="2010-01-01T00:40:00", Value=15)
        AddTimeSeriesLog(input_ws, Name="proton_charge", Time="2010-01-01T00:50:00", Value=100)
        return input_ws

    def _create_test_workspace_group(self):
        ws1 = CloneWorkspace(self.__class__._input_ws)
        ws2 = CloneWorkspace(self.__class__._input_ws)
        ws3 = CloneWorkspace(self.__class__._input_ws)
        mtd.addOrReplace('ws1', ws1)
        mtd.addOrReplace('ws2', ws2)
        mtd.addOrReplace('ws3', ws3)
        group = GroupWorkspaces(InputWorkspaces='ws1,ws2,ws3')
        mtd.addOrReplace('input_ws_group', group)
        return group

    def _create_monitor_workspace(self):
        monitor_ws = CreateSampleWorkspace(OutputWorkspace='monitor_ws', NumBanks=0, NumMonitors=3,
                                           BankPixelWidth=1, NumEvents=10000, Random=False)
        return monitor_ws

    def _create_monitor_workspace_group(self):
        mon1 = CloneWorkspace(self.__class__._monitor_ws)
        mon2 = CloneWorkspace(self.__class__._monitor_ws)
        mon3 = CloneWorkspace(self.__class__._monitor_ws)
        mtd.addOrReplace('mon1', mon1)
        mtd.addOrReplace('mon2', mon2)
        mtd.addOrReplace('mon3', mon3)
        group = GroupWorkspaces(InputWorkspaces='mon1,mon2,mon3')
        mtd.addOrReplace('monitor_ws_group', group)
        return group

    def _create_monitor_workspace_group_with_two_members(self):
        testmon1 = CloneWorkspace(self.__class__._monitor_ws)
        testmon2 = CloneWorkspace(self.__class__._monitor_ws)
        mtd.addOrReplace('testmon1', testmon1)
        mtd.addOrReplace('testmon2', testmon2)
        group = GroupWorkspaces(InputWorkspaces='testmon1,testmon2')
        mtd.addOrReplace('test_monitor_ws_group', group)
        return group

    def _assert_run_algorithm_succeeds(self, args):
        """Run the algorithm with the given args and check it succeeds"""
        alg = create_algorithm('ReflectometrySliceEventWorkspace', **args)
        assertRaisesNothing(self, alg.execute)
        self.assertEqual(mtd.doesExist('output'), True)
        return mtd['output']

    def _assert_run_algorithm_fails(self, args):
        """Run the algorithm with the given args and check it fails to produce output"""
        alg = create_algorithm('ReflectometrySliceEventWorkspace', **args)
        assertRaisesNothing(self, alg.execute)
        self.assertEqual(mtd.doesExist('output'), False)

    def _assert_run_algorithm_throws(self, args = {}):
        """Run the algorithm with the given args and check it throws"""
        throws = False
        alg = create_algorithm('ReflectometrySliceEventWorkspace', **args)
        try:
            alg.execute()
        except:
            throws = True
        self.assertEqual(throws, True)

    def _check_slices(self, workspace_group, expected_names):
        number_of_slices = workspace_group.getNumberOfEntries()
        self.assertEqual(number_of_slices, len(expected_names))
        for child in range(number_of_slices):
            self.assertEqual(workspace_group[child].name(), expected_names[child])

    def _check_y(self, workspace_group, child, spec, expected_bins, expected_values):
        """Check Y values for bins 0, 51 and 99 match the list of expected values"""
        ws = workspace_group[child]
        self.assertEqual(ws.dataX(spec).size, expected_bins)
        self._assert_delta(ws.dataY(spec)[0], expected_values[0])
        self._assert_delta(ws.dataY(spec)[51], expected_values[1])
        self._assert_delta(ws.dataY(spec)[99], expected_values[2])

    def _assert_delta(self, value1, value2):
        self.assertEqual(round(value1, 6), round(value2, 6))


if __name__ == '__main__':
    unittest.main()