本文整理汇总了Python中metpy.testing.assert_array_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_array_equal函数的具体用法?Python assert_array_equal怎么用?Python assert_array_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_array_equal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_convergence
def test_convergence():
"""Test convergence for simple case."""
a = np.arange(3)
u = np.c_[a, a, a] * units('m/s')
c = h_convergence(u, u, 1 * units.meter, 1 * units.meter)
true_c = np.ones_like(u) / units.sec
assert_array_equal(c, true_c)
示例2: test_basic2
def test_basic2(self):
'Basic test of advection'
u = np.ones((3,)) * units('m/s')
s = np.array([1, 2, 3]) * units('kg')
a = advection(s, u, (1 * units.meter,))
truth = -np.ones_like(u) * units('kg/sec')
assert_array_equal(a, truth)
示例3: test_resample_nn
def test_resample_nn():
"""Test 1d nearest neighbor functionality."""
a = np.arange(5.)
b = np.array([2, 3.8])
truth = np.array([2, 4])
assert_array_equal(truth, resample_nn_1d(a, b))
示例4: test_advection_uniform
def test_advection_uniform():
"""Test advection calculation for a uniform 1D field."""
u = np.ones((3,)) * units('m/s')
s = np.ones_like(u) * units.kelvin
a = advection(s, u, (1 * units.meter,))
truth = np.zeros_like(u) * units('K/sec')
assert_array_equal(a, truth)
示例5: test_advection_1d_uniform_wind
def test_advection_1d_uniform_wind():
"""Test advection for simple 1D case with uniform wind."""
u = np.ones((3,)) * units('m/s')
s = np.array([1, 2, 3]) * units('kg')
a = advection(s, u, (1 * units.meter,))
truth = -np.ones_like(u) * units('kg/sec')
assert_array_equal(a, truth)
示例6: test_advection_2d_uniform
def test_advection_2d_uniform():
"""Test advection for uniform 2D field."""
u = np.ones((3, 3)) * units('m/s')
s = np.ones_like(u) * units.kelvin
a = advection(s, [u, u], (1 * units.meter, 1 * units.meter))
truth = np.zeros_like(u) * units('K/sec')
assert_array_equal(a, truth)
示例7: test_basic3
def test_basic3(self):
'Basic test of vorticity and divergence calculation'
a = np.arange(3)
u = np.c_[a, a, a] * units('m/s')
c = h_convergence(u, u, 1 * units.meter, 1 * units.meter)
true_c = np.ones_like(u) / units.sec
assert_array_equal(c, true_c)
示例8: test_advection_1d
def test_advection_1d():
"""Test advection calculation with varying wind and field."""
u = np.array([1, 2, 3]) * units('m/s')
s = np.array([1, 2, 3]) * units('Pa')
a = advection(s, u, (1 * units.meter,))
truth = np.array([-1, -2, -3]) * units('Pa/sec')
assert_array_equal(a, truth)
示例9: test_basic
def test_basic(self):
'Basic braindead test of advection'
u = np.ones((3,)) * units('m/s')
s = np.ones_like(u) * units.kelvin
a = advection(s, u, (1 * units.meter,))
truth = np.zeros_like(u) * units('K/sec')
assert_array_equal(a, truth)
示例10: test_precipitable_water
def test_precipitable_water():
"""Test precipitable water with observed sounding."""
data = get_upper_air_data(datetime(2016, 5, 22, 0), 'DDC')
pw = precipitable_water(data['dewpoint'], data['pressure'],
top=400 * units.hPa)
truth = (0.8899441949243486 * units('inches')).to('millimeters')
assert_array_equal(pw, truth)
示例11: test_zero_gradient
def test_zero_gradient():
"""Test convergence_vorticity when there is no gradient in the field."""
u = np.ones((3, 3)) * units('m/s')
c, v = convergence_vorticity(u, u, 1 * units.meter, 1 * units.meter)
truth = np.zeros_like(u) / units.sec
assert_array_equal(c, truth)
assert_array_equal(v, truth)
示例12: test_zero_convergence
def test_zero_convergence():
"""Test convergence calculation when zeros should be returned."""
a = np.arange(3)
u = np.c_[a, a, a] * units('m/s')
c = h_convergence(u, u.T, 1 * units.meter, 1 * units.meter)
true_c = 2. * np.ones_like(u) / units.sec
assert_array_equal(c, true_c)
示例13: test_vorticity
def test_vorticity():
"""Test vorticity for simple case."""
a = np.arange(3)
u = np.c_[a, a, a] * units('m/s')
v = v_vorticity(u, u, 1 * units.meter, 1 * units.meter)
true_v = np.ones_like(u) / units.sec
assert_array_equal(v, true_v)
示例14: test_zero_vorticity
def test_zero_vorticity():
"""Test vorticity calculation when zeros should be returned."""
a = np.arange(3)
u = np.c_[a, a, a] * units('m/s')
v = v_vorticity(u, u.T, 1 * units.meter, 1 * units.meter)
true_v = np.zeros_like(u) / units.sec
assert_array_equal(v, true_v)
示例15: test_less_or_close
def test_less_or_close():
"""Test floating point less or close to."""
x = np.array([0.0, 1.0, 1.49999, 1.5, 1.5000, 1.7])
comparison_value = 1.5
truth = np.array([True, True, True, True, True, False])
res = _less_or_close(x, comparison_value)
assert_array_equal(res, truth)