Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions erfa_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,11 @@ def process_definitions(self) -> list[str]:
defines.append(var)
# Is variable an array?
name, _, rest = var.partition("[")
# If not, or one of iymdf or ihmsf, ignore (latter are outputs only).
if not rest or rest[:2] == "4]":
if (
not rest
or name in self.func.doc.output # no need to initialize outputs
or name == "iydmf" # eraJdcalf test has a typo
Comment on lines -416 to +419
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.

The typo in the eraJdcalf test also means that iymdf the old comment refers to cannot be found by grepping.

):
continue
# Temporarily create an Argument, so we can use its attributes.
# This translates, e.g., double pv[2][3] to dtype dt_pv.
Expand All @@ -433,11 +436,16 @@ def to_python(self):
# TODO: this is quite hacky right now! Would be good to let function
# calls be understood by the Function class.

out_array_elems = tuple(f"{arg}[" for arg in self.func.doc.output)
out = self.process_definitions()
for line in self.lines:
# In ldn ufunc, the number of bodies is inferred from the array size,
# so no need to keep the definition.
if line == "n = 3" and self.func.pyname == "ldn":
if (
# No need to initialize output arrays in Python
line.startswith(out_array_elems)
# In ldn ufunc, the number of bodies is inferred from the array size,
# so no need to keep the definition.
or (line == "n = 3" and self.func.pyname == "ldn")
):
continue

# Actual function. Start with basic replacements.
Expand Down
Loading