From 45e81ae4b3633776c71b6677f2024f895900524d Mon Sep 17 00:00:00 2001 From: wleong Date: Fri, 8 Nov 2024 12:38:59 +0000 Subject: [PATCH 1/6] Added cpp_type as an attribute and a separate attribute for description --- catbird/param.py | 4 +++- catbird/syntax.py | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/catbird/param.py b/catbird/param.py index 11dbdd6..bcb1a5c 100644 --- a/catbird/param.py +++ b/catbird/param.py @@ -2,13 +2,14 @@ class MooseParam(): """ Class to contain all information about a MOOSE parameter """ - def __init__(self,attr_name, attr_type, is_array, default=None, allowed_vals=None, description=None): + def __init__(self,attr_name, attr_type, is_array, default=None, allowed_vals=None, description=None, type=None): assert attr_type is not type(None) self.attr_type=attr_type self.allowed_vals=allowed_vals self.is_array=is_array + self.cpp_type = cpp_type # Set name if not isinstance(attr_name, str): @@ -31,6 +32,7 @@ def __init__(self,attr_name, attr_type, is_array, default=None, allowed_vals=Non doc_str += attr_name+' : ' doc_str += f'{attr_type.__name__}\n' if description is not None and description != "": + self.description = description doc_str += " " doc_str += description doc_str += "\n" diff --git a/catbird/syntax.py b/catbird/syntax.py index 0e1667d..128cab2 100644 --- a/catbird/syntax.py +++ b/catbird/syntax.py @@ -493,6 +493,10 @@ def get_params_list(json_obj,syntax_path): else: default = _convert_to_type(attr_type, param_info['default']) + cpp_type = None + if 'cpp_type' in param_info.keys(): + cpp_type = param_info['cpp_type'] + # Create and add a MOOSE parameter moose_param=MooseParam(param_name, attr_type, @@ -500,6 +504,7 @@ def get_params_list(json_obj,syntax_path): default=default, allowed_vals=allowed_values, description=param_info.get('description'), + type=cpp_type ) moose_param_list.append(moose_param) From 9e501d0c5d05aec412cb1566c60b07e99f059201 Mon Sep 17 00:00:00 2001 From: Wei Jie Leong <122815453+wleong1@users.noreply.github.com> Date: Fri, 8 Nov 2024 12:42:27 +0000 Subject: [PATCH 2/6] Changed value of self.cpp_type to type --- catbird/param.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catbird/param.py b/catbird/param.py index bcb1a5c..abd7e41 100644 --- a/catbird/param.py +++ b/catbird/param.py @@ -9,7 +9,7 @@ def __init__(self,attr_name, attr_type, is_array, default=None, allowed_vals=Non self.attr_type=attr_type self.allowed_vals=allowed_vals self.is_array=is_array - self.cpp_type = cpp_type + self.cpp_type = type # Set name if not isinstance(attr_name, str): From 2bd966f48162e7dc8971d8701b0fc01967465c2e Mon Sep 17 00:00:00 2001 From: wleong Date: Mon, 20 Jan 2025 13:49:40 +0000 Subject: [PATCH 3/6] Added required as an attribute --- catbird/param.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/catbird/param.py b/catbird/param.py index bcb1a5c..ad919c6 100644 --- a/catbird/param.py +++ b/catbird/param.py @@ -2,7 +2,7 @@ class MooseParam(): """ Class to contain all information about a MOOSE parameter """ - def __init__(self,attr_name, attr_type, is_array, default=None, allowed_vals=None, description=None, type=None): + def __init__(self,attr_name, attr_type, is_array, default=None, allowed_vals=None, required=False, description=None, cpp_type=None): assert attr_type is not type(None) @@ -10,6 +10,7 @@ def __init__(self,attr_name, attr_type, is_array, default=None, allowed_vals=Non self.allowed_vals=allowed_vals self.is_array=is_array self.cpp_type = cpp_type + self.required = required # Set name if not isinstance(attr_name, str): @@ -40,5 +41,5 @@ def __init__(self,attr_name, attr_type, is_array, default=None, allowed_vals=Non doc_str += f' Allowed values: {allowed_vals}\n' if default is not None: doc_str += f' Default value: {default}\n' - + doc_str += f' Required: {required}\n' self.doc=doc_str From b4590cefd9733d9454c7cd1a1013a76a1af620ed Mon Sep 17 00:00:00 2001 From: wleong Date: Thu, 27 Feb 2025 11:22:16 +0000 Subject: [PATCH 4/6] Added IC creation and required param --- catbird/model.py | 3 ++- catbird/syntax.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/catbird/model.py b/catbird/model.py index 12c5595..68bf092 100644 --- a/catbird/model.py +++ b/catbird/model.py @@ -12,7 +12,7 @@ def __init__(self,factory_in): self.moose_objects=[] # Add attributes to this model with default assignments - self.load_default_syntax() + # self.load_default_syntax() # Envisage this being overridden downstream. def load_default_syntax(self): @@ -27,6 +27,7 @@ def load_default_syntax(self): self.add_syntax("Materials") self.add_syntax("BCs") self.add_syntax("Outputs") + self.add_syntax("ICs") def add_syntax(self,syntax_name,**kwargs_in): diff --git a/catbird/syntax.py b/catbird/syntax.py index 128cab2..2e0f853 100644 --- a/catbird/syntax.py +++ b/catbird/syntax.py @@ -493,6 +493,10 @@ def get_params_list(json_obj,syntax_path): else: default = _convert_to_type(attr_type, param_info['default']) + is_required=False + if 'required' in param_info.keys(): + is_required=param_info['required'] + cpp_type = None if 'cpp_type' in param_info.keys(): cpp_type = param_info['cpp_type'] @@ -503,8 +507,9 @@ def get_params_list(json_obj,syntax_path): is_array, default=default, allowed_vals=allowed_values, + required=is_required, description=param_info.get('description'), - type=cpp_type + cpp_type=cpp_type ) moose_param_list.append(moose_param) From c2a2c9555b834dc44d6cead3f749924079848380 Mon Sep 17 00:00:00 2001 From: wleong Date: Fri, 7 Mar 2025 10:27:11 +0000 Subject: [PATCH 5/6] Added cpp_type to docstring --- catbird/param.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catbird/param.py b/catbird/param.py index ad919c6..58f0d8f 100644 --- a/catbird/param.py +++ b/catbird/param.py @@ -31,7 +31,7 @@ def __init__(self,attr_name, attr_type, is_array, default=None, allowed_vals=Non # Set docstring doc_str = '\n' doc_str += attr_name+' : ' - doc_str += f'{attr_type.__name__}\n' + doc_str += f'{cpp_type}\n' if description is not None and description != "": self.description = description doc_str += " " From dfdc1409ff36fe4a5256afcbe13519a1eaa91bda Mon Sep 17 00:00:00 2001 From: wleong Date: Mon, 24 Mar 2025 15:34:25 +0000 Subject: [PATCH 6/6] Changed naming of description file --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index bdac09e..85077c7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,3 @@ [metadata] -description-file = README.md +description_file = README.md license_files = LICENSE \ No newline at end of file