[PyCharm] PY-73914 Scientific View(fix): Fix issues

GitOrigin-RevId: 5e9eb49cfa8b29edeab058f032c57bea8bbef0a8
This commit is contained in:
ekaterina.itsenko
2024-07-16 16:13:34 +02:00
committed by intellij-monorepo-bot
parent cb4b60d98f
commit 85e207094b
4 changed files with 29 additions and 11 deletions

View File

@@ -72,7 +72,13 @@ def __get_table_provider(output):
'pandera.typing.pandas.DataFrame']:
import _pydevd_bundle.tables.pydevd_pandas as table_provider
# dict is needed for sort commands
elif type_qualified_name in ['numpy.ndarray', 'builtins.dict']:
elif type_qualified_name == 'builtins.dict':
table_type = '{}.{}'.format(type(output['data']).__module__, type(output['data']).__name__)
if table_type in ['tensorflow.python.framework.sparse_tensor.SparseTensor', 'torch.Tensor']:
import _pydevd_bundle.tables.pydevd_numpy_based as table_provider
else:
import _pydevd_bundle.tables.pydevd_numpy as table_provider
elif type_qualified_name == 'numpy.ndarray':
import _pydevd_bundle.tables.pydevd_numpy as table_provider
elif type_qualified_name in ['tensorflow.python.framework.ops.EagerTensor',
'tensorflow.python.ops.resource_variable_ops.ResourceVariable',

View File

@@ -409,7 +409,10 @@ def array_to_thrift_struct(array, name, roffset, coffset, rows, cols, format):
def tensor_to_thrift_struct(tensor, name, roffset, coffset, rows, cols, format):
return array_to_thrift_struct(tensor.numpy(), name, roffset, coffset, rows, cols, format)
try:
return array_to_thrift_struct(tensor.numpy(), name, roffset, coffset, rows, cols, format)
except TypeError:
return array_to_thrift_struct(tensor.to_dense().numpy(), name, roffset, coffset, rows, cols, format)
def sparse_tensor_to_thrift_struct(tensor, name, roffset, coffset, rows, cols, format):

View File

@@ -583,7 +583,10 @@ def array_to_xml(array, name, roffset, coffset, rows, cols, format):
def tensor_to_xml(tensor, name, roffset, coffset, rows, cols, format):
return array_to_xml(tensor.numpy(), name, roffset, coffset, rows, cols, format)
try:
return array_to_xml(tensor.numpy(), name, roffset, coffset, rows, cols, format)
except TypeError:
return array_to_xml(tensor.to_dense().numpy(), name, roffset, coffset, rows, cols, format)
def sparse_tensor_to_xml(tensor, name, roffset, coffset, rows, cols, format):

View File

@@ -220,14 +220,20 @@ def _create_table(command, start_index=None, end_index=None):
np_array = command['data']
sort_keys = command['sort_keys']
else:
try:
import tensorflow as tf
if isinstance(command, tf.SparseTensor):
command = tf.sparse.to_dense(tf.sparse.reorder(command))
except ImportError:
pass
finally:
np_array = command
np_array = command
try:
import tensorflow as tf
if isinstance(np_array, tf.SparseTensor):
np_array = tf.sparse.to_dense(tf.sparse.reorder(np_array))
except ImportError:
pass
try:
import torch
if isinstance(np_array, torch.Tensor):
np_array = np_array.to_dense()
except ImportError:
pass
if is_pd:
sorting_arr = _sort_df(pd.DataFrame(np_array), sort_keys)