Skip to content

try_weightcol is incorrectly defined using getattr() #669

Open
@Ryclock

Description

Question Description

In line 372 of the libpysal/weights/weights.py file, the getattr function is called to assign a value to try_weightcol. However, since the third parameter of getattr (the default value to be returned when the attribute is not found) is not passed, it will result in an AttributeError: 'DataFrame' object has no attribute 'weight' if the 'weight_col' column is not present in the 'adjlist', and this will terminate the program.

So, when will the code at lines 373-375 be executed?

if try_weightcol is None:
    adjlist = adjlist.copy(deep=True)
    adjlist["weight"] = 1

Essential Information

  • Platform information: nt win32
  • Python version: 3.10.11[MSC v.1934 64 bit (AMD64)]
  • SciPy version:1.10.1
  • NumPy version:1.24.3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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