diff --git a/tests/test_tf.py b/tests/test_tf.py index 075093d..b24757a 100644 --- a/tests/test_tf.py +++ b/tests/test_tf.py @@ -22,7 +22,6 @@ def test_percentile(): np.testing.assert_almost_equal(p_np, p_t) - def test_normalize_tf(): size = 1024 curr_file_path = os.path.dirname(os.path.realpath(__file__)) diff --git a/tests/test_torch.py b/tests/test_torch.py index 0d79ed1..168d2f1 100644 --- a/tests/test_torch.py +++ b/tests/test_torch.py @@ -8,7 +8,6 @@ from torchvision import transforms from skimage.metrics import structural_similarity as ssim - def test_cov(): x = np.random.randn(10, 10) cov_np = np.cov(x) diff --git a/torchstain/tf/utils/percentile.py b/torchstain/tf/utils/percentile.py index 2db4aeb..de8c6ac 100644 --- a/torchstain/tf/utils/percentile.py +++ b/torchstain/tf/utils/percentile.py @@ -14,5 +14,5 @@ def percentile(t: tf.Tensor, q: float) -> Union[int, float]: :param q: Percentile to compute, which must be between 0 and 100 inclusive. :return: Resulting value (scalar). """ - k = 1 + tf.math.round(.01 * tf.cast(q, tf.float32) * (tf.cast(tf.size(t), tf.float32) - 1)) - return tf.sort(tf.reshape(t, [-1]))[tf.cast(k, tf.int32)] + k = 1 + tf.math.round(.01 * tf.cast(q, tf.float32) * (tf.cast(tf.math.reduce_prod(tf.size(t)), tf.float32) - 1)) + return tf.sort(tf.reshape(t, [-1]))[tf.cast(k - 1, tf.int32)] diff --git a/torchstain/torch/utils/percentile.py b/torchstain/torch/utils/percentile.py index 188f1bb..08273d4 100644 --- a/torchstain/torch/utils/percentile.py +++ b/torchstain/torch/utils/percentile.py @@ -6,7 +6,7 @@ """ def percentile(t: torch.tensor, q: float) -> Union[int, float]: """ - Return the ``q``-th percentile of the flattened input tensor's data. + Return the ``q``-th percentile of the flattenepip d input tensor's data. CAUTION: * Needs PyTorch >= 1.1.0, as ``torch.kthvalue()`` is used.