You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot get correct overload of generic method #821
But when I check the type of a, it gives Variable[System.Double[]] and not VariableArray[System.Double]. This makes sense since it's ambiguous without specifying the type of the output variable or specifying the type for the function. Since in python I can't pin the output variable to a specific type, I tried to resolve the ambiguity with:
It seems that there is pull-request (#227) ongoing, but it looks to have been work in progress for quite a while now. Is this is not priority, is there a workaround that I can try?
The method overload resolution of Python.NET is very tricky to get right, as we're dealing with two different type systems that should somehow be made compatible. I'm not sure how #227 would solve this.
Is there any way to work around this problem? The only thing I can think of is to write a small C# library that explicitly instantiates the generic methods with the types that I need. I hope that python.NET can then resolve the overloads.
Sorry for the late response. Thanks for the info. I tried with a wrapper library around the generic methods and that seems to work. But now I'm having issues with [] overloads. I haven't tried with using reflections yet, I'll give it a try.
Reflection doesn't seem to work either. The problem is that in the module that I'm trying to use (infer.net), Variable is an abstract class and Constant is a static method of this abstract class. I don't know how to invoke the method of an abstract class. If I do:
Activity
filmor commentedon Mar 6, 2019
The method overload resolution of Python.NET is very tricky to get right, as we're dealing with two different type systems that should somehow be made compatible. I'm not sure how #227 would solve this.
Tobimaru commentedon Mar 7, 2019
Is there any way to work around this problem? The only thing I can think of is to write a small C# library that explicitly instantiates the generic methods with the types that I need. I hope that python.NET can then resolve the overloads.
filmor commentedon Mar 8, 2019
Yes, that approach works fine, and I'm currently not aware of a workaround that doesn't require an additional library.
den-run-ai commentedon Mar 8, 2019
You can always use reflection, search this issue tracker or stackoverflow "python.net" tag.
Tobimaru commentedon Mar 20, 2019
Sorry for the late response. Thanks for the info. I tried with a wrapper library around the generic methods and that seems to work. But now I'm having issues with [] overloads. I haven't tried with using reflections yet, I'll give it a try.
Tobimaru commentedon Mar 23, 2019
Reflection doesn't seem to work either. The problem is that in the module that I'm trying to use (infer.net),
Variableis an abstract class andConstantis a static method of this abstract class. I don't know how to invoke the method of an abstract class. If I do:Then I get the error:
christabella commentedon Jan 13, 2021
This is probably too late but an infer.net-specific workaround could be to use
Invoker.InvokeStatic(Variable, "Constant", args)e.g.https://github.com/dotnet/infer/blob/0c75b5ef4190c5eee55e663741e645cb997b7236/test/TestPython/test_tutorials.py#L217
Tests driven by real-world consumer patterns and historical issues
test_thread: cover real-world consumer patterns
test_thread: cover real-world consumer patterns
test_thread: cover real-world consumer patterns
test_thread: cover real-world consumer patterns
Python 3.14 free-threaded support (#2721)