Skip to content

feat: replace narray with numo-narray#120

Open
oleksii-leonov wants to merge 1 commit intotelus-agcg:developfrom
syngenta:feat/replace-narray-with-numo-narray
Open

feat: replace narray with numo-narray#120
oleksii-leonov wants to merge 1 commit intotelus-agcg:developfrom
syngenta:feat/replace-narray-with-numo-narray

Conversation

@oleksii-leonov
Copy link
Contributor

@oleksii-leonov oleksii-leonov commented Jan 28, 2026

Replacing narray with numo-narray.

Some improvements/fixes:

  1. Using narray, GDT_UInt32 was mapped to NArray::INT, which could lead to overflow.
  2. Using narray, GDT_UInt16 was mapped to NArray::INT, which is Ok, but wastes memory.

numo-narray has more types available, so now mapping is a bit more precise:

def _gdal_data_type_to_numo_narray_type_constant(data_type)
  case data_type
  when :GDT_Byte                               then Numo::UInt8
  when :GDT_Int16                              then Numo::Int16
  when :GDT_UInt16                             then Numo::UInt16
  when :GDT_Int32                              then Numo::Int32
  when :GDT_UInt32                             then Numo::UInt32
  when :GDT_Float32                            then Numo::SFloat
  when :GDT_Float64                            then Numo::DFloat
  when :GDT_CInt16, :GDT_CInt32, :GDT_CFloat32 then Numo::SComplex
  when :GDT_CFloat64                           then Numo::DComplex
  else
    raise GDAL::InvalidDataType, "Unknown data type: #{data_type}"
  end
end

numo-narray is not a drop-in replacement for narray, some APIs are different.

It's highly possible that it is a breaking change for some users. But keeping narray, which is C code, unsupported for 10 years, is very shaky.

@oleksii-leonov
Copy link
Contributor Author

Issue #55.

end
end

# DEPRECATED: Use Numo::NArray directly instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@turboladen
Copy link
Contributor

Just a note for any future 👀 that this contains API-breaking changes, so should cause a major version bump.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants