diff options
author | Lisa Schwetlick <mail@lisaschwetlick.de> | 2020-10-09 21:35:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-09 12:35:47 -0700 |
commit | 156cd054e007b05d4ac4829e10a369d19dd2b0b1 (patch) | |
tree | 8e9181a9b5b1156b9f5c3cc9c3d4a6d2876b8df5 /numpy/lib/tests | |
parent | 84a4fcb5af5f9c056e82893223944820af35df18 (diff) | |
download | numpy-156cd054e007b05d4ac4829e10a369d19dd2b0b1.tar.gz |
ENH: add dtype option to cov and corrcoef (#17456)
Adds a keyword-only dtype parameter to correlate and coerrcoef to allow
user to specify the dtype of the output.
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 7bddb941c..4c7c0480c 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -2023,6 +2023,12 @@ class TestCorrCoef: assert_array_almost_equal(c, np.array([[1., -1.], [-1., 1.]])) assert_(np.all(np.abs(c) <= 1.0)) + @pytest.mark.parametrize("test_type", [np.half, np.single, np.double, np.longdouble]) + def test_corrcoef_dtype(self, test_type): + cast_A = self.A.astype(test_type) + res = corrcoef(cast_A, dtype=test_type) + assert test_type == res.dtype + class TestCov: x1 = np.array([[0, 2], [1, 1], [2, 0]]).T @@ -2123,6 +2129,12 @@ class TestCov: aweights=self.unit_weights), self.res1) + @pytest.mark.parametrize("test_type", [np.half, np.single, np.double, np.longdouble]) + def test_cov_dtype(self, test_type): + cast_x1 = self.x1.astype(test_type) + res = cov(cast_x1, dtype=test_type) + assert test_type == res.dtype + class Test_I0: |