Skip to content

Commit

Permalink
Merge pull request #540 from avalentino/bugfix/floating-point-comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese authored Sep 9, 2023
2 parents 04ea38d + 74bcc08 commit efa0469
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pyresample/test/test_bilinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,11 @@ def test_get_sample_from_bil_info(self):
# Sample from data1
res = get_sample_from_bil_info(self.data1.ravel(), t__, s__,
input_idxs, idx_arr)
self.assertEqual(res.ravel()[5], 1.)
self.assertAlmostEqual(res.ravel()[5], 1.)
# Sample from data2
res = get_sample_from_bil_info(self.data2.ravel(), t__, s__,
input_idxs, idx_arr)
self.assertEqual(res.ravel()[5], 2.)
self.assertAlmostEqual(res.ravel()[5], 2.)
# Reshaping
res = get_sample_from_bil_info(self.data2.ravel(), t__, s__,
input_idxs, idx_arr,
Expand All @@ -326,7 +326,7 @@ def test_get_sample_from_bil_info(self):
input_idxs, idx_arr,
output_shape=self.target_def.shape)
# Four pixels are outside of the data
self.assertEqual(np.isnan(res).sum(), 4)
self.assertAlmostEqual(np.isnan(res).sum(), 4)

# Masked array as input, result should be plain Numpy array
data = np.ma.masked_all(self.data1.shape)
Expand Down Expand Up @@ -647,7 +647,7 @@ def test_get_sample_from_bil_info(self):
res = resampler.get_sample_from_bil_info(self.data1)
res = res.compute()
# Check couple of values
self.assertEqual(res.values[1, 1], 1.)
self.assertAlmostEqual(res.values[1, 1], 1.)
self.assertTrue(np.isnan(res.values[0, 3]))
# Check that the values haven't gone down or up a lot
self.assertAlmostEqual(np.nanmin(res.values), 1.)
Expand All @@ -658,15 +658,15 @@ def test_get_sample_from_bil_info(self):
# Sample from data1, custom fill value
res = resampler.get_sample_from_bil_info(self.data1, fill_value=-1.0)
res = res.compute()
self.assertEqual(np.nanmin(res.values), -1.)
self.assertAlmostEqual(np.nanmin(res.values), -1.)

# Sample from integer data
res = resampler.get_sample_from_bil_info(self.data1.astype(np.uint8),
fill_value=None)
res = res.compute()
# Five values should be filled with zeros, which is the
# default fill_value for integer data
self.assertEqual(np.sum(res == 0), 6)
self.assertAlmostEqual(np.sum(res == 0), 6)

# Output coordinates should have been set
self.assertTrue(isinstance(resampler._out_coords, dict))
Expand Down

0 comments on commit efa0469

Please sign in to comment.