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

Class function

xarray/tests/test_units.py:350–382  ·  view source on GitHub ↗

wrapper class for numpy functions Same as method, but the name is used for referencing numpy functions

Source from the content-addressed store, hash-verified

348
349
350class function:
351 """wrapper class for numpy functions
352
353 Same as method, but the name is used for referencing numpy functions
354 """
355
356 def __init__(self, name_or_function, *args, function_label=None, **kwargs):
357 if callable(name_or_function):
358 self.name = (
359 function_label
360 if function_label is not None
361 else name_or_function.__name__
362 )
363 self.func = name_or_function
364 else:
365 self.name = name_or_function if function_label is None else function_label
366 self.func = getattr(np, name_or_function)
367 if self.func is None:
368 raise AttributeError(
369 f"module 'numpy' has no attribute named '{self.name}'"
370 )
371
372 self.args = args
373 self.kwargs = kwargs
374
375 def __call__(self, *args, **kwargs):
376 all_args = merge_args(self.args, args)
377 all_kwargs = {**self.kwargs, **kwargs}
378
379 return self.func(*all_args, **all_kwargs)
380
381 def __repr__(self):
382 return f"function_{self.name}"
383
384
385@pytest.mark.parametrize(

Callers 6

test_align_dataarrayFunction · 0.85
test_align_datasetFunction · 0.85
test_combine_nestedFunction · 0.85
test_merge_dataarrayFunction · 0.85
test_merge_datasetFunction · 0.85
test_univariate_ufuncMethod · 0.85

Calls

no outgoing calls

Tested by 6

test_align_dataarrayFunction · 0.68
test_align_datasetFunction · 0.68
test_combine_nestedFunction · 0.68
test_merge_dataarrayFunction · 0.68
test_merge_datasetFunction · 0.68
test_univariate_ufuncMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…