LIME Tabular 1000
437159
def lime_tabular_regression_1000(model, data):
    
    return lambda X: other.LimeTabularExplainer(model.predict, data, mode="regression").attributions(X, nsamples=1000)
801956
@SuppressWarnings("unchecked")
    String getFormattedTabularData(TabularData td, String indent) {
        StringBuilder sb = new StringBuilder();
        indent += INDENT;

        sb.append("{");
        Collection<CompositeData> values = (Collection<CompositeData>) td.values();
        int valuesRemaining = values.size();
        for (CompositeData cd : values) {
            sb.append(getFormattedCompositeData(cd, indent));
            if (--valuesRemaining > 0) {
                sb.append("\n").append(indent).append("}, {");
            }
        }
        sb.append("}");

        return String.valueOf(sb);
    }
1170272
def prepare_table(table):
    
    n = len(table)
    for i, row in enumerate(table):
        assert len(row) == n
        for j, el in enumerate(row):
            if i == j:
                table[i][i] = 0.0
            elif i > j:
                table[i][j] = 1-table[j][i]
    return table
190928
private void buildHuffTable(final int tab[], final int L[], final int V[][]) throws IOException {
        int temp = 256;
        int k = 0;

        for (int i = 0; i < 8; i++) { // i+1 is Code length
            for (int j = 0; j < L[i]; j++) {
                for (int n = 0; n < (temp >> (i + 1)); n++) {
                    tab[k] = V[i][j] | ((i + 1) << 8);
                    k++;
                }
            }
        }

        for (int i = 1; k < 256; i++, k++) {
            tab[k] = i | MSB;
        }

        int currentTable = 1;
        k = 0;

        for (int i = 8; i < 16; i++) { // i+1 is Code length
            for (int j = 0; j < L[i]; j++) {
                for (int n = 0; n < (temp >> (i - 7)); n++) {
                    tab[(currentTable * 256) + k] = V[i][j] | ((i + 1) << 8);
                    k++;
                }
                if (k >= 256) {
                    if (k > 256) {
                        throw new IIOException("JPEG Huffman Table error");
                    }

                    k = 0;
                    currentTable++;
                }
            }
        }
    }
322933
def _ReadTab(Year):
	'''
	
	'''
	
	dtype_in = [('Year','int32'),('DayNo','int32'),('Hr','int32'),('Mn','int32'),
			('Bx','float32'),('By','float32'),('Bz','float32'),
			('Vx','float32'),('Vy','float32'),('Vz','float32'),
			('Den','float32'),('Temp','float32'),('SymH','float32'),('IMFFlag','int32'),('ISWFlag','int32'),
			('Tilt','float32'),('Pdyn','float32'),('W1','float32'),('W2','float32'),('W3','float32'),
			('W4','float32'),('W5','float32'),('W6','float32')]
	
	fname = Globals.DataPath+'tab/{:04d}.tab'.format(Year)		
	data = pf.ReadASCIIData(fname,Header=False,dtype=dtype_in)
	
			
	dtype_out = [('Date','int32'),('ut','float32'),('Year','int32'),('DayNo','int32'),('Hr','int32'),('Mn','int32'),
			('Bx','float32'),('By','float32'),('Bz','float32'),('Vx','float32'),('Vy','float32'),('Vz','float32'),
			('Den','float32'),('Temp','float32'),('SymH','float32'),('IMFFlag','int32'),('ISWFlag','int32'),
			('Tilt','float32'),('Pdyn','float32'),('W1','float32'),('W2','float32'),('W3','float32'),
			('W4','float32'),('W5','float32'),('W6','float32'),('G1','float32'),('G2','float32'),('Kp','float32')]

	out = np.recarray(data.size,dtype=dtype_out)
	
	names = data.dtype.names
	
	for n in names:
		if n in out.dtype.names:
			out[n] = data[n]
			
	out.G1 = 0.0
	out.G2 = 0.0
	out.Kp = 0.0
	out.ut = out.Hr + out.Mn/60.0
	
	for i in range(0,out.size):
		out.Date[i] = TT.DayNotoDate(out.Year[i],out.DayNo[i])
		
		
	return out
47113
function tblCells( divId ) {
  log( "Pong-Table", 'tblCells( '+divId +' )' );  
  var dtaArr = poTbl[ divId ].pongTableData;
  var rowSt  = 0;
  var rowEn  = dtaArr.length;
  var i = 0;
  
  if ( poTbl[ divId ].sortCol != '' ) {
    pongTable_sc      = poTbl[ divId ].sortCol;
    pongTable_sort_up = poTbl[ divId ].sortUp;
    //alert( "Sort "+poTbl[ divId ].sortCol );
    dtaArr.sort( pongTableCmpFields );
  }

  // if pagination is required, by a maxRow defintion:
  if ( poTbl[ divId ].pongTableDef.maxRows ) {
    rowSt = parseInt( poTbl[ divId ].pongTableStartRow );
    rowEn = parseInt( poTbl[ divId ].pongTableEndRow );	  
    if ( rowSt > dtaArr.length ) {
      poTbl[ divId ].pongTableStartRow = 0;
      poTbl[ divId ].pongTableEndRow   = poTbl[ divId ].pongTableDef.maxRows;
      rowSt = 0;
      rowEn = poTbl[ divId ].pongTableDef.maxRows;
    }
    log( "Pong-Table", "update paginaor label" );  
    var rPP = parseInt( poTbl[ divId ].pongTableDef.maxRows );
    var maxP = Math.ceil( dtaArr.length / rPP );
    var curP = Math.round( rowEn / rPP );
    $( "#"+divId+'PaginLbl' ).html( $.i18n( "page" )+" "+curP+"/"+maxP+ " ("+dtaArr.length+" "+$.i18n("rows")+")" );
    $( '#'+divId+'PongTable' ).find( "td" ).html( '...' );

  } else {
    // need to create empty table rows and cells 
    // del all rows, except 1st
    $( '#'+divId+'PongTable' ).find( "tr:gt(0)" ).remove();
    
    var contentItems = [];
    for ( var r = 0; r < rowEn; r ++ ) {
      var tbl = poTbl[ divId ].pongTableDef;
      // table:  id="'+divId+'PongTable"
      $( '#'+divId+' .'+divId+'Row' ).remove();
      contentItems.push( '<tr id="'+divId+'R'+r+'" class="'+divId+'Row">' );
      for ( var c = 0; c < tbl.cols.length; c ++ ) {
        if ( ( tbl.cols[c].cellType != 'tooltip' ) && 
            ( tbl.cols[c].cellType != 'largeimg' ) && 
            ( tbl.cols[c].cellType != 'textLink' ) && 
            ( tbl.cols[c].cellType != 'cssClass' ) && 
            ( tbl.cols[c].cellType != 'linkFor' ) ) {
          contentItems.push( '<td id="'+divId+'R'+r+'C'+c+'" class="'+divId+'C'+c+'">...</td>'  );
        }
      }
      contentItems.push( "</tr>" );
    }
    $( '#'+divId+'PongTable' ).append( contentItems.join( '\n' ) );
  }
  
  log( "Pong-Table", "tblCells: divId="+divId+"Data #"+poTbl[ divId ].pongTableData.length + " rowSt="+rowSt + " rowEn="+rowEn );
  
  log( "Pong-Table", "row loop" );	
  for ( var r = rowSt; r < rowEn; r++ ) {
    log( "Pong-Table", "row loop" );	
    var rowIdVal =  dtaArr[r][ poTbl[ divId ].pongTableDef.rowId ];
    //console.log( '>>>>>>>> '+ poTbl[ divId ].pongTableDef.rowId + JSON.stringify(dtaArr[r]) )
    if ( r < dtaArr.length ) {
      log( "Pong-Table", "row "+r );	
      var cellDta = dtaArr[r];
      
      
      for ( var c = 0; c < poTbl[ divId ].pongTableDef.cols.length; c++ ) {
        log( "Pong-Table", "col "+c );	
        var cellDef = poTbl[ divId ].pongTableDef.cols[c];
        var cellId =  '#'+divId+'R'+i+'C'+c; 
        tblUpdateCell( divId, cellDef, r, c, i, cellDta, cellId, rowIdVal, divId );
      }
    } else { // clear the rest of the cells
      for ( var c = 0; c < poTbl[ divId ].pongTableDef.cols.length; c++ ) {
        var cellId =  '#'+divId+'R'+i+'C'+c; 
        $( cellId ).html( '&nbsp;' );
      }
    }
    i++;
  }	
}
902876
def summary_table(
    errors: int, fails: int, warns: int, skips: int, infos: int, passes: int, total: int
) -> str:
    """"""

    return f"""<h2>Summary</h2>
            <table>
            <tr>
                <th>{EMOTICON['ERROR']} ERROR</th>
                <th>{EMOTICON['FAIL']} FAIL</th>
                <th>{EMOTICON['WARN']} WARN</th>
                <th>{EMOTICON['SKIP']} SKIP</th>
                <th>{EMOTICON['INFO']} INFO</th>
                <th>{EMOTICON['PASS']} PASS</th>
            </tr>
            <tr>
                <td>{errors}</td>
                <td>{fails}</td>
                <td>{warns}</td>
                <td>{skips}</td>
                <td>{infos}</td>
                <td>{passes}</td>
            </tr>
            <tr>
                <td>{round(errors / total * 100)}%</td>
                <td>{round(fails / total * 100)}%</td>
                <td>{round(warns / total * 100)}%</td>
                <td>{round(skips / total * 100)}%</td>
                <td>{round(infos / total * 100)}%</td>
                <td>{round(passes / total * 100)}%</td>
            </tr>
            </table>
            """
103980
def write_table(self, d):
        """"""
        self._flushbits()
        table_data = AMQPWriter()
        for k, v in items(d):
            table_data.write_shortstr(k)
            table_data.write_item(v, k)
        table_data = table_data.getvalue()
        self.write_long(len(table_data))
        self.out.write(table_data)
864706
function(ca,max_obj){
		var cursor = this.cursor;
		if(ca==='shift'){ cursor.chtarget(); return;}

		var piece = cursor.getobj(); /* cell or excell */
		var target = cursor.detectTarget(piece);
		if(target===0 || (piece.group==='cell' && piece.is51cell())){
			if(ca==='q' && !piece.isnull){
				if(!piece.is51cell()){ piece.set51cell();}
				else                 { piece.remove51cell();}
				cursor.drawaround();
				return;
			}
		}
		if(target===0){ return;}

		var def = this.klass.Cell.prototype[(target===piece.RT?'qnum':'qnum2')];
		var max = piece.getmaxnum(), val=def;

		if('0'<=ca && ca<='9'){
			var num=+ca, cur=this.getnum51(piece,target);
			if(cur<=0 || cur*10+num>max || this.prev!==piece){ cur=0;}
			val = cur*10+num;
			if(val>max){ return;}
		}
		else if(ca==='-' || ca===' '){ val=def;}
		else{ return;}

		this.setnum51(piece,target,val);
		this.prev = piece;
		cursor.draw();
	}
530584
function Table (options){
  this.options = utils.options({
      chars: {
          'top': '─'
        , 'top-mid': '┬'
        , 'top-left': '┌'
        , 'top-right': '┐'
        , 'bottom': '─'
        , 'bottom-mid': '┴'
        , 'bottom-left': '└'
        , 'bottom-right': '┘'
        , 'left': '│'
        , 'left-mid': '├'
        , 'mid': '─'
        , 'mid-mid': '┼'
        , 'right': '│'
        , 'right-mid': '┤'
        , 'middle': '│'
      }
    , truncate: '…'
    , colors: true
    , colWidths: []
    , colAligns: []
    , style: {
          'padding-left': 1
        , 'padding-right': 1
        , head: ['red']
        , border: ['white']
        , compact : false
      }
    , head: []
  }, options);
}
893470
@Override
    public int print(
        ChronoDisplay formattable,
        Appendable buffer,
        AttributeQuery attributes,
        Set<ElementPosition> positions, // optional
        boolean quickPath
    ) throws IOException {

        BigDecimal value = toDecimal(formattable.get(this.element));
        BigDecimal min = toDecimal(formattable.getMinimum(this.element));
        BigDecimal max = toDecimal(formattable.getMaximum(this.element));

        if (value.compareTo(max) > 0) {
            value = max;
        }

        BigDecimal fraction =
            value.subtract(min).divide(
                max.subtract(min).add(BigDecimal.ONE),
                9,
                RoundingMode.FLOOR);

        fraction = (
            (fraction.compareTo(BigDecimal.ZERO) == 0)
            ? BigDecimal.ZERO
            : fraction.stripTrailingZeros()
        );

        char zeroChar = (
            quickPath
                ? this.zeroDigit
                : attributes.get(Attributes.ZERO_DIGIT, Character.valueOf('0')).charValue());

        int start = -1;
        int printed = 0;

        if (buffer instanceof CharSequence) {
            start = ((CharSequence) buffer).length();
        }

        if (fraction.scale() == 0) {
            // scale ist 0, wenn value das Minimum ist
            if (this.minDigits > 0) {
                if (this.hasDecimalSeparator()) {
                    this.decimalSeparator.print(
                        formattable,
                        buffer,
                        attributes,
                        positions,
                        quickPath);
                    printed++;
                }

                for (int i = 0; i < this.minDigits; i++) {
                    buffer.append(zeroChar);
                }

                printed += this.minDigits;
            }
        } else {
            if (this.hasDecimalSeparator()) {
                this.decimalSeparator.print(
                    formattable,
                    buffer,
                    attributes,
                    positions,
                    quickPath);
                printed++;
            }

            int outputScale =
                Math.min(
                    Math.max(fraction.scale(), this.minDigits),
                    this.maxDigits);
            fraction = fraction.setScale(outputScale, RoundingMode.FLOOR);
            String digits = fraction.toPlainString();
            int diff = zeroChar - '0';

            for (int i = 2, n = digits.length(); i < n; i++) {
                char c = (char) (digits.charAt(i) + diff);
                buffer.append(c);
                printed++;
            }
        }

        if (
            (start != -1)
            && (printed > 1)
            && (positions != null)
        ) {
            positions.add( // Zählung ohne Dezimaltrennzeichen
                new ElementPosition(this.element, start + 1, start + printed));
        }

        return printed;

    }
420776
def _tabulate(rows, headers, spacing=5):
    """"""
    if len(rows) == 0:
        return "None\n"
    assert len(rows[0]) == len(headers)
    count = len(rows[0])
    widths = [0 for _ in range(count)]
    rows = [headers] + rows

    for row in rows:
        for index, field in enumerate(row):
            if len(str(field)) > widths[index]:
                widths[index] = len(str(field))

    output = ""
    for row in rows:
        for index, field in enumerate(row):
            field = str(field)
            output += field + (widths[index] - len(field) + spacing) * " "
        output += "\n"
    return output
443702
function findLargestAbsElement (M) {
  const te = M.elements;
  const n = M.dimension;
  let max = _Math.abs(te[0]);
  let rowCol = {
    row: 0,
    column: 0,
    value: te[0]
  };
  for (let i = 0; i < n; ++i) {
    for (let j = 0; j < n; ++j) {
      const val = te[i * n + j];
      const ti = _Math.abs(val);
      if (ti > max) {
        max = ti;
        rowCol.row = j;
        rowCol.column = i;
        rowCol.value = val;
      }
    }
  }
  return rowCol;
}
277282
private void getColumnBoundaryWithoutHeading(TableCandidate tc) {
    	int heads = tc.getHeadingLineNumber() +1;
    	int MAXcolumnNum = tc.getMaxColumnNumber();
    	int footnoteLineIndex = tc.getFootnoteBeginRow();
    	TableRow row;
    	if(MAXcolumnNum==0) return;
    	
    	float[] leftX_tableColumns = new float[MAXcolumnNum*4];
		float[] rightX_tableColumns = new float[MAXcolumnNum*4];
		for (int qq=0; qq<MAXcolumnNum*4; qq++) {
			leftX_tableColumns[qq]=1000.0f;
			rightX_tableColumns[qq] = 0.0f; 
		}
		int cc=1;
		
		boolean fullRowExists = false;
		int maxTextPieceInTableContent = 0;
		/*
		 * Checks whether there is a data line that has the max number of the text pieces
		 */
		for (int pp=heads; pp<footnoteLineIndex; pp++) {
			row = tc.getRows().get(pp);
			if (maxTextPieceInTableContent<row.getCells().size())
					maxTextPieceInTableContent = row.getCells().size();
		}
		if (maxTextPieceInTableContent==MAXcolumnNum) fullRowExists=true;
		/*
		 * Adjusts leftX_tableColumns and rightX_tableColumns based on the cells
		 */
		for (int pp=heads; pp<footnoteLineIndex; pp++) {
			row = tc.getRows().get(pp);
			if (pp==heads) {
				leftX_tableColumns[0]= row.getCells().get(0).getX(); 		//pmoj.cmdX_thisTable[heads][0];
				rightX_tableColumns[0] = row.getCells().get(0).getEndX();  //rightX_tableColumns[0]=pmoj.cmdEndX_thisTable[heads][0];
			}
			
			if( ((fullRowExists==true) && (row.getCells().size() == MAXcolumnNum)) || (fullRowExists == false)){
				/*
				 * Each text piece/cell in a row
				 */
				for (int qq=0; qq< row.getCells().size(); qq++) {
					/*
					 * Gets a new leftmost column
					 */
					if ( ((leftX_tableColumns[0]- row.getCells().get(qq).getEndX())>m_docInfo.getAverageXGap()*2.0) 
					&&  (row.getCells().get(qq).getEndX()>0.0f) ){
						for (int ii=cc; ii>0; ii--) {
							leftX_tableColumns[ii] = leftX_tableColumns[ii-1];
							rightX_tableColumns[ii] = rightX_tableColumns[ii-1];
						}
						leftX_tableColumns[0]=row.getCells().get(qq).getX();
						rightX_tableColumns[0]=row.getCells().get(qq).getEndX();
						cc++;
					}
					else {
						/*
						 * Gets a new rightmost column
						 */
						if ( ( (row.getCells().get(qq).getX()-rightX_tableColumns[cc-1])>m_docInfo.getAverageXGap()*2.0) 
						&& (row.getCells().get(qq).getX()<1000.0f) ){
							leftX_tableColumns[cc]=row.getCells().get(qq).getX();
							rightX_tableColumns[cc]=row.getCells().get(qq).getEndX();
							cc++;
						}
						/*
						 * A new column 
						 */
						else {
							int thisC = 1;
							boolean newMidColumn = false;
							while (thisC<cc) {
								if ( ((row.getCells().get(qq).getX()-rightX_tableColumns[thisC-1])>m_docInfo.getAverageXGap()*2.0) 
								&& ((leftX_tableColumns[thisC]-row.getCells().get(qq).getEndX())>m_docInfo.getAverageXGap() * 2.0) 
								&& (row.getCells().get(qq).getX()<1000.0f) && (row.getCells().get(qq).getEndX()>0.0f)) {
									for (int ii=cc; ii>thisC; ii--) {
										leftX_tableColumns[ii] = leftX_tableColumns[ii-1];
										rightX_tableColumns[ii] = rightX_tableColumns[ii-1];
									}
									cc++;
									leftX_tableColumns[thisC]=row.getCells().get(qq).getX();
									rightX_tableColumns[thisC]=row.getCells().get(qq).getEndX();
									newMidColumn=true;
									break;
								}
								thisC++;
							}
							if (newMidColumn==false) {
								thisC = 0; 
								cc = adjustAColumn(cc, row.getCells().get(qq).getX(), row.getCells().get(qq).getEndX(), leftX_tableColumns, rightX_tableColumns);
								tc.setColumnNum(cc);
							}
						}//end{middleColumn}
					}//end {else}
				}//end{for all pieces in a line}
			}//end if()
		}//end for()
		
		
		/*
		 * Adjusts columns with the information of heading rows
		 */
		for (int pp=0; pp<heads; pp++) {		
			int cellsThisLine = tc.getRows().get(pp).getCells().size();
			for (int dd=0; dd<cellsThisLine; dd++) {
				float b = tc.getRows().get(pp).getCells().get(dd).getX();
				float e = tc.getRows().get(pp).getCells().get(dd).getEndX();
				cc = adjustAColumn(cc, b, e, leftX_tableColumns, rightX_tableColumns);
			}//end(for)
		}//end(for)
		tc.setColumnNum(cc);
		tc.setLeftX_tableColumns(leftX_tableColumns);
		tc.setRightX_tableColumns(rightX_tableColumns);
	}
789792
def tabular_learner(data:DataBunch, layers:Collection[int], emb_szs:Dict[str,int]=None, metrics=None,
        ps:Collection[float]=None, emb_drop:float=0., y_range:OptRange=None, use_bn:bool=True, **learn_kwargs):
    ""
    emb_szs = data.get_emb_szs(ifnone(emb_szs, {}))
    model = TabularModel(emb_szs, len(data.cont_names), out_sz=data.c, layers=layers, ps=ps, emb_drop=emb_drop,
                         y_range=y_range, use_bn=use_bn)
    return Learner(data, model, metrics=metrics, **learn_kwargs)
1033301
def tabular(client, records):
    
    from renku.models._tabulate import tabulate

    echo_via_pager(
        tabulate(
            records,
            headers=OrderedDict((
                ('added', None),
                ('authors_csv', 'authors'),
                ('dataset', None),
                ('full_path', 'path'),
            )),
        )
    )
214615
def write_table(self, d):
        
        self._flushbits()
        table_data = AMQPWriter()
        for k, v in d.items():
            table_data.write_shortstr(k)
            if isinstance(v, basestring):
                if isinstance(v, unicode):
                    v = v.encode('utf-8')
                table_data.write(byte(83)) # 'S'
                table_data.write_longstr(v)
            elif isinstance(v, (int, long)):
                table_data.write(byte(73)) # 'I'
                table_data.write(pack('>i', v))
            elif isinstance(v, Decimal):
                table_data.write(byte(68)) # 'D'
                sign, digits, exponent = v.as_tuple()
                v = 0
                for d in digits:
                    v = (v * 10) + d
                if sign:
                    v = -v
                table_data.write_octet(-exponent)
                table_data.write(pack('>i', v))
            elif isinstance(v, datetime):
                table_data.write(byte(84)) # 'T'
                table_data.write_timestamp(v)
                ## FIXME: timezone ?
            elif isinstance(v, dict):
                table_data.write(byte(70)) # 'F'
                table_data.write_table(v)
            else:
                raise ValueError('%s not serializable in AMQP' % repr(v))
        table_data = table_data.getvalue()
        self.write_long(len(table_data))
        self.out.write(table_data)