def features(self): nodeSize = int( nm.mcount(i=self.nFile, a="cnt").mcut(f="cnt").run()[0][0]) edgeSize = int( nm.mcount(i=self.eFile, a="cnt").mcut(f="cnt").run()[0][0]) dens = None if (nodeSize > 1): dens = float(edgeSize) / (nodeSize * (nodeSize - 1) / 2.0) return nodeSize, edgeSize, dens
def conv(self,iFile,idFN,itemFN,oFile,mapFile): temp=nu.Mtemp() xxtra=temp.file() # 入力ファイルのidがnilの場合は連番を生成して新たなid項目を作成する。 f0 = nm.mcut(f=itemFN+":##item",i=iFile) f0 <<= nm.mcount(k="##item",a="##freq") f0 <<= nm.mnumber(s="##freq%nr",a="##num",o=mapFile) f0.run() f1 = nm.mjoin(k=itemFN,K="##item",f="##num",m=mapFile,i=iFile,o=xxtra) f1.run() #f1 <<= nm.mtra(k=idFN,f="##num") #f1 <<= nm.mnumber(q=True,a="##traID") #f1 <<= nm.mcut(f="##num",nfno=True,o=oFile) extTake.mmaketra(i=xxtra,o=oFile,f="##num",k=idFN) #f1.run() # ##item,##freq%0nr,##num # b,4,0 # d,4,1 size=nu.mrecount(i=oFile,nfn=True) return size
def calGsize(self, file): edgesize = nu.mrecount(i=file, nfni=True) f = None f <<= nm.mcut(i=file, f="0:tra", nfni=True) f <<= nm.mtra(f="tra") f <<= nm.muniq(k="tra") f <<= nm.mcount(a="cnt") f <<= nm.mcut(f="cnt") f <<= nm.writelist(dtype="cnt:int") nodesize = f.run()[0][0] return nodesize, edgesize
def tra2tbl(iFile, oFile, tidFld, itemFld, null=0, dummy=True, aggFld=None, aggStat=None, klassFld=None): klass = None if klassFld is not None and klassFld != "": klass <<= nm.mcut(f=tidFld + "," + klassFld, i=iFile) klass <<= nm.muniq(k=tidFld) f = None # aggFldが指定されていればセル項目を集計 if aggFld is not None and aggFld != "": f <<= nm.mcut(f=tidFld + "," + itemFld + "," + aggFld, i=iFile) f <<= nm.mstats(k=tidFld, f="%s:_cell" % (aggFld), c=aggStat) # aggFldが指定されていなければカウント else: f <<= nm.mcut(f=tidFld + "," + itemFld, i=iFile) # アイテムが出現したかどうか if dummy: f <<= nm.muniq(k=tidFld + "," + itemFld) f <<= nm.msetstr(v=1, a="_cell") # アイテムが何件出現したかどうか else: f <<= nm.mcount(k=tidFld + "," + itemFld, a="_cell") # 横展開 f <<= nm.m2cross(k=tidFld, s=itemFld, f="_cell") # クラス項目が指定されていれば結合する if klassFld is not None and klassFld != "": f <<= nm.mjoin(k=tidFld, m=klass, f=klassFld) # null値を一斉に置換する f <<= nm.mnullto(f="*", v=null, o=oFile) f.run(msg="on")
def __init__(self,iFile,itemFN,taxoFN): # アイテムの項目名(=>String) self.itemFN = None # 分類の項目名(=>String) self.taxoFN = None # アイテムの種類数(=>Fixnum) self.itemSize = None # 分類の種類数(=>Fixnum) self.taxoSize = None # taxonomyデータファイル名(=>String) self.file = None self.temp = mtemp.Mtemp() self.iFile = iFile self.iPath = os.path.abspath(self.iFile) self.itemFN = itemFN self.taxoFN = taxoFN # item順に並べ替えてpathに書き出す self.file = self.temp.file() para_it = self.itemFN +"," + self.taxoFN nm.mcut(f=para_it,i=self.iFile).muniq(k=para_it,o=self.file).run(msg="on") f = nm.mcut(f=self.itemFN,i=self.iFile) f <<= nm.mtrafld(f=self.itemFN,a="__fld",valOnly=True) f <<= nm.mtra(f="__fld",r=True) f <<= nm.muniq(k="__fld") f <<= nm.mcount(a="size") f <<= nm.mcut(f="size") xx1 = f.run() self.itemSize = int(xx1[0][0]) xx2 = nm.mcut(f=self.taxoFN+":item",i=self.file).muniq(k="item").mcount(a="size").mcut(f="size").run() self.taxoSize = int(xx2[0][0])
def run(self): tempW = mtemp.Mtemp() xxtra = tempW.file() xxmap1 = tempW.file() xxmap2 = tempW.file() lcmout = tempW.file() xxt0 = tempW.file() xxp0 = tempW.file() xx3t = tempW.file() xx4t = tempW.file() self.pair2tra(self.ei, self.ef1, self.ef2, xxtra, xxmap1, xxmap2) runPara = {} runPara["type"] = "CIf" runPara["sup"] = 1 runPara["o"] = lcmout runPara["i"] = xxtra if self.minSize2: runPara["l"] = self.minSize2 if self.maxSize2: runPara["u"] = self.maxSize2 extTake.lcm(runPara) extTake.lcmtrans(lcmout, "p", xxt0) f = None f <<= nm.mdelnull(f="pattern", i=xxt0) f <<= nm.mvreplace(vf="pattern", m=xxmap2, K="num2", f="node2") f <<= nm.mcut(f="pid,pattern,size:size2") f <<= nm.mvsort(vf="pattern") f <<= nm.msortf(f="pid") if self.byedge: f_e0 = nm.mtra(f="pattern", i=f, r=True) extTake.lcmtrans(lcmout, "t", xx3t) f_e1 = None f_e1 <<= nm.mjoin(k="__tid", m=xxmap1, f="node1", K="num1", i=xx3t) f_e1 <<= nm.msortf(f="pid") ## xx2 f_e2 = None f_e2 <<= nm.mcount(k="pid", a="size1", i=f_e1) f_e2 <<= nm.mselnum(f="size1", c="[{},{}]".format(self.minSize1, self.maxSize1)) f_e3 = None f_e3 <<= nm.mjoin(k="pid", m=f_e2, f="size1", i=f_e1) f_e3 <<= nm.mnjoin(k="pid", m=f_e0, f="pattern,size2") f_e3 <<= nm.mcut(f="pid:id,node1:{},pattern:{},size1,size2".format( self.ef1, self.ef2), o=self.oFile) f_e3.run() else: extTake.lcmtrans(lcmout, "t", xx4t) f_e4 = None f_e4 <<= nm.mjoin(k="__tid", m=xxmap1, i=xx4t, f="node1", K="num1") f_e4 <<= nm.mtra(k="pid", f="node1") f_e4 <<= nm.mvcount(vf="node1:size1") f_e4 <<= nm.mjoin(k="pid", m=f, f="pattern,size2") f_e4 <<= nm.mselnum(f="size1", c="[{},{}]".format(self.minSize1, self.maxSize1)) f_e4 <<= nm.mvsort(vf="node1,pattern") f_e4 <<= nm.msortf(f="node1,pattern") f_e4 <<= nm.mcut(f="node1:{},pattern:{},size1,size2".format( self.ef1, self.ef2), o=self.oFile) f_e4.run()
def run(self): from datetime import datetime t = datetime.now() temp=nu.Mtemp() xxsspcin=temp.file() xxmap=temp.file() # traファイルの変換とマップファイルの作成 if self.num : total = self.convN(self.iFile,self.idFN,self.itemFN,xxsspcin,xxmap) else: total = self.conv(self.iFile,self.idFN,self.itemFN,xxsspcin,xxmap) # system "head xxsspcin" # 3 5 0 2 # 4 1 2 # 0 2 3 1 # 1 0 2 # 3 4 0 1 # system "head xxmap" # ##item,##freq%0nr,##num # b,4,0 # d,4,1 # f,4,2 minSupp = int(total*self.minSupPrb) if self.minSupPrb else self.minSupCnt # sspc用simの文字列 if self.sim : if self.sim=="J": sspcSim="R" elif self.sim=="P": sspcSim="P" elif self.sim=="C": sspcSim="i" # sim=省略時はRでth=0とする(sim制約なし) else: sspcSim="R" self.th=0 ############ 列挙本体 ############ xxsspcout=temp.file() tpstr = sspcSim+"ft_" if self.msgoff else sspcSim+"ft" extTake.sspc(type=tpstr,TT=minSupp,i=xxsspcin,th=self.th,o=xxsspcout) ################################## xxtmmp=temp.file() f = nm.mread(i=xxsspcout) f <<= nm.cmd("tr ' ()' ','") f <<= nm.mcut(f="1:i1,2:i2,0:frequency,4:sim",nfni=True) if self.num : f <<= nm.mfldname(f="i1:node1,i2:node2") if self.sim!="C": f <<= nm.mfsort(f="node1,node2") f <<= nm.mjoin(k="node1",K="##item",m=xxmap,f="##freq:frequency1") f <<= nm.mjoin(k="node2",K="##item",m=xxmap,f="##freq:frequency2") else: f <<= nm.mjoin(k="i1",K="##num",m=xxmap,f="##item:node1,##freq:frequency1") f <<= nm.mjoin(k="i2",K="##num",m=xxmap,f="##item:node2,##freq:frequency2") if self.sim!="C": f <<= nm.mcut(f="i1,i2,frequency,sim,node1,node2,frequency1,frequency2,node1:node1x,node2:node2x") f <<= nm.mfsort(f="node1x,node2x") f <<= nm.mcal(c='if($s{node1}==$s{node1x},$s{frequency1},$s{frequency2})',a="freq1") f <<= nm.mcal(c='if($s{node2}==$s{node2x},$s{frequency2},$s{frequency1})',a="freq2") f <<= nm.mcut(f="i1,i2,frequency,sim,node1x:node1,node2x:node2,freq1:frequency1,freq2:frequency2") f <<= nm.msetstr(v=total,a="total") f <<= nm.mcal(c='${frequency}/${frequency1}',a="confidence") f <<= nm.mcal(c='${frequency}/${total}',a="support") f <<= nm.mcal(c='${frequency}/(${frequency1}+${frequency2}-${frequency})',a="jaccard") f <<= nm.mcal(c='(${frequency}*${total})/((${frequency1}*${frequency2}))',a="lift") f <<= nm.mcal(c='(ln(${frequency})+ln(${total})-ln(${frequency1})-ln(${frequency2}))/(ln(${total})-ln(${frequency}))',a="PMI") f <<= nm.mcut(f="node1,node2,frequency,frequency1,frequency2,total,support,confidence,lift,jaccard,PMI") f <<= nm.msortf(f="node1,node2",o=self.oeFile) f.run() if self.onFile: f4 = nm.mcut(f=self.itemFN+":node",i=self.iFile) f4 <<= nm.mcount(k="node",a="frequency") if self.node_support : minstr = "[%s,]"%(minSupp) f4 <<= nm.mselnum(f="frequency",c=minstr) f4 <<= nm.msetstr(v=total,a="total") f4 <<= nm.mcal(c='${frequency}/${total}',a="support") f4 <<= nm.mcut(f="node,support,frequency,total",o=self.onFile) f4.run() procTime=datetime.now()-t # ログファイル出力 if self.logFile : kv=[["key","value"]] for k,v in self.args.items(): kv.append([k,str(v)]) kv.append(["time",str(procTime)]) nm.writecsv(i=kv,o=self.logFile).run()
iFile = "%s/price_large.csv" % (iPath) topix = "%s/index.csv" % (iPath) # make a transaction data, which date as a transaction and tickerID as an item tra = None tra <<= nm.mcut(f="id,date,c", i=iFile) tra <<= nm.mjoin(k="date", m=topix, f="i") tra <<= nm.mslide(k="id", s="date", f="date:date2,c:c2,i:i2") tra <<= nm.mcal(c="${c2}/${c}-${i2}/${i}", a="ret") tra <<= nm.mselnum(f="ret", c="[0.05,0.1]") tra <<= nm.mcut(f="id,date2:date,ret") # frequency of one item freq = None freq <<= nm.mcut(f="id", i=tra) freq <<= nm.mcount(k="id", a="freq") freq <<= nm.mselnum(f="freq", c="[5,]") # total number of transactions total = None total <<= nm.mcut(f="date", i=tra) total <<= nm.muniq(k="date") total <<= nm.mcount(a="total") # frequency of cooccurence of id, and calculate lift values itemCoFreq = None itemCoFreq <<= nm.mcut(f="date,id", i=tra) itemCoFreq <<= nm.mcommon(k="id", m=freq) itemCoFreq <<= nm.mcombi(k="date", n=2, f="id", a="id1,id2") itemCoFreq <<= nm.mcut(f="id1,id2") itemCoFreq <<= nm.mfsort(f="id1,id2")
def mnetpie(ei, ni, ef, nf, o, nodeSizeFld=None, nodeTipsFld=None, nodeColorFld=None, edgeWidthFld=None, edgeColorFld=None, pieDataFld=None, pieTipsFld=None, picFld=None, undirect=False, offline=False): #ei:edge file #ef:egfile if type(ef) is str: ef = ef.split(',') if len(ef) != 2: raise Exception("ef= takes just two field names") if not ((pieDataFld == None and pieTipsFld == None) or (pieDataFld != None and pieTipsFld != None)): raise Exception( "pieDataFld= pieTipsFld= are necessary at the same time") if picFld != None and pieDataFld != None: raise Exception( "picFld= cannot be specified with pieDataFld= pieTipsFld=") if nodeColorFld != None: if picFld != None or pieDataFld != None or pieTipsFld != None: raise Exception( "nodeColorFld= cannot be specified with pieDataFld= pieTipsFld= picFld=" ) if pieDataFld != None and pieTipsFld != None: caseNo = 1 elif picFld != None: caseNo = 2 else: caseNo = 0 tempW = mtemp.Mtemp() xxnode = tempW.file() nodefld = [] nodedmy1 = [] nodedmy2 = [] nodefld.append("%s:node" % (nf)) if nodeSizeFld != None: nodefld.append("%s:nodesize" % (nodeSizeFld)) else: nodedmy1.append("nodesize") nodedmy2.append("50") if nodeTipsFld != None: nodefld.append("%s:nodeT" % (nodeTipFld)) else: nodedmy1.append("nodeT") nodedmy2.append("") if nodeColorFld != None: nodefld.append("%s:nodeClr" % (nodeColorFld)) else: nodedmy1.append("nodeClr") nodedmy2.append("skyblue") if caseNo == 1: nodefld.append("%s:pieD" % (pieDataFld)) nodefld.append("%s:pieT" % (pieTipsFld)) elif caseNo == 2: nodefld.append("%s:pic" % (picFld)) else: nodedmy1.append("pic") nodedmy2.append("") f1 = None f1 <<= nm.mcut(i=ni, f=nodefld) if len(nodedmy1) != 0: f1 <<= nm.msetstr(a=nodedmy1, v=nodedmy2) if caseNo == 1: f1 <<= nm.mshare(k="node", f="pieD:pieDS") f1 <<= nm.mnumber(k="node", a="nodeid", B=True) f2 = nm.muniq(k="pieT", i=f1) f2 <<= nm.mnumber(q=True, a="pieTno") f2 <<= nm.mjoin(k="pieT", f="pieTno", i=f1).iredirect("m") f2 <<= nm.msortf(f="nodeid%n,pieTno%n", o=xxnode) else: f2 = nm.mnumber(a="nodeid%n", q=True, i=f1, o=xxnode) f2.run() xxedge = tempW.file() # MAKE EDGE DATA edgefld = [] edgedmy1 = [] edgedmy2 = [] edgefld.append("%s:edgeS" % (ef[0])) edgefld.append("%s:edgeE" % (ef[1])) if edgeWidthFld != None: edgefld.append("%s:edgesize" % (edgeWidthFld)) else: edgedmy1.append("edgesize") edgedmy2.append("1") if edgeColorFld != None: edgefld.append("%s:edgecolor" % (edgeColorFld)) else: edgedmy1.append("edgecolor") edgedmy2.append("black") f3 = None f3 <<= nm.mcut(i=ei, f=edgefld) if len(edgedmy1) != 0: f3 <<= nm.msetstr(a=edgedmy1, v=edgedmy2) f3 <<= nm.mnumber(a="preNo", q=True) f3 <<= nm.mbest(k="edgeS,edgeE", s="preNo%nr") f3 <<= nm.mnumber(s="preNo%n", a="edgeID") f3 <<= nm.mjoin(k="edgeS", K="node", f="nodeid:edgeSid", m=xxnode) f3 <<= nm.mjoin(k="edgeE", K="node", f="nodeid:edgeEid", m=xxnode) #双方向チェック一応 f4 = None f4 <<= nm.mfsort(i=f3, f="edgeS,edgeE") f4 <<= nm.mcount(k="edgeS,edgeE", a="edgecnt") f4 <<= nm.mselnum(c="[2,]", f="edgecnt") f4 <<= nm.msetstr(a="biflg", v=1) f4 <<= nm.mjoin(k="edgeID", f="biflg", n=True, i=f3).iredirect("m") f4 <<= nm.msortf(f="edgeID%n", o=xxedge) f4.run() gdata = "{\"nodes\":[" if caseNo == 1: nodedatastk = [] nodedatas = "" for val, top, bot in nm.readcsv(xxnode).getline(k="nodeid", otype='dict', q=True): name = val["node"] r = val["nodesize"] title = val["nodeT"] if top: nodedatas = "{\"name\":\"%s\",\"title\":\"%s\",\"r\":%s,\"node\":[" % ( name, title, r) pieTno = val["pieTno"] pieT = val["pieT"] pieDS = val["pieDS"] nodedatas += "{\"group\":%s,\"color\":%s,\"value\":%s,\"title\":\"%s\"}" % ( pieTno, pieDS, pieDS, pieT) if bot: nodedatas += "]}" nodedatastk.append(nodedatas) nodedatas = "" else: nodedatas += "," gdata += ",".join(nodedatastk) else: nodedatastk = [] for val in nm.readcsv(xxnode).getline(otype='dict'): name = val["node"] r = val["nodesize"] title = val["nodeT"] pic = val["pic"] nclr = val["nodeClr"] nodedatas = "{\"name\":\"%s\",\"title\":\"%s\",\"pic\":\"%s\",\"color\":\"%s\",\"r\":%s}" % ( name, title, pic, nclr, r) nodedatastk.append(nodedatas) gdata += ",".join(nodedatastk) gdata += "],\"links\": [" edgedatastk = [] for val in nm.readcsv(xxedge).getline(otype='dict'): es = val["edgeSid"] et = val["edgeEid"] esize = val["edgesize"] ecolor = val["edgecolor"] edgedatas = "{\"source\":%s,\"target\":%s,\"length\":500,\"ewidth\":%s,\"color\":\"%s\"}" % ( es, et, esize, ecolor) edgedatastk.append(edgedatas) gdata += ','.join(edgedatastk) gdata += "]}" direct = ".attr('marker-end','url(#arrowhead)')" if undirect: direct = "" nodeTemplate = ''' node .append("circle") .attr("r",function(d){return d.r/4;}) .attr("fill", function(d){return d.color;}) .append("title") .text(function(d){return d.title;}) ''' nodemakeTemplate = ''' for(var i=0 ; i< graph.nodes.length;i++){ graph.nodes[i].id = i } ''' if pieDataFld != None: nodeTemplate = ''' node.selectAll("path") .data( function(d, i){ return pie(d.node); }) .enter() .append("svg:path") .attr("d", arc) .attr("fill", function(d, i) { return color(d.data.group); }) .append("title") .text(function(d){{return d.data.title;}}) node.append("circle") .attr("r",function(d){{return d.r/4;}}) .attr({ 'fill': 'white' }) .append("title") .text(function(d){{return d.title;}}); ''' nodemakeTemplate = ''' for(var i=0 ; i< graph.nodes.length;i++){ var r = graph.nodes[i].r for(var j=0 ; j< graph.nodes[i].node.length;j++){ graph.nodes[i].node[j]['r'] = r } graph.nodes[i].id = i } ''' elif picFld != None: nodeTemplate = ''' node .append("image") .attr("height",function(d){return d.r;}) .attr("width",function(d){return d.r;}) .attr("x",function(d){return -1 * d.r/2; }) .attr("y",function(d){return -1 * d.r/2; }) .attr("xlink:href",function(d){return d.pic; }) .append("title") .text(function(d){return d.title;}) ''' d3js_str = "<script type='text/javascript' src='http://d3js.org/d3.v3.min.js'></script>" if offline: d3js_str = "<script>%s<script>" % (vjs.ViewJs.d3jsMin()) outTemplate = ''' <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> {d3js_str} <style></style> </head> <body> <script type="text/javascript"> var graph = {gdata} ; var width = 4000, height = 3000; var color = d3.scale.category10(); {nodemakeTemplate}; for(var i=0 ; i< graph.links.length;i++){{ graph.links[i].id = i }} var pie = d3.layout.pie() .sort(null) .value(function(d) {{ return d.value; }}); var arc = d3.svg.arc() .outerRadius( function(d){{ return d.data.r ; }}) .innerRadius( function(d){{ return d.data.r/2 ; }} ); var svg = d3.select("body").append("svg") .attr("width", width) .attr("height", height); d3.select("svg").append('defs').append('marker') .attr({{'id':'arrowhead', 'viewBox':'-0 -5 10 10', 'refX':30, 'refY':0, 'orient':'auto-start-reverse', 'markerWidth':5, 'markerHeight':5, 'xoverflow':'visible'}}) .append('path') .attr('d', 'M 0,-5 L 10 ,0 L 0,5') .attr('fill', '#999') .style('stroke','none'); var g = svg.append("g"); var node = g.selectAll(".node"); var link = g.selectAll(".link"); nodes = graph.nodes links = graph.links var force = d3.layout.force() .linkDistance(200) .linkStrength(3.5) .charge(-3500) .gravity(0.1) .friction(0.95) .size([width, height]) .on("tick", function() {{ link .attr("x1", function(d) {{ return d.source.x; }}) .attr("y1", function(d) {{ return d.source.y; }}) .attr("x2", function(d) {{ return d.target.x; }}) .attr("y2", function(d) {{ return d.target.y; }}); node .attr("x", function(d) {{ return d.x; }}) .attr("y", function(d) {{ return d.y; }}) .attr("transform", function(d) {{ return "translate(" + d.x + "," + d.y + ")"}}); }}); node = node.data(nodes, function( d ) {{ return d.id; }} ); link = link.data(links, function( d ) {{ return d.id; }} ); link .enter() .append("line") .attr("class", "link") .style("stroke", function( d ) {{ return d.color; }} ) .style("stroke-width", function( d ) {{ return d.ewidth; }}) {direct} node .enter() .append("g") .attr("class", "node") .style({{}}) .call(force.drag) .on("contextmenu", function(nd) {{ d3.event.preventDefault(); force.stop() nodes.splice( nd.index, 1 ); links = links.filter(function(nl) {{ return nl.source.index != nd.index && nl.target.index != nd.index; }}); node = node.data(nodes, function( d ) {{ return d.id; }} ); node.exit().remove(); link = link.data( links, function( d ) {{ return d.id; }} ); link.exit().remove(); force.nodes(nodes) .links(links) .start(); }}); {nodeTemplate} node .append("text") .attr("text-anchor", "middle") .style("stroke", "black") .text(function(d) {{ return d.name; }}); force.nodes(nodes) .links(links) .start(); </script> </body> </html> '''.format(d3js_str=d3js_str, gdata=gdata, nodemakeTemplate=nodemakeTemplate, direct=direct, nodeTemplate=nodeTemplate) html = sys.stdout if not o == None: html = open(o, "w") html.write(outTemplate) if not o == None: html.close()
def __init__(self, nc, ni, col, order): self.nc = nc self.ni = ni self.col = col self.range = 0 self.min = 0 self.max = 0 self.order = order if self.nc and self.ni: if self.col == "category": self.type = "category" # preparing a color pallet pallet = [] val = [ "FF", "80", "C0", "40", "E0", "60", "A0", "20", "F0", "70", "B0", "30", "D0", "50", "90", "10" ] for v in val: pallet.append("%s0000" % (v)) pallet.append("00%s00" % (v)) pallet.append("0000%s" % (v)) pallet.append("%s%s00" % (v, v)) pallet.append("00%s%s" % (v, v)) pallet.append("%s00%s" % (v, v)) # read color field data and make a mapping table(data to pallet) f = None f <<= nm.mcut(f="%s:ckey" % (self.nc), i=self.ni) f <<= nm.mdelnull(f="ckey") f <<= nm.mcount(k="ckey", a="freq") if self.order == "descend": f <<= nm.mbest(s="freq%nr,ckey", fr=0, size=96) #,o=#{xxcTable} elif self.order == "ascend": f <<= nm.mbest(s="freq%n,ckey", fr=0, size=96) # o=#{xxcTable}" else: f <<= nm.mbest(s="ckey", fr=0, size=96) #o=#{xxcTable}" self.cTable = {} i = 0 for flds in f.getline(otype="dict"): cK = flds["ckey"] self.cTable[cK] = pallet[i] i += 1 else: self.type = "numeric" ary = col.split(",") if len(ary) != 2 or len(ary[0]) != 6 or len(ary[1]) != 6: raise ValueError( "col= takes two 6-digites HEX codes like FF0000,00FF00" ) self.r0 = int(ary[0][0:2], 16) self.g0 = int(ary[0][2:4], 16) self.b0 = int(ary[0][4:6], 16) self.r1 = int(ary[1][0:2], 16) self.g1 = int(ary[1][2:4], 16) self.b1 = int(ary[1][4:6], 16) f = None f <<= nm.mcut(f="%s:ckey" % (self.nc), i=self.ni) f <<= nm.mdelnull(f="ckey") f <<= nm.msummary(f="ckey", c="min,max") xxcTable = f.run() if len(xxcTable) > 0: if len(xxcTable[0]) >= 2: if xxcTable[0][1] != "": self.min = float(xxcTable[0][1]) if xxcTable[0][2] != "": self.max = float(xxcTable[0][2]) if xxcTable[0][1] != "" and xxcTable[0][2] != "": self.range = self.max - self.min