Skip to content

numpy._core._exceptions._UFuncOutputCastingError: Cannot cast ufunc 'subtract' output from dtype('float64') to dtype('int64') with casting rule 'same_kind' #300

@fish4terrisa-MSDSM

Description

@fish4terrisa-MSDSM

A bug seems happened in the pykrige/core.py, with numpy 2.1.3,
Given the following output:

Traceback (most recent call last):
  File "/usr/src/matrix-tests/./matrix2.py", line 52, in <module>
    values_pred = OK.execute('points', x_266, y_266)[0]
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pykrige/ok.py", line 880, in execute
    xpts, ypts = _adjust_for_anisotropy(
                 ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pykrige/core.py", line 145, in _adjust_for_anisotropy
    X -= center
numpy._core._exceptions._UFuncOutputCastingError: Cannot cast ufunc 'subtract' output from dtype('float64') to dtype('int64') with casting rule 'same_kind'

A fast fix would be adding this line

X = X.astype('float64')

before the line

X -= center

in file pykrige/core.py .
(I'm not sure whether that fix will cause any side effects, though. And I'm hoping for official fixes.)

Metadata

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