code: def test_no_zero_prediction(estimator, build_dataset):
      """
      Test that all predicted values are not zero, even when the
      distance d(x,y) and d(x,z) is the same for a triplet of the
      form (x, y, z). i.e border cases.
      """
      triplets, _, _, X = build_dataset(with_preprocessor=False)
      # Force 3 dimentions only, to use cross product and get easy orthogonal vec.
      triplets = np.array(
          [[t[0][:3], t[1][:3], t[2][:3]] for t in triplets]
      )
      X = X[:, :3]
      # Dummy fit
      estimator = clone(estimator)
      set_random_state(estimator)
      estimator.fit(triplets)
      # We force the transformation to be identity, to force euclidean distance
      estimator.components_ = np.eye(X.shape[1])
  
      # Get two orthogonal vectors in respect to X[1]
      k = X[1] / np.linalg.norm(X[1])  # Normalize first vector
      x = X[2] - X[2].dot(k) * k  # Get random orthogonal vector
      x /= np.linalg.norm(x)  # Normalize
      y = np.cross(k, x)  # Get orthogonal vector to x
      # Assert these orthogonal vectors are different
      with pytest.raises(AssertionError):
          assert_array_equal(X[1], x)
      with pytest.raises(AssertionError):
          assert_array_equal(X[1], y)
      # Assert the distance is the same for both
      assert estimator.get_metric()(X[1], x) == estimator.get_metric()(
          X[1], y
      )
  
      # Form the three scenarios where predict() gives 0 with numpy.sign
      triplets_test = np.array(  # Critical examples
          [[X[0], X[2], X[2]], [X[1], X[1], X[1]], [X[1], x, y]]
      )
      # Predict
      predictions = estimator.predict(triplets_test)
      # Check there are no zero values
      assert np.sum(predictions == 0) == 0
  
file_path: metric-learn/test/test_triplets_classifiers.py
imports: import pytest
  from sklearn.exceptions import NotFittedError
  from sklearn.model_selection import train_test_split
  from metric_learn import SCML
  from test.test_utils import triplets_learners, ids_triplets_learners, build_triplets
  from metric_learn.sklearn_shims import set_random_state
  from sklearn import clone
  import numpy
  from numpy.testing import assert_array_equal
label_desc: Use image node_id 2 for calling a global function with example usage: test_no_zero_prediction(estimator, build_dataset) without return types