Skip to content

Commit 3cf9ade

Browse files
committed
simplify comments & add to do
1 parent e3042e0 commit 3cf9ade

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

homonim/fuse.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ def process(
361361
Configuration dictionary for block processing. See :meth:`~RasterFuse.create_block_config` for keys and
362362
default values.
363363
"""
364+
# TODO: is it possible to have an auto block_config that adjusts threads and block mem to available memory
364365
self._assert_open()
365366

366367
# prepare configuration

homonim/raster_array.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,7 @@ def _convert_array_dtype(self, dtype: str, nodata: Union[float, None] = None) ->
362362
nodata_change = nodata is not None and not utils.nan_equals(nodata, self.nodata)
363363
array = self._array
364364
if nodata_change or unsafe_cast:
365-
# If necessary and possible, promote source dtype to be able to represent destination dtype exactly.
366-
# (This works around the (undocumented?) situation where even if a clipped array contains only values
367-
# that can be represented as the destination dtype, there is still casting overflow when these values
368-
# are near the dtype limits e.g. float32->int32 should be promoted to float64->int32. There is no way
369-
# of preventing this situation for float*->int64.)
365+
# promote dtype to be able to represent destination dtype exactly (if possible) to clip correctly
370366
array = array.astype(np.promote_types(self.dtype, dtype), copy=True)
371367

372368
# round if converting from float to integer dtype
@@ -380,8 +376,8 @@ def _convert_array_dtype(self, dtype: str, nodata: Union[float, None] = None) ->
380376
if src_info.min < dst_info.min or src_info.max > dst_info.max:
381377
np.clip(array, dst_info.min, dst_info.max, out=array)
382378

383-
# convert dtype
384-
with np.errstate(invalid='ignore'): # ignore numpy warning for cast of nodata=nan to dtype
379+
# convert dtype (ignoring numpy warnings for float overflow or cast of nan to integer)
380+
with np.errstate(invalid='ignore', over='ignore'):
385381
array = array.astype(dtype, copy=False, casting='unsafe')
386382

387383
# set nodata value if it has changed, or may be invalid after rounding, clipping and casting

0 commit comments

Comments
 (0)