MCPcopy Index your code
hub / github.com/pydata/xarray / generate_example

Method generate_example

xarray/util/generate_aggregations.py:470–487  ·  view source on GitHub ↗
(self, method)

Source from the content-addressed store, hash-verified

468 yield self.generate_code(method, self.has_keep_attrs)
469
470 def generate_example(self, method):
471 created = self.datastructure.create_example.format(
472 example_array=method.np_example_array
473 )
474 calculation = f"{self.datastructure.example_var_name}{self.example_call_preamble}.{method.name}"
475 if method.extra_kwargs:
476 extra_examples = "".join(
477 kwarg.example for kwarg in method.extra_kwargs if kwarg.example
478 ).format(calculation=calculation, method=method.name)
479 else:
480 extra_examples = ""
481
482 return f"""
483 Examples
484 --------{created}
485 >>> {self.datastructure.example_var_name}
486
487 >>> {calculation}(){extra_examples}"""
488
489
490class GroupByAggregationGenerator(AggregationGenerator):

Callers 1

generate_methodMethod · 0.95

Calls 2

formatMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected