From 48c2c324b10ff82d1fef3aeee3b614445c3cee6a Mon Sep 17 00:00:00 2001 From: barate Date: Fri, 22 Apr 2011 14:01:25 +0000 Subject: [PATCH] Reorganized Python modules for parametric studies (and corresponding doc) --- configure.ac | 1 + doc/docutils/Makefile.am | 4 +- doc/docutils/docapi.rst | 47 ++---------------- doc/docutils/kernel.rst | 37 ++++++++++++++ doc/docutils/parametric.rst | 15 ++++++ src/KERNEL_PY/kernel/Makefile.am | 5 +- src/KERNEL_PY/kernel/parametric/Makefile.am | 8 +++ src/KERNEL_PY/kernel/parametric/__init__.py | 0 .../kernel/parametric/compo_utils.py | 49 +++++++++++++++++++ .../study_exchange_vars.py} | 2 +- 10 files changed, 121 insertions(+), 47 deletions(-) create mode 100644 doc/docutils/kernel.rst create mode 100644 doc/docutils/parametric.rst create mode 100644 src/KERNEL_PY/kernel/parametric/Makefile.am create mode 100644 src/KERNEL_PY/kernel/parametric/__init__.py create mode 100644 src/KERNEL_PY/kernel/parametric/compo_utils.py rename src/KERNEL_PY/kernel/{varlist.py => parametric/study_exchange_vars.py} (99%) diff --git a/configure.ac b/configure.ac index 95133756f..afe7ef2f3 100644 --- a/configure.ac +++ b/configure.ac @@ -578,6 +578,7 @@ AC_OUTPUT([ \ src/KERNEL_PY/Makefile \ src/KERNEL_PY/kernel/Makefile \ src/KERNEL_PY/kernel/logconfig.py \ + src/KERNEL_PY/kernel/parametric/Makefile \ src/Launcher/Makefile \ src/LifeCycleCORBA/Makefile \ src/LifeCycleCORBA/Test/Makefile \ diff --git a/doc/docutils/Makefile.am b/doc/docutils/Makefile.am index dbed1cc91..b8bee607e 100644 --- a/doc/docutils/Makefile.am +++ b/doc/docutils/Makefile.am @@ -70,7 +70,9 @@ RSTFILES= \ index.rst \ overview.rst \ docapi.rst \ - salomepypkg.rst + salomepypkg.rst \ + kernel.rst \ + parametric.rst EXTRA_DIST+= $(RSTFILES) diff --git a/doc/docutils/docapi.rst b/doc/docutils/docapi.rst index b0b2b5348..fd36cbc19 100644 --- a/doc/docutils/docapi.rst +++ b/doc/docutils/docapi.rst @@ -7,47 +7,8 @@ This section describes the python modules of the ``salome.kernel`` python package. The main part is generated from the code documentation included in source python files. -:mod:`salome.kernel` -- Package containing the KERNEL python utilities -====================================================================== +.. toctree:: + :maxdepth: 3 -:mod:`deprecation` -- Indication of deprecated modules and functions --------------------------------------------------------------------- - -.. automodule:: salome.kernel.deprecation - :members: - - -:mod:`termcolor` -- Display colored text in terminal ----------------------------------------------------- - -.. automodule:: salome.kernel.termcolor - :members: - :exclude-members: TEST_termcolor - - -:mod:`logger` -- Logging utility --------------------------------- - -.. automodule:: salome.kernel.logger - -.. autoclass:: Logger - :members: - :show-inheritance: - -.. autoclass:: ExtLogger - :members: - :show-inheritance: - - -:mod:`studyedit` -- Study editor --------------------------------- - -.. automodule:: salome.kernel.studyedit - :members: - - -:mod:`varlist` -- Handle Exchange Variables -------------------------------------------- - -.. automodule:: salome.kernel.varlist - :members: + kernel.rst + parametric.rst diff --git a/doc/docutils/kernel.rst b/doc/docutils/kernel.rst new file mode 100644 index 000000000..f73f234d7 --- /dev/null +++ b/doc/docutils/kernel.rst @@ -0,0 +1,37 @@ +:mod:`salome.kernel` -- Package containing the KERNEL python utilities +====================================================================== + +:mod:`deprecation` -- Indication of deprecated modules and functions +-------------------------------------------------------------------- + +.. automodule:: salome.kernel.deprecation + :members: + + +:mod:`termcolor` -- Display colored text in terminal +---------------------------------------------------- + +.. automodule:: salome.kernel.termcolor + :members: + :exclude-members: TEST_termcolor + + +:mod:`logger` -- Logging utility +-------------------------------- + +.. automodule:: salome.kernel.logger + +.. autoclass:: Logger + :members: + :show-inheritance: + +.. autoclass:: ExtLogger + :members: + :show-inheritance: + + +:mod:`studyedit` -- Study editor +-------------------------------- + +.. automodule:: salome.kernel.studyedit + :members: diff --git a/doc/docutils/parametric.rst b/doc/docutils/parametric.rst new file mode 100644 index 000000000..25e815c90 --- /dev/null +++ b/doc/docutils/parametric.rst @@ -0,0 +1,15 @@ +:mod:`salome.kernel.parametric` -- Package for parametric studies +================================================================= + +:mod:`study_exchange_vars` -- Handle Exchange Variables +------------------------------------------------------- + +.. automodule:: salome.kernel.parametric.study_exchange_vars + :members: + + +:mod:`compo_utils` -- Useful functions for SALOME components used in parametric studies +--------------------------------------------------------------------------------------- + +.. automodule:: salome.kernel.parametric.compo_utils + :members: diff --git a/src/KERNEL_PY/kernel/Makefile.am b/src/KERNEL_PY/kernel/Makefile.am index 36f267414..847220f33 100644 --- a/src/KERNEL_PY/kernel/Makefile.am +++ b/src/KERNEL_PY/kernel/Makefile.am @@ -8,5 +8,6 @@ mypkgpython_PYTHON = \ logger.py \ studyedit.py \ termcolor.py \ - logconfig.py \ - varlist.py + logconfig.py + +SUBDIRS = parametric diff --git a/src/KERNEL_PY/kernel/parametric/Makefile.am b/src/KERNEL_PY/kernel/parametric/Makefile.am new file mode 100644 index 000000000..f8062fbc7 --- /dev/null +++ b/src/KERNEL_PY/kernel/parametric/Makefile.am @@ -0,0 +1,8 @@ +include $(top_srcdir)/salome_adm/unix/make_common_starter.am + +mypkgpythondir =$(salomepypkgdir)/kernel/parametric + +mypkgpython_PYTHON = \ + __init__.py \ + study_exchange_vars.py \ + compo_utils.py diff --git a/src/KERNEL_PY/kernel/parametric/__init__.py b/src/KERNEL_PY/kernel/parametric/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/KERNEL_PY/kernel/parametric/compo_utils.py b/src/KERNEL_PY/kernel/parametric/compo_utils.py new file mode 100644 index 000000000..c96675944 --- /dev/null +++ b/src/KERNEL_PY/kernel/parametric/compo_utils.py @@ -0,0 +1,49 @@ +# Copyright (C) 2011 CEA/DEN, EDF R&D, OPEN CASCADE +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or +# email : webmaster.salome@opencascade.com +# + +import SALOME_TYPES + +def create_input_dict(deterministic_dict, parametric_input): + # Simply get the first point from input (no time series, single observation) + input_point = parametric_input.inputValues[0][0] + + if len(input_point) != len(parametric_input.inputVarList): + raise Exception("Size mismatch between inputVarList and point to evaluate") + + input_dict = deterministic_dict + for i in range(len(input_point)): + input_dict[parametric_input.inputVarList[i]] = input_point[i][0] + + return input_dict + +def create_normal_parametric_output(output_dict, parametric_input): + output_values = [[[]]] + for output_var in parametric_input.outputVarList: + output_values[0][0].append([output_dict[output_var]]) + return SALOME_TYPES.ParametricOutput(outputValues = output_values, + specificOutputInfos = [], + returnCode = 0, + errorMessage = "") + +def create_error_parametric_output(error_message): + return SALOME_TYPES.ParametricOutput(outputValues = [], + specificOutputInfos = [], + returnCode = 1, + errorMessage = error_message) diff --git a/src/KERNEL_PY/kernel/varlist.py b/src/KERNEL_PY/kernel/parametric/study_exchange_vars.py similarity index 99% rename from src/KERNEL_PY/kernel/varlist.py rename to src/KERNEL_PY/kernel/parametric/study_exchange_vars.py index a2cadeb47..8c0316538 100644 --- a/src/KERNEL_PY/kernel/varlist.py +++ b/src/KERNEL_PY/kernel/parametric/study_exchange_vars.py @@ -25,7 +25,7 @@ computation code. These Exchange Variables can be stored in a SObject in Salome study. """ -from studyedit import getStudyEditor +from salome.kernel.studyedit import getStudyEditor DEFAULT_NAME = "Variables" INPUT_VAR_NAMES = "ExchangeVariables.InputVarNames" -- 2.39.2