# Path: ldif/torch/sif.py
# def ensure_are_tensors(named_tensors):
# def ensure_type(v, t, name):
# def _load_v1_txt(path):
# def _tile_for_symgroups(elements, symmetry_count):
# def reflect_z(samples):
# def _generate_symgroup_samples(samples, element_count, symmetry_count):
# def _generate_symgroup_frames(world2local, symmetry_count):
#   def __init__(self, constants, centers, radii, rotations, symmetry_count):
#   def from_file(cls, path):
#   def from_flat_tensor(cls, tensor, symmetry_count):
#   def to_flat_tensor(self):
#   def rbf_influence(self, samples):
#   def effective_element_count(self):
#   def constants(self):
#   def _tiled_constants(self):
#   def _tiled_centers(self):
#   def _tiled_radii(self):
#   def _tiled_rotations(self):
#   def world2local(self):
#   def eval(self, samples):
# class Sif(object):


import os
import sys
import unittest
import numpy as np
import torch
from ldif.torch import sif
    self.assertAlmostEqual(shape._rotations[0, 4, 2].cpu().numpy(), -0.0532, places=4)

  def test_flatten_unflatten(self):
    sif_path = os.path.join(TEST_DATA_DIR, 'b831f60f211435df5bbc861d0124304c.txt')
    shape = sif.Sif.from_file(sif_path)
    flattened, symc = shape.to_flat_tensor()
    unflattened = sif.Sif.from_flat_tensor(flattened, symc)
    self._ensure_sifs_equal(shape, unflattened)

  def test_batching(self):
    flattened_shapes = []
    test_names = ['b831f60f211435df5bbc861d0124304c',
        'b7eefc4c25dd9e49238581dd5a8af82c']
    paths = [os.path.join(TEST_DATA_DIR, name + '.txt') for name in test_names]
    for path in paths:
      shape = sif.Sif.from_file(path)
      flattened_shapes.append(shape.to_flat_tensor())
    flats = [x[0] for x in flattened_shapes]
    symcs = [x[1] for x in flattened_shapes]

    for symc in symcs:
      self.assertEqual(symc, symcs[0])

    batched_tensor = torch.cat(flats, dim=0)
    batched_sif = sif.Sif.from_flat_tensor(batched_tensor, symcs[0])
    self.assertEqual(batched_sif.bs, 2)
    auto_batched_sif = sif.Sif.from_file(paths)
    self._ensure_sifs_equal(batched_sif, auto_batched_sif, -1)

  def _test_rbf_evaluation(self):

# Path: ldif/torch/sif.py
# def ensure_are_tensors(named_tensors):
# def ensure_type(v, t, name):
# def _load_v1_txt(path):
# def _tile_for_symgroups(elements, symmetry_count):
# def reflect_z(samples):
# def _generate_symgroup_samples(samples, element_count, symmetry_count):
# def _generate_symgroup_frames(world2local, symmetry_count):
#   def __init__(self, constants, centers, radii, rotations, symmetry_count):
#   def from_file(cls, path):
#   def from_flat_tensor(cls, tensor, symmetry_count):
#   def to_flat_tensor(self):
#   def rbf_influence(self, samples):
#   def effective_element_count(self):
#   def constants(self):
#   def _tiled_constants(self):
#   def _tiled_centers(self):
#   def _tiled_radii(self):
#   def _tiled_rotations(self):
#   def world2local(self):
#   def eval(self, samples):
# class Sif(object):


# Path: ldif/torch/sif_test.py
import os
import sys
import unittest
import numpy as np
import torch
from ldif.torch import sif

    self.assertAlmostEqual(shape._rotations[0, 4, 2].cpu().numpy(), -0.0532, places=4)

  def test_flatten_unflatten(self):
    sif_path = os.path.join(TEST_DATA_DIR, 'b831f60f211435df5bbc861d0124304c.txt')
    shape = sif.Sif.from_file(sif_path)
    flattened, symc = shape.to_flat_tensor()
    unflattened = sif.Sif.from_flat_tensor(flattened, symc)
    self._ensure_sifs_equal(shape, unflattened)

  def test_batching(self):
    flattened_shapes = []
    test_names = ['b831f60f211435df5bbc861d0124304c',
        'b7eefc4c25dd9e49238581dd5a8af82c']
    paths = [os.path.join(TEST_DATA_DIR, name + '.txt') for name in test_names]
    for path in paths:
      shape = sif.Sif.from_file(path)
      flattened_shapes.append(shape.to_flat_tensor())
    flats = [x[0] for x in flattened_shapes]
    symcs = [x[1] for x in flattened_shapes]

    for symc in symcs:
      self.assertEqual(symc, symcs[0])

    batched_tensor = torch.cat(flats, dim=0)
    batched_sif = sif.Sif.from_flat_tensor(batched_tensor, symcs[0])
    self.assertEqual(batched_sif.bs, 2)
    auto_batched_sif = sif.Sif.from_file(paths)
    self._ensure_sifs_equal(batched_sif, auto_batched_sif, -1)

  def _test_rbf_evaluation(self):

    sif_path = os.path.join(TEST_DATA_DIR, 'b831f60f211435df5bbc861d0124304c.txt')