From 4edf8e1c6c5eb39fc231d5dd9db5e5588f1453e0 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Fri, 26 Feb 2021 21:26:24 +0100 Subject: [PATCH 01/21] better yaml error description for type mismatch --- src/YAML_types.f90 | 72 +++++++++++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/src/YAML_types.f90 b/src/YAML_types.f90 index b71261d9c..92e2a41ba 100644 --- a/src/YAML_types.f90 +++ b/src/YAML_types.f90 @@ -302,16 +302,22 @@ end subroutine tScalar_assign__ !-------------------------------------------------------------------------------------------------- !> @brief Type guard, guarantee scalar !-------------------------------------------------------------------------------------------------- -function tNode_asScalar(self) result(scalar) +function tNode_asScalar(self,parent_node) result(scalar) - class(tNode), intent(in), target :: self - class(tScalar), pointer :: scalar + class(tNode), intent(in), target :: self + class(tNode), intent(in), optional :: parent_node + class(tScalar), pointer :: scalar select type(self) class is(tScalar) scalar => self class default - call IO_error(706,ext_msg='Expected "scalar"') + if (present(parent_node)) write(6,'(a)') parent_node%asFormattedString() + if(self%isDict()) then + call IO_error(706,ext_msg='Expected "scalar", found "dict"') + else + call IO_error(706,ext_msg='Expected "scalar", found "list"') + endif end select end function tNode_asScalar @@ -320,16 +326,22 @@ end function tNode_asScalar !-------------------------------------------------------------------------------------------------- !> @brief Type guard, guarantee list !-------------------------------------------------------------------------------------------------- -function tNode_asList(self) result(list) +function tNode_asList(self,parent_node) result(list) - class(tNode), intent(in), target :: self - class(tList), pointer :: list + class(tNode), intent(in), target :: self + class(tNode), intent(in),optional :: parent_node + class(tList), pointer :: list select type(self) class is(tList) list => self class default - call IO_error(706,ext_msg='Expected "list"') + if (present(parent_node)) write(6,'(a)') parent_node%asFormattedString() + if(self%isScalar()) then + call IO_error(706,ext_msg='Expected "list", found "scalar"') + else + call IO_error(706,ext_msg='Expected "list", found "dict"') + endif end select end function tNode_asList @@ -340,14 +352,19 @@ end function tNode_asList !-------------------------------------------------------------------------------------------------- function tNode_asDict(self) result(dict) - class(tNode), intent(in), target :: self - class(tDict), pointer :: dict + class(tNode), intent(in), target :: self + class(tDict), pointer :: dict select type(self) class is(tDict) dict => self class default - call IO_error(706,ext_msg='Expected "dict"') + write(6,'(a)') self%asFormattedString() + if(self%isScalar()) then + call IO_error(706,ext_msg='Expected "dict", found "scalar"') + else + call IO_error(706,ext_msg='Expected "dict", found "list"') + endif end select end function tNode_asDict @@ -444,7 +461,7 @@ function tNode_get_byIndex_asFloat(self,i) result(nodeAsFloat) type(tScalar), pointer :: scalar node => self%get(i) - scalar => node%asScalar() + scalar => node%asScalar(self) nodeAsFloat = scalar%asFloat() end function tNode_get_byIndex_asFloat @@ -463,7 +480,7 @@ function tNode_get_byIndex_asInt(self,i) result(nodeAsInt) type(tScalar), pointer :: scalar node => self%get(i) - scalar => node%asScalar() + scalar => node%asScalar(self) nodeAsInt = scalar%asInt() end function tNode_get_byIndex_asInt @@ -482,7 +499,7 @@ function tNode_get_byIndex_asBool(self,i) result(nodeAsBool) type(tScalar), pointer :: scalar node => self%get(i) - scalar => node%asScalar() + scalar => node%asScalar(self) nodeAsBool = scalar%asBool() end function tNode_get_byIndex_asBool @@ -501,7 +518,7 @@ function tNode_get_byIndex_asString(self,i) result(nodeAsString) type(tScalar), pointer :: scalar node => self%get(i) - scalar => node%asScalar() + scalar => node%asScalar(self) nodeAsString = scalar%asString() end function tNode_get_byIndex_asString @@ -520,7 +537,7 @@ function tNode_get_byIndex_asFloats(self,i) result(nodeAsFloats) class(tList), pointer :: list node => self%get(i) - list => node%asList() + list => node%asList(self) nodeAsFloats = list%asFloats() end function tNode_get_byIndex_asFloats @@ -539,7 +556,7 @@ function tNode_get_byIndex_asInts(self,i) result(nodeAsInts) class(tList), pointer :: list node => self%get(i) - list => node%asList() + list => node%asList(self) nodeAsInts = list%asInts() end function tNode_get_byIndex_asInts @@ -558,7 +575,7 @@ function tNode_get_byIndex_asBools(self,i) result(nodeAsBools) class(tList), pointer :: list node => self%get(i) - list => node%asList() + list => node%asList(self) nodeAsBools = list%asBools() end function tNode_get_byIndex_asBools @@ -577,7 +594,7 @@ function tNode_get_byIndex_asStrings(self,i) result(nodeAsStrings) type(tList), pointer :: list node => self%get(i) - list => node%asList() + list => node%asList(self) nodeAsStrings = list%asStrings() end function tNode_get_byIndex_asStrings @@ -699,10 +716,11 @@ function tNode_get_byKey_asFloat(self,k,defaultVal) result(nodeAsFloat) class(tNode), pointer :: node type(tScalar), pointer :: scalar + character(len=:), allocatable :: str if(self%contains(k)) then node => self%get(k) - scalar => node%asScalar() + scalar => node%asScalar(self) nodeAsFloat = scalar%asFloat() elseif(present(defaultVal)) then nodeAsFloat = defaultVal @@ -728,7 +746,7 @@ function tNode_get_byKey_asInt(self,k,defaultVal) result(nodeAsInt) if(self%contains(k)) then node => self%get(k) - scalar => node%asScalar() + scalar => node%asScalar(self) nodeAsInt = scalar%asInt() elseif(present(defaultVal)) then nodeAsInt = defaultVal @@ -754,7 +772,7 @@ function tNode_get_byKey_asBool(self,k,defaultVal) result(nodeAsBool) if(self%contains(k)) then node => self%get(k) - scalar => node%asScalar() + scalar => node%asScalar(self) nodeAsBool = scalar%asBool() elseif(present(defaultVal)) then nodeAsBool = defaultVal @@ -780,7 +798,7 @@ function tNode_get_byKey_asString(self,k,defaultVal) result(nodeAsString) if(self%contains(k)) then node => self%get(k) - scalar => node%asScalar() + scalar => node%asScalar(self) nodeAsString = scalar%asString() elseif(present(defaultVal)) then nodeAsString = defaultVal @@ -808,7 +826,7 @@ function tNode_get_byKey_asFloats(self,k,defaultVal,requiredSize) result(nodeAsF if(self%contains(k)) then node => self%get(k) - list => node%asList() + list => node%asList(self) nodeAsFloats = list%asFloats() elseif(present(defaultVal)) then nodeAsFloats = defaultVal @@ -839,7 +857,7 @@ function tNode_get_byKey_asInts(self,k,defaultVal,requiredSize) result(nodeAsInt if(self%contains(k)) then node => self%get(k) - list => node%asList() + list => node%asList(self) nodeAsInts = list%asInts() elseif(present(defaultVal)) then nodeAsInts = defaultVal @@ -869,7 +887,7 @@ function tNode_get_byKey_asBools(self,k,defaultVal) result(nodeAsBools) if(self%contains(k)) then node => self%get(k) - list => node%asList() + list => node%asList(self) nodeAsBools = list%asBools() elseif(present(defaultVal)) then nodeAsBools = defaultVal @@ -895,7 +913,7 @@ function tNode_get_byKey_asStrings(self,k,defaultVal) result(nodeAsStrings) if(self%contains(k)) then node => self%get(k) - list => node%asList() + list => node%asList(self) nodeAsStrings = list%asStrings() elseif(present(defaultVal)) then nodeAsStrings = defaultVal From c0620037a166c3bfbf4428a58063cdc43bbab6e7 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Sat, 27 Feb 2021 13:14:53 -0500 Subject: [PATCH 02/21] simplified tNode_get_byKey_asIndex and tNode_getKey_byIndex; syntax polishing --- src/YAML_types.f90 | 74 ++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 42 deletions(-) diff --git a/src/YAML_types.f90 b/src/YAML_types.f90 index 92e2a41ba..342440b34 100644 --- a/src/YAML_types.f90 +++ b/src/YAML_types.f90 @@ -72,7 +72,7 @@ module YAML_types getKey => tNode_getKey_byIndex procedure :: & contains => tNode_contains - + generic :: & get => tNode_get_byIndex, & tNode_get_byKey @@ -157,7 +157,7 @@ module YAML_types emptyDict type(tList), target, public :: & emptyList - + abstract interface recursive function asFormattedString(self,indent) @@ -179,7 +179,7 @@ module YAML_types public :: & YAML_types_init, & - output_asStrings, & !ToDo: Hack for GNU. Remove later + output_asStrings, & !ToDo: Hack for GNU. Remove later assignment(=) contains @@ -435,13 +435,12 @@ function tNode_get_byIndex(self,i) result(node) integer :: j self_ => self%asList() + item => self_%first + if(i < 1 .or. i > self_%length) call IO_error(150,ext_msg='tNode_get_byIndex') - j = 1 - item => self_%first - do while(j item%next - j = j + 1 enddo node => item%node @@ -615,14 +614,10 @@ function tNode_getKey_byIndex(self,i) result(key) dict => self%asDict() item => dict%first - do j = 1, dict%length - if(j == i) then - key = item%key - exit - else - item => item%next - endif + do j = 1, min(i,dict%length)-1 + item => item%next enddo + key = item%key end function tNode_getKey_byIndex @@ -630,7 +625,7 @@ end function tNode_getKey_byIndex !------------------------------------------------------------------------------------------------- !> @brief Checks if a given key/item is present in the dict/list !------------------------------------------------------------------------------------------------- -function tNode_contains(self,k) result(exists) +function tNode_contains(self,k) result(exists) class(tNode), intent(in), target :: self character(len=*), intent(in) :: k @@ -641,18 +636,18 @@ function tNode_contains(self,k) result(exists) type(tDict), pointer :: dict exists = .false. - if(self%isDict()) then + if (self%isDict()) then dict => self%asDict() do j=1, dict%length - if(dict%getKey(j) == k) then + if (dict%getKey(j) == k) then exists = .true. return endif enddo - elseif(self%isList()) then + elseif (self%isList()) then list => self%asList() - do j =1, list%length - if(list%get_asString(j) == k) then + do j=1, list%length + if (list%get_asString(j) == k) then exists = .true. return endif @@ -681,7 +676,7 @@ function tNode_get_byKey(self,k,defaultVal) result(node) found = present(defaultVal) if(found) node => defaultVal - + self_ => self%asDict() j = 1 @@ -694,7 +689,7 @@ function tNode_get_byKey(self,k,defaultVal) result(node) item => item%next j = j + 1 enddo - + if (.not. found) then call IO_error(143,ext_msg=k) else @@ -911,11 +906,11 @@ function tNode_get_byKey_asStrings(self,k,defaultVal) result(nodeAsStrings) class(tNode), pointer :: node type(tList), pointer :: list - if(self%contains(k)) then + if (self%contains(k)) then node => self%get(k) list => node%asList(self) nodeAsStrings = list%asStrings() - elseif(present(defaultVal)) then + elseif (present(defaultVal)) then nodeAsStrings = defaultVal else call IO_error(143,ext_msg=k) @@ -943,7 +938,7 @@ function output_asStrings(self) result(output) !ToDo: SR: Rem end function output_asStrings - + !-------------------------------------------------------------------------------------------------- !> @brief Returns the index of a key in a dictionary @@ -954,25 +949,20 @@ function tNode_get_byKey_asIndex(self,key) result(keyIndex) character(len=*), intent(in) :: key integer :: keyIndex - integer :: i type(tDict), pointer :: dict type(tItem), pointer :: item dict => self%asDict() item => dict%first - keyIndex = -1 - do i = 1, dict%length - if(key == item%key) then - keyIndex = i - exit - else - item => item%next - endif + keyIndex = 1 + do while (associated(item%next) .and. item%key /= key) + item => item%next + keyIndex = keyIndex+1 enddo - if(keyIndex == -1) call IO_error(140,ext_msg=key) + if (item%key /= key) call IO_error(140,ext_msg=key) + - end function tNode_get_byKey_asIndex @@ -1003,7 +993,7 @@ recursive function tList_asFormattedString(self,indent) result(str) integer :: i, indent_ str = '' - if(present(indent)) then + if (present(indent)) then indent_ = indent else indent_ = 0 @@ -1011,7 +1001,7 @@ recursive function tList_asFormattedString(self,indent) result(str) item => self%first do i = 1, self%length - if(i /= 1) str = str//repeat(' ',indent_) + if (i /= 1) str = str//repeat(' ',indent_) str = str//'- '//item%node%asFormattedString(indent_+2) item => item%next end do @@ -1032,7 +1022,7 @@ recursive function tDict_asFormattedString(self,indent) result(str) integer :: i, indent_ str = '' - if(present(indent)) then + if (present(indent)) then indent_ = indent else indent_ = 0 @@ -1040,7 +1030,7 @@ recursive function tDict_asFormattedString(self,indent) result(str) item => self%first do i = 1, self%length - if(i /= 1) str = str//repeat(' ',indent_) + if (i /= 1) str = str//repeat(' ',indent_) select type(node_1 =>item%node) class is(tScalar) str = str//trim(item%key)//': '//item%node%asFormattedString(indent_+len_trim(item%key)+2) @@ -1254,7 +1244,7 @@ subroutine tDict_set(self,key,node) if (item%key == key) exit item => item%next end do searchExisting - if (.not. item%key == key) then + if (item%key /= key) then allocate(item%next) item => item%next self%length = self%length + 1 @@ -1288,7 +1278,7 @@ recursive subroutine tItem_finalize(self) type(tItem),intent(inout) :: self deallocate(self%node) - if(associated(self%next)) deallocate(self%next) + if (associated(self%next)) deallocate(self%next) end subroutine tItem_finalize From fd24c9c2a193972ea17e94ba848d87d2aeb43028 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Sat, 27 Feb 2021 13:22:46 -0500 Subject: [PATCH 03/21] simplified tNode_get_byKey_asIndex and tNode_getKey_byIndex==>get_byIndex_asKey; syntax polishing --- src/YAML_types.f90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/YAML_types.f90 b/src/YAML_types.f90 index 342440b34..7a741a5c8 100644 --- a/src/YAML_types.f90 +++ b/src/YAML_types.f90 @@ -67,9 +67,9 @@ module YAML_types procedure :: & tNode_get_byKey_asStrings => tNode_get_byKey_asStrings procedure :: & - getIndex => tNode_get_byKey_asIndex + getKey => tNode_get_byIndex_asKey procedure :: & - getKey => tNode_getKey_byIndex + getIndex => tNode_get_byKey_asIndex procedure :: & contains => tNode_contains @@ -602,7 +602,7 @@ end function tNode_get_byIndex_asStrings !-------------------------------------------------------------------------------------------------- !> @brief Returns the key in a dictionary as a string !-------------------------------------------------------------------------------------------------- -function tNode_getKey_byIndex(self,i) result(key) +function tNode_get_byIndex_asKey(self,i) result(key) class(tNode), intent(in), target :: self integer, intent(in) :: i @@ -619,7 +619,7 @@ function tNode_getKey_byIndex(self,i) result(key) enddo key = item%key -end function tNode_getKey_byIndex +end function tNode_get_byIndex_asKey !------------------------------------------------------------------------------------------------- From 5d51da11e527615c5a7f3adfdf9ff76c2e83ac3a Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Tue, 2 Mar 2021 18:41:26 +0100 Subject: [PATCH 04/21] trying new structure to have better yaml error messages --- src/YAML_types.f90 | 175 +++++++++++++++++++++++++++++++-------------- 1 file changed, 123 insertions(+), 52 deletions(-) diff --git a/src/YAML_types.f90 b/src/YAML_types.f90 index b71261d9c..a6b9d9740 100644 --- a/src/YAML_types.f90 +++ b/src/YAML_types.f90 @@ -310,8 +310,6 @@ function tNode_asScalar(self) result(scalar) select type(self) class is(tScalar) scalar => self - class default - call IO_error(706,ext_msg='Expected "scalar"') end select end function tNode_asScalar @@ -328,8 +326,6 @@ function tNode_asList(self) result(list) select type(self) class is(tList) list => self - class default - call IO_error(706,ext_msg='Expected "list"') end select end function tNode_asList @@ -346,8 +342,6 @@ function tNode_asDict(self) result(dict) select type(self) class is(tDict) dict => self - class default - call IO_error(706,ext_msg='Expected "dict"') end select end function tNode_asDict @@ -417,7 +411,12 @@ function tNode_get_byIndex(self,i) result(node) class(tItem), pointer :: item integer :: j - self_ => self%asList() + if(self%isList()) then + self_ => self%asList() + else + call IO_error(706,ext_msg='Expected List') + endif + if(i < 1 .or. i > self_%length) call IO_error(150,ext_msg='tNode_get_byIndex') j = 1 @@ -444,8 +443,12 @@ function tNode_get_byIndex_asFloat(self,i) result(nodeAsFloat) type(tScalar), pointer :: scalar node => self%get(i) - scalar => node%asScalar() - nodeAsFloat = scalar%asFloat() + if(node%isScalar()) then + scalar => node%asScalar() + nodeAsFloat = scalar%asFloat() + else + call IO_error(706,ext_msg='Expected Scalar') + endif end function tNode_get_byIndex_asFloat @@ -463,8 +466,12 @@ function tNode_get_byIndex_asInt(self,i) result(nodeAsInt) type(tScalar), pointer :: scalar node => self%get(i) - scalar => node%asScalar() - nodeAsInt = scalar%asInt() + if(node%isScalar()) then + scalar => node%asScalar() + nodeAsInt = scalar%asInt() + else + call IO_error(706,ext_msg='Expected Scalar') + endif end function tNode_get_byIndex_asInt @@ -482,8 +489,12 @@ function tNode_get_byIndex_asBool(self,i) result(nodeAsBool) type(tScalar), pointer :: scalar node => self%get(i) - scalar => node%asScalar() - nodeAsBool = scalar%asBool() + if(node%isScalar()) then + scalar => node%asScalar() + nodeAsBool = scalar%asBool() + else + call IO_error(706,ext_msg='Expected Scalar') + endif end function tNode_get_byIndex_asBool @@ -501,8 +512,12 @@ function tNode_get_byIndex_asString(self,i) result(nodeAsString) type(tScalar), pointer :: scalar node => self%get(i) - scalar => node%asScalar() - nodeAsString = scalar%asString() + if(node%isScalar()) then + scalar => node%asScalar() + nodeAsString = scalar%asString() + else + call IO_error(706,ext_msg='Expected Scalar') + endif end function tNode_get_byIndex_asString @@ -520,8 +535,12 @@ function tNode_get_byIndex_asFloats(self,i) result(nodeAsFloats) class(tList), pointer :: list node => self%get(i) - list => node%asList() - nodeAsFloats = list%asFloats() + if(node%isList()) then + list => node%asList() + nodeAsFloats = list%asFloats() + else + call IO_error(706,ext_msg='Expected list') + endif end function tNode_get_byIndex_asFloats @@ -539,8 +558,12 @@ function tNode_get_byIndex_asInts(self,i) result(nodeAsInts) class(tList), pointer :: list node => self%get(i) - list => node%asList() - nodeAsInts = list%asInts() + if(node%isList()) then + list => node%asList() + nodeAsInts = list%asInts() + else + call IO_error(706,ext_msg='Expected list') + endif end function tNode_get_byIndex_asInts @@ -558,8 +581,12 @@ function tNode_get_byIndex_asBools(self,i) result(nodeAsBools) class(tList), pointer :: list node => self%get(i) - list => node%asList() - nodeAsBools = list%asBools() + if(node%isList()) then + list => node%asList() + nodeAsBools = list%asBools() + else + call IO_error(706,ext_msg='Expected list') + endif end function tNode_get_byIndex_asBools @@ -577,8 +604,12 @@ function tNode_get_byIndex_asStrings(self,i) result(nodeAsStrings) type(tList), pointer :: list node => self%get(i) - list => node%asList() - nodeAsStrings = list%asStrings() + if(node%isList()) then + list => node%asList() + nodeAsStrings = list%asStrings() + else + call IO_error(706,ext_msg='Expected list') + endif end function tNode_get_byIndex_asStrings @@ -596,16 +627,20 @@ function tNode_getKey_byIndex(self,i) result(key) type(tDict), pointer :: dict type(tItem), pointer :: item - dict => self%asDict() - item => dict%first - do j = 1, dict%length - if(j == i) then - key = item%key - exit - else - item => item%next - endif - enddo + if(self%isDict()) then + dict => self%asDict() + item => dict%first + do j = 1, dict%length + if(j == i) then + key = item%key + exit + else + item => item%next + endif + enddo + else + call IO_error(706,ext_msg='Expected dict') + endif end function tNode_getKey_byIndex @@ -641,7 +676,7 @@ function tNode_contains(self,k) result(exists) endif enddo else - call IO_error(706,ext_msg='Expected "list" or "dict"') + call IO_error(706,ext_msg='Expected "list" or "dict"') endif end function tNode_contains @@ -664,8 +699,12 @@ function tNode_get_byKey(self,k,defaultVal) result(node) found = present(defaultVal) if(found) node => defaultVal - - self_ => self%asDict() + + if(self%isDict()) then + self_ => self%asDict() + else + call IO_error(706,ext_msg='Expected Dict for key '//k) + endif j = 1 item => self_%first @@ -702,8 +741,12 @@ function tNode_get_byKey_asFloat(self,k,defaultVal) result(nodeAsFloat) if(self%contains(k)) then node => self%get(k) - scalar => node%asScalar() - nodeAsFloat = scalar%asFloat() + if(node%isScalar()) then + scalar => node%asScalar() + nodeAsFloat = scalar%asFloat() + else + call IO_error(706,ext_msg='Expected Scalar for key '//k) + endif elseif(present(defaultVal)) then nodeAsFloat = defaultVal else @@ -728,8 +771,12 @@ function tNode_get_byKey_asInt(self,k,defaultVal) result(nodeAsInt) if(self%contains(k)) then node => self%get(k) - scalar => node%asScalar() - nodeAsInt = scalar%asInt() + if(node%isScalar()) then + scalar => node%asScalar() + nodeAsInt = scalar%asInt() + else + call IO_error(706,ext_msg='Expected Scalar for key '//k) + endif elseif(present(defaultVal)) then nodeAsInt = defaultVal else @@ -754,8 +801,12 @@ function tNode_get_byKey_asBool(self,k,defaultVal) result(nodeAsBool) if(self%contains(k)) then node => self%get(k) - scalar => node%asScalar() - nodeAsBool = scalar%asBool() + if(node%isScalar()) then + scalar => node%asScalar() + nodeAsBool = scalar%asBool() + else + call IO_error(706,ext_msg='Expected Scalar for key '//k) + endif elseif(present(defaultVal)) then nodeAsBool = defaultVal else @@ -780,8 +831,12 @@ function tNode_get_byKey_asString(self,k,defaultVal) result(nodeAsString) if(self%contains(k)) then node => self%get(k) - scalar => node%asScalar() - nodeAsString = scalar%asString() + if(node%isScalar()) then + scalar => node%asScalar() + nodeAsString = scalar%asString() + else + call IO_error(706,ext_msg='Expected Scalar for key '//k) + endif elseif(present(defaultVal)) then nodeAsString = defaultVal else @@ -808,8 +863,12 @@ function tNode_get_byKey_asFloats(self,k,defaultVal,requiredSize) result(nodeAsF if(self%contains(k)) then node => self%get(k) - list => node%asList() - nodeAsFloats = list%asFloats() + if(node%isList()) then + list => node%asList() + nodeAsFloats = list%asFloats() + else + call IO_error(706,ext_msg='Expected list for key '//k) + endif elseif(present(defaultVal)) then nodeAsFloats = defaultVal else @@ -839,8 +898,12 @@ function tNode_get_byKey_asInts(self,k,defaultVal,requiredSize) result(nodeAsInt if(self%contains(k)) then node => self%get(k) - list => node%asList() - nodeAsInts = list%asInts() + if(node%isList()) then + list => node%asList() + nodeAsInts = list%asInts() + else + call IO_error(706,ext_msg='Expected list for key '//k) + endif elseif(present(defaultVal)) then nodeAsInts = defaultVal else @@ -869,8 +932,12 @@ function tNode_get_byKey_asBools(self,k,defaultVal) result(nodeAsBools) if(self%contains(k)) then node => self%get(k) - list => node%asList() - nodeAsBools = list%asBools() + if(node%isList())then + list => node%asList() + nodeAsBools = list%asBools() + else + call IO_error(706,ext_msg='Expected list for key '//k) + endif elseif(present(defaultVal)) then nodeAsBools = defaultVal else @@ -895,8 +962,12 @@ function tNode_get_byKey_asStrings(self,k,defaultVal) result(nodeAsStrings) if(self%contains(k)) then node => self%get(k) - list => node%asList() - nodeAsStrings = list%asStrings() + if(node%isList()) then + list => node%asList() + nodeAsStrings = list%asStrings() + else + call IO_error(706,ext_msg='Expected list for key '//k) + endif elseif(present(defaultVal)) then nodeAsStrings = defaultVal else From 03d54be58a073f27ca7544af45aebb2d6a0fa16e Mon Sep 17 00:00:00 2001 From: Test User Date: Mon, 29 Mar 2021 08:21:53 +0200 Subject: [PATCH 05/21] [skip ci] updated version information after successful test of v3.0.0-alpha2-670-ge6143f6ee --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 6a9c51c19..445e4606c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-662-gb36ff26cb +v3.0.0-alpha2-670-ge6143f6ee From aa5cd76d33c1e4728bdcc454b5bb1312061cf8a3 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Mon, 29 Mar 2021 13:47:23 +0200 Subject: [PATCH 06/21] function not needed --- src/YAML_types.f90 | 345 ++++++++++++++++++++------------------------- 1 file changed, 154 insertions(+), 191 deletions(-) diff --git a/src/YAML_types.f90 b/src/YAML_types.f90 index 9c5214164..5ee9325b4 100644 --- a/src/YAML_types.f90 +++ b/src/YAML_types.f90 @@ -20,16 +20,10 @@ module YAML_types procedure(asFormattedString), deferred :: asFormattedString procedure :: & asScalar => tNode_asScalar - procedure :: & - isScalar => tNode_isScalar procedure :: & asList => tNode_asList - procedure :: & - isList => tNode_isList procedure :: & asDict => tNode_asDict - procedure :: & - isDict => tNode_isDict procedure :: & tNode_get_byIndex => tNode_get_byIndex procedure :: & @@ -347,57 +341,6 @@ function tNode_asDict(self) result(dict) end function tNode_asDict -!-------------------------------------------------------------------------------------------------- -!> @brief Checks if node is a scalar -!-------------------------------------------------------------------------------------------------- -function tNode_isScalar(self) result(scalar) - - class(tNode), intent(in), target :: self - logical :: scalar - - scalar = .false. - select type(self) - class is(tScalar) - scalar = .true. - end select - -end function tNode_isScalar - - -!-------------------------------------------------------------------------------------------------- -!> @brief Checks if node is a list -!-------------------------------------------------------------------------------------------------- -function tNode_isList(self) result(list) - - class(tNode), intent(in), target :: self - logical :: list - - list = .false. - select type(self) - class is(tList) - list = .true. - end select - -end function tNode_isList - - -!-------------------------------------------------------------------------------------------------- -!> @brief Checks if node is a dict -!-------------------------------------------------------------------------------------------------- -function tNode_isDict(self) result(dict) - - class(tNode), intent(in), target :: self - logical :: dict - - dict = .false. - select type(self) - class is(tDict) - dict = .true. - end select - -end function tNode_isDict - - !-------------------------------------------------------------------------------------------------- !> @brief Access by index !-------------------------------------------------------------------------------------------------- @@ -411,11 +354,12 @@ function tNode_get_byIndex(self,i) result(node) class(tItem), pointer :: item integer :: j - if (self%isList()) then - self_ => self%asList() - else - call IO_error(706,ext_msg='Expected List') - endif + select type(self) + class is(tList) + self_ => self%asList() + class default + call IO_error(706,ext_msg='Expected List') + endselect item => self_%first @@ -442,12 +386,13 @@ function tNode_get_byIndex_asFloat(self,i) result(nodeAsFloat) type(tScalar), pointer :: scalar node => self%get(i) - if (node%isScalar()) then - scalar => node%asScalar() - nodeAsFloat = scalar%asFloat() - else - call IO_error(706,ext_msg='Expected Scalar') - endif + select type(node) + class is(tScalar) + scalar => node%asScalar() + nodeAsFloat = scalar%asFloat() + class default + call IO_error(706,ext_msg='Expected Scalar') + end select end function tNode_get_byIndex_asFloat @@ -465,12 +410,13 @@ function tNode_get_byIndex_asInt(self,i) result(nodeAsInt) type(tScalar), pointer :: scalar node => self%get(i) - if (node%isScalar()) then - scalar => node%asScalar() - nodeAsInt = scalar%asInt() - else - call IO_error(706,ext_msg='Expected Scalar') - endif + select type(node) + class is(tScalar) + scalar => node%asScalar() + nodeAsInt = scalar%asInt() + class default + call IO_error(706,ext_msg='Expected Scalar') + end select end function tNode_get_byIndex_asInt @@ -488,12 +434,13 @@ function tNode_get_byIndex_asBool(self,i) result(nodeAsBool) type(tScalar), pointer :: scalar node => self%get(i) - if (node%isScalar()) then - scalar => node%asScalar() - nodeAsBool = scalar%asBool() - else - call IO_error(706,ext_msg='Expected Scalar') - endif + select type(node) + class is(tScalar) + scalar => node%asScalar() + nodeAsBool = scalar%asBool() + class default + call IO_error(706,ext_msg='Expected Scalar') + endselect end function tNode_get_byIndex_asBool @@ -511,12 +458,13 @@ function tNode_get_byIndex_asString(self,i) result(nodeAsString) type(tScalar), pointer :: scalar node => self%get(i) - if (node%isScalar()) then - scalar => node%asScalar() - nodeAsString = scalar%asString() - else - call IO_error(706,ext_msg='Expected Scalar') - endif + select type(node) + class is(tScalar) + scalar => node%asScalar() + nodeAsString = scalar%asString() + class default + call IO_error(706,ext_msg='Expected Scalar') + endselect end function tNode_get_byIndex_asString @@ -534,12 +482,13 @@ function tNode_get_byIndex_asFloats(self,i) result(nodeAsFloats) class(tList), pointer :: list node => self%get(i) - if (node%isList()) then - list => node%asList() - nodeAsFloats = list%asFloats() - else - call IO_error(706,ext_msg='Expected list') - endif + select type(node) + class is(tList) + list => node%asList() + nodeAsFloats = list%asFloats() + class default + call IO_error(706,ext_msg='Expected list') + endselect end function tNode_get_byIndex_asFloats @@ -557,12 +506,13 @@ function tNode_get_byIndex_asInts(self,i) result(nodeAsInts) class(tList), pointer :: list node => self%get(i) - if (node%isList()) then - list => node%asList() - nodeAsInts = list%asInts() - else - call IO_error(706,ext_msg='Expected list') - endif + select type(node) + class is(tList) + list => node%asList() + nodeAsInts = list%asInts() + class default + call IO_error(706,ext_msg='Expected list') + endselect end function tNode_get_byIndex_asInts @@ -580,12 +530,13 @@ function tNode_get_byIndex_asBools(self,i) result(nodeAsBools) class(tList), pointer :: list node => self%get(i) - if (node%isList()) then - list => node%asList() - nodeAsBools = list%asBools() - else - call IO_error(706,ext_msg='Expected list') - endif + select type(node) + class is(tList) + list => node%asList() + nodeAsBools = list%asBools() + class default + call IO_error(706,ext_msg='Expected list') + endselect end function tNode_get_byIndex_asBools @@ -603,12 +554,13 @@ function tNode_get_byIndex_asStrings(self,i) result(nodeAsStrings) type(tList), pointer :: list node => self%get(i) - if (node%isList()) then - list => node%asList() - nodeAsStrings = list%asStrings() - else - call IO_error(706,ext_msg='Expected list') - endif + select type(node) + class is(tList) + list => node%asList() + nodeAsStrings = list%asStrings() + class default + call IO_error(706,ext_msg='Expected list') + endselect end function tNode_get_byIndex_asStrings @@ -626,15 +578,16 @@ function tNode_get_byIndex_asKey(self,i) result(key) type(tDict), pointer :: dict type(tItem), pointer :: item - if (self%isDict()) then - dict => self%asDict() - item => dict%first - do j = 1, min(i,dict%length)-1 - item => item%next - enddo - else - call IO_error(706,ext_msg='Expected dict') - endif + select type(self) + class is(tDict) + dict => self%asDict() + item => dict%first + do j = 1, min(i,dict%length)-1 + item => item%next + enddo + class default + call IO_error(706,ext_msg='Expected dict') + endselect key = item%key @@ -655,25 +608,26 @@ function tNode_contains(self,k) result(exists) type(tDict), pointer :: dict exists = .false. - if (self%isDict()) then - dict => self%asDict() - do j=1, dict%length - if (dict%getKey(j) == k) then - exists = .true. - return - endif - enddo - elseif (self%isList()) then - list => self%asList() - do j=1, list%length - if (list%get_asString(j) == k) then - exists = .true. - return - endif - enddo - else - call IO_error(706,ext_msg='Expected "list" or "dict"') - endif + select type(self) + class is(tDict) + dict => self%asDict() + do j=1, dict%length + if (dict%getKey(j) == k) then + exists = .true. + return + endif + enddo + class is(tList) + list => self%asList() + do j=1, list%length + if (list%get_asString(j) == k) then + exists = .true. + return + endif + enddo + class default + call IO_error(706,ext_msg='Expected "list" or "dict"') + endselect end function tNode_contains @@ -696,11 +650,12 @@ function tNode_get_byKey(self,k,defaultVal) result(node) found = present(defaultVal) if (found) node => defaultVal - if (self%isDict()) then - self_ => self%asDict() - else - call IO_error(706,ext_msg='Expected Dict for key '//k) - endif + select type(self) + class is(tDict) + self_ => self%asDict() + class default + call IO_error(706,ext_msg='Expected Dict for key '//k) + endselect j = 1 item => self_%first @@ -738,12 +693,13 @@ function tNode_get_byKey_asFloat(self,k,defaultVal) result(nodeAsFloat) if (self%contains(k)) then node => self%get(k) - if (node%isScalar()) then - scalar => node%asScalar() - nodeAsFloat = scalar%asFloat() - else - call IO_error(706,ext_msg='Expected Scalar for key '//k) - endif + select type(node) + class is(tScalar) + scalar => node%asScalar() + nodeAsFloat = scalar%asFloat() + class default + call IO_error(706,ext_msg='Expected Scalar for key '//k) + endselect elseif (present(defaultVal)) then nodeAsFloat = defaultVal else @@ -768,12 +724,13 @@ function tNode_get_byKey_asInt(self,k,defaultVal) result(nodeAsInt) if (self%contains(k)) then node => self%get(k) - if (node%isScalar()) then - scalar => node%asScalar() - nodeAsInt = scalar%asInt() - else - call IO_error(706,ext_msg='Expected Scalar for key '//k) - endif + select type(node) + class is(tScalar) + scalar => node%asScalar() + nodeAsInt = scalar%asInt() + class default + call IO_error(706,ext_msg='Expected Scalar for key '//k) + endselect elseif (present(defaultVal)) then nodeAsInt = defaultVal else @@ -798,12 +755,13 @@ function tNode_get_byKey_asBool(self,k,defaultVal) result(nodeAsBool) if (self%contains(k)) then node => self%get(k) - if (node%isScalar()) then - scalar => node%asScalar() - nodeAsBool = scalar%asBool() - else - call IO_error(706,ext_msg='Expected Scalar for key '//k) - endif + select type(node) + class is(tScalar) + scalar => node%asScalar() + nodeAsBool = scalar%asBool() + class default + call IO_error(706,ext_msg='Expected Scalar for key '//k) + endselect elseif (present(defaultVal)) then nodeAsBool = defaultVal else @@ -828,12 +786,13 @@ function tNode_get_byKey_asString(self,k,defaultVal) result(nodeAsString) if (self%contains(k)) then node => self%get(k) - if (node%isScalar()) then - scalar => node%asScalar() - nodeAsString = scalar%asString() - else - call IO_error(706,ext_msg='Expected Scalar for key '//k) - endif + select type(node) + class is(tScalar) + scalar => node%asScalar() + nodeAsString = scalar%asString() + class default + call IO_error(706,ext_msg='Expected Scalar for key '//k) + endselect elseif (present(defaultVal)) then nodeAsString = defaultVal else @@ -860,12 +819,13 @@ function tNode_get_byKey_asFloats(self,k,defaultVal,requiredSize) result(nodeAsF if (self%contains(k)) then node => self%get(k) - if (node%isList()) then - list => node%asList() - nodeAsFloats = list%asFloats() - else - call IO_error(706,ext_msg='Expected list for key '//k) - endif + select type(self) + class is(tList) + list => node%asList() + nodeAsFloats = list%asFloats() + class default + call IO_error(706,ext_msg='Expected list for key '//k) + endselect elseif (present(defaultVal)) then nodeAsFloats = defaultVal else @@ -895,12 +855,13 @@ function tNode_get_byKey_asInts(self,k,defaultVal,requiredSize) result(nodeAsInt if (self%contains(k)) then node => self%get(k) - if (node%isList()) then - list => node%asList() - nodeAsInts = list%asInts() - else - call IO_error(706,ext_msg='Expected list for key '//k) - endif + select type(node) + class is(tList) + list => node%asList() + nodeAsInts = list%asInts() + class default + call IO_error(706,ext_msg='Expected list for key '//k) + endselect elseif (present(defaultVal)) then nodeAsInts = defaultVal else @@ -929,12 +890,13 @@ function tNode_get_byKey_asBools(self,k,defaultVal) result(nodeAsBools) if (self%contains(k)) then node => self%get(k) - if (node%isList())then - list => node%asList() - nodeAsBools = list%asBools() - else - call IO_error(706,ext_msg='Expected list for key '//k) - endif + select type(node) + class is(tList) + list => node%asList() + nodeAsBools = list%asBools() + class default + call IO_error(706,ext_msg='Expected list for key '//k) + endselect elseif (present(defaultVal)) then nodeAsBools = defaultVal else @@ -959,12 +921,13 @@ function tNode_get_byKey_asStrings(self,k,defaultVal) result(nodeAsStrings) if (self%contains(k)) then node => self%get(k) - if (node%isList()) then - list => node%asList() - nodeAsStrings = list%asStrings() - else - call IO_error(706,ext_msg='Expected list for key '//k) - endif + select type(node) + class is(tList) + list => node%asList() + nodeAsStrings = list%asStrings() + class default + call IO_error(706,ext_msg='Expected list for key '//k) + endselect elseif (present(defaultVal)) then nodeAsStrings = defaultVal else From 7e8f630a6260fadb4cfa82b5984699e03c686a4f Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Mon, 29 Mar 2021 21:44:37 +0200 Subject: [PATCH 07/21] consistent --- src/YAML_types.f90 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/YAML_types.f90 b/src/YAML_types.f90 index 72262f1ad..eff5f2483 100644 --- a/src/YAML_types.f90 +++ b/src/YAML_types.f90 @@ -855,7 +855,7 @@ function tNode_get_byKey_as1dFloat(self,k,defaultVal,requiredSize) result(nodeAs list => node%asList() nodeAs1dFloat = list%as1dFloat() class default - call IO_error(706,ext_msg='Expected 1D list for key '//k) + call IO_error(706,ext_msg='Expected 1D Float array for key '//k) endselect elseif (present(defaultVal)) then nodeAs1dFloat = defaultVal @@ -891,7 +891,7 @@ function tNode_get_byKey_as2dFloat(self,k,defaultVal) result(nodeAs2dFloat) rows => node%asList() nodeAs2dFloat = rows%as2dFloat() class default - call IO_error(706,ext_msg='Expected 2D list for key '//k) + call IO_error(706,ext_msg='Expected 2D Float array for key '//k) endselect elseif(present(defaultVal)) then nodeAs2dFloat = defaultVal @@ -923,7 +923,7 @@ function tNode_get_byKey_as1dInt(self,k,defaultVal,requiredSize) result(nodeAs1d list => node%asList() nodeAs1dInt = list%as1dInt() class default - call IO_error(706,ext_msg='Expected list for key '//k) + call IO_error(706,ext_msg='Expected 1D Integer array for key '//k) endselect elseif (present(defaultVal)) then nodeAs1dInt = defaultVal @@ -958,7 +958,7 @@ function tNode_get_byKey_as1dBool(self,k,defaultVal) result(nodeAs1dBool) list => node%asList() nodeAs1dBool = list%as1dBool() class default - call IO_error(706,ext_msg='Expected list for key '//k) + call IO_error(706,ext_msg='Expected 1D Boolean array for key '//k) endselect elseif (present(defaultVal)) then nodeAs1dBool = defaultVal @@ -989,7 +989,7 @@ function tNode_get_byKey_as1dString(self,k,defaultVal) result(nodeAs1dString) list => node%asList() nodeAs1dString = list%as1dString() class default - call IO_error(706,ext_msg='Expected list for key '//k) + call IO_error(706,ext_msg='Expected 1D String array for key '//k) endselect elseif (present(defaultVal)) then nodeAs1dString = defaultVal From d1af4b031acce9e1165666fb501f4703b2a08973 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 30 Mar 2021 17:02:57 +0200 Subject: [PATCH 08/21] source for python-compatible versioning --- python/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/setup.py b/python/setup.py index 0642c0b7d..f6ba83b7b 100644 --- a/python/setup.py +++ b/python/setup.py @@ -2,6 +2,7 @@ import setuptools from pathlib import Path import re +# https://www.python.org/dev/peps/pep-0440 with open(Path(__file__).parent/'damask/VERSION') as f: version = re.sub(r'(-([^-]*)).*$',r'.\2',re.sub(r'^v(\d+\.\d+(\.\d+)?)',r'\1',f.readline().strip())) From b9b66fac45b4ea34ea6f44bd19aabbbc79b7ef31 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 30 Mar 2021 17:15:02 +0200 Subject: [PATCH 09/21] simplified --- python/damask/_result.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/python/damask/_result.py b/python/damask/_result.py index 415ddded9..ba726d4d3 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -139,8 +139,7 @@ class Result: datasets = ['*'] elif datasets is False: datasets = [] - choice = datasets if hasattr(datasets,'__iter__') and not isinstance(datasets,str) else \ - [datasets] + choice = [datasets] if isinstance(datasets,str) else datasets.copy() inc = 'inc' if self.version_minor < 12 else 'increment_' # compatibility hack if what == 'increments': From 7865092b821bc41227036d319ae1985e9d0be667 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 30 Mar 2021 17:24:19 +0200 Subject: [PATCH 10/21] not needed --- python/damask/_configmaterial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/damask/_configmaterial.py b/python/damask/_configmaterial.py index e2762be4d..dedf4373b 100644 --- a/python/damask/_configmaterial.py +++ b/python/damask/_configmaterial.py @@ -1,4 +1,4 @@ -import os.path +import os import numpy as np import h5py From c43dc0cb9530774756e46fc8defdaa4ff711350c Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 30 Mar 2021 19:45:35 +0200 Subject: [PATCH 11/21] better log --- .gitlab-ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c322b57d8..3f33842a4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -96,7 +96,7 @@ processing: stage: python script: - cd $DAMASKROOT/python - - pytest --basetemp=${TESTROOT}/python -v --cov --cov-report=term + - COLUMS=256 pytest --basetemp=${TESTROOT}/python -v --cov --cov-report=term - coverage report --fail-under=90 except: - master @@ -116,7 +116,7 @@ compile_grid_Intel: script: - module load $IntelCompiler $MPI_Intel $PETSc_Intel - cd pytest - - pytest -k 'compile and grid' --basetemp=${TESTROOT}/compile_grid_Intel + - COLUMNS=256 pytest -k 'compile and grid' --basetemp=${TESTROOT}/compile_grid_Intel except: - master - release @@ -126,7 +126,7 @@ compile_mesh_Intel: script: - module load $IntelCompiler $MPI_Intel $PETSc_Intel - cd pytest - - pytest -k 'compile and mesh' --basetemp=${TESTROOT}/compile_mesh_Intel + - COLUMNS=256 pytest -k 'compile and mesh' --basetemp=${TESTROOT}/compile_mesh_Intel except: - master - release @@ -136,7 +136,7 @@ compile_grid_GNU: script: - module load $GNUCompiler $MPI_GNU $PETSc_GNU - cd pytest - - pytest -k 'compile and grid' --basetemp=${TESTROOT}/compile_grid_GNU + - COLUMNS=256 pytest -k 'compile and grid' --basetemp=${TESTROOT}/compile_grid_GNU except: - master - release @@ -146,7 +146,7 @@ compile_mesh_GNU: script: - module load $GNUCompiler $MPI_GNU $PETSc_GNU - cd pytest - - pytest -k 'compile and mesh' --basetemp=${TESTROOT}/compile_mesh_GNU + - COLUMNS=256 pytest -k 'compile and mesh' --basetemp=${TESTROOT}/compile_mesh_GNU except: - master - release @@ -156,7 +156,7 @@ compile_Marc: script: - module load $IntelMarc $HDF5Marc $MSC - cd pytest - - pytest -k 'compile and Marc' --basetemp=${TESTROOT}/compile_Marc + - COLUMNS=256 pytest -k 'compile and Marc' --basetemp=${TESTROOT}/compile_Marc except: - master - release @@ -191,7 +191,7 @@ core: script: - module load $IntelCompiler $MPI_Intel $PETSc_Intel - cd pytest - - pytest -k 'not compile' --basetemp=${TESTROOT}/fortran -v + - COLUMNS=256 pytest -k 'not compile' --basetemp=${TESTROOT}/fortran -v except: - master - release From 7b846efe4ac2145363e24b78ac4f4a9a8b2dc949 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 30 Mar 2021 19:57:49 +0200 Subject: [PATCH 12/21] arguments can be int, bool, str --- python/.gitignore | 1 + python/damask/_result.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/python/.gitignore b/python/.gitignore index 7c60e1af8..89d206b99 100644 --- a/python/.gitignore +++ b/python/.gitignore @@ -2,3 +2,4 @@ dist damask.egg-info .coverage +.coverage.* diff --git a/python/damask/_result.py b/python/damask/_result.py index ba726d4d3..b2a0dd4a1 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -125,7 +125,7 @@ class Result: Select from 'set', 'add', and 'del'. what : str Attribute to change (must be from self.visible). - datasets : list of str or bool + datasets : str, int, list of str, list of int, or bool Name of datasets as list; supports ? and * wildcards. True is equivalent to [*], False is equivalent to []. @@ -139,7 +139,8 @@ class Result: datasets = ['*'] elif datasets is False: datasets = [] - choice = [datasets] if isinstance(datasets,str) else datasets.copy() + choice = list(datasets).copy() if hasattr(datasets,'__iter__') and not isinstance(datasets,str) else \ + [datasets] inc = 'inc' if self.version_minor < 12 else 'increment_' # compatibility hack if what == 'increments': From 8ac4850dd3a5107d0526c6d5c90f195ebb53d3b2 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 31 Mar 2021 10:55:25 -0400 Subject: [PATCH 13/21] more consistent error messages --- src/YAML_types.f90 | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/YAML_types.f90 b/src/YAML_types.f90 index eff5f2483..b294f9ba1 100644 --- a/src/YAML_types.f90 +++ b/src/YAML_types.f90 @@ -389,7 +389,7 @@ function tNode_get_byIndex(self,i) result(node) class is(tList) self_ => self%asList() class default - call IO_error(706,ext_msg='Expected List') + call IO_error(706,ext_msg='Expected list') endselect item => self_%first @@ -418,11 +418,11 @@ function tNode_get_byIndex_asFloat(self,i) result(nodeAsFloat) node => self%get(i) select type(node) - class is(tScalar) + class is(tScalar) scalar => node%asScalar() nodeAsFloat = scalar%asFloat() class default - call IO_error(706,ext_msg='Expected Scalar') + call IO_error(706,ext_msg='Expected scalar float') end select end function tNode_get_byIndex_asFloat @@ -446,7 +446,7 @@ function tNode_get_byIndex_asInt(self,i) result(nodeAsInt) scalar => node%asScalar() nodeAsInt = scalar%asInt() class default - call IO_error(706,ext_msg='Expected Scalar') + call IO_error(706,ext_msg='Expected scalar integer') end select end function tNode_get_byIndex_asInt @@ -470,7 +470,7 @@ function tNode_get_byIndex_asBool(self,i) result(nodeAsBool) scalar => node%asScalar() nodeAsBool = scalar%asBool() class default - call IO_error(706,ext_msg='Expected Scalar') + call IO_error(706,ext_msg='Expected scalar Boolean') endselect end function tNode_get_byIndex_asBool @@ -494,7 +494,7 @@ function tNode_get_byIndex_asString(self,i) result(nodeAsString) scalar => node%asScalar() nodeAsString = scalar%asString() class default - call IO_error(706,ext_msg='Expected Scalar') + call IO_error(706,ext_msg='Expected scalar string') endselect end function tNode_get_byIndex_asString @@ -518,7 +518,7 @@ function tNode_get_byIndex_as1dFloat(self,i) result(nodeAs1dFloat) list => node%asList() nodeAs1dFloat = list%as1dFloat() class default - call IO_error(706,ext_msg='Expected list') + call IO_error(706,ext_msg='Expected list of floats') endselect end function tNode_get_byIndex_as1dFloat @@ -542,7 +542,7 @@ function tNode_get_byIndex_as1dInt(self,i) result(nodeAs1dInt) list => node%asList() nodeAs1dInt = list%as1dInt() class default - call IO_error(706,ext_msg='Expected list') + call IO_error(706,ext_msg='Expected list of integers') endselect end function tNode_get_byIndex_as1dInt @@ -566,7 +566,7 @@ function tNode_get_byIndex_as1dBool(self,i) result(nodeAs1dBool) list => node%asList() nodeAs1dBool = list%as1dBool() class default - call IO_error(706,ext_msg='Expected list') + call IO_error(706,ext_msg='Expected list of Booleans') endselect end function tNode_get_byIndex_as1dBool @@ -590,7 +590,7 @@ function tNode_get_byIndex_as1dString(self,i) result(nodeAs1dString) list => node%asList() nodeAs1dString = list%as1dString() class default - call IO_error(706,ext_msg='Expected list') + call IO_error(706,ext_msg='Expected list of strings') endselect end function tNode_get_byIndex_as1dString @@ -619,7 +619,7 @@ function tNode_get_byIndex_asKey(self,i) result(key) class default call IO_error(706,ext_msg='Expected dict') endselect - + key = item%key end function tNode_get_byIndex_asKey @@ -657,7 +657,7 @@ function tNode_contains(self,k) result(exists) endif enddo class default - call IO_error(706,ext_msg='Expected "list" or "dict"') + call IO_error(706,ext_msg='Expected list or dict') endselect end function tNode_contains @@ -685,7 +685,7 @@ function tNode_get_byKey(self,k,defaultVal) result(node) class is(tDict) self_ => self%asDict() class default - call IO_error(706,ext_msg='Expected Dict for key '//k) + call IO_error(706,ext_msg='Expected dict for key '//k) endselect j = 1 @@ -729,7 +729,7 @@ function tNode_get_byKey_asFloat(self,k,defaultVal) result(nodeAsFloat) scalar => node%asScalar() nodeAsFloat = scalar%asFloat() class default - call IO_error(706,ext_msg='Expected Scalar for key '//k) + call IO_error(706,ext_msg='Expected scalar float for key '//k) endselect elseif (present(defaultVal)) then nodeAsFloat = defaultVal @@ -760,7 +760,7 @@ function tNode_get_byKey_asInt(self,k,defaultVal) result(nodeAsInt) scalar => node%asScalar() nodeAsInt = scalar%asInt() class default - call IO_error(706,ext_msg='Expected Scalar for key '//k) + call IO_error(706,ext_msg='Expected scalar integer for key '//k) endselect elseif (present(defaultVal)) then nodeAsInt = defaultVal @@ -791,7 +791,7 @@ function tNode_get_byKey_asBool(self,k,defaultVal) result(nodeAsBool) scalar => node%asScalar() nodeAsBool = scalar%asBool() class default - call IO_error(706,ext_msg='Expected Scalar for key '//k) + call IO_error(706,ext_msg='Expected scalar Boolean for key '//k) endselect elseif (present(defaultVal)) then nodeAsBool = defaultVal @@ -822,7 +822,7 @@ function tNode_get_byKey_asString(self,k,defaultVal) result(nodeAsString) scalar => node%asScalar() nodeAsString = scalar%asString() class default - call IO_error(706,ext_msg='Expected Scalar for key '//k) + call IO_error(706,ext_msg='Expected scalar string for key '//k) endselect elseif (present(defaultVal)) then nodeAsString = defaultVal @@ -855,7 +855,7 @@ function tNode_get_byKey_as1dFloat(self,k,defaultVal,requiredSize) result(nodeAs list => node%asList() nodeAs1dFloat = list%as1dFloat() class default - call IO_error(706,ext_msg='Expected 1D Float array for key '//k) + call IO_error(706,ext_msg='Expected 1D float array for key '//k) endselect elseif (present(defaultVal)) then nodeAs1dFloat = defaultVal @@ -891,7 +891,7 @@ function tNode_get_byKey_as2dFloat(self,k,defaultVal) result(nodeAs2dFloat) rows => node%asList() nodeAs2dFloat = rows%as2dFloat() class default - call IO_error(706,ext_msg='Expected 2D Float array for key '//k) + call IO_error(706,ext_msg='Expected 2D float array for key '//k) endselect elseif(present(defaultVal)) then nodeAs2dFloat = defaultVal @@ -923,7 +923,7 @@ function tNode_get_byKey_as1dInt(self,k,defaultVal,requiredSize) result(nodeAs1d list => node%asList() nodeAs1dInt = list%as1dInt() class default - call IO_error(706,ext_msg='Expected 1D Integer array for key '//k) + call IO_error(706,ext_msg='Expected 1D integer array for key '//k) endselect elseif (present(defaultVal)) then nodeAs1dInt = defaultVal @@ -989,7 +989,7 @@ function tNode_get_byKey_as1dString(self,k,defaultVal) result(nodeAs1dString) list => node%asList() nodeAs1dString = list%as1dString() class default - call IO_error(706,ext_msg='Expected 1D String array for key '//k) + call IO_error(706,ext_msg='Expected 1D string array for key '//k) endselect elseif (present(defaultVal)) then nodeAs1dString = defaultVal From 07c9cf5f1a9dbd2d3cb07afbd49902ef3dfcd4c1 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 31 Mar 2021 18:30:07 +0000 Subject: [PATCH 14/21] - improved reporting and slicing of table. - implemented numpy-like `allclose` and `isclose` --- python/damask/_table.py | 196 ++++++++++++++++++++++++---- python/damask/_test.py | 4 +- python/tests/test_ConfigMaterial.py | 9 +- python/tests/test_Grid.py | 3 +- python/tests/test_Table.py | 57 ++++---- 5 files changed, 212 insertions(+), 57 deletions(-) diff --git a/python/damask/_table.py b/python/damask/_table.py index ee64ba017..fb7e17ef8 100644 --- a/python/damask/_table.py +++ b/python/damask/_table.py @@ -27,20 +27,69 @@ class Table: self.comments = [] if comments_ is None else [c for c in comments_] self.data = pd.DataFrame(data=data) self.shapes = { k:(v,) if isinstance(v,(np.int64,np.int32,int)) else v for k,v in shapes.items() } - self._label_uniform() + self._relabel('uniform') + def __repr__(self): """Brief overview.""" - return '\n'.join(['# '+c for c in self.comments])+'\n'+self.data.__repr__() + self._relabel('shapes') + data_repr = self.data.__repr__() + self._relabel('uniform') + return '\n'.join(['# '+c for c in self.comments])+'\n'+data_repr + def __getitem__(self,item): - """Return slice according to item.""" - return self.__class__(data=self.data[item],shapes=self.shapes,comments=self.comments) + """ + Slice the Table according to item. + + Parameters + ---------- + item : row and/or column indexer + Slice to select from Table. + + Returns + ------- + slice : Table + Sliced part of the Table. + + Examples + -------- + >>> import damask + >>> import numpy as np + >>> tbl = damask.Table(data=np.arange(12).reshape((4,3)), + ... shapes=dict(colA=(1,),colB=(1,),colC=(1,))) + >>> tbl['colA','colB'] + colA colB + 0 0 1 + 1 3 4 + 2 6 7 + 3 9 10 + >>> tbl[::2,['colB','colA']] + colB colA + 0 1 0 + 2 7 6 + >>> tbl[1:2,'colB'] + colB + 1 4 + 2 7 + + """ + item = (item,slice(None,None,None)) if isinstance(item,slice) else \ + item if isinstance(item[0],slice) else \ + (slice(None,None,None),item) + sliced = self.data.loc[item] + cols = np.array(sliced.columns if isinstance(sliced,pd.core.frame.DataFrame) else [item[1]]) + _,idx = np.unique(cols,return_index=True) + return self.__class__(data=sliced, + shapes = {k:self.shapes[k] for k in cols[np.sort(idx)]}, + comments=self.comments) + def __len__(self): """Number of rows.""" return len(self.data) + def __copy__(self): """Create deep copy.""" return copy.deepcopy(self) @@ -48,21 +97,51 @@ class Table: copy = __copy__ - def _label_discrete(self): - """Label data individually, e.g. v v v ==> 1_v 2_v 3_v.""" + def _label(self,what,how): + """ + Expand labels according to data shape. + + Parameters + ---------- + what : str or list + Labels to expand. + how : str + Mode of labeling. + 'uniform' ==> v v v + 'shapes' ==> 3:v v v + 'linear' ==> 1_v 2_v 3_v + + """ + what = [what] if isinstance(what,str) else what labels = [] - for label,shape in self.shapes.items(): - size = int(np.prod(shape)) - labels += [('' if size == 1 else f'{i+1}_')+label for i in range(size)] - self.data.columns = labels + for label in what: + shape = self.shapes[label] + size = np.prod(shape,dtype=int) + if how == 'uniform': + labels += [label] * size + elif how == 'shapes': + labels += [('' if size == 1 or i>0 else f'{util.srepr(shape,"x")}:')+label for i in range(size)] + elif how == 'linear': + labels += [('' if size == 1 else f'{i+1}_')+label for i in range(size)] + else: + raise KeyError + return labels - def _label_uniform(self): - """Label data uniformly, e.g. 1_v 2_v 3_v ==> v v v.""" - labels = [] - for label,shape in self.shapes.items(): - labels += [label] * int(np.prod(shape)) - self.data.columns = labels + def _relabel(self,how): + """ + Modify labeling of data in-place. + + Parameters + ---------- + how : str + Mode of labeling. + 'uniform' ==> v v v + 'shapes' ==> 3:v v v + 'linear' ==> 1_v 2_v 3_v + + """ + self.data.columns = self._label(self.shapes,how) def _add_comment(self,label,shape,info): @@ -72,6 +151,62 @@ class Table: self.comments.append(f'{specific} / {general}') + def isclose(self,other,rtol=1e-5,atol=1e-8,equal_nan=True): + """ + Report where values are approximately equal to corresponding ones of other Table. + + Parameters + ---------- + other : Table + Table to compare against. + rtol : float, optional + Relative tolerance of equality. + atol : float, optional + Absolute tolerance of equality. + equal_nan : bool, optional + Consider matching NaN values as equal. Defaults to True. + + Returns + ------- + mask : numpy.ndarray bool + Mask indicating where corresponding table values are close. + + """ + return np.isclose( self.data.to_numpy(), + other.data.to_numpy(), + rtol=rtol, + atol=atol, + equal_nan=equal_nan) + + + def allclose(self,other,rtol=1e-5,atol=1e-8,equal_nan=True): + """ + Test whether all values are approximately equal to corresponding ones of other Table. + + Parameters + ---------- + other : Table + Table to compare against. + rtol : float, optional + Relative tolerance of equality. + atol : float, optional + Absolute tolerance of equality. + equal_nan : bool, optional + Consider matching NaN values as equal. Defaults to True. + + Returns + ------- + answer : bool + Whether corresponding values are close between both tables. + + """ + return np.allclose( self.data.to_numpy(), + other.data.to_numpy(), + rtol=rtol, + atol=atol, + equal_nan=equal_nan) + + @staticmethod def load(fname): """ @@ -130,12 +265,13 @@ class Table: return Table(data,shapes,comments) + @staticmethod def load_ang(fname): """ Load from ang file. - A valid TSL ang file needs to contains the following columns: + A valid TSL ang file has to have the following columns: * Euler angles (Bunge notation) in radians, 3 floats, label 'eu'. * Spatial position in meters, 2 floats, label 'pos'. * Image quality, 1 float, label 'IQ'. @@ -225,10 +361,12 @@ class Table: """ dup = self.copy() dup._add_comment(label,data.shape[1:],info) - - if re.match(r'[0-9]*?_',label): - idx,key = label.split('_',1) - iloc = dup.data.columns.get_loc(key).tolist().index(True) + int(idx) -1 + m = re.match(r'(.*)\[((\d+,)*(\d+))\]',label) + if m: + key = m.group(1) + idx = np.ravel_multi_index(tuple(map(int,m.group(2).split(","))), + self.shapes[key]) + iloc = dup.data.columns.get_loc(key).tolist().index(True) + idx dup.data.iloc[:,iloc] = data else: dup.data[label] = data.reshape(dup.data[label].shape) @@ -331,10 +469,18 @@ class Table: Updated table. """ + labels_ = [labels] if isinstance(labels,str) else labels.copy() + for i,l in enumerate(labels_): + m = re.match(r'(.*)\[((\d+,)*(\d+))\]',l) + if m: + idx = np.ravel_multi_index(tuple(map(int,m.group(2).split(','))), + self.shapes[m.group(1)]) + labels_[i] = f'{1+idx}_{m.group(1)}' + dup = self.copy() - dup._label_discrete() - dup.data.sort_values(labels,axis=0,inplace=True,ascending=ascending) - dup._label_uniform() + dup._relabel('linear') + dup.data.sort_values(labels_,axis=0,inplace=True,ascending=ascending) + dup._relabel('uniform') dup.comments.append(f'sorted {"ascending" if ascending else "descending"} by {labels}') return dup @@ -399,7 +545,7 @@ class Table: ---------- fname : file, str, or pathlib.Path Filename or file for writing. - legacy : Boolean, optional + legacy : bool, optional Write table in legacy style, indicating header lines by "N header" in contrast to using comment sign ('#') at beginning of lines. diff --git a/python/damask/_test.py b/python/damask/_test.py index f8fb24cca..455a92520 100644 --- a/python/damask/_test.py +++ b/python/damask/_test.py @@ -399,7 +399,7 @@ class Test: tables = [damask.Table.load(filename) for filename in files] for table in tables: - table._label_discrete() + table._relabel('linear') columns += [columns[0]]*(len(files)-len(columns)) # extend to same length as files columns = columns[:len(files)] # truncate to same length as files @@ -419,7 +419,7 @@ class Test: data = [] for table,labels in zip(tables,columns): - table._label_uniform() + table._relabel('uniform') data.append(np.hstack(list(table.get(label) for label in labels))) diff --git a/python/tests/test_ConfigMaterial.py b/python/tests/test_ConfigMaterial.py index 5ac0e546a..cf4a8ab9d 100644 --- a/python/tests/test_ConfigMaterial.py +++ b/python/tests/test_ConfigMaterial.py @@ -86,9 +86,12 @@ class TestConfigMaterial: def test_from_table(self): N = np.random.randint(3,10) - a = np.vstack((np.hstack((np.arange(N),np.arange(N)[::-1])),np.ones(N*2),np.zeros(N*2),np.ones(N*2),np.ones(N*2))).T - t = Table(a,{'varying':1,'constant':4}) - c = ConfigMaterial.from_table(t,**{'phase':'varying','O':'constant','homogenization':'4_constant'}) + a = np.vstack((np.hstack((np.arange(N),np.arange(N)[::-1])), + np.ones(N*2),np.zeros(N*2),np.ones(N*2),np.ones(N*2), + np.ones(N*2), + )).T + t = Table(a,{'varying':1,'constant':4,'ones':1}) + c = ConfigMaterial.from_table(t,**{'phase':'varying','O':'constant','homogenization':'ones'}) assert len(c['material']) == N for i,m in enumerate(c['material']): assert m['homogenization'] == 1 and (m['constituents'][0]['O'] == [1,0,1,1]).all() diff --git a/python/tests/test_Grid.py b/python/tests/test_Grid.py index 7e94686ee..018ff8a30 100644 --- a/python/tests/test_Grid.py +++ b/python/tests/test_Grid.py @@ -407,7 +407,8 @@ class TestGrid: z=np.ones(cells.prod()) z[cells[:2].prod()*int(cells[2]/2):]=0 t = Table(np.column_stack((coords,z)),{'coords':3,'z':1}) - g = Grid.from_table(t,'coords',['1_coords','z']) + t = t.add('indicator',t.get('coords')[:,0]) + g = Grid.from_table(t,'coords',['indicator','z']) assert g.N_materials == g.cells[0]*2 and (g.material[:,:,-1]-g.material[:,:,0] == cells[0]).all() diff --git a/python/tests/test_Table.py b/python/tests/test_Table.py index 8f617aff5..286c176e6 100644 --- a/python/tests/test_Table.py +++ b/python/tests/test_Table.py @@ -36,13 +36,33 @@ class TestTable: d = default.get('F') assert np.allclose(d,1.0) and d.shape[1:] == (3,3) - def test_get_component(self,default): - d = default.get('5_F') - assert np.allclose(d,1.0) and d.shape[1:] == (1,) + def test_set(self,default): + d = default.set('F',np.zeros((5,3,3)),'set to zero').get('F') + assert np.allclose(d,0.0) and d.shape[1:] == (3,3) - @pytest.mark.parametrize('N',[10,40]) - def test_getitem(self,N): - assert len(Table(np.random.rand(N,1),{'X':1})[:N//2]) == N//2 + def test_set_component(self,default): + d = default.set('F[0,0]',np.zeros((5)),'set to zero').get('F') + assert np.allclose(d[...,0,0],0.0) and d.shape[1:] == (3,3) + + def test_labels(self,default): + assert default.labels == ['F','v','s'] + + def test_add(self,default): + d = np.random.random((5,9)) + assert np.allclose(d,default.add('nine',d,'random data').get('nine')) + + def test_isclose(self,default): + assert default.isclose(default).all() + + def test_allclose(self,default): + assert default.allclose(default) + + @pytest.mark.parametrize('N',[1,3,4]) + def test_slice(self,default,N): + assert len(default[:N]) == 1+N + assert len(default[:N,['F','s']]) == 1+N + assert default[N:].get('F').shape == (len(default)-N,3,3) + assert (default[:N,['v','s']].data == default['v','s'][:N].data).all().all() @pytest.mark.parametrize('mode',['str','path']) def test_write_read(self,default,tmp_path,mode): @@ -91,21 +111,6 @@ class TestTable: with open(ref_path/fname) as f: Table.load(f) - def test_set(self,default): - d = default.set('F',np.zeros((5,3,3)),'set to zero').get('F') - assert np.allclose(d,0.0) and d.shape[1:] == (3,3) - - def test_set_component(self,default): - d = default.set('1_F',np.zeros((5)),'set to zero').get('F') - assert np.allclose(d[...,0,0],0.0) and d.shape[1:] == (3,3) - - def test_labels(self,default): - assert default.labels == ['F','v','s'] - - def test_add(self,default): - d = np.random.random((5,9)) - assert np.allclose(d,default.add('nine',d,'random data').get('nine')) - def test_rename_equivalent(self): x = np.random.random((5,13)) t = Table(x,{'F':(3,3),'v':(3,),'s':(1,)},['random test data']) @@ -176,15 +181,15 @@ class TestTable: def test_sort_component(self): x = np.random.random((5,12)) t = Table(x,{'F':(3,3),'v':(3,)},['random test data']) - unsort = t.get('4_F') - sort = t.sort_by('4_F').get('4_F') + unsort = t.get('F')[:,1,0] + sort = t.sort_by('F[1,0]').get('F')[:,1,0] assert np.all(np.sort(unsort,0)==sort) def test_sort_revert(self): x = np.random.random((5,12)) t = Table(x,{'F':(3,3),'v':(3,)},['random test data']) - sort = t.sort_by('4_F',ascending=False).get('4_F') - assert np.all(np.sort(sort,0)==sort[::-1,:]) + sort = t.sort_by('F[1,0]',ascending=False).get('F')[:,1,0] + assert np.all(np.sort(sort,0)==sort[::-1]) def test_sort(self): t = Table(np.array([[0,1,],[2,1,]]), @@ -192,4 +197,4 @@ class TestTable: ['test data'])\ .add('s',np.array(['b','a']))\ .sort_by('s') - assert np.all(t.get('1_v') == np.array([2,0]).reshape(2,1)) + assert np.all(t.get('v')[:,0] == np.array([2,0])) From c1176141ef48d20fe3ebfc89531094066db0abca Mon Sep 17 00:00:00 2001 From: Test User Date: Thu, 1 Apr 2021 00:01:17 +0200 Subject: [PATCH 15/21] [skip ci] updated version information after successful test of v3.0.0-alpha2-673-g0c08c9753 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 445e4606c..0c9d33075 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-670-ge6143f6ee +v3.0.0-alpha2-673-g0c08c9753 From c1f7ea750b03999106c67dba4306d0a09b148bfa Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 1 Apr 2021 00:13:07 +0200 Subject: [PATCH 16/21] legacy access not needed anymore --- PRIVATE | 2 +- python/damask/_table.py | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/PRIVATE b/PRIVATE index 4511a963d..f1ac733d5 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 4511a963da5094db309a6a68783f24a23c76da81 +Subproject commit f1ac733d5eb90de1cdcaf79a261157c9034f8136 diff --git a/python/damask/_table.py b/python/damask/_table.py index e010bdd22..e5f436f75 100644 --- a/python/damask/_table.py +++ b/python/damask/_table.py @@ -322,11 +322,7 @@ class Table: Array of column data. """ - if re.match(r'[0-9]*?_',label): - idx,key = label.split('_',1) - data = self.data[key].to_numpy()[:,int(idx)-1].reshape(-1,1) - else: - data = self.data[label].to_numpy().reshape((-1,)+self.shapes[label]) + data = self.data[label].to_numpy().reshape((-1,)+self.shapes[label]) return data.astype(type(data.flatten()[0])) From 09beb8f38cb0dd06bf471aca2d4f01aedc9bcf7a Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 3 Apr 2021 16:44:38 +0200 Subject: [PATCH 17/21] white space adjustments --- src/YAML_types.f90 | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/YAML_types.f90 b/src/YAML_types.f90 index b294f9ba1..3d83831e6 100644 --- a/src/YAML_types.f90 +++ b/src/YAML_types.f90 @@ -123,15 +123,15 @@ module YAML_types procedure :: asFormattedString => tList_asFormattedString procedure :: append => tList_append procedure :: & - as1dFloat => tList_as1dFloat + as1dFloat => tList_as1dFloat procedure :: & - as2dFloat => tList_as2dFloat + as2dFloat => tList_as2dFloat procedure :: & - as1dInt => tList_as1dInt + as1dInt => tList_as1dInt procedure :: & - as1dBool => tList_as1dBool + as1dBool => tList_as1dBool procedure :: & - as1dString => tList_as1dString + as1dString => tList_as1dString final :: tList_finalize end type tList @@ -329,8 +329,8 @@ end subroutine tScalar_assign__ !-------------------------------------------------------------------------------------------------- function tNode_asScalar(self) result(scalar) - class(tNode), intent(in), target :: self - class(tScalar), pointer :: scalar + class(tNode), intent(in), target :: self + class(tScalar), pointer :: scalar select type(self) class is(tScalar) @@ -345,8 +345,8 @@ end function tNode_asScalar !-------------------------------------------------------------------------------------------------- function tNode_asList(self) result(list) - class(tNode), intent(in), target :: self - class(tList), pointer :: list + class(tNode), intent(in), target :: self + class(tList), pointer :: list select type(self) class is(tList) @@ -361,8 +361,8 @@ end function tNode_asList !-------------------------------------------------------------------------------------------------- function tNode_asDict(self) result(dict) - class(tNode), intent(in), target :: self - class(tDict), pointer :: dict + class(tNode), intent(in), target :: self + class(tDict), pointer :: dict select type(self) class is(tDict) @@ -720,7 +720,6 @@ function tNode_get_byKey_asFloat(self,k,defaultVal) result(nodeAsFloat) class(tNode), pointer :: node type(tScalar), pointer :: scalar - character(len=:), allocatable :: str if (self%contains(k)) then node => self%get(k) From 857a990a0ef3590560184e059b6a9f6b540d0c84 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 3 Apr 2021 20:39:07 +0200 Subject: [PATCH 18/21] avoid long lines --- src/mesh/DAMASK_mesh.f90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesh/DAMASK_mesh.f90 b/src/mesh/DAMASK_mesh.f90 index 5ef0f7a36..e19aee822 100644 --- a/src/mesh/DAMASK_mesh.f90 +++ b/src/mesh/DAMASK_mesh.f90 @@ -89,7 +89,8 @@ program DAMASK_mesh if (maxCutBack < 0) call IO_error(301,ext_msg='maxCutBack') ! reading basic information from load case file and allocate data structure containing load cases - call DMGetDimension(geomMesh,dimPlex,ierr); CHKERRA(ierr) !< dimension of mesh (2D or 3D) + call DMGetDimension(geomMesh,dimPlex,ierr) !< dimension of mesh (2D or 3D) + CHKERRA(ierr) nActiveFields = 1 allocate(solres(nActiveFields)) From 7371c421d4f5b03395fd9d01a7471415d0ef60bd Mon Sep 17 00:00:00 2001 From: Test User Date: Sat, 3 Apr 2021 22:22:58 +0200 Subject: [PATCH 19/21] [skip ci] updated version information after successful test of v3.0.0-alpha2-687-g857a990a0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0c9d33075..d816b70f2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-673-g0c08c9753 +v3.0.0-alpha2-687-g857a990a0 From 194b0386c55ef64fb4729cea02557d148fb15b67 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 4 Apr 2021 14:07:50 +0200 Subject: [PATCH 20/21] typo --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3f33842a4..9df1e9330 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -96,7 +96,7 @@ processing: stage: python script: - cd $DAMASKROOT/python - - COLUMS=256 pytest --basetemp=${TESTROOT}/python -v --cov --cov-report=term + - COLUMNS=256 pytest --basetemp=${TESTROOT}/python -v --cov --cov-report=term - coverage report --fail-under=90 except: - master From 0ef6e43e62161ab85ecafccdd1df58ff716d69aa Mon Sep 17 00:00:00 2001 From: Test User Date: Sun, 4 Apr 2021 22:35:53 +0200 Subject: [PATCH 21/21] [skip ci] updated version information after successful test of v3.0.0-alpha2-753-g565dab120 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index d816b70f2..e5c6789ca 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.0.0-alpha2-687-g857a990a0 +v3.0.0-alpha2-753-g565dab120