Example #1
0
def test_complex_array_results():
    """ test that ``complex_array`` returns appropriate results """
    arr1 = np.random.random((4, 5))
    arr2 = np.random.random((4, 5))

    from_complex_array = complex_array(arr1, arr2)
    by_hand = arr1 + 1j * arr2
    assert from_complex_array.dtype == by_hand.dtype
    assert np.allclose(from_complex_array, by_hand)
Example #2
0
    def test_results(self):
        """ test that ``complex_array`` returns appropriate results """
        arr1 = np.random.random((4, 5))
        arr2 = np.random.random((4, 5))

        from_complex_array = complex_array(arr1, arr2)
        by_hand = arr1 + 1j * arr2
        self.assertEqual(from_complex_array.dtype, by_hand.dtype)
        self.assertTrue(np.allclose(from_complex_array, by_hand))
Example #3
0
def test_complex_array_non_floats():
    """ Test that two integer arrays are cast correctly """
    real, imag = np.empty((3, 4), dtype=np.int16), np.empty((3, 4),
                                                            dtype=np.int8)
    assert complex_array(real, imag).dtype == complex
Example #4
0
def test_complex_array_floats():
    """ Test that two floating arrays are cast correctly """
    real, imag = np.empty((3, 4), dtype=float), np.empty((3, 4), dtype=float)
    assert complex_array(real, imag).dtype == complex
Example #5
0
 def test_non_floats(self):
     """ Test that two integer arrays are cast correctly """
     real, imag = np.empty((3, 4), dtype=np.int16), np.empty((3, 4),
                                                             dtype=np.int8)
     self.assertEqual(complex_array(real, imag).dtype, np.complex)
Example #6
0
 def test_floats(self):
     """ Test that two floating arrays are cast correctly """
     real, imag = np.empty((3, 4), dtype=np.float), np.empty((3, 4),
                                                             dtype=np.float)
     self.assertEqual(complex_array(real, imag).dtype, np.complex)