deephaven.jcompat#
This module provides Java compatibility support including convenience functions to create some widely used Java data structures from corresponding Python ones in order to be able to call Java methods.
- j_binary_operator(func, dtype)[source]#
Constructs a Java ‘Function<PyObject, PyObject, Object>’ implementation from a Python callable or an object with an ‘apply’ method that accepts a single argument.
- j_function(func, dtype)[source]#
Constructs a Java ‘Function<PyObject, Object>’ implementation from a Python callable or an object with an ‘apply’ method that accepts a single argument.
- j_lambda(func, lambda_jtype, return_dtype=None)[source]#
Wraps a Python Callable as a Java “lambda” type.
Java lambda types must contain a single abstract method.
- Parameters:
func (Callable) – Any Python Callable or object with an ‘apply’ method that accepts the same arguments (number and type) the target Java lambda type
lambda_jtype (jpy.JType) – The Java lambda interface to wrap the provided callable in
return_dtype (DType) – The expected return type if conversion should be applied. None (the default) does not attempt to convert the return value and returns a Java Object.
- j_runnable(callable)[source]#
Constructs a Java ‘Runnable’ implementation from a Python callable that doesn’t take any arguments and returns None.
- Parameters:
callable (Callable[[], None]) – a Python callable that doesn’t take any arguments and returns None
- Return type:
- Returns:
io.deephaven.integrations.python.PythonRunnable instance
- j_unary_operator(func, dtype)[source]#
Constructs a Java ‘Function<PyObject, Object>’ implementation from a Python callable or an object with an ‘apply’ method that accepts a single argument.
- to_sequence(v=None, wrapped=False)[source]#
A convenience function to create a sequence of wrapped or unwrapped object from either one or a sequence of input values to help JPY find the matching Java overloaded method to call.
This also enables a function to provide parameters that can accept both singular and plural values of the same type for the convenience of the users, e.g. both x= “abc” and x = [“abc”] are valid arguments.
- Parameters:
v (Union[T, Sequence[T]], optional) – the input value(s) to be converted to a sequence
wrapped (bool, optional) – if True, the input value(s) will remain wrapped in a JPy object; otherwise, the input value(s) will be unwrapped. Defaults to False.
- Returns:
a sequence of wrapped or unwrapped objects
- Return type:
Sequence[Union[T, jpy.JType]]