From 0476cde99e793b568ad7a251327da87ee63852da Mon Sep 17 00:00:00 2001 From: Florian Deconinck Date: Wed, 19 Feb 2025 08:42:54 -0500 Subject: [PATCH] Some docstrings --- ndsl/stencils/testing/translate.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ndsl/stencils/testing/translate.py b/ndsl/stencils/testing/translate.py index e3fc8845..7aae7922 100644 --- a/ndsl/stencils/testing/translate.py +++ b/ndsl/stencils/testing/translate.py @@ -51,6 +51,12 @@ def _convert(value: Union[Quantity, np.ndarray]) -> np.ndarray: class TranslateFortranData2Py: + """Translate test main class + + The translate test will will test a set of inputs and outputs, after having processed + the inputs via the user provided `compute_func`. + """ + max_error = 1e-14 near_zero = 1e-18 mmr_absolute_eps = -1 @@ -73,6 +79,8 @@ def setup(self, inputs): self.make_storage_data_input_vars(inputs) def compute_func(self, **inputs): + """Compute function to transform the dictionary of `inputs`. + Must return a dictionnary of updated variables""" raise NotImplementedError("Implement a child class compute method") def compute(self, inputs): @@ -81,6 +89,10 @@ def compute(self, inputs): # assume inputs already has been turned into gt4py storages (or Quantities) def compute_from_storage(self, inputs): + """Run `compute_func` and return an updated `inputs` dictionary with + the returned results of `compute_func`. + + Hypothesis: `inputs` are `gt4py.storages`""" outputs = self.compute_func(**inputs) if outputs is not None: inputs.update(outputs) @@ -109,6 +121,10 @@ def make_storage_data( read_only: bool = False, full_shape: bool = False, ) -> Dict[str, "Field"]: + """Copy input data into a gt4py.storage with given shape. + + `array` is copied. Takes care of the device upload if necessary. + """ use_shape = list(self.maxshape) if dummy_axes: for axis in dummy_axes: @@ -168,6 +184,8 @@ def collect_start_indices(self, datashape, varinfo): return istart, jstart, kstart def make_storage_data_input_vars(self, inputs, storage_vars=None, dict_4d=True): + """From a set of raw inputs, use the `in_vars` dictionnary to update inputs to + their configured shape.""" inputs_in = {**inputs} inputs_out = {} if storage_vars is None: