Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
data_mask = numpy.array([[0, 1, 1, 0],
[0, 0, 0, 0],
[1, 0, 0, 0],
[0, 0, 1, 1],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]], dtype='bool')
X = [(1, -1)]
Y = [(0, 0)]
Z = [(0, -1), (1, -2), (2, 0)]
tau_max = 2
# No masking
res = _construct_array(
X=X, Y=Y, Z=Z,
tau_max=tau_max,
use_mask=False,
data=data,
mask=data_mask,
missing_flag=None,
mask_type=None, verbosity=verbosity)
print(res[0])
numpy.testing.assert_almost_equal(res[0],
numpy.array([[13, 14, 15],
[ 4, 5, 6],
[ 3, 4, 5],
[12, 13, 14],
[24, 25, 26]]))
numpy.testing.assert_almost_equal(res[1], numpy.array([0, 1, 2, 2, 2]))
data_mask = numpy.array([[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]], dtype='bool')
X = [(1, -2)]
Y = [(0, 0)]
Z = [(2, -1)]
tau_max = 1
# Missing values
res = _construct_array(
X=X, Y=Y, Z=Z,
tau_max=tau_max,
use_mask=False,
data=data,
mask=data_mask,
missing_flag=999,
mask_type=['y'], verbosity=verbosity)
# print(res[0])
numpy.testing.assert_almost_equal(res[0],
numpy.array([[10, 14],
[ 2, 6],
[21, 25]]))
use_mask=False,
data=data,
mask=data_mask,
missing_flag=None,
mask_type=None, verbosity=verbosity)
print(res[0])
numpy.testing.assert_almost_equal(res[0],
numpy.array([[13, 14, 15],
[ 4, 5, 6],
[ 3, 4, 5],
[12, 13, 14],
[24, 25, 26]]))
numpy.testing.assert_almost_equal(res[1], numpy.array([0, 1, 2, 2, 2]))
# masking y
res = _construct_array(
X=X, Y=Y, Z=Z,
tau_max=tau_max,
use_mask=True,
data=data,
mask=data_mask,
mask_type=['y'], verbosity=verbosity)
print(res[0])
numpy.testing.assert_almost_equal(res[0],
numpy.array([[13, 14, 15],
[ 4, 5, 6],
[ 3, 4, 5],
[12, 13, 14],
[24, 25, 26]]))
numpy.testing.assert_almost_equal(res[1], numpy.array([0, 1, 2, 2, 2]))