IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

28 lines
901B

  1. from triacontagon.cumcount import dfill, \
  2. argunsort, \
  3. cumcount
  4. import torch
  5. import numpy as np
  6. def test_dfill_01():
  7. input = torch.tensor([1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5])
  8. output = dfill(input)
  9. expected = torch.tensor([0, 0, 0, 0, 0, 5, 5, 7, 7, 7, 10, 10, 12, 12])
  10. assert torch.all(output == expected)
  11. def test_argunsort_01():
  12. input = torch.tensor([1, 1, 2, 3, 3, 4, 1, 1, 5, 5, 2, 3, 1, 4])
  13. output = np.argsort(input.numpy())
  14. output = argunsort(torch.tensor(output))
  15. expected = torch.tensor([0, 1, 5, 7, 8, 10, 2, 3, 12, 13, 6, 9, 4, 11])
  16. assert torch.all(output == expected)
  17. def test_cumcount_01():
  18. input = torch.tensor([1, 1, 2, 3, 3, 4, 1, 1, 5, 5, 2, 3, 1, 4])
  19. output = cumcount(input)
  20. expected = torch.tensor([0, 1, 0, 0, 1, 0, 2, 3, 0, 1, 1, 2, 4, 1])
  21. assert torch.all(output == expected)