From 5247f02ff3ca6c04549f9c0b9ee59b9c1ba2ee35 Mon Sep 17 00:00:00 2001
From: Tamas Gal <tgal@km3net.de>
Date: Tue, 20 Sep 2022 07:15:38 +0000
Subject: [PATCH] Resolve "Installing Jppy does not work on my MacOS system"

---
 scripts/get_pdfs.sh         |  2 +-
 src/jpp/JLang/JSTDTypes.hh  | 40 ++++++++++++++++++++++---------------
 src/jpp/JMath/JMath.hh      | 14 ++++++-------
 tests/test_pdf.py           | 16 +++++++--------
 tests/test_pdf_evaluator.py | 19 ++++++++----------
 5 files changed, 48 insertions(+), 43 deletions(-)

diff --git a/scripts/get_pdfs.sh b/scripts/get_pdfs.sh
index 9dd954d..6b6a15d 100755
--- a/scripts/get_pdfs.sh
+++ b/scripts/get_pdfs.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 
-export URL="http://sftp.km3net.de/data/latest/"
+export URL="https://sftp.km3net.de/data/v17.0.0/"
 if [ ! -d "pdfs" ]; then
     echo "Retrieving PDFs..."
     mkdir pdfs
diff --git a/src/jpp/JLang/JSTDTypes.hh b/src/jpp/JLang/JSTDTypes.hh
index 9811aaa..e29dc2c 100644
--- a/src/jpp/JLang/JSTDTypes.hh
+++ b/src/jpp/JLang/JSTDTypes.hh
@@ -8,22 +8,30 @@
  * \author mdejong
  */
 
-namespace std {
-  template<class JElement_t, class JAllocator_t>                                    class vector;
-  template<class JElement_t, class JComparator_t, class JAllocator_t>               class set;
-  template<class JElement_t, class JComparator_t, class JAllocator_t>               class multiset;
-  template<class JFirst_t, class JSecond_t>                                         class pair;
-  template<class JKey_t, class JValue_t, class JComparator_t, class JAllocator_t>   class map;
-  template<class JKey_t, class JValue_t, class JComparator_t, class JAllocator_t>   class multimap;
-  template<class Category, class T, class Distance, class Pointer, class Reference> struct iterator;
-#ifdef _GLIBCXX_USE_CXX11_ABI
-  inline namespace __cxx11 {
-    template<class JElement_t, class JAllocator_t>                                  class list;
-  }
-#else
-  template<class JElement_t, class JAllocator_t>                                    class list;
-#endif 
-}
+#include <vector>
+#include <set>
+#include <utility>
+#include <map>
+#include <list>
+#include <iterator>
+
+// TODO: this gives an ambigous error on macOS with std::pair
+// namespace std {
+//   template<class JElement_t, class JAllocator_t>                                    class vector;
+//   template<class JElement_t, class JComparator_t, class JAllocator_t>               class set;
+//   template<class JElement_t, class JComparator_t, class JAllocator_t>               class multiset;
+//   template<class JFirst_t, class JSecond_t>                                         struct pair;
+//   template<class JKey_t, class JValue_t, class JComparator_t, class JAllocator_t>   class map;
+//   template<class JKey_t, class JValue_t, class JComparator_t, class JAllocator_t>   class multimap;
+//   template<class Category, class T, class Distance, class Pointer, class Reference> struct iterator;
+// #ifdef _GLIBCXX_USE_CXX11_ABI
+//   inline namespace __cxx11 {
+//     template<class JElement_t, class JAllocator_t>                                  class list;
+//   }
+// #else
+//   template<class JElement_t, class JAllocator_t>                                    class list;
+// #endif
+// }
 
 #endif
 
diff --git a/src/jpp/JMath/JMath.hh b/src/jpp/JMath/JMath.hh
index 8c37cc9..7221e22 100644
--- a/src/jpp/JMath/JMath.hh
+++ b/src/jpp/JMath/JMath.hh
@@ -32,7 +32,7 @@ namespace JMATH {
   
   
   /**
-   * Power \f$x^y\f$.
+   * Power \f$ x^{y} \f$.
    *
    * \param  x              value
    * \param  y              power
@@ -54,7 +54,7 @@ namespace JMATH {
 
   private:
     /**
-     * Power \f$x^y\f$.
+     * Power \f$ x^{y} \f$.
      * This method corresponds to primitive data types.
      *
      * \param  x              value
@@ -70,8 +70,8 @@ namespace JMATH {
 
 
     /**
-     * Power \f$x^y\f$.
-     * Power.
+     * Power \f$ x^{y} \f$.
+     *
      * This method corresponds to non-primitive data types.
      *
      * \param  x              value
@@ -88,7 +88,7 @@ namespace JMATH {
 
 
   /**
-   * Power \f$x^y\f$.
+   * Power \f$ x^{y} \f$.
    *
    * \param  x              value
    * \param  y              power
@@ -296,7 +296,7 @@ namespace JMATH {
      */
     friend T& operator*=(T& first, const T& second)
     {
-      return first.mul(second);
+      return static_cast<JMath<T>&>(first).mul(second);
     }
 
     
@@ -483,7 +483,7 @@ namespace JMATH {
    * Template definition so that compiler error is generated if implementation is missing (see JEigen3D.hh).
    */
   template<>
-  class JAverage<JGEOMETRY3D::JQuaternion3D>;
+  struct JAverage<JGEOMETRY3D::JQuaternion3D>;
 
 
   /**
diff --git a/tests/test_pdf.py b/tests/test_pdf.py
index 6936c8c..0a74838 100644
--- a/tests/test_pdf.py
+++ b/tests/test_pdf.py
@@ -7,16 +7,16 @@ class TestMuonPDF(unittest.TestCase):
     def test_pdf(self):
         muon_pdf = jppy.pdf.JMuonPDF(PDFS, 0)
         result = muon_pdf.calculate(10, 5, 0, 0, 23)
-        self.assertAlmostEqual(0.001545692, result.f)
-        self.assertAlmostEqual(-1.220889709e-05, result.fp)
-        self.assertAlmostEqual(0.022764524, result.v)
-        self.assertAlmostEqual(0.115814468, result.V)
+        self.assertAlmostEqual(0.00067762789, result.f)
+        self.assertAlmostEqual(-1.9661888268460384e-05, result.fp)
+        self.assertAlmostEqual(0.01374949305, result.v)
+        self.assertAlmostEqual(0.053314508, result.V)
 
 class TestShowerPDF(unittest.TestCase):
     def test_pdf(self):
         shower_pdf = jppy.pdf.JShowerPDF(PDFS, 0)
         result = shower_pdf.calculate(100, 10, 0.1, 0.2, 0.3, 6)
-        self.assertAlmostEqual(0.001383343, result.f)
-        self.assertAlmostEqual(5.091930537e-05, result.fp)
-        self.assertAlmostEqual(0.010475308, result.v)
-        self.assertAlmostEqual(0.149635554, result.V)
+        self.assertAlmostEqual(0.0013937540, result.f)
+        self.assertAlmostEqual(5.1614638414144165e-05, result.fp)
+        self.assertAlmostEqual(0.01054815545, result.v)
+        self.assertAlmostEqual(0.150554603, result.V)
diff --git a/tests/test_pdf_evaluator.py b/tests/test_pdf_evaluator.py
index 42bd061..a50fa48 100644
--- a/tests/test_pdf_evaluator.py
+++ b/tests/test_pdf_evaluator.py
@@ -8,20 +8,17 @@ class TestMuonPDFEvaluator(unittest.TestCase):
         E, t0, t_obs, D, cd, theta, phi = [1e3, 56, 292, 50, 0.7, 1.57, 3.14]
         muon_pdf = jppy.pdf_evaluator.MuonPDF(PDFS, E, t0)
         result = muon_pdf.evaluate(D, cd, theta, phi, t_obs)
-        self.assertAlmostEqual( 0.003644475, result.f)
-        self.assertAlmostEqual(-0.000715558, result.fp)
-        self.assertAlmostEqual( 0.033748905, result.v)
-        self.assertAlmostEqual( 0.097171157, result.V)
+        self.assertAlmostEqual( 0.00388579021, result.f)
+        self.assertAlmostEqual(-0.000739757, result.fp)
+        self.assertAlmostEqual(0.035047945, result.v)
+        self.assertAlmostEqual(0.09606971431, result.V)
 
 class TestShowerPDFEvaluator(unittest.TestCase):
     def test_pdf_evaluator(self):
         E, t0, t_obs, D, cd, theta, phi = [50, 198, 226, 5, 0.6, 0.5, 0.4]
         shower_pdf = jppy.pdf_evaluator.ShowerPDF(PDFS, E, t0)
         result = shower_pdf.evaluate(D, cd, theta, phi, t_obs)
-        self.assertAlmostEqual(0.006204617, result.f)
-        self.assertAlmostEqual(0.000641669, result.fp)
-        self.assertAlmostEqual(0.013960066, result.v)
-        self.assertAlmostEqual(0.296589983, result.V)
-
-
-    
+        self.assertAlmostEqual(0.006247665, result.f)
+        self.assertAlmostEqual(0.0006429129, result.fp)
+        self.assertAlmostEqual(0.01406847423, result.v)
+        self.assertAlmostEqual(0.297769976, result.V)
-- 
GitLab