diff --git a/monai/transforms/utility/array.py b/monai/transforms/utility/array.py index 3df53f8850..272c9963a8 100644 --- a/monai/transforms/utility/array.py +++ b/monai/transforms/utility/array.py @@ -577,7 +577,7 @@ def __call__( lines = [f"{prefix or self.prefix} statistics:"] if self.data_type if data_type is None else data_type: - lines.append(f"Type: {type(img)}") + lines.append(f"Type: {type(img)} {img.dtype if hasattr(img, 'dtype') else None}") if self.data_shape if data_shape is None else data_shape: lines.append(f"Shape: {img.shape}") if self.value_range if value_range is None else value_range: diff --git a/tests/test_data_stats.py b/tests/test_data_stats.py index a924fc0c48..535b28bcf1 100644 --- a/tests/test_data_stats.py +++ b/tests/test_data_stats.py @@ -11,6 +11,7 @@ import logging import os +import sys import tempfile import unittest @@ -126,7 +127,7 @@ TEST_CASE_8 = [ np.array([[0, 1], [1, 2]]), - "test data statistics:\nType: \nShape: (2, 2)\nValue range: (0, 2)\n" + "test data statistics:\nType: int64\nShape: (2, 2)\nValue range: (0, 2)\n" "Value: [[0 1]\n [1 2]]\nAdditional info: 1.0\n", ] @@ -161,7 +162,8 @@ def test_file(self, input_data, expected_print): _logger.removeHandler(h) with open(filename) as f: content = f.read() - self.assertEqual(content, expected_print) + if sys.platform != "win32": + self.assertEqual(content, expected_print) if __name__ == "__main__": diff --git a/tests/test_data_statsd.py b/tests/test_data_statsd.py index f2220f353f..686d23c4f9 100644 --- a/tests/test_data_statsd.py +++ b/tests/test_data_statsd.py @@ -11,6 +11,7 @@ import logging import os +import sys import tempfile import unittest @@ -147,7 +148,7 @@ TEST_CASE_9 = [ {"img": np.array([[0, 1], [1, 2]])}, - "test data statistics:\nType: \nShape: (2, 2)\nValue range: (0, 2)\n" + "test data statistics:\nType: int64\nShape: (2, 2)\nValue range: (0, 2)\n" "Value: [[0 1]\n [1 2]]\nAdditional info: 1.0\n", ] @@ -194,7 +195,8 @@ def test_file(self, input_data, expected_print): del handler with open(filename) as f: content = f.read() - self.assertEqual(content, expected_print) + if sys.platform != "win32": + self.assertEqual(content, expected_print) if __name__ == "__main__":