Reputation: 17
I'm new to Python, so there might be some good reason for this, but it looks like it does nothing:
def preprocess(t):
return t
It looks to me like one of the old time-wasting functions to slow something down.
I see "preprocess" show up in several spots downstream, so if it's calling "preprocess" and passing to "t", then returning "t", I have no idea why it's passing it back-and-forth.
Upvotes: 2
Views: 40
Reputation: 2143
It might be a default do nothing implementation in a base class that is expected to be extended and the behavior updated in the child class. Would need more context around the function to tell if that is the case.
Upvotes: 0
Reputation: 531165
The identity function is useful as a no-op in places where some function is otherwise expected. For example, you can eliminate a conditional from a function like
def do_something(value, f=None):
if f is not None:
value = f(value)
# some some more stuff with value
by writing
def do_something(value, f=preprocess):
value = f(value)
# do some more stuff with value
Upvotes: 0
Reputation: 45741
No, this code does nothing useful.
It is likely being used as a placeholder implementation so that the code calling this function can run; even if preprocess
isn't implemented yet.
The alternative would be to comment out or otherwise remove the calls to preprocess
until it's implemented, but that could be awkward if it's used in multiple places.
Upvotes: 1