Skip to content

Replace the only Jinja macro with Python code#267

Merged
avalentino merged 1 commit into
liberfa:mainfrom
eerovaher:replace-jinja-macro-with-python-code
Jun 8, 2026
Merged

Replace the only Jinja macro with Python code#267
avalentino merged 1 commit into
liberfa:mainfrom
eerovaher:replace-jinja-macro-with-python-code

Conversation

@eerovaher

Copy link
Copy Markdown
Contributor

I am not aware of any good reasons why code should be written as Jinja macros rather than Python functions. Luckily it is not very complicated to get rid of the macros because there is only one.

Comment thread erfa_generator.py
Comment on lines +205 to +208
# note: one can only have 1 or 2 dimensions
lines.append(
f"int copy_{name} = (is_{name}0 != sizeof({self.ctype}));"
if self.ndim <= 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Based on the comment I would have expected that we could check if self.ndim == 1, but turns out that it is necessary to use <= instead of == because in a few cases self.ndim is 0. Furthermore, in the templates the Argument.ndim property is always used as arg.ndim or 1, and this function also uses the analogous self.ndim or 1. I am getting the impression that something is being set up wrong, and instead of fixing the problem where it occurs the current code contains workarounds wherever the problem is encountered. I'll have to investigate what the real problem is and how to solve it.

@avalentino avalentino merged commit 4b80c34 into liberfa:main Jun 8, 2026
28 checks passed
@eerovaher eerovaher deleted the replace-jinja-macro-with-python-code branch June 9, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants