Skip to content

Numpy ValueError in function adjustResultCoordinates #3

@Jerry191202

Description

@Jerry191202

There seems to be a numpy problem in the function adjustResultCoordinates of https://github.com/MaterialEyes/Plot2Spec/blob/main/src/axis_alignment/tick_detection/craft_utils.py:

def adjustResultCoordinates(polys, ratio_w, ratio_h, ratio_net = 2):
    if len(polys) > 0:
        polys = np.array(polys)
        for k in range(len(polys)):
            if polys[k] is not None:
                polys[k] *= (ratio_w * ratio_net, ratio_h * ratio_net)
    return polys

The list variable polys here may consist simultaneously of some 1D arrays and some None values. When it's being converted to a 2D array in the third line polys = np.array(polys), we get an error like this:

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (22,) + inhomogeneous part.

I simply commented out this line and everything seemed to be alright.
Not sure if this is a compatibility issue. My numpy version is 1.24.4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions