Skip to content

Unexpected behavior for bn.move_std with float32 array #164

Description

@d-chambers

Hello,

A colleague and I have noticed that using the move_std method on a large float 32 array can return some strange results, mainly zeros when the std of the window is not 0. Moreover, if the move_std is calculated again for just the window of interest it returns the correct result. When the array is cast to dtype np.float64 it seems to work fine. Is float32 not supported? If so the operation should probably raise an exception, or at least a warning.

I have attached a jupyter notebook and the data demonstrating the issue. Basically:

import bottleneck as bn
import numpy as np
import pandas as pd
# read data
input_arr = np.load('PXZ.EHZ.npy')
std = bn.move_std(input_arr, 121)
zeros = np.where(std == 0)
assert not len(zeros[0]) 

fails because zeros were found in the std array, but

input_arr = np.load('PXZ.EHZ.npy').astype(np.float64)
std = bn.move_std(input_arr, 121)
zeros = np.where(std == 0)
assert not len(zeros[0]) 

does not fail as there are no zeros in the std array.

bad_move.zip

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