-
-
Notifications
You must be signed in to change notification settings - Fork 25.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve FunctionTransformer
diagram representation
#29032
Comments
Convinced, we need to work the details but definitely this is better. I still think we should have the info that this is a |
|
I think that I better the harder way (unfortunately :)). |
I also like 'the harder way' better. Two further possible improvements:
|
It's actually "fortunately" for me as I also like the harder way but afraid that people don't think it's worth the complexity 🤣
Thanks for confirmation.
This is what I initially did, but then I found the info icon tooltip actually shows "documentation of {name}" which in that case would be "documentation of func name" which I think is improper. I will definitely consider this if I can find an easy way to tweak the info icon tooltip text individually.
This I'm hesitant. I do agree that |
Checking the Developer API for HTML representation it seems we could overwrite the
We can implement a recursive function for those edge cases, like so: sample implementation for `get_function_name`import numpy as np
import functools
def get_function_name(func):
"""
Retrieves the name of a function, supporting `np.vectorize` and `functools.partial`,
including nested variations.
"""
# Check if the function has a `__name__` attribute directly
if hasattr(func, '__name__'):
return func.__name__
# Check for functools.partial
if isinstance(func, functools.partial):
return get_function_name(func.func)
# Check for np.vectorize
if isinstance(func, np.vectorize):
return get_function_name(func.pyfunc)
# Check if the function has a `__wrapped__` attribute (for other decorators)
if hasattr(func, '__wrapped__'):
return get_function_name(func.__wrapped__)
# If all else fails, return a placeholder name or indication
return "<unknown_function>"
# Example Usage:
def example_function(x):
return x
partial_func = functools.partial(example_function, x=2)
vectorized_func = np.vectorize(example_function)
partial_vectorized_func = functools.partial(vectorized_func, x=2)
print(get_function_name(example_function)) # Output: example_function
print(get_function_name(partial_func)) # Output: example_function
print(get_function_name(vectorized_func)) # Output: example_function
print(get_function_name(partial_vectorized_func)) # Output: example_function
print(get_function_name(lambda x: x)) # Output: <lambda> That will deal with the vast majority of functions and it has a fallback. |
|
Sorry that I made a few mistakes in my earlier comments:
Hence I think we do not need to care about that many corner cases. Having a special case for |
Describe the workflow you want to enable
Currently, using multiple
FunctionTransformers
in a pipeline leads to an uninformative view:I would like to see the name of the function being used in the visual blocks
Describe your proposed solution
I would like to see something like this:
(or perhaps
Function(<name of function>)
or<name of function>()
orFunctionTransformer_<name of function>
)A sample implementation might be look like this:
Describe alternatives you've considered, if relevant
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: