lib/numru/gphys/assoccoords.rb in gphys-1.1.1 vs lib/numru/gphys/assoccoords.rb in gphys-1.2.2

- old
+ new

@@ -53,21 +53,37 @@ # < grouping in terms of original-dimension sharing > @groups = Hash.new # axnames => assoc coord names assoc_crds.each do |gp| pushed = false + axnames_sv = acnames_sv = nil @groups.each do | axnames, acnames | a = gp.axnames if (axnames - a).length < axnames.length # included? - axnames.concat(a).uniq! - acnames.push(gp.name) + unless pushed + # first time in this loop + axnames.concat(a).uniq! + acnames.push(gp.name) + axnames_sv = axnames + acnames_sv = acnames + else + # second or greater time in this loop --> need merger to the first + @groups.delete(axnames) + axnames_sv.concat(axnames).uniq! + acnames_sv.concat(acnames).uniq! + end pushed = true - break + #break # <-- old code; this doesn't work end end @groups[ gp.axnames ] = [gp.name] if !pushed # new group end + # < sort keys in @groups in the order of original axes > + # -- though its necesity was not originally supposed, but... + @groups.each_key do |axnames| + axnames.replace( @axnames - (@axnames - axnames) ) + end end attr_reader :assoc_crds, :axnames, :axlens protected :assoc_crds, :axnames