# Path: molmod/periodic.py
# class AtomInfo(object):
# class PeriodicData(object):
#     def __init__(self):
#         def append_convertor(word):
#     def _add_atom_info(self, atom_info):
#     def __len__(self):
#     def __getitem__(self, index):
#     def iter_numbers(self):
# 
# Path: molmod/test/test_unit_cells.py
# def get_random_uc(scale=2, num_active=3, min_spacing=0.1):
#     while True:
#         active = np.random.randint(0, 2, 3).astype(bool)
#         if active.sum() == num_active:
#             break
#     while True:
#         try:
#             result = UnitCell(np.random.uniform(-scale, scale, (3, 3)), active)
#             if not active.any() or result.spacings[active].min() >= min_spacing:
#                 return result
#         except ValueError:
#             pass


import unittest
import numpy as np
import pkg_resources
import pytest
from molmod import *
from molmod.io import *
from molmod.periodic import periodic
from molmod.test.test_unit_cells import get_random_uc
                assert frac_key1.max() < 0.5, str(key1) + str(frac_key1)
                assert key1 not in encountered, str(key0) + str(key1)
                encountered.add(key1)

    def verify_distances_intra(self, coordinates, cutoff, distances, unit_cell=None):
        def iter_pairs():
            for index0, coord0 in enumerate(coordinates):
                for index1, coord1 in enumerate(coordinates[:index0]):
                    yield (index0, coord0), (index1, coord1)
        self.verify_distances(iter_pairs, cutoff, distances, frozenset, unit_cell)

    def verify_distances_inter(self, coordinates0, coordinates1, cutoff, distances, unit_cell=None):
        def iter_pairs():
            for index0, coord0 in enumerate(coordinates0):
                for index1, coord1 in enumerate(coordinates1):
                    yield (index0, coord0), (index1, coord1)
        self.verify_distances(iter_pairs, cutoff, distances, tuple, unit_cell)

    def test_distances_intra_lau(self):
        coordinates = XYZFile(pkg_resources.resource_filename("molmod", "data/test/lau.xyz")).geometries[0]
        cutoff = periodic.max_radius*2
        distances = [
            (frozenset([i0, i1]), distance)
            for i0, i1, delta, distance
            in PairSearchIntra(coordinates, cutoff)
        ]
        self.verify_distances_intra(coordinates, cutoff, distances)

    def test_distances_intra_lau_periodic(self):
        coordinates = XYZFile(pkg_resources.resource_filename("molmod", "data/test/lau.xyz")).geometries[0]

# Path: molmod/periodic.py
# class AtomInfo(object):
# class PeriodicData(object):
#     def __init__(self):
#         def append_convertor(word):
#     def _add_atom_info(self, atom_info):
#     def __len__(self):
#     def __getitem__(self, index):
#     def iter_numbers(self):
# 
# Path: molmod/test/test_unit_cells.py
# def get_random_uc(scale=2, num_active=3, min_spacing=0.1):
#     while True:
#         active = np.random.randint(0, 2, 3).astype(bool)
#         if active.sum() == num_active:
#             break
#     while True:
#         try:
#             result = UnitCell(np.random.uniform(-scale, scale, (3, 3)), active)
#             if not active.any() or result.spacings[active].min() >= min_spacing:
#                 return result
#         except ValueError:
#             pass


# Path: molmod/test/test_binning.py
import unittest
import numpy as np
import pkg_resources
import pytest
from molmod import *
from molmod.io import *
from molmod.periodic import periodic
from molmod.test.test_unit_cells import get_random_uc

                assert frac_key1.max() < 0.5, str(key1) + str(frac_key1)
                assert key1 not in encountered, str(key0) + str(key1)
                encountered.add(key1)

    def verify_distances_intra(self, coordinates, cutoff, distances, unit_cell=None):
        def iter_pairs():
            for index0, coord0 in enumerate(coordinates):
                for index1, coord1 in enumerate(coordinates[:index0]):
                    yield (index0, coord0), (index1, coord1)
        self.verify_distances(iter_pairs, cutoff, distances, frozenset, unit_cell)

    def verify_distances_inter(self, coordinates0, coordinates1, cutoff, distances, unit_cell=None):
        def iter_pairs():
            for index0, coord0 in enumerate(coordinates0):
                for index1, coord1 in enumerate(coordinates1):
                    yield (index0, coord0), (index1, coord1)
        self.verify_distances(iter_pairs, cutoff, distances, tuple, unit_cell)

    def test_distances_intra_lau(self):
        coordinates = XYZFile(pkg_resources.resource_filename("molmod", "data/test/lau.xyz")).geometries[0]
        cutoff = periodic.max_radius*2
        distances = [
            (frozenset([i0, i1]), distance)
            for i0, i1, delta, distance
            in PairSearchIntra(coordinates, cutoff)
        ]
        self.verify_distances_intra(coordinates, cutoff, distances)

    def test_distances_intra_lau_periodic(self):
        coordinates = XYZFile(pkg_resources.resource_filename("molmod", "data/test/lau.xyz")).geometries[0]

        cutoff = periodic.max_radius*2