From 6cdedbf95e57f04f1a7e95631c63bf78a18724c7 Mon Sep 17 00:00:00 2001
From: Walter Van Herck <w.van.herck@fz-juelich.de>
Date: Wed, 31 Jan 2018 10:35:54 +0100
Subject: [PATCH] Removed last remains of getIntensityData()

---
 Core/Simulation/SpecularSimulation.cpp        |   7 --
 Core/Simulation/SpecularSimulation.h          |   3 -
 .../BeamAngularDivergence.py                  |   7 +-
 .../ex06_Reflectometry/BeamFullDivergence.py  |   7 +-
 .../Core/Fresnel/SpecularSimulationTest.h     |  18 +--
 Wrap/swig/libBornAgainCore.i                  |   2 -
 auto/Wrap/doxygen_core.i                      |   5 -
 auto/Wrap/libBornAgainCore.py                 |  13 ---
 auto/Wrap/libBornAgainCore_wrap.cpp           | 108 ------------------
 9 files changed, 17 insertions(+), 153 deletions(-)

diff --git a/Core/Simulation/SpecularSimulation.cpp b/Core/Simulation/SpecularSimulation.cpp
index f122391ea1a..0622c97fe73 100644
--- a/Core/Simulation/SpecularSimulation.cpp
+++ b/Core/Simulation/SpecularSimulation.cpp
@@ -188,13 +188,6 @@ SpecularSimulation::generateSingleThreadedComputation(size_t start, size_t n_ele
                                                  begin + static_cast<long>(n_elements));
 }
 
-Histogram1D* SpecularSimulation::getIntensityData(AxesUnits units_type) const
-{
-    auto sim_result = result();
-    std::unique_ptr<OutputData<double>> result(sim_result.data(units_type));
-    return new Histogram1D(*result);
-}
-
 std::vector<complex_t> SpecularSimulation::getScalarR(size_t i_layer) const
 {
     return getData(i_layer, &ILayerRTCoefficients::getScalarR);
diff --git a/Core/Simulation/SpecularSimulation.h b/Core/Simulation/SpecularSimulation.h
index 47546fb8be4..231ecf0d278 100644
--- a/Core/Simulation/SpecularSimulation.h
+++ b/Core/Simulation/SpecularSimulation.h
@@ -61,9 +61,6 @@ public:
     //! Returns a pointer to incident angle axis.
     const IAxis* getAlphaAxis() const;
 
-    //! Returns detector signal (\f$ \propto |R|^2\f$) in the form of 1D Histogram
-    Histogram1D* getIntensityData(AxesUnits units_type = AxesUnits::DEFAULT) const;
-
 private:
     typedef complex_t (ILayerRTCoefficients::*DataGetter)() const;
 
diff --git a/Examples/python/simulation/ex06_Reflectometry/BeamAngularDivergence.py b/Examples/python/simulation/ex06_Reflectometry/BeamAngularDivergence.py
index 361f8b3bd61..643654eafb1 100644
--- a/Examples/python/simulation/ex06_Reflectometry/BeamAngularDivergence.py
+++ b/Examples/python/simulation/ex06_Reflectometry/BeamAngularDivergence.py
@@ -94,7 +94,7 @@ def run_simulation():
     simulation = get_simulation()
     simulation.setSample(sample)
     simulation.runSimulation()
-    return simulation.getIntensityData()
+    return simulation.result()
 
 
 def plot(data):
@@ -104,8 +104,9 @@ def plot(data):
     from matplotlib import pyplot as plt
     plt.figure(figsize=(12.80, 10.24))
 
-    axis = data.getXaxis().getBinCenters()
-    intensities = data.getArray()
+    hist = data.histogram1d()
+    axis = hist.getXaxis().getBinCenters()
+    intensities = data.array()
 
     genx_axis, genx_values = create_real_data()
 
diff --git a/Examples/python/simulation/ex06_Reflectometry/BeamFullDivergence.py b/Examples/python/simulation/ex06_Reflectometry/BeamFullDivergence.py
index 8e42ed24f90..1f81d8039e8 100644
--- a/Examples/python/simulation/ex06_Reflectometry/BeamFullDivergence.py
+++ b/Examples/python/simulation/ex06_Reflectometry/BeamFullDivergence.py
@@ -81,7 +81,7 @@ def run_simulation():
     simulation = get_simulation()
     simulation.setSample(sample)
     simulation.runSimulation()
-    return simulation.getIntensityData()
+    return simulation.result()
 
 
 def plot(data):
@@ -91,8 +91,9 @@ def plot(data):
     from matplotlib import pyplot as plt
     plt.figure(figsize=(12.80, 10.24))
 
-    axis = data.getXaxis().getBinCenters()
-    intensities = data.getArray()
+    hist = data.histogram1d()
+    axis = hist.getXaxis().getBinCenters()
+    intensities = data.array()
 
     plt.xlabel(r'$\alpha_f$ (rad)', fontsize=16)
     plt.ylabel(r'Reflectivity, a.u.', fontsize=16)
diff --git a/Tests/UnitTests/Core/Fresnel/SpecularSimulationTest.h b/Tests/UnitTests/Core/Fresnel/SpecularSimulationTest.h
index ab555a18c73..21782ef47ff 100644
--- a/Tests/UnitTests/Core/Fresnel/SpecularSimulationTest.h
+++ b/Tests/UnitTests/Core/Fresnel/SpecularSimulationTest.h
@@ -50,7 +50,6 @@ TEST_F(SpecularSimulationTest, InitialState)
     ASSERT_THROW(sim.runSimulation(), std::runtime_error);
     ASSERT_THROW(sim.getAlphaAxis(), std::runtime_error);
     EXPECT_EQ(nullptr, sim.sample());
-    ASSERT_THROW(sim.getIntensityData(), std::runtime_error);
     ASSERT_THROW(sim.result(), std::runtime_error);
 }
 
@@ -78,7 +77,6 @@ TEST_F(SpecularSimulationTest, CloneOfEmpty)
     ASSERT_THROW(clone->runSimulation(), std::runtime_error);
     ASSERT_THROW(clone->getAlphaAxis(), std::runtime_error);
     EXPECT_EQ(nullptr, clone->sample());
-    ASSERT_THROW(clone->getIntensityData(), std::runtime_error);
     ASSERT_THROW(clone->result(), std::runtime_error);
 
     checkBeamState(sim);
@@ -148,17 +146,18 @@ TEST_F(SpecularSimulationTest, ConstructSimulation)
 
     EXPECT_EQ(3u, sim->sample()->numberOfLayers());
 
-    ASSERT_THROW(sim->getIntensityData(), std::runtime_error);
+    ASSERT_THROW(sim->result(), std::runtime_error);
 
     sim->runSimulation();
+    auto sim_result = sim->result();
 
-    const std::unique_ptr<Histogram1D> reflectivity(sim->getIntensityData(AxesUnits::RADIANS));
+    const std::unique_ptr<Histogram1D> reflectivity(sim_result.histogram1d(AxesUnits::RADIANS));
     EXPECT_EQ(10u, reflectivity->getTotalNumberOfBins());
     EXPECT_EQ(1u, reflectivity->getRank());
     EXPECT_EQ(0.0, reflectivity->getXaxis().getMin());
     EXPECT_EQ(2.0 * Units::degree, reflectivity->getXaxis().getMax());
 
-    const std::unique_ptr<OutputData<double>> output(sim->result().data(AxesUnits::RADIANS));
+    const std::unique_ptr<OutputData<double>> output(sim_result.data(AxesUnits::RADIANS));
     EXPECT_EQ(reflectivity->getTotalNumberOfBins(), output->getAllocatedSize());
     EXPECT_EQ(reflectivity->getRank(), output->getRank());
     EXPECT_EQ(reflectivity->getXaxis().getMin(), output->getAxis(0).getMin());
@@ -176,7 +175,6 @@ TEST_F(SpecularSimulationTest, SimulationClone)
 
     EXPECT_EQ(3u, clone->sample()->numberOfLayers());
 
-    ASSERT_THROW(clone->getIntensityData(), std::runtime_error);
     ASSERT_THROW(clone->result(), std::runtime_error);
 
     checkBeamState(*clone);
@@ -184,11 +182,12 @@ TEST_F(SpecularSimulationTest, SimulationClone)
     sim->runSimulation();
 
     std::unique_ptr<SpecularSimulation> clone2(sim->clone());
+    auto clone_result = clone2->result();
 
-    std::unique_ptr<Histogram1D> output(clone2->getIntensityData());
+    std::unique_ptr<Histogram1D> output(clone_result.histogram1d());
     EXPECT_EQ(10u, output->getTotalNumberOfBins());
 
-    const std::unique_ptr<OutputData<double>> output_data(clone2->result().data());
+    const std::unique_ptr<OutputData<double>> output_data(clone_result.data());
     EXPECT_EQ(10u, output_data->getAllocatedSize());
 
     checkBeamState(*clone2);
@@ -228,8 +227,9 @@ TEST_F(SpecularSimulationTest, OutOfRangeAngles)
     beam.parameter(BornAgain::Inclination)->setValue(-0.2 * Units::deg);
 
     sim->runSimulation();
+    auto sim_result = sim->result();
 
-    std::unique_ptr<Histogram1D> result(sim->getIntensityData());
+    std::unique_ptr<Histogram1D> result(sim_result.histogram1d());
     EXPECT_EQ(0.0, result->getBinContent(0));
     EXPECT_NE(0.0, result->getBinContent(1));
 }
diff --git a/Wrap/swig/libBornAgainCore.i b/Wrap/swig/libBornAgainCore.i
index 792f8bd004e..35a493080ab 100644
--- a/Wrap/swig/libBornAgainCore.i
+++ b/Wrap/swig/libBornAgainCore.i
@@ -226,8 +226,6 @@
 
 // ownership
 
-%newobject SpecularSimulation::getIntensityData(AxesUnits units_type = AxesUnits::DEFAULT) const;
-
 %newobject SimulationResult::data(AxesUnits units_type = AxesUnits::DEFAULT) const;
 %newobject SimulationResult::histogram2d(AxesUnits units_type = AxesUnits::DEFAULT) const;
 
diff --git a/auto/Wrap/doxygen_core.i b/auto/Wrap/doxygen_core.i
index 2232a330958..4dc2da0754d 100644
--- a/auto/Wrap/doxygen_core.i
+++ b/auto/Wrap/doxygen_core.i
@@ -14250,11 +14250,6 @@ Sets beam parameters with alpha_i of the beam defined in the range.
 Returns a pointer to incident angle axis. 
 ";
 
-%feature("docstring")  SpecularSimulation::getIntensityData "Histogram1D * SpecularSimulation::getIntensityData(AxesUnits units_type=AxesUnits::DEFAULT) const
-
-Returns detector signal (  $ \\\\propto |R|^2$) in the form of 1D Histogram. 
-";
-
 
 // File: classSpecularSimulationElement.xml
 %feature("docstring") SpecularSimulationElement "
diff --git a/auto/Wrap/libBornAgainCore.py b/auto/Wrap/libBornAgainCore.py
index 75d29e9191b..f60426b6382 100644
--- a/auto/Wrap/libBornAgainCore.py
+++ b/auto/Wrap/libBornAgainCore.py
@@ -26570,19 +26570,6 @@ class SpecularSimulation(Simulation):
         return _libBornAgainCore.SpecularSimulation_getAlphaAxis(self)
 
 
-    def getIntensityData(self, *args):
-        """
-        getIntensityData(SpecularSimulation self, AxesUnits units_type) -> Histogram1D
-        getIntensityData(SpecularSimulation self) -> Histogram1D
-
-        Histogram1D * SpecularSimulation::getIntensityData(AxesUnits units_type=AxesUnits::DEFAULT) const
-
-        Returns detector signal (  $ \\propto |R|^2$) in the form of 1D Histogram. 
-
-        """
-        return _libBornAgainCore.SpecularSimulation_getIntensityData(self, *args)
-
-
     def setSampleBuilder(self, ptr):
         self.samplebuilder = ptr
         self.setSampleBuilderCpp(ptr)
diff --git a/auto/Wrap/libBornAgainCore_wrap.cpp b/auto/Wrap/libBornAgainCore_wrap.cpp
index 493a088b150..8f0338ead2c 100644
--- a/auto/Wrap/libBornAgainCore_wrap.cpp
+++ b/auto/Wrap/libBornAgainCore_wrap.cpp
@@ -111293,105 +111293,6 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_SpecularSimulation_getIntensityData__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  SpecularSimulation *arg1 = (SpecularSimulation *) 0 ;
-  AxesUnits arg2 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int val2 ;
-  int ecode2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  Histogram1D *result = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OO:SpecularSimulation_getIntensityData",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_SpecularSimulation, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpecularSimulation_getIntensityData" "', argument " "1"" of type '" "SpecularSimulation const *""'"); 
-  }
-  arg1 = reinterpret_cast< SpecularSimulation * >(argp1);
-  ecode2 = SWIG_AsVal_int(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SpecularSimulation_getIntensityData" "', argument " "2"" of type '" "AxesUnits""'");
-  } 
-  arg2 = static_cast< AxesUnits >(val2);
-  result = (Histogram1D *)((SpecularSimulation const *)arg1)->getIntensityData(arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Histogram1D, SWIG_POINTER_OWN |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_SpecularSimulation_getIntensityData__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  SpecularSimulation *arg1 = (SpecularSimulation *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  Histogram1D *result = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:SpecularSimulation_getIntensityData",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_SpecularSimulation, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SpecularSimulation_getIntensityData" "', argument " "1"" of type '" "SpecularSimulation const *""'"); 
-  }
-  arg1 = reinterpret_cast< SpecularSimulation * >(argp1);
-  result = (Histogram1D *)((SpecularSimulation const *)arg1)->getIntensityData();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Histogram1D, SWIG_POINTER_OWN |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_SpecularSimulation_getIntensityData(PyObject *self, PyObject *args) {
-  Py_ssize_t argc;
-  PyObject *argv[3] = {
-    0
-  };
-  Py_ssize_t ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 1) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_SpecularSimulation, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_SpecularSimulation_getIntensityData__SWIG_1(self, args);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_SpecularSimulation, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_int(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_SpecularSimulation_getIntensityData__SWIG_0(self, args);
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'SpecularSimulation_getIntensityData'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    SpecularSimulation::getIntensityData(AxesUnits) const\n"
-    "    SpecularSimulation::getIntensityData() const\n");
-  return 0;
-}
-
-
 SWIGINTERN PyObject *SpecularSimulation_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
   if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
@@ -127419,15 +127320,6 @@ static PyMethodDef SwigMethods[] = {
 		"Returns a pointer to incident angle axis. \n"
 		"\n"
 		""},
-	 { (char *)"SpecularSimulation_getIntensityData", _wrap_SpecularSimulation_getIntensityData, METH_VARARGS, (char *)"\n"
-		"getIntensityData(AxesUnits units_type) -> Histogram1D\n"
-		"SpecularSimulation_getIntensityData(SpecularSimulation self) -> Histogram1D\n"
-		"\n"
-		"Histogram1D * SpecularSimulation::getIntensityData(AxesUnits units_type=AxesUnits::DEFAULT) const\n"
-		"\n"
-		"Returns detector signal (  $ \\\\propto |R|^2$) in the form of 1D Histogram. \n"
-		"\n"
-		""},
 	 { (char *)"SpecularSimulation_swigregister", SpecularSimulation_swigregister, METH_VARARGS, NULL},
 	 { (char *)"new_ThreadInfo", _wrap_new_ThreadInfo, METH_VARARGS, (char *)"\n"
 		"new_ThreadInfo() -> ThreadInfo\n"
-- 
GitLab