ZGIS / semantique

Semantic Querying in Earth Observation Data Cubes
https://zgis.github.io/semantique/
Apache License 2.0
16 stars 6 forks source link

Reducer `n` returns int64 dtype while the defautl is float #35

Open loreabad6 opened 11 months ago

loreabad6 commented 11 months ago

Description

As far as I undesrtand, semantique is designed to return all results from reducer operations as float types. However, the n reducer outputs int64 types. This is because n uses numpy.nansum to retrieve the values (see here), which deaults to int types.

Reproducible example

A code chunck that reproduces the bug.

import numpy as np

# Create an array with NaN values
arr = np.array([1, 2, 4, 5])

# Compute the sum of the array elements using numpy.nansum
result = np.nansum(arr)

print(result)
print(type(result))

#> 12
#> <class 'numpy.int64'>

Expected behavior

The result of n is converted to float to keep consistency.

luukvdmeer commented 11 months ago

I would say in Python it does not matter if it's int or float, so I rather don't add code to semantique that converts this for no real reason. However, if the Sen2Cube frontend requires it we could convert all int data to float in here