#!/usr/bin/env python # # Author: Mike McKerns (mmckerns @caltech and @uqfoundation) # Copyright (c) 1997-2016 California Institute of Technology. # Copyright (c) 2016-2019 The Uncertainty Quantification Foundation. # License: 3-clause BSD. The full license text is available at: # - https://github.com/uqfoundation/mystic/blob/master/LICENSE import numpy as np from mystic.math.measures import _k if __name__ == '__main__': # even-length w = [3, 1, 1, 1, 3, 3] assert _k(w) == w # even-length clipping assert (np.array(_k(w, (10, 10), clip=True)) > 0).tolist() == [ 1, 1, 1, 1, 1, 1 ] assert (np.array(_k(w, (25, 25), clip=True)) > 0).tolist() == [ 0, 1, 1, 1, 1, 0 ] assert (np.array(_k(w, (50, 50), clip=True)) > 0).tolist() == [ 0, 0, 0, 1, 1, 0 ] assert (np.array(_k(w, (49, 50), clip=True)) > 0).tolist() == [ 0, 0, 0, 1, 0, 0 ] assert (np.array(_k(w, (50, 49), clip=True)) > 0).tolist() == [ 0, 0, 0, 0, 1, 0 ]
#!/usr/bin/env python # # Author: Mike McKerns (mmckerns @caltech and @uqfoundation) # Copyright (c) 1997-2016 California Institute of Technology. # Copyright (c) 2016-2017 The Uncertainty Quantification Foundation. # License: 3-clause BSD. The full license text is available at: # - https://github.com/uqfoundation/mystic/blob/master/LICENSE import numpy as np from mystic.math.measures import _k if __name__ == '__main__': # even-length w = [3,1,1,1,3,3] assert _k(w) == w # even-length clipping assert (np.array(_k(w,(10,10),clip=True)) > 0).tolist() == [1,1,1,1,1,1] assert (np.array(_k(w,(25,25),clip=True)) > 0).tolist() == [0,1,1,1,1,0] assert (np.array(_k(w,(50,50),clip=True)) > 0).tolist() == [0,0,0,1,1,0] assert (np.array(_k(w,(49,50),clip=True)) > 0).tolist() == [0,0,0,1,0,0] assert (np.array(_k(w,(50,49),clip=True)) > 0).tolist() == [0,0,0,0,1,0] assert (np.array(_k(w,(49,49),clip=True)) > 0).tolist() == [0,0,0,1,1,0] assert (np.array(_k(w,(25,75),clip=True)) > 0).tolist() == [1,1,0,0,0,0] assert (np.array(_k(w,(24,75),clip=True)) > 0).tolist() == [1,0,0,0,0,0] assert (np.array(_k(w,(25,74),clip=True)) > 0).tolist() == [0,1,0,0,0,0] assert (np.array(_k(w,(24,74),clip=True)) > 0).tolist() == [1,1,0,0,0,0] assert (np.array(_k(w,(75,25),clip=True)) > 0).tolist() == [0,0,0,0,1,1] assert (np.array(_k(w,(74,25),clip=True)) > 0).tolist() == [0,0,0,0,1,0] assert (np.array(_k(w,(75,24),clip=True)) > 0).tolist() == [0,0,0,0,0,1] assert (np.array(_k(w,(74,24),clip=True)) > 0).tolist() == [0,0,0,0,1,1]