Skip to content

Entries missing from input_parameters#104

Open
Bernadette-Mohr wants to merge 1 commit intodevelopfrom
103-support-for-umbrella-sampling-calculations-in-nomad
Open

Entries missing from input_parameters#104
Bernadette-Mohr wants to merge 1 commit intodevelopfrom
103-support-for-umbrella-sampling-calculations-in-nomad

Conversation

@Bernadette-Mohr
Copy link
Copy Markdown
Member

No description provided.

@Bernadette-Mohr Bernadette-Mohr linked an issue Apr 16, 2024 that may be closed by this pull request
val_scalar_group2 = val_scalar.group(2)
inline_comment = re_comment.match(val_scalar_group2)
if inline_comment:
parameters[val_scalar.group(1)] = inline_comment.group(1)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try this:

parameters[val_scalar.group(1)] = inline_comment.group()

if inline_comment:
parameters[val_scalar.group(1)] = inline_comment.group(1)
else:
parameters[val_scalar.group(1)] = val_scalar.group(2)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not functional, but just to avoid calling the group() twice: parameters[val_scalar.group(1)] = val_scalar_group2

@JFRudzinski
Copy link
Copy Markdown
Collaborator

The other quantities parse fine as well. Here is the code I am using, but it should be identical to yours except the changes above

class GromacsMdpParser(TextParser):
    def __init__(self):
        super().__init__(None)

    def init_quantities(self):
        def str_to_input_parameters(val_in):
            re_array = re.compile(r"\s*([\w\-]+)\[[\d ]+\]\s*=\s*\{*(.+)")
            re_scalar = re.compile(r"\s*([\w\-]+)\s*[=:]\s*(.+)")
            re_comment = re.compile(r"^\S+?(?=[\s;])")
            parameters = dict()
            val = [line.strip() for line in val_in.splitlines()]
            for val_n in val:
                val_scalar = re_scalar.match(val_n)
                if val_scalar:
                    val_scalar_group2 = val_scalar.group(2)
                    inline_comment = re_comment.match(val_scalar_group2)
                    if inline_comment:
                        parameters[val_scalar.group(1)] = inline_comment.group()
                    else:
                        parameters[val_scalar.group(1)] = val_scalar_group2
                    continue
                val_array = re_array.match(val_n)
                if val_array:
                    # print("val_array", val_array)
                    parameters.setdefault(val_array.group(1), [])
                    value = [
                        to_float(v) for v in val_array.group(2).rstrip("}").split(",")
                    ]
                    parameters[val_array.group(1)].append(
                        value[0] if len(value) == 1 else value
                    )
            # print("\nTEST:", parameters)
            return parameters

@JFRudzinski JFRudzinski added the backlog Issue not currently being worked on, and no plans for efforts in the near future label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backlog Issue not currently being worked on, and no plans for efforts in the near future

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Umbrella Sampling Calculations in NOMAD

2 participants