class_docstr: Tests for identifying inverse relationships and leakage.
class_docstr_tok: ["Tests","for","identifying","inverse","relationships","and","leakage","."]
docstr: Test :func:`_translate_triples`.
docstr_tok: ["Test",":","func",":","`","_translate_triples","`","."]
code: def test_translate_triples(self):
      """Test :func:`_translate_triples`."""
      max_e_id = 13
      max_r_id = 7
      num_triples = 31
      triples = torch.stack(
          [
              2 * torch.randint(max_id, size=(num_triples,))
              for max_id in (max_e_id, max_r_id, max_e_id)
          ],
          dim=-1,
      )
      entity_translation = torch.full(
          size=(2 * max_e_id,), fill_value=-1, dtype=torch.long
      )
      entity_translation[::2] = torch.arange(max_e_id)
      relation_translation = torch.full(
          size=(2 * max_r_id,), fill_value=-1, dtype=torch.long
      )
      relation_translation[::2] = torch.arange(max_r_id)
      new_triples = _translate_triples(
          triples=triples,
          entity_translation=entity_translation,
          relation_translation=relation_translation,
      )
      # check type
      assert torch.is_tensor(new_triples)
      assert new_triples.dtype == torch.long
      # check shape
      assert new_triples.shape == (num_triples, 3)
      # check content
      assert (new_triples >= 0).all()
      assert (new_triples[:, [0, 2]] < max_e_id).all()
      assert (new_triples[:, 1] < max_r_id).all()
  
file_path: pykeen/tests/test_leakage.py
imports: import itertools
  import unittest
  import numpy
  import numpy
  import scipy.sparse
  import torch
  from pykeen.datasets import Nations
  from pykeen.triples import TriplesFactory
  from pykeen.triples.leakage import Sealant, _generate_compact_vectorized_lookup, _translate_triples, get_candidate_pairs, jaccard_similarity_scipy, mapped_triples_to_sparse_matrices, triples_factory_to_sparse_matrices
label_desc: Use image node_id 3 for calling the TestLeakage obj's underlying member method code with example usage: obj.test_translate_triples() without return types