Skip to content

Commit

Permalink
RFC: simplify AnalysisCallback implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Oct 10, 2023
1 parent da304a7 commit 89287a4
Showing 1 changed file with 1 addition and 11 deletions.
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 Down

0 comments on commit 89287a4

Please sign in to comment.