Skip to content

AttributeError: numpy module has no attribute 'warnings' when encountering All-NaN slice/axis #704

@junweizeng

Description

@junweizeng

Hi all,

I encountered an issue while using the kmeans_plusplus_initializer function in the pyclustering.cluster.center_initializer module. The error message is as follows:

AttributeError: module 'numpy' has no attribute 'warnings'

The real cause of this error is in the following location of pyclustering 0.10.1.2:

numpy.warnings.filterwarnings('ignore', r'All-NaN (slice|axis) encountered')

This error occurs seems that because the numpy.warnings module has been removed in recent versions of numpy, and the warnings module from Python's standard library should be used instead.

I was able to resolve this issue by modifying the source code in center_initializer.py. I replaced numpy.warnings.filterwarnings('ignore', r'All-NaN (slice|axis) encountered') with warnings.filterwarnings('ignore', r'All-NaN (slice|axis) encountered').

If this is indeed an issue, I would be happy to submit a PR to fix this bug. Please let me know if you would like me to proceed with this.

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