# 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
    def verify_bins_intra_periodic(self, bins):
        neighbor_set = set([tuple(index) for index in bins.neighbor_indexes])
        self.assertEqual(len(neighbor_set), len(bins.neighbor_indexes))

        for key0, bin0 in bins:
            encountered = set([])
            for key1, bin1 in bins.iter_surrounding(key0):
                frac_key1 = bins.integer_cell.to_fractional(key1)
                assert frac_key1.max() < 0.5, str(key1) + str(frac_key1)
                assert key1 not in encountered, str(key0) + str(key1)
                encountered.add(key1)

    @pytest.mark.xfail
    def verify_bins_inter_periodic(self, bins0, bins1):
        for bins in bins0, bins1:
            neighbor_set = set([tuple(index) for index in bins.neighbor_indexes])
            self.assertEqual(len(neighbor_set), len(bins.neighbor_indexes))

        for key0, bin0 in bins0:
            encountered = set([])
            for key1, bin1 in bins1.iter_surrounding(key0):
                frac_key1 = bins0.integer_cell.to_fractional(key1)
                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]):

# 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

    def verify_bins_intra_periodic(self, bins):
        neighbor_set = set([tuple(index) for index in bins.neighbor_indexes])
        self.assertEqual(len(neighbor_set), len(bins.neighbor_indexes))

        for key0, bin0 in bins:
            encountered = set([])
            for key1, bin1 in bins.iter_surrounding(key0):
                frac_key1 = bins.integer_cell.to_fractional(key1)
                assert frac_key1.max() < 0.5, str(key1) + str(frac_key1)
                assert key1 not in encountered, str(key0) + str(key1)
                encountered.add(key1)

    @pytest.mark.xfail
    def verify_bins_inter_periodic(self, bins0, bins1):
        for bins in bins0, bins1:
            neighbor_set = set([tuple(index) for index in bins.neighbor_indexes])
            self.assertEqual(len(neighbor_set), len(bins.neighbor_indexes))

        for key0, bin0 in bins0:
            encountered = set([])
            for key1, bin1 in bins1.iter_surrounding(key0):
                frac_key1 = bins0.integer_cell.to_fractional(key1)
                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)