Salome HOME
Add Matrix keyword into ObservationOperator dict
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 26 Sep 2019 12:38:42 +0000 (14:38 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 26 Sep 2019 12:38:42 +0000 (14:38 +0200)
AdaoExchangeLayer.cxx
AdaoExchangeLayer.hxx
AdaoModelKeyVal.cxx

index c5c15b8c1add3af5167d6018ae4633911eef6f8b..8e9e28087c4fb37e828299c6f88f8b8d5812c151 100644 (file)
@@ -228,6 +228,27 @@ PyObject *AdaoExchangeLayer::getPythonContext() const
   return _internal->_context;
 }
 
+std::string AdaoExchangeLayer::printContext() const
+{
+  AutoGIL agil;
+  PyObject *obj(this->getPythonContext());
+  if(!PyDict_Check(obj))
+    throw AdaoExchangeLayerException("printContext : not a dict !");
+  PyObject *key(nullptr), *value(nullptr);
+  Py_ssize_t pos(0);
+  std::ostringstream oss;
+  while( PyDict_Next(obj, &pos, &key, &value) )
+    {
+      if(!PyUnicode_Check(key))
+        throw AdaoExchangeLayerException("printContext : not a string as key !");
+      oss << PyUnicode_AsUTF8(key) << " = ";
+      PyObjectRAII reprOfValue(PyObjectRAII::FromNew(PyObject_Repr(value)));
+      oss << PyUnicode_AsUTF8(reprOfValue);
+      oss << std::endl;
+    }
+  return oss.str();
+}
+
 /*!
  * AdaoExchangeLayer is based on multithreaded paradigm.
  * Master thread (thread calling this method) and slave thread (thread calling ADAO algo)
index dbb3dbabc71d7ecbc20dc2631e1585cf7b34c7c1..988e23cf742f919268707d96b0c561430089be14 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "Python.h"
 
+#include <string>
+
 class AdaoCallbackSt;
 
 namespace AdaoModel
@@ -36,6 +38,7 @@ public:
   AdaoExchangeLayer();
   ~AdaoExchangeLayer();
   PyObject *getPythonContext() const;
+  std::string printContext() const;
   void init();
   void loadTemplate(AdaoModel::MainModel *model);
   void execute();
index 0c218328b0b633bed6229f77f798c89a15088139..c22f022f5eb38f45bd3a3b43d1308eab6d9a068c 100644 (file)
@@ -333,11 +333,13 @@ Observation::Observation():DictKeyVal(KEY)
 ObservationOperator::ObservationOperator():DictKeyVal(KEY)
 {
   std::shared_ptr<OneFunction> v0(std::make_shared<OneFunction>());
-  std::shared_ptr<ObservationOperatorParameters> v1(std::make_shared<ObservationOperatorParameters>());
-  std::shared_ptr<InputFunctionAsMulti> v2(std::make_shared<InputFunctionAsMulti>());
+  std::shared_ptr<MatrixBackgroundError> v1(std::make_shared<MatrixBackgroundError>());
+  std::shared_ptr<ObservationOperatorParameters> v2(std::make_shared<ObservationOperatorParameters>());
+  std::shared_ptr<InputFunctionAsMulti> v3(std::make_shared<InputFunctionAsMulti>());
   _pairs.push_back(std::static_pointer_cast<GenericKeyVal,OneFunction>(v0));
-  _pairs.push_back(std::static_pointer_cast<GenericKeyVal,ObservationOperatorParameters>(v1));
-  _pairs.push_back(std::static_pointer_cast<GenericKeyVal,InputFunctionAsMulti>(v2));
+  _pairs.push_back(std::static_pointer_cast<GenericKeyVal,MatrixBackgroundError>(v1));
+  _pairs.push_back(std::static_pointer_cast<GenericKeyVal,ObservationOperatorParameters>(v2));
+  _pairs.push_back(std::static_pointer_cast<GenericKeyVal,InputFunctionAsMulti>(v3));
 }
 
 ObserverEntry::ObserverEntry():DictKeyVal(KEY)