How to use expand method in rester

Best Python code snippet using rester_python

Parallel.js

Source:Parallel.js Github

copy

Full Screen

1/**2 * Parallel Coordinates3 * <https://en.wikipedia.org/wiki/Parallel_coordinates>4 */5import * as zrUtil from 'zrender/src/core/util';6import * as matrix from 'zrender/src/core/matrix';7import * as layoutUtil from '../../util/layout';8import * as axisHelper from '../../coord/axisHelper';9import ParallelAxis from './ParallelAxis';10import * as graphic from '../../util/graphic';11import * as numberUtil from '../../util/number';12import sliderMove from '../../component/helper/sliderMove';13var each = zrUtil.each;14var mathMin = Math.min;15var mathMax = Math.max;16var mathFloor = Math.floor;17var mathCeil = Math.ceil;18var round = numberUtil.round;19var PI = Math.PI;20function Parallel(parallelModel, ecModel, api) {21 /**22 * key: dimension23 * @type {Object.<string, module:echarts/coord/parallel/Axis>}24 * @private25 */26 this._axesMap = zrUtil.createHashMap();27 /**28 * key: dimension29 * value: {position: [], rotation, }30 * @type {Object.<string, Object>}31 * @private32 */33 this._axesLayout = {};34 /**35 * Always follow axis order.36 * @type {Array.<string>}37 * @readOnly38 */39 this.dimensions = parallelModel.dimensions;40 /**41 * @type {module:zrender/core/BoundingRect}42 */43 this._rect;44 /**45 * @type {module:echarts/coord/parallel/ParallelModel}46 */47 this._model = parallelModel;48 this._init(parallelModel, ecModel, api);49}50Parallel.prototype = {51 type: 'parallel',52 constructor: Parallel,53 /**54 * Initialize cartesian coordinate systems55 * @private56 */57 _init: function (parallelModel, ecModel, api) {58 var dimensions = parallelModel.dimensions;59 var parallelAxisIndex = parallelModel.parallelAxisIndex;60 each(dimensions, function (dim, idx) {61 var axisIndex = parallelAxisIndex[idx];62 var axisModel = ecModel.getComponent('parallelAxis', axisIndex);63 var axis = this._axesMap.set(dim, new ParallelAxis(64 dim,65 axisHelper.createScaleByModel(axisModel),66 [0, 0],67 axisModel.get('type'),68 axisIndex69 ));70 var isCategory = axis.type === 'category';71 axis.onBand = isCategory && axisModel.get('boundaryGap');72 axis.inverse = axisModel.get('inverse');73 // Injection74 axisModel.axis = axis;75 axis.model = axisModel;76 axis.coordinateSystem = axisModel.coordinateSystem = this;77 }, this);78 },79 /**80 * Update axis scale after data processed81 * @param {module:echarts/model/Global} ecModel82 * @param {module:echarts/ExtensionAPI} api83 */84 update: function (ecModel, api) {85 this._updateAxesFromSeries(this._model, ecModel);86 },87 /**88 * @override89 */90 containPoint: function (point) {91 var layoutInfo = this._makeLayoutInfo();92 var axisBase = layoutInfo.axisBase;93 var layoutBase = layoutInfo.layoutBase;94 var pixelDimIndex = layoutInfo.pixelDimIndex;95 var pAxis = point[1 - pixelDimIndex];96 var pLayout = point[pixelDimIndex];97 return pAxis >= axisBase98 && pAxis <= axisBase + layoutInfo.axisLength99 && pLayout >= layoutBase100 && pLayout <= layoutBase + layoutInfo.layoutLength;101 },102 getModel: function () {103 return this._model;104 },105 /**106 * Update properties from series107 * @private108 */109 _updateAxesFromSeries: function (parallelModel, ecModel) {110 ecModel.eachSeries(function (seriesModel) {111 if (!parallelModel.contains(seriesModel, ecModel)) {112 return;113 }114 var data = seriesModel.getData();115 each(this.dimensions, function (dim) {116 var axis = this._axesMap.get(dim);117 axis.scale.unionExtentFromData(data, dim);118 axisHelper.niceScaleExtent(axis.scale, axis.model);119 }, this);120 }, this);121 },122 /**123 * Resize the parallel coordinate system.124 * @param {module:echarts/coord/parallel/ParallelModel} parallelModel125 * @param {module:echarts/ExtensionAPI} api126 */127 resize: function (parallelModel, api) {128 this._rect = layoutUtil.getLayoutRect(129 parallelModel.getBoxLayoutParams(),130 {131 width: api.getWidth(),132 height: api.getHeight()133 }134 );135 this._layoutAxes();136 },137 /**138 * @return {module:zrender/core/BoundingRect}139 */140 getRect: function () {141 return this._rect;142 },143 /**144 * @private145 */146 _makeLayoutInfo: function () {147 var parallelModel = this._model;148 var rect = this._rect;149 var xy = ['x', 'y'];150 var wh = ['width', 'height'];151 var layout = parallelModel.get('layout');152 var pixelDimIndex = layout === 'horizontal' ? 0 : 1;153 var layoutLength = rect[wh[pixelDimIndex]];154 var layoutExtent = [0, layoutLength];155 var axisCount = this.dimensions.length;156 var axisExpandWidth = restrict(parallelModel.get('axisExpandWidth'), layoutExtent);157 var axisExpandCount = restrict(parallelModel.get('axisExpandCount') || 0, [0, axisCount]);158 var axisExpandable = parallelModel.get('axisExpandable')159 && axisCount > 3160 && axisCount > axisExpandCount161 && axisExpandCount > 1162 && axisExpandWidth > 0163 && layoutLength > 0;164 // `axisExpandWindow` is According to the coordinates of [0, axisExpandLength],165 // for sake of consider the case that axisCollapseWidth is 0 (when screen is narrow),166 // where collapsed axes should be overlapped.167 var axisExpandWindow = parallelModel.get('axisExpandWindow');168 var winSize;169 if (!axisExpandWindow) {170 winSize = restrict(axisExpandWidth * (axisExpandCount - 1), layoutExtent);171 var axisExpandCenter = parallelModel.get('axisExpandCenter') || mathFloor(axisCount / 2);172 axisExpandWindow = [axisExpandWidth * axisExpandCenter - winSize / 2];173 axisExpandWindow[1] = axisExpandWindow[0] + winSize;174 }175 else {176 winSize = restrict(axisExpandWindow[1] - axisExpandWindow[0], layoutExtent);177 axisExpandWindow[1] = axisExpandWindow[0] + winSize;178 }179 var axisCollapseWidth = (layoutLength - winSize) / (axisCount - axisExpandCount);180 // Avoid axisCollapseWidth is too small.181 axisCollapseWidth < 3 && (axisCollapseWidth = 0);182 // Find the first and last indices > ewin[0] and < ewin[1].183 var winInnerIndices = [184 mathFloor(round(axisExpandWindow[0] / axisExpandWidth, 1)) + 1,185 mathCeil(round(axisExpandWindow[1] / axisExpandWidth, 1)) - 1186 ];187 // Pos in ec coordinates.188 var axisExpandWindow0Pos = axisCollapseWidth / axisExpandWidth * axisExpandWindow[0];189 return {190 layout: layout,191 pixelDimIndex: pixelDimIndex,192 layoutBase: rect[xy[pixelDimIndex]],193 layoutLength: layoutLength,194 axisBase: rect[xy[1 - pixelDimIndex]],195 axisLength: rect[wh[1 - pixelDimIndex]],196 axisExpandable: axisExpandable,197 axisExpandWidth: axisExpandWidth,198 axisCollapseWidth: axisCollapseWidth,199 axisExpandWindow: axisExpandWindow,200 axisCount: axisCount,201 winInnerIndices: winInnerIndices,202 axisExpandWindow0Pos: axisExpandWindow0Pos203 };204 },205 /**206 * @private207 */208 _layoutAxes: function () {209 var rect = this._rect;210 var axes = this._axesMap;211 var dimensions = this.dimensions;212 var layoutInfo = this._makeLayoutInfo();213 var layout = layoutInfo.layout;214 axes.each(function (axis) {215 var axisExtent = [0, layoutInfo.axisLength];216 var idx = axis.inverse ? 1 : 0;217 axis.setExtent(axisExtent[idx], axisExtent[1 - idx]);218 });219 each(dimensions, function (dim, idx) {220 var posInfo = (layoutInfo.axisExpandable221 ? layoutAxisWithExpand : layoutAxisWithoutExpand222 )(idx, layoutInfo);223 var positionTable = {224 horizontal: {225 x: posInfo.position,226 y: layoutInfo.axisLength227 },228 vertical: {229 x: 0,230 y: posInfo.position231 }232 };233 var rotationTable = {234 horizontal: PI / 2,235 vertical: 0236 };237 var position = [238 positionTable[layout].x + rect.x,239 positionTable[layout].y + rect.y240 ];241 var rotation = rotationTable[layout];242 var transform = matrix.create();243 matrix.rotate(transform, transform, rotation);244 matrix.translate(transform, transform, position);245 // TODO246 // tick等排布信息。247 // TODO248 // 根据axis order 更新 dimensions顺序。249 this._axesLayout[dim] = {250 position: position,251 rotation: rotation,252 transform: transform,253 axisNameAvailableWidth: posInfo.axisNameAvailableWidth,254 axisLabelShow: posInfo.axisLabelShow,255 nameTruncateMaxWidth: posInfo.nameTruncateMaxWidth,256 tickDirection: 1,257 labelDirection: 1,258 labelInterval: axes.get(dim).getLabelInterval()259 };260 }, this);261 },262 /**263 * Get axis by dim.264 * @param {string} dim265 * @return {module:echarts/coord/parallel/ParallelAxis} [description]266 */267 getAxis: function (dim) {268 return this._axesMap.get(dim);269 },270 /**271 * Convert a dim value of a single item of series data to Point.272 * @param {*} value273 * @param {string} dim274 * @return {Array}275 */276 dataToPoint: function (value, dim) {277 return this.axisCoordToPoint(278 this._axesMap.get(dim).dataToCoord(value),279 dim280 );281 },282 /**283 * Travel data for one time, get activeState of each data item.284 * @param {module:echarts/data/List} data285 * @param {Functio} cb param: {string} activeState 'active' or 'inactive' or 'normal'286 * {number} dataIndex287 * @param {Object} context288 */289 eachActiveState: function (data, callback, context) {290 var dimensions = this.dimensions;291 var axesMap = this._axesMap;292 var hasActiveSet = this.hasAxisBrushed();293 for (var i = 0, len = data.count(); i < len; i++) {294 var values = data.getValues(dimensions, i);295 var activeState;296 if (!hasActiveSet) {297 activeState = 'normal';298 }299 else {300 activeState = 'active';301 for (var j = 0, lenj = dimensions.length; j < lenj; j++) {302 var dimName = dimensions[j];303 var state = axesMap.get(dimName).model.getActiveState(values[j], j);304 if (state === 'inactive') {305 activeState = 'inactive';306 break;307 }308 }309 }310 callback.call(context, activeState, i);311 }312 },313 /**314 * Whether has any activeSet.315 * @return {boolean}316 */317 hasAxisBrushed: function () {318 var dimensions = this.dimensions;319 var axesMap = this._axesMap;320 var hasActiveSet = false;321 for (var j = 0, lenj = dimensions.length; j < lenj; j++) {322 if (axesMap.get(dimensions[j]).model.getActiveState() !== 'normal') {323 hasActiveSet = true;324 }325 }326 return hasActiveSet;327 },328 /**329 * Convert coords of each axis to Point.330 * Return point. For example: [10, 20]331 * @param {Array.<number>} coords332 * @param {string} dim333 * @return {Array.<number>}334 */335 axisCoordToPoint: function (coord, dim) {336 var axisLayout = this._axesLayout[dim];337 return graphic.applyTransform([coord, 0], axisLayout.transform);338 },339 /**340 * Get axis layout.341 */342 getAxisLayout: function (dim) {343 return zrUtil.clone(this._axesLayout[dim]);344 },345 /**346 * @param {Array.<number>} point347 * @return {Object} {axisExpandWindow, delta, behavior: 'jump' | 'slide' | 'none'}.348 */349 getSlidedAxisExpandWindow: function (point) {350 var layoutInfo = this._makeLayoutInfo();351 var pixelDimIndex = layoutInfo.pixelDimIndex;352 var axisExpandWindow = layoutInfo.axisExpandWindow.slice();353 var winSize = axisExpandWindow[1] - axisExpandWindow[0];354 var extent = [0, layoutInfo.axisExpandWidth * (layoutInfo.axisCount - 1)];355 // Out of the area of coordinate system.356 if (!this.containPoint(point)) {357 return {behavior: 'none', axisExpandWindow: axisExpandWindow};358 }359 // Conver the point from global to expand coordinates.360 var pointCoord = point[pixelDimIndex] - layoutInfo.layoutBase - layoutInfo.axisExpandWindow0Pos;361 // For dragging operation convenience, the window should not be362 // slided when mouse is the center area of the window.363 var delta;364 var behavior = 'slide';365 var axisCollapseWidth = layoutInfo.axisCollapseWidth;366 var triggerArea = this._model.get('axisExpandSlideTriggerArea');367 // But consider touch device, jump is necessary.368 var useJump = triggerArea[0] != null;369 if (axisCollapseWidth) {370 if (useJump && axisCollapseWidth && pointCoord < winSize * triggerArea[0]) {371 behavior = 'jump';372 delta = pointCoord - winSize * triggerArea[2];373 }374 else if (useJump && axisCollapseWidth && pointCoord > winSize * (1 - triggerArea[0])) {375 behavior = 'jump';376 delta = pointCoord - winSize * (1 - triggerArea[2]);377 }378 else {379 (delta = pointCoord - winSize * triggerArea[1]) >= 0380 && (delta = pointCoord - winSize * (1 - triggerArea[1])) <= 0381 && (delta = 0);382 }383 delta *= layoutInfo.axisExpandWidth / axisCollapseWidth;384 delta385 ? sliderMove(delta, axisExpandWindow, extent, 'all')386 // Avoid nonsense triger on mousemove.387 : (behavior = 'none');388 }389 // When screen is too narrow, make it visible and slidable, although it is hard to interact.390 else {391 var winSize = axisExpandWindow[1] - axisExpandWindow[0];392 var pos = extent[1] * pointCoord / winSize;393 axisExpandWindow = [mathMax(0, pos - winSize / 2)];394 axisExpandWindow[1] = mathMin(extent[1], axisExpandWindow[0] + winSize);395 axisExpandWindow[0] = axisExpandWindow[1] - winSize;396 }397 return {398 axisExpandWindow: axisExpandWindow,399 behavior: behavior400 };401 }402};403function restrict(len, extent) {404 return mathMin(mathMax(len, extent[0]), extent[1]);405}406function layoutAxisWithoutExpand(axisIndex, layoutInfo) {407 var step = layoutInfo.layoutLength / (layoutInfo.axisCount - 1);408 return {409 position: step * axisIndex,410 axisNameAvailableWidth: step,411 axisLabelShow: true412 };413}414function layoutAxisWithExpand(axisIndex, layoutInfo) {415 var layoutLength = layoutInfo.layoutLength;416 var axisExpandWidth = layoutInfo.axisExpandWidth;417 var axisCount = layoutInfo.axisCount;418 var axisCollapseWidth = layoutInfo.axisCollapseWidth;419 var winInnerIndices = layoutInfo.winInnerIndices;420 var position;421 var axisNameAvailableWidth = axisCollapseWidth;422 var axisLabelShow = false;423 var nameTruncateMaxWidth;424 if (axisIndex < winInnerIndices[0]) {425 position = axisIndex * axisCollapseWidth;426 nameTruncateMaxWidth = axisCollapseWidth;427 }428 else if (axisIndex <= winInnerIndices[1]) {429 position = layoutInfo.axisExpandWindow0Pos430 + axisIndex * axisExpandWidth - layoutInfo.axisExpandWindow[0];431 axisNameAvailableWidth = axisExpandWidth;432 axisLabelShow = true;433 }434 else {435 position = layoutLength - (axisCount - 1 - axisIndex) * axisCollapseWidth;436 nameTruncateMaxWidth = axisCollapseWidth;437 }438 return {439 position: position,440 axisNameAvailableWidth: axisNameAvailableWidth,441 axisLabelShow: axisLabelShow,442 nameTruncateMaxWidth: nameTruncateMaxWidth443 };444}...

Full Screen

Full Screen

sm3.ts

Source:sm3.ts Github

copy

Full Screen

1export class SM3 {2 readonly BLOCK_SIZE = 64 as const;3 // IV4 state = {5 A: 0x7380166f,6 B: 0x4914b2b9,7 C: 0x172442d7,8 D: 0xda8a0600,9 E: 0xa96f30bc,10 F: 0x163138aa,11 G: 0xe38dee4d,12 H: 0xb0fb0e4e,13 };14 // max 64 bytes, cleared when final15 cache?: Buffer = undefined;16 // big-ending byte length17 total = Buffer.alloc(8);18 update(data: string | Buffer, encoding?: 'utf8' | 'hex') {19 if (data.length === 0) {20 return;21 }22 if (typeof data === 'string') {23 data = Buffer.from(data, encoding);24 }25 const len = data.length;26 let n = 0;27 // update total28 const view = new DataView(this.total.buffer, this.total.byteOffset);29 let h = view.getUint32(0);30 let l = view.getUint32(4);31 l += len;32 l = l >>> 0;33 if (l < len) {34 h += 1;35 }36 view.setUint32(0, h);37 view.setUint32(4, l);38 if (this.cache) {39 n = this.cache.length;40 if (len >= this.BLOCK_SIZE || len + n >= this.BLOCK_SIZE) {41 // make a block42 const block = Buffer.alloc(this.BLOCK_SIZE);43 block.set(this.cache);44 block.set(data.subarray(0, this.BLOCK_SIZE - n), n);45 this.blockProcess(block);46 data = data.subarray(this.BLOCK_SIZE - n);47 // have process48 this.cache = undefined;49 } else {50 // not fill a block, cache it51 const cache = Buffer.alloc(len + n);52 cache.set(this.cache);53 cache.set(data, n);54 this.cache = cache;55 return;56 }57 }58 for (59 ;60 data.length >= this.BLOCK_SIZE;61 data = data.subarray(this.BLOCK_SIZE)62 ) {63 this.blockProcess(data);64 }65 if (data.length > 0) {66 // cache remained67 this.cache = Buffer.from(data);68 }69 }70 final(encoding?: 'hex'): Buffer | string {71 const block = Buffer.alloc(this.BLOCK_SIZE);72 let n = 0;73 if (this.cache) {74 block.set(this.cache);75 n = this.cache.length;76 this.cache = undefined;77 }78 block[n] = 0x80;79 n += 1;80 if (n > this.BLOCK_SIZE - 8) {81 this.blockProcess(block);82 n = 0;83 block.fill(0);84 }85 let view: DataView;86 view = new DataView(this.total.buffer, this.total.byteOffset);87 // bit length88 let h = view.getUint32(0);89 let l = view.getUint32(4);90 this.total.fill(0);91 h = (h << 3) | (l >>> 29);92 l = l << 3;93 view = new DataView(block.buffer, block.byteOffset);94 view.setUint32(this.BLOCK_SIZE - 8, h);95 view.setUint32(this.BLOCK_SIZE - 4, l);96 this.blockProcess(block);97 const d = Buffer.alloc(32);98 view = new DataView(d.buffer, d.byteOffset);99 const { A, B, C, D, E, F, G, H } = this.state;100 view.setUint32(0, A);101 view.setUint32(4, B);102 view.setUint32(8, C);103 view.setUint32(12, D);104 view.setUint32(16, E);105 view.setUint32(20, F);106 view.setUint32(24, G);107 view.setUint32(28, H);108 return encoding ? d.toString(encoding) : d;109 }110 private blockProcess(block: Buffer) {111 let A, B, C, D, E, F, G, H;112 ({ A, B, C, D, E, F, G, H } = this.state);113 const view = new DataView(block.buffer, block.byteOffset);114 let W00 = view.getUint32(0);115 let W01 = view.getUint32(4);116 let W02 = view.getUint32(8);117 let W03 = view.getUint32(12);118 let W04 = view.getUint32(16);119 let W05 = view.getUint32(20);120 let W06 = view.getUint32(24);121 let W07 = view.getUint32(28);122 let W08 = view.getUint32(32);123 let W09 = view.getUint32(36);124 let W10 = view.getUint32(40);125 let W11 = view.getUint32(44);126 let W12 = view.getUint32(48);127 let W13 = view.getUint32(52);128 let W14 = view.getUint32(56);129 let W15 = view.getUint32(60);130 [B, D, F, H] = R1(A, B, C, D, E, F, G, H, 0x79cc4519, W00, W00 ^ W04);131 W00 = EXPAND(W00, W07, W13, W03, W10);132 [A, C, E, G] = R1(D, A, B, C, H, E, F, G, 0xf3988a32, W01, W01 ^ W05);133 W01 = EXPAND(W01, W08, W14, W04, W11);134 [D, B, H, F] = R1(C, D, A, B, G, H, E, F, 0xe7311465, W02, W02 ^ W06);135 W02 = EXPAND(W02, W09, W15, W05, W12);136 [C, A, G, E] = R1(B, C, D, A, F, G, H, E, 0xce6228cb, W03, W03 ^ W07);137 W03 = EXPAND(W03, W10, W00, W06, W13);138 [B, D, F, H] = R1(A, B, C, D, E, F, G, H, 0x9cc45197, W04, W04 ^ W08);139 W04 = EXPAND(W04, W11, W01, W07, W14);140 [A, C, E, G] = R1(D, A, B, C, H, E, F, G, 0x3988a32f, W05, W05 ^ W09);141 W05 = EXPAND(W05, W12, W02, W08, W15);142 [D, B, H, F] = R1(C, D, A, B, G, H, E, F, 0x7311465e, W06, W06 ^ W10);143 W06 = EXPAND(W06, W13, W03, W09, W00);144 [C, A, G, E] = R1(B, C, D, A, F, G, H, E, 0xe6228cbc, W07, W07 ^ W11);145 W07 = EXPAND(W07, W14, W04, W10, W01);146 [B, D, F, H] = R1(A, B, C, D, E, F, G, H, 0xcc451979, W08, W08 ^ W12);147 W08 = EXPAND(W08, W15, W05, W11, W02);148 [A, C, E, G] = R1(D, A, B, C, H, E, F, G, 0x988a32f3, W09, W09 ^ W13);149 W09 = EXPAND(W09, W00, W06, W12, W03);150 [D, B, H, F] = R1(C, D, A, B, G, H, E, F, 0x311465e7, W10, W10 ^ W14);151 W10 = EXPAND(W10, W01, W07, W13, W04);152 [C, A, G, E] = R1(B, C, D, A, F, G, H, E, 0x6228cbce, W11, W11 ^ W15);153 W11 = EXPAND(W11, W02, W08, W14, W05);154 [B, D, F, H] = R1(A, B, C, D, E, F, G, H, 0xc451979c, W12, W12 ^ W00);155 W12 = EXPAND(W12, W03, W09, W15, W06);156 [A, C, E, G] = R1(D, A, B, C, H, E, F, G, 0x88a32f39, W13, W13 ^ W01);157 W13 = EXPAND(W13, W04, W10, W00, W07);158 [D, B, H, F] = R1(C, D, A, B, G, H, E, F, 0x11465e73, W14, W14 ^ W02);159 W14 = EXPAND(W14, W05, W11, W01, W08);160 [C, A, G, E] = R1(B, C, D, A, F, G, H, E, 0x228cbce6, W15, W15 ^ W03);161 W15 = EXPAND(W15, W06, W12, W02, W09);162 [B, D, F, H] = R2(A, B, C, D, E, F, G, H, 0x9d8a7a87, W00, W00 ^ W04);163 W00 = EXPAND(W00, W07, W13, W03, W10);164 [A, C, E, G] = R2(D, A, B, C, H, E, F, G, 0x3b14f50f, W01, W01 ^ W05);165 W01 = EXPAND(W01, W08, W14, W04, W11);166 [D, B, H, F] = R2(C, D, A, B, G, H, E, F, 0x7629ea1e, W02, W02 ^ W06);167 W02 = EXPAND(W02, W09, W15, W05, W12);168 [C, A, G, E] = R2(B, C, D, A, F, G, H, E, 0xec53d43c, W03, W03 ^ W07);169 W03 = EXPAND(W03, W10, W00, W06, W13);170 [B, D, F, H] = R2(A, B, C, D, E, F, G, H, 0xd8a7a879, W04, W04 ^ W08);171 W04 = EXPAND(W04, W11, W01, W07, W14);172 [A, C, E, G] = R2(D, A, B, C, H, E, F, G, 0xb14f50f3, W05, W05 ^ W09);173 W05 = EXPAND(W05, W12, W02, W08, W15);174 [D, B, H, F] = R2(C, D, A, B, G, H, E, F, 0x629ea1e7, W06, W06 ^ W10);175 W06 = EXPAND(W06, W13, W03, W09, W00);176 [C, A, G, E] = R2(B, C, D, A, F, G, H, E, 0xc53d43ce, W07, W07 ^ W11);177 W07 = EXPAND(W07, W14, W04, W10, W01);178 [B, D, F, H] = R2(A, B, C, D, E, F, G, H, 0x8a7a879d, W08, W08 ^ W12);179 W08 = EXPAND(W08, W15, W05, W11, W02);180 [A, C, E, G] = R2(D, A, B, C, H, E, F, G, 0x14f50f3b, W09, W09 ^ W13);181 W09 = EXPAND(W09, W00, W06, W12, W03);182 [D, B, H, F] = R2(C, D, A, B, G, H, E, F, 0x29ea1e76, W10, W10 ^ W14);183 W10 = EXPAND(W10, W01, W07, W13, W04);184 [C, A, G, E] = R2(B, C, D, A, F, G, H, E, 0x53d43cec, W11, W11 ^ W15);185 W11 = EXPAND(W11, W02, W08, W14, W05);186 [B, D, F, H] = R2(A, B, C, D, E, F, G, H, 0xa7a879d8, W12, W12 ^ W00);187 W12 = EXPAND(W12, W03, W09, W15, W06);188 [A, C, E, G] = R2(D, A, B, C, H, E, F, G, 0x4f50f3b1, W13, W13 ^ W01);189 W13 = EXPAND(W13, W04, W10, W00, W07);190 [D, B, H, F] = R2(C, D, A, B, G, H, E, F, 0x9ea1e762, W14, W14 ^ W02);191 W14 = EXPAND(W14, W05, W11, W01, W08);192 [C, A, G, E] = R2(B, C, D, A, F, G, H, E, 0x3d43cec5, W15, W15 ^ W03);193 W15 = EXPAND(W15, W06, W12, W02, W09);194 [B, D, F, H] = R2(A, B, C, D, E, F, G, H, 0x7a879d8a, W00, W00 ^ W04);195 W00 = EXPAND(W00, W07, W13, W03, W10);196 [A, C, E, G] = R2(D, A, B, C, H, E, F, G, 0xf50f3b14, W01, W01 ^ W05);197 W01 = EXPAND(W01, W08, W14, W04, W11);198 [D, B, H, F] = R2(C, D, A, B, G, H, E, F, 0xea1e7629, W02, W02 ^ W06);199 W02 = EXPAND(W02, W09, W15, W05, W12);200 [C, A, G, E] = R2(B, C, D, A, F, G, H, E, 0xd43cec53, W03, W03 ^ W07);201 W03 = EXPAND(W03, W10, W00, W06, W13);202 [B, D, F, H] = R2(A, B, C, D, E, F, G, H, 0xa879d8a7, W04, W04 ^ W08);203 W04 = EXPAND(W04, W11, W01, W07, W14);204 [A, C, E, G] = R2(D, A, B, C, H, E, F, G, 0x50f3b14f, W05, W05 ^ W09);205 W05 = EXPAND(W05, W12, W02, W08, W15);206 [D, B, H, F] = R2(C, D, A, B, G, H, E, F, 0xa1e7629e, W06, W06 ^ W10);207 W06 = EXPAND(W06, W13, W03, W09, W00);208 [C, A, G, E] = R2(B, C, D, A, F, G, H, E, 0x43cec53d, W07, W07 ^ W11);209 W07 = EXPAND(W07, W14, W04, W10, W01);210 [B, D, F, H] = R2(A, B, C, D, E, F, G, H, 0x879d8a7a, W08, W08 ^ W12);211 W08 = EXPAND(W08, W15, W05, W11, W02);212 [A, C, E, G] = R2(D, A, B, C, H, E, F, G, 0x0f3b14f5, W09, W09 ^ W13);213 W09 = EXPAND(W09, W00, W06, W12, W03);214 [D, B, H, F] = R2(C, D, A, B, G, H, E, F, 0x1e7629ea, W10, W10 ^ W14);215 W10 = EXPAND(W10, W01, W07, W13, W04);216 [C, A, G, E] = R2(B, C, D, A, F, G, H, E, 0x3cec53d4, W11, W11 ^ W15);217 W11 = EXPAND(W11, W02, W08, W14, W05);218 [B, D, F, H] = R2(A, B, C, D, E, F, G, H, 0x79d8a7a8, W12, W12 ^ W00);219 W12 = EXPAND(W12, W03, W09, W15, W06);220 [A, C, E, G] = R2(D, A, B, C, H, E, F, G, 0xf3b14f50, W13, W13 ^ W01);221 W13 = EXPAND(W13, W04, W10, W00, W07);222 [D, B, H, F] = R2(C, D, A, B, G, H, E, F, 0xe7629ea1, W14, W14 ^ W02);223 W14 = EXPAND(W14, W05, W11, W01, W08);224 [C, A, G, E] = R2(B, C, D, A, F, G, H, E, 0xcec53d43, W15, W15 ^ W03);225 W15 = EXPAND(W15, W06, W12, W02, W09);226 [B, D, F, H] = R2(A, B, C, D, E, F, G, H, 0x9d8a7a87, W00, W00 ^ W04);227 W00 = EXPAND(W00, W07, W13, W03, W10);228 [A, C, E, G] = R2(D, A, B, C, H, E, F, G, 0x3b14f50f, W01, W01 ^ W05);229 W01 = EXPAND(W01, W08, W14, W04, W11);230 [D, B, H, F] = R2(C, D, A, B, G, H, E, F, 0x7629ea1e, W02, W02 ^ W06);231 W02 = EXPAND(W02, W09, W15, W05, W12);232 [C, A, G, E] = R2(B, C, D, A, F, G, H, E, 0xec53d43c, W03, W03 ^ W07);233 W03 = EXPAND(W03, W10, W00, W06, W13);234 [B, D, F, H] = R2(A, B, C, D, E, F, G, H, 0xd8a7a879, W04, W04 ^ W08);235 [A, C, E, G] = R2(D, A, B, C, H, E, F, G, 0xb14f50f3, W05, W05 ^ W09);236 [D, B, H, F] = R2(C, D, A, B, G, H, E, F, 0x629ea1e7, W06, W06 ^ W10);237 [C, A, G, E] = R2(B, C, D, A, F, G, H, E, 0xc53d43ce, W07, W07 ^ W11);238 [B, D, F, H] = R2(A, B, C, D, E, F, G, H, 0x8a7a879d, W08, W08 ^ W12);239 [A, C, E, G] = R2(D, A, B, C, H, E, F, G, 0x14f50f3b, W09, W09 ^ W13);240 [D, B, H, F] = R2(C, D, A, B, G, H, E, F, 0x29ea1e76, W10, W10 ^ W14);241 [C, A, G, E] = R2(B, C, D, A, F, G, H, E, 0x53d43cec, W11, W11 ^ W15);242 [B, D, F, H] = R2(A, B, C, D, E, F, G, H, 0xa7a879d8, W12, W12 ^ W00);243 [A, C, E, G] = R2(D, A, B, C, H, E, F, G, 0x4f50f3b1, W13, W13 ^ W01);244 [D, B, H, F] = R2(C, D, A, B, G, H, E, F, 0x9ea1e762, W14, W14 ^ W02);245 [C, A, G, E] = R2(B, C, D, A, F, G, H, E, 0x3d43cec5, W15, W15 ^ W03);246 this.state.A ^= A;247 this.state.B ^= B;248 this.state.C ^= C;249 this.state.D ^= D;250 this.state.E ^= E;251 this.state.F ^= F;252 this.state.G ^= G;253 this.state.H ^= H;254 }255}256type State = {257 readonly A: number;258 readonly B: number;259 readonly C: number;260 readonly D: number;261 readonly E: number;262 readonly F: number;263 readonly G: number;264 readonly H: number;265};266// function logState(...states: number[]) {267// const ss = states.map((x) => (x >>> 0).toString(16).padStart(8, '0'));268// console.log(ss.join(' '));269// }270function ROTATE(a: number, n: number): number {271 return (a << n) | (a >>> (32 - n));272}273function P0(x: number): number {274 return x ^ ROTATE(x, 9) ^ ROTATE(x, 17);275}276function P1(x: number): number {277 return x ^ ROTATE(x, 15) ^ ROTATE(x, 23);278}279type FF = (x: number, y: number, z: number) => number;280type GG = (x: number, y: number, z: number) => number;281function FF0(x: number, y: number, z: number): number {282 return x ^ y ^ z;283}284function GG0(x: number, y: number, z: number): number {285 return x ^ y ^ z;286}287function FF1(x: number, y: number, z: number): number {288 // return (x & y) ^ (x & z) ^ (y & z);289 return (x & y) | ((x | y) & z);290}291function GG1(x: number, y: number, z: number): number {292 // return (x & y) | (~x & z);293 return z ^ (x & (y ^ z));294}295function EXPAND(296 W0: number,297 W7: number,298 W13: number,299 W3: number,300 W10: number301): number {302 return P1(W0 ^ W7 ^ ROTATE(W13, 15)) ^ ROTATE(W3, 7) ^ W10;303}304type RNDResult = readonly [number, number, number, number];305function RND(306 state: State,307 TJ: number,308 Wi: number,309 Wj: number,310 FF: FF,311 GG: GG312): RNDResult {313 // eslint-disable-next-line prefer-const314 let { A, B, C, D, E, F, G, H } = state;315 const A12 = ROTATE(A, 12);316 const A12_SM = A12 + E + TJ;317 const SS1 = ROTATE(A12_SM, 7);318 const TT1 = FF(A, B, C) + D + (SS1 ^ A12) + Wj;319 const TT2 = GG(E, F, G) + H + SS1 + Wi;320 B = ROTATE(B, 9);321 D = TT1;322 F = ROTATE(F, 19);323 H = P0(TT2);324 return [B, D, F, H];325}326function R1(327 A: number,328 B: number,329 C: number,330 D: number,331 E: number,332 F: number,333 G: number,334 H: number,335 TJ: number,336 Wi: number,337 Wj: number338): RNDResult {339 return RND({ A, B, C, D, E, F, G, H }, TJ, Wi, Wj, FF0, GG0);340}341function R2(342 A: number,343 B: number,344 C: number,345 D: number,346 E: number,347 F: number,348 G: number,349 H: number,350 TJ: number,351 Wi: number,352 Wj: number353): RNDResult {354 return RND({ A, B, C, D, E, F, G, H }, TJ, Wi, Wj, FF1, GG1);...

Full Screen

Full Screen

test_autoexpand.py

Source:test_autoexpand.py Github

copy

Full Screen

...51 expand = self.auto_expand.expand_word_event52 equal = self.assertEqual53 self.text.insert('insert', 'ab ac bx ad ab a')54 equal(self.auto_expand.getwords(), ['ab', 'ad', 'ac', 'a'])55 expand('event')56 equal(previous(), 'ab')57 expand('event')58 equal(previous(), 'ad')59 expand('event')60 equal(previous(), 'ac')61 expand('event')62 equal(previous(), 'a')63 def test_after_only(self):64 # Also add punctuation 'noise' that should be ignored.65 text = self.text66 previous = self.auto_expand.getprevword67 expand = self.auto_expand.expand_word_event68 equal = self.assertEqual69 text.insert('insert', 'a, [ab] ac: () bx"" cd ac= ad ya')70 text.mark_set('insert', '1.1')71 equal(self.auto_expand.getwords(), ['ab', 'ac', 'ad', 'a'])72 expand('event')73 equal(previous(), 'ab')74 expand('event')75 equal(previous(), 'ac')76 expand('event')77 equal(previous(), 'ad')78 expand('event')79 equal(previous(), 'a')80 def test_both_before_after(self):81 text = self.text82 previous = self.auto_expand.getprevword83 expand = self.auto_expand.expand_word_event84 equal = self.assertEqual85 text.insert('insert', 'ab xy yz\n')86 text.insert('insert', 'a ac by ac')87 text.mark_set('insert', '2.1')88 equal(self.auto_expand.getwords(), ['ab', 'ac', 'a'])89 expand('event')90 equal(previous(), 'ab')91 expand('event')92 equal(previous(), 'ac')93 expand('event')94 equal(previous(), 'a')95 def test_other_expand_cases(self):96 text = self.text97 expand = self.auto_expand.expand_word_event98 equal = self.assertEqual99 # no expansion candidate found100 equal(self.auto_expand.getwords(), [])101 equal(expand('event'), 'break')102 text.insert('insert', 'bx cy dz a')103 equal(self.auto_expand.getwords(), [])104 # reset state by successfully expanding once105 # move cursor to another position and expand again106 text.insert('insert', 'ac xy a ac ad a')107 text.mark_set('insert', '1.7')108 expand('event')109 initial_state = self.auto_expand.state110 text.mark_set('insert', '1.end')111 expand('event')112 new_state = self.auto_expand.state113 self.assertNotEqual(initial_state, new_state)114if __name__ == '__main__':...

Full Screen

Full Screen

expand.js

Source:expand.js Github

copy

Full Screen

1// Expand trigger component module2'use strict';3module.exports = function Expand() {4 var expand = {};5 /**6 * @example7 * <button id="expand" class="button">8 * Lorem ipsum ...9 * </button>10 *11 * <div id="expand-container" class="container">12 * Container13 * </div>14 *15 * import Expand from '@sulu/web/packages/components/expand';16 * var component = new Expand();17 * component.initialize(document.getElementById('expand'), {});18 *19 * @param {HTMLElement} el20 * @param {object} options21 */22 expand.initialize = function initialize(el, options) {23 expand.el = el;24 expand.id = el.id;25 expand.closeOnEsc = options.closeOnEsc ? options.closeOnEsc : false;26 expand.container = options.container27 ? document.getElementById(options.container)28 : document.getElementById(expand.id + '-container');29 expand.modifier = options.modifier ? options.modifier : '--open';30 expand.toggleButtonClass = expand.getFirstClass(expand.el) + expand.modifier;31 expand.toggleContainerClass = expand.getFirstClass(expand.container) + expand.modifier;32 // Run init functions33 expand.bindEvents();34 };35 /**36 * @param {HTMLElement} element37 * @returns {string}38 */39 expand.getFirstClass = function getFirstClass(element) {40 return element.getAttribute('class').split(' ')[0];41 };42 expand.bindEvents = function bindEvents() {43 expand.el.addEventListener('click', expand.toggle);44 if (expand.closeOnEsc) {45 document.addEventListener('keyup', function(event) {46 if (event.keyCode === 27) {47 expand.close();48 }49 });50 }51 };52 expand.toggle = function toggle() {53 expand.el.classList.toggle(expand.toggleButtonClass);54 expand.container.classList.toggle(expand.toggleContainerClass);55 };56 expand.close = function close() {57 expand.el.classList.remove(expand.toggleButtonClass);58 expand.container.classList.remove(expand.toggleContainerClass);59 };60 return {61 initialize: expand.initialize,62 };...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run rester automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful