Skip to content

Commit

Permalink
[Func1] Improve nomenclature
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl committed Jul 31, 2024
1 parent 32b81b8 commit 84af00b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions include/cantera/numerics/Func1Factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ shared_ptr<Func1> 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
Expand Down
10 changes: 5 additions & 5 deletions interfaces/cython/cantera/func1.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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]:
Expand Down
10 changes: 5 additions & 5 deletions interfaces/matlab_experimental/Func/Func1.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions src/numerics/Func1Factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ shared_ptr<Func1> 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
Expand Down
4 changes: 2 additions & 2 deletions test/general/test_numerics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 84af00b

Please sign in to comment.