MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / array_to_xml

Function array_to_xml

_pydevd_bundle/pydevd_vars.py:669–711  ·  view source on GitHub ↗
(array, roffset, coffset, rows, cols, format)

Source from the content-addressed store, hash-verified

667
668
669def array_to_xml(array, roffset, coffset, rows, cols, format):
670 xml = ""
671 rows = min(rows, MAXIMUM_ARRAY_SIZE)
672 cols = min(cols, MAXIMUM_ARRAY_SIZE)
673
674 # there is no obvious rule for slicing (at least 5 choices)
675 if len(array) == 1 and (rows > 1 or cols > 1):
676 array = array[0]
677 if array.size > len(array):
678 array = array[roffset:, coffset:]
679 rows = min(rows, len(array))
680 cols = min(cols, len(array[0]))
681 if len(array) == 1:
682 array = array[0]
683 elif array.size == len(array):
684 if roffset == 0 and rows == 1:
685 array = array[coffset:]
686 cols = min(cols, len(array))
687 elif coffset == 0 and cols == 1:
688 array = array[roffset:]
689 rows = min(rows, len(array))
690
691 xml += '<arraydata rows="%s" cols="%s"/>' % (rows, cols)
692 for row in range(rows):
693 xml += '<row index="%s"/>' % to_string(row)
694 for col in range(cols):
695 value = array
696 if rows == 1 or cols == 1:
697 if rows == 1 and cols == 1:
698 value = array[0]
699 else:
700 if rows == 1:
701 dim = col
702 else:
703 dim = row
704 value = array[dim]
705 if "ndarray" in str(type(value)):
706 value = value[0]
707 else:
708 value = array[row][col]
709 value = format % value
710 xml += var_to_xml(value, "")
711 return xml
712
713
714def array_to_meta_xml(array, name, format):

Callers 1

table_like_struct_to_xmlFunction · 0.85

Calls 2

to_stringFunction · 0.90
var_to_xmlFunction · 0.90

Tested by

no test coverage detected