Skip to content

UnboundLocalError of reshape_order in FGmaxGrid.read_output #691

@peanutfun

Description

@peanutfun

Commit 437db74 introduced a bug in FGmaxGrid.read_output: If point_style is not one of 2, 3, or 4, the variable reshape_order is not set.

if point_style in [2,3,4]:
if indexing == 'xy':
reshape_order = 'C'
elif indexing == 'ij':
reshape_order = 'F'
else:
raise InputError("*** indexing must by 'xy' or 'ij'")
self.indexing = indexing # make available to user

This leads to an error later, where reshape_order is always used, irrespective of the point_style:

X = numpy.reshape(d[:,0],fg_shape,order=reshape_order)
Y = numpy.reshape(d[:,1],fg_shape,order=reshape_order)
y0 = 0.5*(Y.min() + Y.max()) # mid-latitude for scaling plots
h = numpy.reshape(d[:,ind_h],fg_shape,order=reshape_order)
# AMR level used for each fgmax value:
level = numpy.reshape(d[:,ind_level].astype('int'),fg_shape,
order=reshape_order)

>       X = numpy.reshape(d[:,0],fg_shape,order=reshape_order)
                                                ^^^^^^^^^^^^^
E       UnboundLocalError: cannot access local variable 'reshape_order' where it is not associated with a value

There should be a default value set for reshape_order to avoid this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions