From 84af00b67dd63e032cbef3c147caf54c9e33c469 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Tue, 30 Jul 2024 12:21:47 +0200 Subject: [PATCH] [Func1] Improve nomenclature --- include/cantera/numerics/Func1Factory.h | 6 +++--- interfaces/cython/cantera/func1.pyx | 10 +++++----- interfaces/matlab_experimental/Func/Func1.m | 10 +++++----- src/numerics/Func1Factory.cpp | 4 ++-- test/general/test_numerics.cpp | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/cantera/numerics/Func1Factory.h b/include/cantera/numerics/Func1Factory.h index 198371c76b..fab729f3c3 100644 --- a/include/cantera/numerics/Func1Factory.h +++ b/include/cantera/numerics/Func1Factory.h @@ -146,9 +146,9 @@ shared_ptr newFunc1(const string& func1Type, //! Check definition of functor object. //! @param func1Type String identifying functor type. //! @return string indicating functor type: @c "undefined" if not defined; -//! @c "simple" if @ref func1basic or @ref func1advanced (defined in Func1Factory); -//! @c "compound" if @ref func1compound (defined in Math1FactoryA); or -//! @c "modified" if @ref func1modified (defined in Math1FactoryB). +//! @c "standard" if @ref func1basic or @ref func1advanced (defined in +//! Func1Factory); @c "compound" if @ref func1compound (defined in Math1FactoryA); +//! or @c "modified" if @ref func1modified (defined in Math1FactoryB). //! @internal Not intended for use in external API's (Python, MATLAB, etc.). //! @ingroup func1helper //! @since New in %Cantera 3.1 diff --git a/interfaces/cython/cantera/func1.pyx b/interfaces/cython/cantera/func1.pyx index 084b4dbae1..4a58222cfa 100644 --- a/interfaces/cython/cantera/func1.pyx +++ b/interfaces/cython/cantera/func1.pyx @@ -127,17 +127,17 @@ cdef class Func1: func1_type = pystr(CxxCheckFunc1(cxx_string)) if func1_type == "undefined": raise NotImplementedError(f"Functor '{functor_type}' is not implemented.") - if len(args) == 0 and func1_type == "simple": - # simple functor with no parameter + if len(args) == 0 and func1_type == "standard": + # basic functor with no parameter func = CxxNewFunc1(cxx_string, 1.) - elif len(args) == 1 and func1_type == "simple": + elif len(args) == 1 and func1_type == "standard": if hasattr(args[0], "__len__"): # advanced functor with array and no parameter for v in args[0]: arr.push_back(v) func = CxxNewFunc1(cxx_string, arr) else: - # simple functor with scalar parameter + # basic functor with scalar parameter func = CxxNewFunc1(cxx_string, float(args[0])) elif len(args) == 2: if func1_type == "compound": @@ -161,7 +161,7 @@ cdef class Func1: else: raise ValueError(f"Invalid arguments for modifying functor.") func = CxxNewFunc1(cxx_string, f0._func, float(args[1])) - elif func1_type == "simple": + elif func1_type == "standard": # tabulating functor if hasattr(args[0], "__len__") and hasattr(args[1], "__len__"): for v in args[0]: diff --git a/interfaces/matlab_experimental/Func/Func1.m b/interfaces/matlab_experimental/Func/Func1.m index 8d8643f995..b231a5176c 100644 --- a/interfaces/matlab_experimental/Func/Func1.m +++ b/interfaces/matlab_experimental/Func/Func1.m @@ -76,13 +76,13 @@ error(['Functor ''' typ ''' is not implemented']) end - if length(varargin) == 0 && func1Type == "simple" - % simple functor with no parameter + if length(varargin) == 0 && func1Type == "standard" + % basic functor with no parameter x.id = ctFunc('func_new_basic', typ, 1.); - elseif length(varargin) == 1 && func1Type == "simple" + elseif length(varargin) == 1 && func1Type == "standard" coeffs = varargin{1}; if length(coeffs) == 1 - % simple functor with scalar parameter + % basic functor with scalar parameter x.id = ctFunc('func_new_basic', typ, coeffs); elseif isa(coeffs, 'double') % advanced functor with array parameter @@ -110,7 +110,7 @@ error('Invalid arguments for modifying functor') end x.id = ctFunc('func_new_modified', typ, arg1.id, arg2); - else % func1Type == "simple" + else % func1Type == "standard" % tabulating functors if ~isa(arg1, 'double') || ~isa(arg2, 'double') error('Invalid arguments for tabulating functor') diff --git a/src/numerics/Func1Factory.cpp b/src/numerics/Func1Factory.cpp index 90c2605b5f..7a30245dc0 100644 --- a/src/numerics/Func1Factory.cpp +++ b/src/numerics/Func1Factory.cpp @@ -171,8 +171,8 @@ shared_ptr newFunc1(const string& func1Type, string checkFunc1(const string& func1Type) { if (Func1Factory::factory()->exists(func1Type)) { - // simple functor - return "simple"; + // standard functor + return "standard"; } if (Math1FactoryA::factory()->exists(func1Type)) { // compounding functor diff --git a/test/general/test_numerics.cpp b/test/general/test_numerics.cpp index 78f499ddb6..8a2cfbfd88 100644 --- a/test/general/test_numerics.cpp +++ b/test/general/test_numerics.cpp @@ -145,7 +145,7 @@ TEST(ctfunc, invalid) TEST(ctfunc, sin) { - ASSERT_EQ(checkFunc1("sin"), "simple"); + ASSERT_EQ(checkFunc1("sin"), "standard"); double omega = 2.; auto functor = newFunc1("sin", omega); ASSERT_EQ(functor->type(), "sin"); @@ -274,7 +274,7 @@ TEST(ctfunc, tabulated_previous) TEST(ctfunc, poly) { - ASSERT_EQ(checkFunc1("polynomial3"), "simple"); + ASSERT_EQ(checkFunc1("polynomial3"), "standard"); double a0 = .5; double a1 = .25; double a2 = .125;