From 9f65aa2d2e5829093ca1318341aafac9a2fb389b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 26 Jul 2022 21:40:43 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/ludwig/utils/test_data_utils.py | 2 +- tests/ludwig/utils/test_server_utils.py | 26 ++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/ludwig/utils/test_data_utils.py b/tests/ludwig/utils/test_data_utils.py index e0a055cf780..d42163dbcd7 100644 --- a/tests/ludwig/utils/test_data_utils.py +++ b/tests/ludwig/utils/test_data_utils.py @@ -25,8 +25,8 @@ figure_data_format_dataset, get_abs_path, hash_dict, - use_credentials, NumpyEncoder, + use_credentials, ) try: diff --git a/tests/ludwig/utils/test_server_utils.py b/tests/ludwig/utils/test_server_utils.py index 34d64700527..cb746aed038 100644 --- a/tests/ludwig/utils/test_server_utils.py +++ b/tests/ludwig/utils/test_server_utils.py @@ -7,25 +7,25 @@ def test_numpy_json_response(): response = NumpyJSONResponse() # Test Python builtin data type encoding. - assert response.render(None) == "null".encode("utf-8") - assert response.render({}) == "{}".encode("utf-8") - assert response.render(1) == "1".encode("utf-8") - assert response.render(1.0) == "1.0".encode("utf-8") - assert response.render("a") == '"a"'.encode("utf-8") - assert response.render([0, 1, 2, 3, 4]) == "[0,1,2,3,4]".encode("utf-8") - assert response.render((0, 1, 2, 3, 4)) == "[0,1,2,3,4]".encode("utf-8") - assert response.render({0, 1, 2, 3, 4}) == "[0,1,2,3,4]".encode("utf-8") - assert response.render({"a": "b"}) == '{"a":"b"}'.encode("utf-8") + assert response.render(None) == b"null" + assert response.render({}) == b"{}" + assert response.render(1) == b"1" + assert response.render(1.0) == b"1.0" + assert response.render("a") == b'"a"' + assert response.render([0, 1, 2, 3, 4]) == b"[0,1,2,3,4]" + assert response.render((0, 1, 2, 3, 4)) == b"[0,1,2,3,4]" + assert response.render({0, 1, 2, 3, 4}) == b"[0,1,2,3,4]" + assert response.render({"a": "b"}) == b'{"a":"b"}' # Test numpy data type encoding for dtype in [np.byte, np.ubyte, np.short, np.ushort, np.int, np.uint, np.longlong, np.ulonglong]: x = np.arange(5, dtype=dtype) - assert response.render(x) == "[0,1,2,3,4]".encode("utf-8") + assert response.render(x) == b"[0,1,2,3,4]" for i in x: - assert response.render(i) == f"{i}".encode("utf-8") + assert response.render(i) == f"{i}".encode() for dtype in [np.half, np.single, np.double, np.longdouble]: x = np.arange(5, dtype=dtype) - assert response.render(x) == "[0.0,1.0,2.0,3.0,4.0]".encode("utf-8") + assert response.render(x) == b"[0.0,1.0,2.0,3.0,4.0]" for i in x: - assert response.render(i) == f"{i}".encode("utf-8") + assert response.render(i) == f"{i}".encode()