"vllm/vscode:/vscode.git/clone" did not exist on "614856da25fe59f633af865aefc874fad32d25a0"
test_text.py 663 Bytes
Newer Older
root's avatar
root committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import filecmp
import os
import tempfile
import unittest

import numpy

import cupy


class TestText(unittest.TestCase):

    def test_savetxt(self):
        tmp_cupy = tempfile.NamedTemporaryFile(delete=False)
        tmp_numpy = tempfile.NamedTemporaryFile(delete=False)
        try:
            tmp_cupy.close()
            tmp_numpy.close()
            array = [[1, 2, 3], [2, 3, 4]]
            cupy.savetxt(tmp_cupy.name, cupy.array(array))
            numpy.savetxt(tmp_numpy.name, numpy.array(array))
            assert filecmp.cmp(tmp_cupy.name, tmp_numpy.name)
        finally:
            os.remove(tmp_cupy.name)
            os.remove(tmp_numpy.name)