Skip to content

Problem with the xml() cube method with new numpy=1.22 #4478

@valeriupredoi

Description

@valeriupredoi

📰 Custom Issue

Hey guys, we are seeing this when trying to access the cube.xml() method of a certain cube (picked up by CI tests here and reproduced locally, of which the output below is from) with the new numpy=1.22, otherwise 1.21.x works no problemo:

so when trying to access cube.xml() method:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../miniconda3/envs/esmvaltool-stock2/lib/python3.9/site-packages/iris/cube.py:3069: in xml
    cube_xml_element = self._xml_element(
../miniconda3/envs/esmvaltool-stock2/lib/python3.9/site-packages/iris/cube.py:3130: in _xml_element
    dimmeta_xml_element(coord, "coord", self.coord_dims)
../miniconda3/envs/esmvaltool-stock2/lib/python3.9/site-packages/iris/cube.py:3121: in dimmeta_xml_element
    xml_element.appendChild(element.xml_element(doc))
../miniconda3/envs/esmvaltool-stock2/lib/python3.9/site-packages/iris/coords.py:2666: in xml_element
    element = super().xml_element(doc)
../miniconda3/envs/esmvaltool-stock2/lib/python3.9/site-packages/iris/coords.py:2271: in xml_element
    element = super().xml_element(doc=doc)
../miniconda3/envs/esmvaltool-stock2/lib/python3.9/site-packages/iris/coords.py:632: in xml_element
    element.setAttribute(values_term, self._xml_array_repr(self._values))
../miniconda3/envs/esmvaltool-stock2/lib/python3.9/site-packages/iris/coords.py:663: in _xml_array_repr
    result = iris.util.format_array(data)
../miniconda3/envs/esmvaltool-stock2/lib/python3.9/site-packages/iris/util.py:1052: in format_array
    result = formatArray(
../miniconda3/envs/esmvaltool-stock2/lib/python3.9/site-packages/numpy/core/arrayprint.py:889: in _formatArray
    return recurser(index=(),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

index = (), hanging_indent = '\t\t', curr_width = 50

    def recurser(index, hanging_indent, curr_width):
        """
        By using this local function, we don't need to recurse with all the
        arguments. Since this function is not created recursively, the cost is
        not significant
        """
        axis = len(index)
        axes_left = a.ndim - axis
    
        if axes_left == 0:
            return format_function(a[index])
    
        # when recursing, add a space to align with the [ added, and reduce the
        # length of the line by 1
        next_hanging_indent = hanging_indent + ' '
>       if legacy <= 113:
E       TypeError: '<=' not supported between instances of 'str' and 'int'

Without digging deeper in iris source code, is there anything I should do to fix it? Cheers and a Happy New Year to you all at SciTools 🍺

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions