def test_findNearestValue(self): searchList = [0.1, 0.2, 0.25, 0.35, 0.4] searchValue = 0.225 self.assertEqual(utils.findNearestValue(searchList, searchValue), 0.2) searchValue = 0.226 self.assertEqual(utils.findNearestValue(searchList, searchValue), 0.25) searchValue = 0.0 self.assertEqual(utils.findNearestValue(searchList, searchValue), 0.1) searchValue = 10 self.assertEqual(utils.findNearestValue(searchList, searchValue), 0.4)
def _create_anl_energies_with_group_energies(group_energy_bounds): """Set energy group bounds to the nearest ultra-fine group boundaries.""" ufgEnergies = _create_anl_energies_with_group_lethargies(itertools.repeat(1, 2082)) modifiedEnergyBounds = [] for energyBound in group_energy_bounds: modifiedEnergyBounds.append(utils.findNearestValue(ufgEnergies, energyBound)) return modifiedEnergyBounds
def _create_multigroup_structures_on_finegroup_energies( multigroup_energy_bounds, finegroup_energy_bounds): """Set energy group bounds to the nearest ultra-fine group boundaries.""" modifiedEnergyBounds = set() modifiedEnergyBounds.add(max(finegroup_energy_bounds)) for energyBound in multigroup_energy_bounds[1:]: modifiedEnergyBounds.add( utils.findNearestValue(finegroup_energy_bounds, energyBound)) return sorted(modifiedEnergyBounds, reverse=True)