Skip to content

Commit

Permalink
Merge pull request #234 from neutrinoceros/rfc_analysis_cb
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros authored Oct 19, 2023
2 parents a99296e + c0d5b2a commit 42ce382
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
18 changes: 2 additions & 16 deletions yt_astro_analysis/halo_analysis/halo_catalog/analysis_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,10 @@ class AnalysisCallback:
to the target object, write out data, etc, but does not return anything.
"""

def __init__(self, function, args=None, kwargs=None):
def __init__(self, function, *args, **kwargs):
self.function = function
self.args = args
if self.args is None:
self.args = []
self.kwargs = kwargs
if self.kwargs is None:
self.kwargs = {}

def __call__(self, target):
self.function(target, *self.args, **self.kwargs)
Expand All @@ -49,9 +45,6 @@ class AnalysisFilter(AnalysisCallback):
whether analysis is continued.
"""

def __init__(self, function, *args, **kwargs):
AnalysisCallback.__init__(self, function, args, kwargs)

def __call__(self, target):
return self.function(target, *self.args, **self.kwargs)

Expand All @@ -69,9 +62,6 @@ class AnalysisQuantity(AnalysisCallback):
performs some analysis, and then returns a value.
"""

def __init__(self, function, *args, **kwargs):
AnalysisCallback.__init__(self, function, args, kwargs)

def __call__(self, target):
return self.function(target, *self.args, **self.kwargs)

Expand All @@ -89,14 +79,10 @@ class AnalysisRecipe:
adds a series of callbacks, quantities, and filters.
"""

def __init__(self, function, args=None, kwargs=None):
def __init__(self, function, *args, **kwargs):
self.function = function
self.args = args
if self.args is None:
self.args = []
self.kwargs = kwargs
if self.kwargs is None:
self.kwargs = {}

def __call__(self, pipeline):
return self.function(pipeline, *self.args, **self.kwargs)
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,10 @@ class HaloFindingMethod:
dataset and returns a new dataset that is the loaded halo finder output.
"""

def __init__(self, function, args=None, kwargs=None):
def __init__(self, function, *args, **kwargs):
self.function = function
self.args = args
if self.args is None:
self.args = []
self.kwargs = kwargs
if self.kwargs is None:
self.kwargs = {}

def __call__(self, hc):
return self.function(hc, *self.args, **self.kwargs)
Expand Down

0 comments on commit 42ce382

Please sign in to comment.