Skip to content

Commit

Permalink
Merge pull request #387 from akvelon/post-release-local
Browse files Browse the repository at this point in the history
clean line
  • Loading branch information
Amar3tto authored Jan 28, 2025
2 parents fc3e856 + e03331a commit d93118d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions sdks/python/apache_beam/examples/complete/distribopt_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

# pytype: skip-file

import json
import logging
import unittest
import uuid
Expand Down Expand Up @@ -78,16 +77,16 @@ def test_basics(self):
# Only 1 result
self.assertEqual(len(lines), 1)

# Handle NumPy string representation before parsing
cleaned_line = lines[0].replace("np.str_('", "'").replace("')", "'")

# parse result line and verify optimum
optimum = json.loads(lines[0])
optimum = make_tuple(cleaned_line)
self.assertAlmostEqual(optimum['cost'], 454.39597, places=3)
self.assertDictEqual(optimum['mapping'], EXPECTED_MAPPING)

# Ensure production values are NumPy arrays before comparison
production = optimum['production']
for plant in ['A', 'B', 'C']:
values = np.array(production[plant]) # Convert to NumPy array if needed
np.testing.assert_almost_equal(values, np.ones(3))
np.testing.assert_almost_equal(production[plant], np.ones(3))


if __name__ == '__main__':
Expand Down

0 comments on commit d93118d

Please sign in to comment.