Files
pytorch/test/test_complex.py
anjali411 13e4ee7883 Added tensor.is_complex(), is_complex and dtype.is_complex py binding, tensor printing, and dixed the scalar type returned for complex float (#33268)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/33268

Test Plan: Imported from OSS

Differential Revision: D19907698

Pulled By: anjali411

fbshipit-source-id: c3ce2e99fc09da91a90a8fb94e5525a00bb23703
2020-02-20 13:38:01 -08:00

14 lines
449 B
Python

import torch
import unittest
devices = (torch.device('cpu'), torch.device('cuda:0'))
class TestComplexTensor(unittest.TestCase):
def test_to_list_with_complex_64(self):
# test that the complex float tensor has expected values and
# there's no garbage value in the resultant list
self.assertEqual(torch.zeros((2, 2), dtype=torch.complex64).tolist(), [[0j, 0j], [0j, 0j]])
if __name__ == '__main__':
unittest.main()