From a7f4084fb12b1c8d309eebb4ce5a892a71235b2e Mon Sep 17 00:00:00 2001 From: Eero Vaher Date: Fri, 8 May 2026 19:41:43 +0200 Subject: [PATCH] Remove `Argument.view_dtype` property In practice the property had only one possible value, so it is simpler to hardcode that value where it is used. --- erfa/core.py.templ | 5 ++--- erfa_generator.py | 15 --------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/erfa/core.py.templ b/erfa/core.py.templ index 81cdaec..a43969c 100644 --- a/erfa/core.py.templ +++ b/erfa/core.py.templ @@ -98,7 +98,6 @@ def check_errwarn(statcodes, func_name): # <------------------------structured dtype conversion------------------------> dt_bytes1 = np.dtype('S1') -dt_bytes12 = np.dtype('S12') # <--------------------------Actual ERFA-wrapping code------------------------> @@ -175,8 +174,8 @@ def {{ func.pyname }}({{ func.args_by_inout('in|inout')|map(attribute='name')|jo # Any string outputs will be in structs; view them as their base type. #} {%- for arg in func.args_by_inout('out') -%} - {%- if 'char' in arg.ctype %} - {{ arg.name }} = {{ arg.name }}.view({{ arg.view_dtype }}) + {%- if arg.ctype == "char" %} + {{ arg.name }} = {{ arg.name }}.view(dt_bytes1) {%- endif %} {%- endfor %} {#- diff --git a/erfa_generator.py b/erfa_generator.py index 6c6b1c9..d6718e3 100644 --- a/erfa_generator.py +++ b/erfa_generator.py @@ -175,21 +175,6 @@ def dtype(self): return super().dtype raise ValueError(f"ctype {self.ctype} with shape {self.shape} not recognized.") - @property - def view_dtype(self): - """Name of dtype corresponding to the ctype for viewing back as array. - - E.g., dt_double for double, dt_double33 for double[3][3]. - - The types are defined in core.py, where they are used for view-casts - of structured results as regular arrays. - """ - if self.ctype == 'const char': - return 'dt_bytes12' - if self.ctype == "char": - return 'dt_bytes1' - raise ValueError("Only char ctype should need view back!") - @property def ndim(self): return len(self.shape)