Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ The rules for this file:
- tylerjereddy
- IAlibay
- orbeckst
- chr-sa

### Added
<!-- Added functionality -->

### Fixed
- Fix "NameError" for "long" in mdaencore/clustering/affinityprop.pyx (#72, PR #78)
- All dependencies added to pyproject.toml, setup.py, and conda envs (#57)
- Temporary fix for Windows integer size default change in NumPy 2.0.0
- Temporary fix for Windows integer size default change in NumPy 2.0.0 (PR #60)

### Changed
- Update CI and wheel deployment to include macos-arm64 and py3.12 (PR #63)
Expand Down
2 changes: 1 addition & 1 deletion mdaencore/clustering/affinityprop.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def AffinityPropagation(s, preference, float lam, int max_iterations, int conver

# Prepare input and ouput arrays
cdef numpy.ndarray[numpy.float32_t, ndim=1] matndarray = numpy.ascontiguousarray(s._elements, dtype=numpy.float32)
cdef numpy.ndarray[long, ndim=1] clusters = numpy.zeros((s.size),dtype=numpy.dtype("long"))
cdef numpy.ndarray[numpy.int64_t, ndim=1] clusters = numpy.zeros((s.size),dtype=numpy.int64)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tylerjereddy do you have a quick opinion on what's the right approach here in matching dtypes in cython?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Admittedly, given that "long" can be 32 bits on Windows, the proposed fix sounds like the right approach. I am then just a bit surprised that previously the Linux and Windows results agreed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the proposed fix just does not work because clusters would always be 64 bit and CAffinityPropagation takes long, which is 32 bit on Windows. Imo the "right" approach would be to use a 64 bit datatype everywhere for consistency, but that would change behavior on Windows.

I only tested my change on Linux and MacOS, where long is 64 bit matching the int64, and was not aware of the Windows behavior before, that's why I initially thought it works.


# run C module Affinity Propagation
iterations = CAffinityPropagation(<float*>matndarray.data, cn, lam, max_iterations, convergence, noise, <long*>clusters.data)
Expand Down
Loading