def test_age_classes_consecutive_open_range_min(): myAgeClasses = [ AgeClass(1900, 1918), AgeClass(None, 1933), # open range in between! AgeClass(1934, None) ] assert AgeClass.are_age_classes_consecutive(myAgeClasses) == False
def test_age_classes_consecutive_overlap(): myAgeClasses = [ AgeClass(1900, 1918), AgeClass(1919, 1925), AgeClass(1922, None) # overlap here! ] assert AgeClass.are_age_classes_consecutive(myAgeClasses) == False
def test_age_classes_consecutive_ok_fully_defined(): myAgeClasses = [ AgeClass(1900, 1918), AgeClass(1919, 1925), AgeClass(1926, 1933) ] assert AgeClass.are_age_classes_consecutive(myAgeClasses)
def test_age_classes_consecutive_ok(): myAgeClasses = [ AgeClass(None, 1918), AgeClass(1919, 1925), AgeClass(1926, None) ] assert AgeClass.are_age_classes_consecutive(myAgeClasses)
def test_age_classes_consecutive_gap(): myAgeClasses = [ AgeClass(None, 1918), AgeClass(1919, 1925), AgeClass(1926, 1933), AgeClass(1935, None) # it's not consecutive here, gap of 2 years ] assert AgeClass.are_age_classes_consecutive(myAgeClasses) == False
def _init_age_class_lookup(self) -> Dict[AgeClass, str]: ageclass_archetype = {} for archetype_shortname, archetype_cfg in self._cfg[ "ARCHETYPES"].items(): arch_uri = archetype_cfg["URI"] age_class = self._constr_reader.get_age_class_of_archetype( arch_uri) ageclass_archetype[age_class] = arch_uri if not AgeClass.are_age_classes_consecutive( list(ageclass_archetype.keys())): logging.error( "age classes retrieved from database are not consecutive. check min/max age of the used age classes so that there are neighter gaps nor overlaps." ) return ageclass_archetype