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.

is_java_type(obj)[source]

Returns True if the object is originated in Java.

Return type

bool

j_array_list(values=None)[source]

Creates a Java ArrayList instance from an iterable.

Return type

JType

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.

Parameters
  • func (Callable) – a Python callable or an object with an ‘apply’ method that accepts two arguments

  • dtype (DType) – the return type of ‘func’

Return type

JType

Returns

io.deephaven.integrations.python.PythonFunction instance

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.

Parameters
  • func (Callable) – a Python callable or an object with an ‘apply’ method that accepts a single argument

  • dtype (DType) – the return type of ‘func’

Return type

JType

Returns

io.deephaven.integrations.python.PythonFunction instance

j_hashmap(d=None)[source]

Creates a Java HashMap from a dict.

Return type

JType

j_hashset(s=None)[source]

Creates a Java HashSet from a set.

Return type

JType

j_map_to_dict(m)[source]

Converts a java map to a python dictionary.

j_properties(d=None)[source]

Creates a Java Properties from a dict.

Return type

JType

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.

Parameters
  • func (Callable) – a Python callable or an object with an ‘apply’ method that accepts a single argument

  • dtype (DType) – the return type of ‘func’

Return type

JType

Returns

io.deephaven.integrations.python.PythonFunction instance

to_sequence(v=None)[source]

A convenience function to create a sequence of 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.

Return type

Sequence[Union[~T, JType]]