How to use input method in stryker-parent

Best JavaScript code snippet using stryker-parent

BeforeInputEventPlugin-test.js

Source:BeforeInputEventPlugin-test.js Github

copy

Full Screen

1/**2 * Copyright (c) Facebook, Inc. and its affiliates.3 *4 * This source code is licensed under the MIT license found in the5 * LICENSE file in the root directory of this source tree.6 *7 * @emails react-core8 */9'use strict';10let React;11let ReactDOM;12describe('BeforeInputEventPlugin', () => {13 let container;14 function loadReactDOM(envSimulator) {15 jest.resetModules();16 if (envSimulator) {17 envSimulator();18 }19 return require('react-dom');20 }21 function simulateIE11() {22 document.documentMode = 11;23 window.CompositionEvent = {};24 }25 function simulateWebkit() {26 window.CompositionEvent = {};27 window.TextEvent = {};28 }29 function simulateComposition() {30 window.CompositionEvent = {};31 }32 function simulateNoComposition() {33 // no composition event in Window - will use fallback34 }35 function simulateEvent(elem, type, data) {36 const event = new Event(type, {bubbles: true});37 Object.assign(event, data);38 elem.dispatchEvent(event);39 }40 function simulateKeyboardEvent(elem, type, data) {41 const {char, value, ...rest} = data;42 const event = new KeyboardEvent(type, {43 bubbles: true,44 ...rest,45 });46 if (char) {47 event.char = char;48 }49 if (value) {50 elem.value = value;51 }52 elem.dispatchEvent(event);53 }54 function simulatePaste(elem) {55 const pasteEvent = new Event('paste', {56 bubbles: true,57 });58 pasteEvent.clipboardData = {59 dropEffect: null,60 effectAllowed: null,61 files: null,62 items: null,63 types: null,64 };65 elem.dispatchEvent(pasteEvent);66 }67 beforeEach(() => {68 React = require('react');69 container = document.createElement('div');70 document.body.appendChild(container);71 });72 afterEach(() => {73 delete document.documentMode;74 delete window.CompositionEvent;75 delete window.TextEvent;76 delete window.opera;77 document.body.removeChild(container);78 container = null;79 });80 function keyCode(char) {81 return char.charCodeAt(0);82 }83 const scenarios = [84 {85 eventSimulator: simulateEvent,86 eventSimulatorArgs: [87 'compositionstart',88 {detail: {data: 'test'}, data: 'test'},89 ],90 },91 {92 eventSimulator: simulateEvent,93 eventSimulatorArgs: [94 'compositionupdate',95 {detail: {data: 'test string'}, data: 'test string'},96 ],97 },98 {99 eventSimulator: simulateEvent,100 eventSimulatorArgs: [101 'compositionend',102 {detail: {data: 'test string 3'}, data: 'test string 3'},103 ],104 },105 {106 eventSimulator: simulateEvent,107 eventSimulatorArgs: ['textInput', {data: 'abcß'}],108 },109 {110 eventSimulator: simulateKeyboardEvent,111 eventSimulatorArgs: ['keypress', {which: keyCode('a')}],112 },113 {114 eventSimulator: simulateKeyboardEvent,115 eventSimulatorArgs: ['keypress', {which: keyCode(' ')}, ' '],116 },117 {118 eventSimulator: simulateEvent,119 eventSimulatorArgs: ['textInput', {data: ' '}],120 },121 {122 eventSimulator: simulateKeyboardEvent,123 eventSimulatorArgs: ['keypress', {which: keyCode('a'), ctrlKey: true}],124 },125 {126 eventSimulator: simulateKeyboardEvent,127 eventSimulatorArgs: ['keypress', {which: keyCode('b'), altKey: true}],128 },129 {130 eventSimulator: simulateKeyboardEvent,131 eventSimulatorArgs: [132 'keypress',133 {which: keyCode('c'), altKey: true, ctrlKey: true},134 ],135 },136 {137 eventSimulator: simulateKeyboardEvent,138 eventSimulatorArgs: [139 'keypress',140 {which: keyCode('X'), char: '\uD83D\uDE0A'},141 ],142 },143 {144 eventSimulator: simulateEvent,145 eventSimulatorArgs: ['textInput', {data: '\uD83D\uDE0A'}],146 },147 {148 eventSimulator: simulateKeyboardEvent,149 eventSimulatorArgs: ['keydown', {keyCode: 229, value: 'foo'}],150 },151 {152 eventSimulator: simulateKeyboardEvent,153 eventSimulatorArgs: ['keydown', {keyCode: 9, value: 'foobar'}],154 },155 {156 eventSimulator: simulateKeyboardEvent,157 eventSimulatorArgs: ['keydown', {keyCode: 229, value: 'foofoo'}],158 },159 {160 eventSimulator: simulateKeyboardEvent,161 eventSimulatorArgs: ['keyup', {keyCode: 9, value: 'fooBARfoo'}],162 },163 {164 eventSimulator: simulateKeyboardEvent,165 eventSimulatorArgs: ['keydown', {keyCode: 229, value: 'foofoo'}],166 },167 {168 eventSimulator: simulateKeyboardEvent,169 eventSimulatorArgs: ['keypress', {keyCode: 60, value: 'Barfoofoo'}],170 },171 {172 eventSimulator: simulatePaste,173 eventSimulatorArgs: [],174 },175 ];176 const environments = [177 {178 emulator: simulateWebkit,179 assertions: [180 {181 run: ({182 beforeInputEvent,183 compositionStartEvent,184 spyOnBeforeInput,185 spyOnCompositionStart,186 }) => {187 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);188 expect(beforeInputEvent).toBeNull();189 expect(spyOnCompositionStart).toHaveBeenCalledTimes(1);190 expect(compositionStartEvent.type).toBe('compositionstart');191 expect(compositionStartEvent.data).toBe('test');192 },193 },194 {195 run: ({196 beforeInputEvent,197 compositionUpdateEvent,198 spyOnBeforeInput,199 spyOnCompositionUpdate,200 }) => {201 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);202 expect(beforeInputEvent).toBeNull();203 expect(spyOnCompositionUpdate).toHaveBeenCalledTimes(1);204 expect(compositionUpdateEvent.type).toBe('compositionupdate');205 expect(compositionUpdateEvent.data).toBe('test string');206 },207 },208 {209 run: ({beforeInputEvent, spyOnBeforeInput}) => {210 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);211 expect(beforeInputEvent.type).toBe('compositionend');212 expect(beforeInputEvent.data).toBe('test string 3');213 },214 },215 {216 run: ({beforeInputEvent, spyOnBeforeInput}) => {217 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);218 expect(beforeInputEvent.type).toBe('textInput');219 expect(beforeInputEvent.data).toBe('abcß');220 },221 },222 {223 run: ({beforeInputEvent, spyOnBeforeInput}) => {224 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);225 expect(beforeInputEvent).toBeNull();226 },227 },228 {229 run: ({beforeInputEvent, spyOnBeforeInput}) => {230 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);231 expect(beforeInputEvent.type).toBe('keypress');232 expect(beforeInputEvent.data).toBe(' ');233 },234 },235 {236 run: ({beforeInputEvent, spyOnBeforeInput}) => {237 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);238 expect(beforeInputEvent).toBeNull();239 },240 },241 {242 run: ({beforeInputEvent, spyOnBeforeInput}) => {243 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);244 expect(beforeInputEvent).toBeNull();245 },246 },247 {248 run: ({beforeInputEvent, spyOnBeforeInput}) => {249 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);250 expect(beforeInputEvent).toBeNull();251 },252 },253 {254 run: ({beforeInputEvent, spyOnBeforeInput}) => {255 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);256 expect(beforeInputEvent).toBeNull();257 },258 },259 {260 run: ({beforeInputEvent, spyOnBeforeInput}) => {261 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);262 expect(beforeInputEvent).toBeNull();263 },264 },265 {266 run: ({beforeInputEvent, spyOnBeforeInput}) => {267 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);268 expect(beforeInputEvent.type).toBe('textInput');269 expect(beforeInputEvent.data).toBe('\uD83D\uDE0A');270 },271 },272 {273 run: ({beforeInputEvent, spyOnBeforeInput}) => {274 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);275 expect(beforeInputEvent).toBeNull();276 },277 },278 {279 run: ({beforeInputEvent, spyOnBeforeInput}) => {280 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);281 expect(beforeInputEvent).toBeNull();282 },283 },284 {285 run: ({beforeInputEvent, spyOnBeforeInput}) => {286 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);287 expect(beforeInputEvent).toBeNull();288 },289 },290 {291 run: ({beforeInputEvent, spyOnBeforeInput}) => {292 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);293 expect(beforeInputEvent).toBeNull();294 },295 },296 {297 run: ({beforeInputEvent, spyOnBeforeInput}) => {298 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);299 expect(beforeInputEvent).toBeNull();300 },301 },302 {303 run: ({beforeInputEvent, spyOnBeforeInput}) => {304 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);305 expect(beforeInputEvent).toBeNull();306 },307 },308 {309 run: ({beforeInputEvent, spyOnBeforeInput}) => {310 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);311 expect(beforeInputEvent).toBeNull();312 },313 },314 ],315 },316 {317 emulator: simulateIE11,318 assertions: [319 {320 run: ({beforeInputEvent, spyOnBeforeInput}) => {321 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);322 expect(beforeInputEvent).toBeNull();323 },324 },325 {326 run: ({beforeInputEvent, spyOnBeforeInput}) => {327 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);328 expect(beforeInputEvent).toBeNull();329 },330 },331 {332 run: ({beforeInputEvent, spyOnBeforeInput}) => {333 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);334 expect(beforeInputEvent).toBeNull();335 },336 },337 {338 run: ({beforeInputEvent, spyOnBeforeInput}) => {339 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);340 expect(beforeInputEvent).toBeNull();341 },342 },343 {344 run: ({beforeInputEvent, spyOnBeforeInput}) => {345 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);346 expect(beforeInputEvent.type).toBe('keypress');347 expect(beforeInputEvent.data).toBe('a');348 },349 },350 {351 run: ({beforeInputEvent, spyOnBeforeInput}) => {352 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);353 expect(beforeInputEvent.type).toBe('keypress');354 expect(beforeInputEvent.data).toBe(' ');355 },356 },357 {358 run: ({beforeInputEvent, spyOnBeforeInput}) => {359 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);360 expect(beforeInputEvent).toBeNull();361 },362 },363 {364 run: ({beforeInputEvent, spyOnBeforeInput}) => {365 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);366 expect(beforeInputEvent).toBeNull();367 },368 },369 {370 run: ({beforeInputEvent, spyOnBeforeInput}) => {371 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);372 expect(beforeInputEvent).toBeNull();373 },374 },375 {376 run: ({beforeInputEvent, spyOnBeforeInput}) => {377 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);378 expect(beforeInputEvent.type).toBe('keypress');379 expect(beforeInputEvent.data).toBe('c');380 },381 },382 {383 run: ({beforeInputEvent, spyOnBeforeInput}) => {384 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);385 expect(beforeInputEvent.type).toBe('keypress');386 expect(beforeInputEvent.data).toBe('\uD83D\uDE0A');387 },388 },389 {390 run: ({beforeInputEvent, spyOnBeforeInput}) => {391 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);392 expect(beforeInputEvent).toBeNull();393 },394 },395 {396 run: ({beforeInputEvent, spyOnBeforeInput}) => {397 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);398 expect(beforeInputEvent).toBeNull();399 },400 },401 {402 run: ({beforeInputEvent, spyOnBeforeInput}) => {403 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);404 expect(beforeInputEvent).toBeNull();405 },406 },407 {408 run: ({beforeInputEvent, spyOnBeforeInput}) => {409 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);410 expect(beforeInputEvent).toBeNull();411 },412 },413 {414 run: ({beforeInputEvent, spyOnBeforeInput}) => {415 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);416 expect(beforeInputEvent).toBeNull();417 },418 },419 {420 run: ({beforeInputEvent, spyOnBeforeInput}) => {421 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);422 expect(beforeInputEvent).toBeNull();423 },424 },425 {426 run: ({beforeInputEvent, spyOnBeforeInput}) => {427 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);428 expect(beforeInputEvent).toBeNull();429 },430 },431 {432 run: ({beforeInputEvent, spyOnBeforeInput}) => {433 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);434 expect(beforeInputEvent).toBeNull();435 },436 },437 ],438 },439 {440 emulator: simulateNoComposition,441 assertions: [442 {443 run: ({beforeInputEvent, spyOnBeforeInput}) => {444 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);445 expect(beforeInputEvent).toBeNull();446 },447 },448 {449 run: ({beforeInputEvent, spyOnBeforeInput}) => {450 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);451 expect(beforeInputEvent).toBeNull();452 },453 },454 {455 run: ({beforeInputEvent, spyOnBeforeInput}) => {456 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);457 expect(beforeInputEvent).toBeNull();458 },459 },460 {461 run: ({beforeInputEvent, spyOnBeforeInput}) => {462 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);463 expect(beforeInputEvent).toBeNull();464 },465 },466 {467 run: ({beforeInputEvent, spyOnBeforeInput}) => {468 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);469 expect(beforeInputEvent.type).toBe('keypress');470 expect(beforeInputEvent.data).toBe('a');471 },472 },473 {474 run: ({beforeInputEvent, spyOnBeforeInput}) => {475 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);476 expect(beforeInputEvent.type).toBe('keypress');477 expect(beforeInputEvent.data).toBe(' ');478 },479 },480 {481 run: ({beforeInputEvent, spyOnBeforeInput}) => {482 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);483 expect(beforeInputEvent).toBeNull();484 },485 },486 {487 run: ({beforeInputEvent, spyOnBeforeInput}) => {488 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);489 expect(beforeInputEvent).toBeNull();490 },491 },492 {493 run: ({beforeInputEvent, spyOnBeforeInput}) => {494 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);495 expect(beforeInputEvent).toBeNull();496 },497 },498 {499 run: ({beforeInputEvent, spyOnBeforeInput}) => {500 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);501 expect(beforeInputEvent.type).toBe('keypress');502 expect(beforeInputEvent.data).toBe('c');503 },504 },505 {506 run: ({beforeInputEvent, spyOnBeforeInput}) => {507 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);508 expect(beforeInputEvent.type).toBe('keypress');509 expect(beforeInputEvent.data).toBe('\uD83D\uDE0A');510 },511 },512 {513 run: ({beforeInputEvent, spyOnBeforeInput}) => {514 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);515 expect(beforeInputEvent).toBeNull();516 },517 },518 {519 run: ({beforeInputEvent, spyOnBeforeInput}) => {520 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);521 expect(beforeInputEvent).toBeNull();522 },523 },524 {525 run: ({beforeInputEvent, spyOnBeforeInput}) => {526 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);527 expect(beforeInputEvent.type).toBe('keydown');528 expect(beforeInputEvent.data).toBe('bar');529 },530 },531 {532 run: ({beforeInputEvent, spyOnBeforeInput}) => {533 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);534 expect(beforeInputEvent).toBeNull();535 },536 },537 {538 run: ({beforeInputEvent, spyOnBeforeInput}) => {539 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);540 expect(beforeInputEvent.type).toBe('keyup');541 expect(beforeInputEvent.data).toBe('BAR');542 },543 },544 {545 run: ({beforeInputEvent, spyOnBeforeInput}) => {546 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);547 expect(beforeInputEvent).toBeNull();548 },549 },550 {551 run: ({beforeInputEvent, spyOnBeforeInput}) => {552 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);553 expect(beforeInputEvent.type).toBe('keypress');554 expect(beforeInputEvent.data).toBe('Bar');555 },556 },557 {558 run: ({beforeInputEvent, spyOnBeforeInput}) => {559 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);560 expect(beforeInputEvent).toBeNull();561 },562 },563 ],564 },565 {566 emulator: simulateComposition,567 assertions: [568 {569 run: ({beforeInputEvent, spyOnBeforeInput}) => {570 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);571 expect(beforeInputEvent).toBeNull();572 },573 },574 {575 run: ({beforeInputEvent, spyOnBeforeInput}) => {576 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);577 expect(beforeInputEvent).toBeNull();578 },579 },580 {581 run: ({beforeInputEvent, spyOnBeforeInput}) => {582 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);583 expect(beforeInputEvent.type).toBe('compositionend');584 expect(beforeInputEvent.data).toBe('test string 3');585 },586 },587 {588 run: ({beforeInputEvent, spyOnBeforeInput}) => {589 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);590 expect(beforeInputEvent).toBeNull();591 },592 },593 {594 run: ({beforeInputEvent, spyOnBeforeInput}) => {595 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);596 expect(beforeInputEvent.type).toBe('keypress');597 expect(beforeInputEvent.data).toBe('a');598 },599 },600 {601 run: ({beforeInputEvent, spyOnBeforeInput}) => {602 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);603 expect(beforeInputEvent.type).toBe('keypress');604 expect(beforeInputEvent.data).toBe(' ');605 },606 },607 {608 run: ({beforeInputEvent, spyOnBeforeInput}) => {609 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);610 expect(beforeInputEvent).toBeNull();611 },612 },613 {614 run: ({beforeInputEvent, spyOnBeforeInput}) => {615 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);616 expect(beforeInputEvent).toBeNull();617 },618 },619 {620 run: ({beforeInputEvent, spyOnBeforeInput}) => {621 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);622 expect(beforeInputEvent).toBeNull();623 },624 },625 {626 run: ({beforeInputEvent, spyOnBeforeInput}) => {627 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);628 expect(beforeInputEvent.type).toBe('keypress');629 expect(beforeInputEvent.data).toBe('c');630 },631 },632 {633 run: ({beforeInputEvent, spyOnBeforeInput}) => {634 expect(spyOnBeforeInput).toHaveBeenCalledTimes(1);635 expect(beforeInputEvent.type).toBe('keypress');636 expect(beforeInputEvent.data).toBe('\uD83D\uDE0A');637 },638 },639 {640 run: ({beforeInputEvent, spyOnBeforeInput}) => {641 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);642 expect(beforeInputEvent).toBeNull();643 },644 },645 {646 run: ({beforeInputEvent, spyOnBeforeInput}) => {647 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);648 expect(beforeInputEvent).toBeNull();649 },650 },651 {652 run: ({beforeInputEvent, spyOnBeforeInput}) => {653 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);654 expect(beforeInputEvent).toBeNull();655 },656 },657 {658 run: ({beforeInputEvent, spyOnBeforeInput}) => {659 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);660 expect(beforeInputEvent).toBeNull();661 },662 },663 {664 run: ({beforeInputEvent, spyOnBeforeInput}) => {665 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);666 expect(beforeInputEvent).toBeNull();667 },668 },669 {670 run: ({beforeInputEvent, spyOnBeforeInput}) => {671 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);672 expect(beforeInputEvent).toBeNull();673 },674 },675 {676 run: ({beforeInputEvent, spyOnBeforeInput}) => {677 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);678 expect(beforeInputEvent).toBeNull();679 },680 },681 {682 run: ({beforeInputEvent, spyOnBeforeInput}) => {683 expect(spyOnBeforeInput).toHaveBeenCalledTimes(0);684 expect(beforeInputEvent).toBeNull();685 },686 },687 ],688 },689 ];690 const testInputComponent = (env, scenes) => {691 let beforeInputEvent;692 let compositionStartEvent;693 let compositionUpdateEvent;694 let spyOnBeforeInput;695 let spyOnCompositionStart;696 let spyOnCompositionUpdate;697 ReactDOM = loadReactDOM(env.emulator);698 const node = ReactDOM.render(699 <input700 type="text"701 onBeforeInput={({type, data}) => {702 spyOnBeforeInput();703 beforeInputEvent = {type, data};704 }}705 onCompositionStart={({type, data}) => {706 spyOnCompositionStart();707 compositionStartEvent = {type, data};708 }}709 onCompositionUpdate={({type, data}) => {710 spyOnCompositionUpdate();711 compositionUpdateEvent = {type, data};712 }}713 />,714 container,715 );716 scenes.forEach((s, id) => {717 beforeInputEvent = null;718 compositionStartEvent = null;719 compositionUpdateEvent = null;720 spyOnBeforeInput = jest.fn();721 spyOnCompositionStart = jest.fn();722 spyOnCompositionUpdate = jest.fn();723 s.eventSimulator.apply(null, [node, ...s.eventSimulatorArgs]);724 env.assertions[id].run({725 beforeInputEvent,726 compositionStartEvent,727 compositionUpdateEvent,728 spyOnBeforeInput,729 spyOnCompositionStart,730 spyOnCompositionUpdate,731 });732 });733 };734 const testContentEditableComponent = (env, scenes) => {735 let beforeInputEvent;736 let compositionStartEvent;737 let compositionUpdateEvent;738 let spyOnBeforeInput;739 let spyOnCompositionStart;740 let spyOnCompositionUpdate;741 ReactDOM = loadReactDOM(env.emulator);742 const node = ReactDOM.render(743 <div744 contentEditable={true}745 onBeforeInput={({type, data}) => {746 spyOnBeforeInput();747 beforeInputEvent = {type, data};748 }}749 onCompositionStart={({type, data}) => {750 spyOnCompositionStart();751 compositionStartEvent = {type, data};752 }}753 onCompositionUpdate={({type, data}) => {754 spyOnCompositionUpdate();755 compositionUpdateEvent = {type, data};756 }}757 />,758 container,759 );760 scenes.forEach((s, id) => {761 beforeInputEvent = null;762 compositionStartEvent = null;763 compositionUpdateEvent = null;764 spyOnBeforeInput = jest.fn();765 spyOnCompositionStart = jest.fn();766 spyOnCompositionUpdate = jest.fn();767 s.eventSimulator.apply(null, [node, ...s.eventSimulatorArgs]);768 env.assertions[id].run({769 beforeInputEvent,770 compositionStartEvent,771 compositionUpdateEvent,772 spyOnBeforeInput,773 spyOnCompositionStart,774 spyOnCompositionUpdate,775 });776 });777 };778 it('should extract onBeforeInput when simulating in Webkit on input[type=text]', () => {779 testInputComponent(environments[0], scenarios);780 });781 it('should extract onBeforeInput when simulating in Webkit on contenteditable', () => {782 testContentEditableComponent(environments[0], scenarios);783 });784 it('should extract onBeforeInput when simulating in IE11 on input[type=text]', () => {785 testInputComponent(environments[1], scenarios);786 });787 it('should extract onBeforeInput when simulating in IE11 on contenteditable', () => {788 testContentEditableComponent(environments[1], scenarios);789 });790 it('should extract onBeforeInput when simulating in env with no CompositionEvent on input[type=text]', () => {791 testInputComponent(environments[2], scenarios);792 });793 // in an environment using composition fallback onBeforeInput will not work794 // as expected on a contenteditable as keydown and keyup events are translated795 // to keypress events796 it('should extract onBeforeInput when simulating in env with only CompositionEvent on input[type=text]', () => {797 testInputComponent(environments[3], scenarios);798 });799 it('should extract onBeforeInput when simulating in env with only CompositionEvent on contenteditable', () => {800 testContentEditableComponent(environments[3], scenarios);801 });...

Full Screen

Full Screen

Microsoft.py

Source:Microsoft.py Github

copy

Full Screen

1from ReadInput import getClosingPrices2from Input_Variables import exponentialMovingAverage,inputRdp,trainingOutputRdp_5,changeInPrice,scale3from sklearn import svm,preprocessing4import numpy as np5from Output_Variables import calculateCorrectPredictions6pathOfMicrosoft = '/home/Documents/dataset/MS'7datePriceDictionary = getClosingPrices(pathOfMicrosoft,'MicrosoftTraining.xlsx')8initialPriceDictionary = getClosingPrices(pathOfMicrosoft,'Training.xlsx')9last5PriceDictionary = getClosingPrices(pathOfMicrosoft,'Last5Days.xlsx')10dateList = datePriceDictionary.keys()11closingPriceList = datePriceDictionary.values()12initialPriceValues = initialPriceDictionary.values()13SVM_trainingInput = []14SVM_trainingOutputValues = []15SVM_trainingOutputClasses = []16SVM_trainingOutputClasses.append(1)17last5List = last5PriceDictionary.values()18changeInPrice(closingPriceList,SVM_trainingOutputClasses)19sumClosingPrices = 0.020for iter in xrange(5,20):21 sumClosingPrices = sumClosingPrices+float(initialPriceValues[iter])22simpleMovingAverage = sumClosingPrices/float(15)23emaYesterDay = simpleMovingAverage24emaList = []25for i in xrange(0,closingPriceList.__len__()):26 ema_15 = exponentialMovingAverage(closingPriceList[i],15,emaYesterDay)27 emaList.append(ema_15)28 emaYesterDay= ema_1529emaLastList = []30for j in xrange(0,5):31 ema_15Last = exponentialMovingAverage(last5List[j],15,emaYesterDay)32 emaLastList.append(ema_15Last)33ema_15_Input_List = []34rdp_5_Input_List = []35rdp_10_Input_List = []36rdp_15_Input_List = []37rdp_20_Input_List = []38for iterator in xrange(0,closingPriceList.__len__()):39 ema15Input = closingPriceList[iterator] - emaList[iterator]40 ema_15_Input_List.append(ema15Input)41 if iterator<5:42 rdp_5_Input = inputRdp(closingPriceList[iterator],initialPriceValues[iterator+15])43 rdp_5_Input_List.append(rdp_5_Input)44 rdp_10_Input = inputRdp(closingPriceList[iterator],initialPriceValues[iterator+10])45 rdp_10_Input_List.append(rdp_10_Input)46 rdp_15_Input = inputRdp(closingPriceList[iterator],initialPriceValues[iterator+5])47 rdp_15_Input_List.append(rdp_15_Input)48 rdp_20_Input = inputRdp(closingPriceList[iterator],initialPriceValues[iterator])49 rdp_20_Input_List.append(rdp_20_Input)50 elif iterator<10:51 rdp_5_Input = inputRdp(closingPriceList[iterator],closingPriceList[iterator-5])52 rdp_5_Input_List.append(rdp_5_Input)53 rdp_10_Input = inputRdp(closingPriceList[iterator],initialPriceValues[iterator+10])54 rdp_10_Input_List.append(rdp_10_Input)55 rdp_15_Input = inputRdp(closingPriceList[iterator],initialPriceValues[iterator+5])56 rdp_15_Input_List.append(rdp_15_Input)57 rdp_20_Input = inputRdp(closingPriceList[iterator],initialPriceValues[iterator])58 rdp_20_Input_List.append(rdp_20_Input)59 elif iterator<15:60 rdp_5_Input = inputRdp(closingPriceList[iterator],closingPriceList[iterator-5])61 rdp_5_Input_List.append(rdp_5_Input)62 rdp_10_Input = inputRdp(closingPriceList[iterator],closingPriceList[iterator-10])63 rdp_10_Input_List.append(rdp_10_Input)64 rdp_15_Input = inputRdp(closingPriceList[iterator],initialPriceValues[iterator+5])65 rdp_15_Input_List.append(rdp_15_Input)66 rdp_20_Input = inputRdp(closingPriceList[iterator],initialPriceValues[iterator])67 rdp_20_Input_List.append(rdp_20_Input)68 elif iterator<20:69 rdp_5_Input = inputRdp(closingPriceList[iterator],closingPriceList[iterator-5])70 rdp_5_Input_List.append(rdp_5_Input)71 rdp_10_Input = inputRdp(closingPriceList[iterator],closingPriceList[iterator-10])72 rdp_10_Input_List.append(rdp_10_Input)73 rdp_15_Input = inputRdp(closingPriceList[iterator],closingPriceList[iterator-15])74 rdp_15_Input_List.append(rdp_15_Input)75 rdp_20_Input = inputRdp(closingPriceList[iterator],initialPriceValues[iterator])76 rdp_20_Input_List.append(rdp_20_Input)77 else:78 rdp_5_Input = inputRdp(closingPriceList[iterator],closingPriceList[iterator-5])79 rdp_5_Input_List.append(rdp_5_Input)80 rdp_10_Input = inputRdp(closingPriceList[iterator],closingPriceList[iterator-10])81 rdp_10_Input_List.append(rdp_10_Input)82 rdp_15_Input = inputRdp(closingPriceList[iterator],closingPriceList[iterator-15])83 rdp_15_Input_List.append(rdp_15_Input)84 rdp_20_Input = inputRdp(closingPriceList[iterator],closingPriceList[iterator-20])85 rdp_20_Input_List.append(rdp_20_Input)86closingPriceListLength = closingPriceList.__len__()87for itr1 in xrange(0,closingPriceListLength):88 if itr1 == 0:89 rdp_5_Output = trainingOutputRdp_5(closingPriceList[itr1],closingPriceList[itr1+5],simpleMovingAverage,emaList[itr1+4])90 SVM_trainingOutputValues.append(rdp_5_Output)91 elif itr1 < (closingPriceListLength-5):92 rdp_5_Output = trainingOutputRdp_5(closingPriceList[itr1],closingPriceList[itr1+5],emaList[itr1-1],emaList[itr1+4])93 SVM_trainingOutputValues.append(rdp_5_Output)94 else:95 rdp_5_Output = trainingOutputRdp_5(closingPriceList[itr1],last5List[abs(closingPriceListLength-iterator-5)],emaList[itr1-1],emaLastList[abs(closingPriceListLength-iterator-5)])96 SVM_trainingOutputValues.append(rdp_5_Output)97print 'DEBUGGING:',ema_15_Input_List.__len__()98'''preprocessing.scale(ema_15_Input_List)99preprocessing.scale(rdp_5_Input_List)100preprocessing.scale(rdp_10_Input_List)101preprocessing.scale(rdp_15_Input_List)102preprocessing.scale(rdp_20_Input_List)'''103for count in xrange(0,ema_15_Input_List.__len__()):104 rowWiseInputList = []105 rowWiseInputList.append(ema_15_Input_List[count])106 rowWiseInputList.append(rdp_5_Input_List[count])107 rowWiseInputList.append(rdp_10_Input_List[count])108 rowWiseInputList.append(rdp_15_Input_List[count])109 rowWiseInputList.append(rdp_20_Input_List[count])110 SVM_trainingInput.append(rowWiseInputList)111testingDictionary = getClosingPrices(pathOfMicrosoft,'MicrosoftTesting.xlsx')112testingInputValues = testingDictionary.values()113emaTestList = []114emaOld=emaList[emaList.__len__()-1]115for it in xrange(0,testingInputValues.__len__()):116 emaTest = exponentialMovingAverage(testingInputValues[it],15,emaOld)117 emaTestList.append(emaTest)118 emaOld=emaTest119ema_15_Test_List = []120rdp_5_Test_List = []121rdp_10_Test_List = []122rdp_15_Test_List = []123rdp_20_Test_List = []124closingPricesLast_20_daysList = []125for itr2 in xrange(closingPriceList.__len__()-20,closingPriceList.__len__()):126 closingPricesLast_20_daysList.append(closingPriceList[itr2])127for iterator_1 in xrange(0,testingInputValues.__len__()):128 ema_15TestInput = testingInputValues[iterator_1] - emaTestList[iterator_1]129 ema_15_Test_List.append(ema_15TestInput)130 if iterator_1 < 5:131 rdp_5_test = inputRdp(testingInputValues[iterator_1],closingPricesLast_20_daysList[iterator_1+15])132 rdp_5_Test_List.append(rdp_5_test)133 rdp_10_test = inputRdp(testingInputValues[iterator_1],closingPricesLast_20_daysList[iterator_1+10])134 rdp_10_Test_List.append(rdp_10_test)135 rdp_15_test = inputRdp(testingInputValues[iterator_1],closingPricesLast_20_daysList[iterator_1+5])136 rdp_15_Test_List.append(rdp_15_test)137 rdp_20_Test = inputRdp(testingInputValues[iterator_1],closingPricesLast_20_daysList[iterator_1])138 rdp_20_Test_List.append(rdp_20_Test)139 elif iterator_1<10:140 rdp_5_test = inputRdp(testingInputValues[iterator_1],testingInputValues[iterator_1-5])141 rdp_5_Test_List.append(rdp_5_test)142 rdp_10_test = inputRdp(testingInputValues[iterator_1],closingPricesLast_20_daysList[iterator_1+10])143 rdp_10_Test_List.append(rdp_10_test)144 rdp_15_test = inputRdp(testingInputValues[iterator_1],closingPricesLast_20_daysList[iterator_1+5])145 rdp_15_Test_List.append(rdp_15_test)146 rdp_20_Test = inputRdp(testingInputValues[iterator_1],closingPricesLast_20_daysList[iterator_1])147 rdp_20_Test_List.append(rdp_20_Test)148 elif iterator_1<15:149 rdp_5_test = inputRdp(testingInputValues[iterator_1],testingInputValues[iterator_1-5])150 rdp_5_Test_List.append(rdp_5_test)151 rdp_10_test = inputRdp(testingInputValues[iterator_1],testingInputValues[iterator_1-10])152 rdp_10_Test_List.append(rdp_10_test)153 rdp_15_test = inputRdp(testingInputValues[iterator_1],closingPricesLast_20_daysList[iterator_1+5])154 rdp_15_Test_List.append(rdp_15_test)155 rdp_20_Test = inputRdp(testingInputValues[iterator_1],closingPricesLast_20_daysList[iterator_1])156 rdp_20_Test_List.append(rdp_20_Test)157 elif iterator_1<20:158 rdp_5_test = inputRdp(testingInputValues[iterator_1],testingInputValues[iterator_1-5])159 rdp_5_Test_List.append(rdp_5_test)160 rdp_10_test = inputRdp(testingInputValues[iterator_1],testingInputValues[iterator_1-10])161 rdp_10_Test_List.append(rdp_10_test)162 rdp_15_test = inputRdp(testingInputValues[iterator_1],testingInputValues[iterator_1-15])163 rdp_15_Test_List.append(rdp_15_test)164 rdp_20_Test = inputRdp(testingInputValues[iterator_1],closingPricesLast_20_daysList[iterator_1])165 rdp_20_Test_List.append(rdp_20_Test)166 else:167 rdp_5_test = inputRdp(testingInputValues[iterator_1],testingInputValues[iterator_1-5])168 rdp_5_Test_List.append(rdp_5_test)169 rdp_10_test = inputRdp(testingInputValues[iterator_1],testingInputValues[iterator_1-10])170 rdp_10_Test_List.append(rdp_10_test)171 rdp_15_test = inputRdp(testingInputValues[iterator_1],testingInputValues[iterator_1-15])172 rdp_15_Test_List.append(rdp_15_test)173 rdp_20_Test = inputRdp(testingInputValues[iterator_1],testingInputValues[iterator_1-20])174 rdp_20_Test_List.append(rdp_20_Test)175'''preprocessing.scale(ema_15_Test_List)176preprocessing.scale(rdp_5_Test_List)177preprocessing.scale(rdp_10_Test_List)178preprocessing.scale(rdp_15_Test_List)179preprocessing.scale(rdp_20_Test_List)'''180#-------------------------------------------------------181minMaxScaler = preprocessing.MinMaxScaler(feature_range=(-0.9,0.9))182minMaxScaler.fit(SVM_trainingInput)183SVM_trainingInputScaled = minMaxScaler.transform(SVM_trainingInput)184print 'SVM_trainingInputScaled' ,SVM_trainingInputScaled185#--------------------------------------------------------186SVR_TestList = []187for count1 in xrange(0,ema_15_Test_List.__len__()):188 rowWiseTestList = []189 rowWiseTestList.append(ema_15_Test_List[count1])190 rowWiseTestList.append(rdp_5_Test_List[count1])191 rowWiseTestList.append(rdp_10_Test_List[count1])192 rowWiseTestList.append(rdp_15_Test_List[count1])193 rowWiseTestList.append(rdp_20_Test_List[count1])194 SVR_TestList.append(rowWiseTestList)195SVR_TestListExpectedOutput = []196SVR_TestListExpectedOutput.append(1)197changeInPrice(testingInputValues,SVR_TestListExpectedOutput)198#----------------------------------------------Classification----------------------------------------------199#temp = np.array(SVM_trainingInput)200#myGamma = 1/float(np.power(np.var(SVM_trainingInput),2))201#------------------------------------------------------------202minMaxScaler.fit(SVR_TestList)203SVR_TestListScaled = minMaxScaler.transform(SVR_TestList)204#------------------------------------------------------------205classifier = svm.SVC(kernel='rbf',gamma=1/10.0)206classifier.fit(SVM_trainingInputScaled,SVM_trainingOutputClasses)207y = classifier.predict(SVR_TestList)208regression = svm.SVR(kernel='poly',coef0=3,degree=1)#(kernel='rbf',gamma=1/1000.0)209scale(SVM_trainingOutputValues)210regression.fit(SVM_trainingInput,SVM_trainingOutputValues)211print 'SVROUTPUTTRAINING::',SVM_trainingOutputValues212print 'SVRTEST::',SVR_TestList213z = regression.predict(SVR_TestList)214z = np.array(z).tolist()215print z216predictedList = []217predictedList.append(1)218changeInPrice(z,predictedList)219print 'SVR_TestListLength:',SVR_TestList.__len__()220print 'Expected Value:',SVR_TestListExpectedOutput221print 'Predicted::',predictedList222numberOfCorrectPredictions,probabiltyOfCorrectPredictions = calculateCorrectPredictions(SVR_TestListExpectedOutput,predictedList)223print 'NUMBER OF CORRECT CLASSIFICATIONS::',numberOfCorrectPredictions...

Full Screen

Full Screen

input.js

Source:input.js Github

copy

Full Screen

1import $ from 'dom7';2import { window, document } from 'ssr-window';3import Utils from '../../utils/utils';4import Device from '../../utils/device';5const Input = {6 ignoreTypes: ['checkbox', 'button', 'submit', 'range', 'radio', 'image'],7 createTextareaResizableShadow() {8 const $shadowEl = $(document.createElement('textarea'));9 $shadowEl.addClass('textarea-resizable-shadow');10 $shadowEl.prop({11 disabled: true,12 readonly: true,13 });14 Input.textareaResizableShadow = $shadowEl;15 },16 textareaResizableShadow: undefined,17 resizeTextarea(textareaEl) {18 const app = this;19 const $textareaEl = $(textareaEl);20 if (!Input.textareaResizableShadow) {21 Input.createTextareaResizableShadow();22 }23 const $shadowEl = Input.textareaResizableShadow;24 if (!$textareaEl.length) return;25 if (!$textareaEl.hasClass('resizable')) return;26 if (Input.textareaResizableShadow.parents().length === 0) {27 app.root.append($shadowEl);28 }29 const styles = window.getComputedStyle($textareaEl[0]);30 ('padding-top padding-bottom padding-left padding-right margin-left margin-right margin-top margin-bottom width font-size font-family font-style font-weight line-height font-variant text-transform letter-spacing border box-sizing display').split(' ').forEach((style) => {31 let styleValue = styles[style];32 if (('font-size line-height letter-spacing width').split(' ').indexOf(style) >= 0) {33 styleValue = styleValue.replace(',', '.');34 }35 $shadowEl.css(style, styleValue);36 });37 const currentHeight = $textareaEl[0].clientHeight;38 $shadowEl.val('');39 const initialHeight = $shadowEl[0].scrollHeight;40 $shadowEl.val($textareaEl.val());41 $shadowEl.css('height', 0);42 const scrollHeight = $shadowEl[0].scrollHeight;43 if (currentHeight !== scrollHeight) {44 if (scrollHeight > initialHeight) {45 $textareaEl.css('height', `${scrollHeight}px`);46 $textareaEl.trigger('textarea:resize', { initialHeight, currentHeight, scrollHeight });47 } else if (scrollHeight < currentHeight) {48 $textareaEl.css('height', '');49 $textareaEl.trigger('textarea:resize', { initialHeight, currentHeight, scrollHeight });50 }51 }52 },53 validate(inputEl) {54 const $inputEl = $(inputEl);55 if (!$inputEl.length) return;56 const $itemInputEl = $inputEl.parents('.item-input');57 const $inputWrapEl = $inputEl.parents('.input');58 const validity = $inputEl[0].validity;59 const validationMessage = $inputEl.dataset().errorMessage || $inputEl[0].validationMessage || '';60 if (!validity) return;61 if (!validity.valid) {62 let $errorEl = $inputEl.nextAll('.item-input-error-message, .input-error-message');63 if (validationMessage) {64 if ($errorEl.length === 0) {65 $errorEl = $(`<div class="${$inputWrapEl.length ? 'input-error-message' : 'item-input-error-message'}"></div>`);66 $errorEl.insertAfter($inputEl);67 }68 $errorEl.text(validationMessage);69 }70 if ($errorEl.length > 0) {71 $itemInputEl.addClass('item-input-with-error-message');72 $inputWrapEl.addClass('input-with-eror-message');73 }74 $itemInputEl.addClass('item-input-invalid');75 $inputWrapEl.addClass('input-invalid');76 $inputEl.addClass('input-invalid');77 } else {78 $itemInputEl.removeClass('item-input-invalid item-input-with-error-message');79 $inputWrapEl.removeClass('input-invalid input-with-error-message');80 $inputEl.removeClass('input-invalid');81 }82 },83 validateInputs(el) {84 const app = this;85 $(el).find('input, textarea, select').each((index, inputEl) => {86 app.input.validate(inputEl);87 });88 },89 focus(inputEl) {90 const $inputEl = $(inputEl);91 const type = $inputEl.attr('type');92 if (Input.ignoreTypes.indexOf(type) >= 0) return;93 $inputEl.parents('.item-input').addClass('item-input-focused');94 $inputEl.parents('.input').addClass('input-focused');95 $inputEl.addClass('input-focused');96 },97 blur(inputEl) {98 const $inputEl = $(inputEl);99 $inputEl.parents('.item-input').removeClass('item-input-focused');100 $inputEl.parents('.input').removeClass('input-focused');101 $inputEl.removeClass('input-focused');102 },103 checkEmptyState(inputEl) {104 let $inputEl = $(inputEl);105 if (!$inputEl.is('input, select, textarea')) {106 $inputEl = $inputEl.find('input, select, textarea').eq(0);107 }108 if (!$inputEl.length) return;109 const value = $inputEl.val();110 const $itemInputEl = $inputEl.parents('.item-input');111 const $inputWrapEl = $inputEl.parents('.input');112 if ((value && (typeof value === 'string' && value.trim() !== '')) || (Array.isArray(value) && value.length > 0)) {113 $itemInputEl.addClass('item-input-with-value');114 $inputWrapEl.addClass('input-with-value');115 $inputEl.addClass('input-with-value');116 $inputEl.trigger('input:notempty');117 } else {118 $itemInputEl.removeClass('item-input-with-value');119 $inputWrapEl.removeClass('input-with-value');120 $inputEl.removeClass('input-with-value');121 $inputEl.trigger('input:empty');122 }123 },124 scrollIntoView(inputEl, duration = 0, centered, force) {125 const $inputEl = $(inputEl);126 const $scrollableEl = $inputEl.parents('.page-content, .panel').eq(0);127 if (!$scrollableEl.length) {128 return false;129 }130 const contentHeight = $scrollableEl[0].offsetHeight;131 const contentScrollTop = $scrollableEl[0].scrollTop;132 const contentPaddingTop = parseInt($scrollableEl.css('padding-top'), 10);133 const contentPaddingBottom = parseInt($scrollableEl.css('padding-bottom'), 10);134 const contentOffsetTop = $scrollableEl.offset().top - contentScrollTop;135 const inputOffsetTop = $inputEl.offset().top - contentOffsetTop;136 const inputHeight = $inputEl[0].offsetHeight;137 const min = (inputOffsetTop + contentScrollTop) - contentPaddingTop;138 const max = ((inputOffsetTop + contentScrollTop) - contentHeight) + contentPaddingBottom + inputHeight;139 const centeredPosition = min + ((max - min) / 2);140 if (contentScrollTop > min) {141 $scrollableEl.scrollTop(centered ? centeredPosition : min, duration);142 return true;143 }144 if (contentScrollTop < max) {145 $scrollableEl.scrollTop(centered ? centeredPosition : max, duration);146 return true;147 }148 if (force) {149 $scrollableEl.scrollTop(centered ? centeredPosition : max, duration);150 }151 return false;152 },153 init() {154 const app = this;155 Input.createTextareaResizableShadow();156 function onFocus() {157 const inputEl = this;158 if (app.params.input.scrollIntoViewOnFocus) {159 if (Device.android) {160 $(window).once('resize', () => {161 if (document && document.activeElement === inputEl) {162 app.input.scrollIntoView(inputEl, app.params.input.scrollIntoViewDuration, app.params.input.scrollIntoViewCentered, app.params.input.scrollIntoViewAlways);163 }164 });165 } else {166 app.input.scrollIntoView(inputEl, app.params.input.scrollIntoViewDuration, app.params.input.scrollIntoViewCentered, app.params.input.scrollIntoViewAlways);167 }168 }169 app.input.focus(inputEl);170 }171 function onBlur() {172 const $inputEl = $(this);173 const tag = $inputEl[0].nodeName.toLowerCase();174 app.input.blur($inputEl);175 if ($inputEl.dataset().validate || $inputEl.attr('validate') !== null) {176 app.input.validate($inputEl);177 }178 // Resize textarea179 if (tag === 'textarea' && $inputEl.hasClass('resizable')) {180 if (Input.textareaResizableShadow) Input.textareaResizableShadow.remove();181 }182 }183 function onChange() {184 const $inputEl = $(this);185 const type = $inputEl.attr('type');186 const tag = $inputEl[0].nodeName.toLowerCase();187 if (Input.ignoreTypes.indexOf(type) >= 0) return;188 // Check Empty State189 app.input.checkEmptyState($inputEl);190 // Check validation191 if ($inputEl.dataset().validate || $inputEl.attr('validate') !== null) {192 app.input.validate($inputEl);193 }194 // Resize textarea195 if (tag === 'textarea' && $inputEl.hasClass('resizable')) {196 app.input.resizeTextarea($inputEl);197 }198 }199 function onInvalid(e) {200 const $inputEl = $(this);201 if ($inputEl.dataset().validate || $inputEl.attr('validate') !== null) {202 e.preventDefault();203 app.input.validate($inputEl);204 }205 }206 function clearInput() {207 const $clicked = $(this);208 const $inputEl = $clicked.siblings('input, textarea').eq(0);209 const previousValue = $inputEl.val();210 $inputEl211 .val('')212 .trigger('input change')213 .focus()214 .trigger('input:clear', previousValue);215 }216 $(document).on('click', '.input-clear-button', clearInput);217 $(document).on('change input', 'input, textarea, select', onChange, true);218 $(document).on('focus', 'input, textarea, select', onFocus, true);219 $(document).on('blur', 'input, textarea, select', onBlur, true);220 $(document).on('invalid', 'input, textarea, select', onInvalid, true);221 },222};223export default {224 name: 'input',225 params: {226 input: {227 scrollIntoViewOnFocus: Device.android,228 scrollIntoViewCentered: false,229 scrollIntoViewDuration: 0,230 scrollIntoViewAlways: false,231 },232 },233 create() {234 const app = this;235 Utils.extend(app, {236 input: {237 scrollIntoView: Input.scrollIntoView.bind(app),238 focus: Input.focus.bind(app),239 blur: Input.blur.bind(app),240 validate: Input.validate.bind(app),241 validateInputs: Input.validateInputs.bind(app),242 checkEmptyState: Input.checkEmptyState.bind(app),243 resizeTextarea: Input.resizeTextarea.bind(app),244 init: Input.init.bind(app),245 },246 });247 },248 on: {249 init() {250 const app = this;251 app.input.init();252 },253 tabMounted(tabEl) {254 const app = this;255 const $tabEl = $(tabEl);256 $tabEl.find('.item-input, .input').each((itemInputIndex, itemInputEl) => {257 const $itemInputEl = $(itemInputEl);258 $itemInputEl.find('input, select, textarea').each((inputIndex, inputEl) => {259 const $inputEl = $(inputEl);260 if (Input.ignoreTypes.indexOf($inputEl.attr('type')) >= 0) return;261 app.input.checkEmptyState($inputEl);262 });263 });264 $tabEl.find('textarea.resizable').each((textareaIndex, textareaEl) => {265 app.input.resizeTextarea(textareaEl);266 });267 },268 pageInit(page) {269 const app = this;270 const $pageEl = page.$el;271 $pageEl.find('.item-input, .input').each((itemInputIndex, itemInputEl) => {272 const $itemInputEl = $(itemInputEl);273 $itemInputEl.find('input, select, textarea').each((inputIndex, inputEl) => {274 const $inputEl = $(inputEl);275 if (Input.ignoreTypes.indexOf($inputEl.attr('type')) >= 0) return;276 app.input.checkEmptyState($inputEl);277 });278 });279 $pageEl.find('textarea.resizable').each((textareaIndex, textareaEl) => {280 app.input.resizeTextarea(textareaEl);281 });282 },283 },...

Full Screen

Full Screen

t.py

Source:t.py Github

copy

Full Screen

1import math2from tkinter import *3from PIL import ImageTk, Image4import matplotlib.pyplot as plt5from scipy. integrate import odeint6import numpy as np7mu0 = 4 * math.pi * (10 ** (-7))8tau = 1.7759l = 3.510wc = 1411wr = 2412delta = 0.06513Rc = 114Rr = 215Lcs = 0.0012616Lrs = 0.00126*217J = 0.118p = 219D = 2*tau/math.pi*p20pi = math.pi21kcc = p*(4*wc*wc*tau*l*mu0)/(pi*delta*pi)22krc = p*(4*wr*wc*tau*l*mu0)/(pi*delta*pi)23krr = p*(4*wr*wr*tau*l*mu0)/(pi*delta*pi)24t_max = 425t_del = 50000026t = np.linspace(0, t_max, t_del)27y0 = [0, 0, 0, 0, 0, 0, 0, 0]28Uc = 40029fc = 5030phic = 031def B_delta(Ica, Icb, Icc, Ira, Irb, Irc, x, phi):32 return (2*mu0/(math.pi*delta)*(wc*Ica*math.cos(math.pi/tau*x)+wc*Icb*math.cos(math.pi/tau*x-2*math.pi/3)+wc*Icc*math.cos(math.pi/tau*x+2*math.pi/3)+wr*Ira*math.cos(math.pi/tau*x-phi*p)+wr*Irb*math.cos(math.pi/tau*x-phi*p-2*math.pi/3)+wr*Irc*math.cos(math.pi/tau*x-phi*p+2*math.pi/3)))33def f(input_variable, t):34 main_det = [[-kcc*(math.sin(pi/2) - (-1)*math.sin(pi/6)) - Lcs, -kcc*(math.sin(pi/2 + 2*pi/3) - (-1)*math.sin(pi/6 - 2*pi/3)) + Lcs, -kcc*(math.sin(pi/2 - 2*pi/3) - (-1)*math.sin(pi/6 + 2*pi/3)), -krc*(math.sin(pi/2 + input_variable[7]*p) - (-1)*math.sin(pi/6 - input_variable[7]*p)), -krc*(math.sin(pi/2 + input_variable[7]*p + 2*pi/3) - (-1)*math.sin(pi/6 - input_variable[7]*p - 2*pi/3)), -krc*(math.sin(pi/2 + input_variable[7]*p - 2*pi/3) - (-1)*math.sin(pi/6 - input_variable[7]*p + 2*pi/3))],35 [-kcc*((-1)*math.sin(pi/6) - math.sin(-pi/6)), -kcc*((-1)*math.sin(pi/6 - 2*pi/3) - math.sin(-pi/6 - 2*pi/3)) - Lcs, -kcc*((-1)*math.sin(pi/6 + 2*pi/3) - math.sin(-pi/6 + 2*pi/3)) + Lcs, -krc*((-1)*math.sin(pi/6 - input_variable[7]*p) - math.sin(-pi/6 - input_variable[7]*p)), -krc*((-1)*math.sin(pi/6 - input_variable[7]*p - 2*pi/3) - math.sin(-pi/6 - input_variable[7]*p - 2*pi/3)), -krc*((-1)*math.sin(pi/6 - input_variable[7]*p + 2*pi/3) - math.sin(-pi/6 - input_variable[7]*p + 2*pi/3))],36 [-kcc*math.sin(-pi/6), -kcc*math.sin(-pi/6 - 2*pi/3), -kcc*math.sin(-pi/6 + 2*pi/3) - Lcs, -krc*math.sin(-pi/6 - input_variable[7]*p), -krc*math.sin(-pi/6 - input_variable[7]*p - 2*pi/3), -krc*math.sin(-pi/6 - input_variable[7]*p + 2*pi/3)],37 [-krc*math.sin(pi/2-input_variable[7]*p-0), -krc*math.sin(pi/2-input_variable[7]*p+2*pi/3), -krc*math.sin(pi/2-input_variable[7]*p-2*pi/3), -krr*math.sin(pi/2-0) - Lrs, -krr*math.sin(pi/2+2*pi/3), -krr*math.sin(pi/2-2*pi/3)],38 [-krc*(-1)*math.sin(pi/6+input_variable[7]*p-0), -krc*(-1)*math.sin(pi/6+input_variable[7]*p-2*pi/3), -krc*(-1)*math.sin(pi/6+input_variable[7]*p+2*pi/3), -krr*(-1)*math.sin(pi/6+0), -krr*(-1)*math.sin(pi/6-2*pi/3) - Lrs, -krr*(-1)*math.sin(pi/6+2*pi/3)],39 [-krc*math.sin(-pi/6+input_variable[7]*p-0), -krc*math.sin(-pi/6+input_variable[7]*p-2*pi/3), -krc*math.sin(-pi/6+input_variable[7]*p+2*pi/3), -krr*math.sin(-pi/6+0), -krr*math.sin(-pi/6-2*pi/3), -krr*math.sin(-pi/6+2*pi/3) - Lrs]40 ]41 own_matrix = [input_variable[0]*Rc + Uc*(math.sin(2*math.pi*fc*t + phic) - math.sin(2*math.pi*fc*t + phic - 2*pi/3)) - input_variable[1]*Rc + krc*p*input_variable[6]*(input_variable[3]*math.cos(pi/2 + input_variable[7]*p) + input_variable[4]*math.cos(pi/2 + input_variable[7]*p + 2*pi/3) + input_variable[5]*math.cos(pi/2 + input_variable[7]*p - 2*pi/3) + (-1)*input_variable[3]*math.cos(pi/6 - input_variable[7]*p) + (-1)*input_variable[4]*math.cos(pi/6 - input_variable[7]*p - 2*pi/3) + (-1)*input_variable[5]*math.cos(pi/6 - input_variable[7]*p + 2*pi/3)),42 input_variable[1]*Rc + Uc*(math.sin(2*math.pi*fc*t + phic - 2*pi/3) - math.sin(2*math.pi*fc*t + phic + 2*pi/3)) - input_variable[2]*Rc + krc*p*input_variable[6]*(input_variable[3]*math.cos(pi/6 - input_variable[7]*p) + input_variable[4]*math.cos(pi/6 - input_variable[7]*p - 2*pi/3) + input_variable[5]*math.cos(pi/6 - input_variable[7]*p + 2*pi/3) + input_variable[3]*math.cos(-pi/6 - input_variable[7]*p) + input_variable[4]*math.cos(-pi/6 - input_variable[7]*p - 2*pi/3) + input_variable[5]*math.cos(-pi/6 - input_variable[7]*p + 2*pi/3)),43 input_variable[2]*Rc + Uc*math.sin(2*math.pi*fc*t + phic + 2*pi/3) - krc*p*input_variable[6]*(input_variable[3]*math.cos(-pi/6 - input_variable[7]*p) + input_variable[4]*math.cos(-pi/6 - input_variable[7]*p - 2*pi/3) + input_variable[5]*math.cos(-pi/6 - input_variable[7]*p + 2*pi/3)),44 input_variable[3]*Rr-input_variable[6]*krc*p*(input_variable[0]*math.cos(pi/2-input_variable[7]*p)+input_variable[1]*math.cos(pi/2-input_variable[7]*p+2*pi/3)+input_variable[2]*math.cos(pi/2-input_variable[7]*p-2*pi/3)),45 input_variable[4]*Rr+input_variable[6]*krc*p*(-1)*(input_variable[0]*math.cos(pi/6+input_variable[7]*p)+input_variable[1]*math.cos(pi/6+input_variable[7]*p-2*pi/3)+input_variable[2]*math.cos(pi/6+input_variable[7]*p+2*pi/3)),46 input_variable[5]*Rr+input_variable[6]*krc*p*(input_variable[0]*math.cos(-pi/6+input_variable[7]*p)+input_variable[1]*math.cos(-pi/6+input_variable[7]*p-2*pi/3)+input_variable[2]*math.cos(-pi/6+input_variable[7]*p+2*pi/3))47 ]48 49 Melmag = D*l*wr*(input_variable[3]*B_delta(input_variable[0], input_variable[1], input_variable[2], input_variable[3], input_variable[4], input_variable[5], tau/pi*input_variable[7]*p-tau/2, input_variable[7])+input_variable[4]*B_delta(input_variable[0], input_variable[1], input_variable[2], input_variable[3], input_variable[4], input_variable[5], tau/pi*input_variable[7]*p+tau/6, input_variable[7])+input_variable[5]*B_delta(input_variable[0], input_variable[1], input_variable[2], input_variable[3], input_variable[4], input_variable[5], tau/pi*input_variable[7]*p-7*tau/6, input_variable[7]))50 derw = (-0*math.tanh(input_variable[6]) - p*Melmag)/J51 solve_matrix = np.linalg.solve(main_det, own_matrix)52 print(t/t_max*100)53 return [solve_matrix[0],54 solve_matrix[1],55 solve_matrix[2],56 solve_matrix[3],57 solve_matrix[4],58 solve_matrix[5],59 derw,60 input_variable[6]]61ww = odeint(f, y0, t)62m_f = []63for i in range(len(t)):64 m_f.append(ww[:, 6][i]/2/pi)65plt.subplot(3, 1, 1)66plt.plot(t, ww[:, 0], linewidth=1, color='red')67plt.xlabel('Время, с', fontsize=12, color='black')68plt.ylabel('Ток статора, А', fontsize=12, color='black')69plt.grid(True)70plt.subplot(3, 1, 2)71plt.plot(t, ww[:, 3], linewidth=1, color='red')72plt.xlabel('Время, с', fontsize=12, color='black')73plt.ylabel('Ток ротора, А', fontsize=12, color='black')74plt.grid(True)75plt.subplot(3, 1, 3)76plt.plot(t, m_f, linewidth=1, color='red')77plt.xlabel('Время, с', fontsize=12, color='black')78plt.ylabel('Частота, Гц', fontsize=12, color='black')79plt.grid(True)80plt.show()81[-kcc*(math.sin(pi/2)-(-1)*math.sin(pi/6)-math.sin(pi/2-2*pi/3)+(-1)*math.sin(pi/6+2*pi/3))-Lcs, -kcc*(math.sin(pi/2+2*pi/3)-(-1)*math.sin(pi/6-2*pi/3)-math.sin(pi/2-2*pi/3)+(-1)*math.sin(pi/6+2*pi/3))+Lcs, -krc*(math.sin(pi/2 + input_variable[6]*p) - (-1)*math.sin(pi/6 - input_variable[6]*p)), -krc*(math.sin(pi/2 + input_variable[6]*p + 2*pi/3) - (-1)*math.sin(pi/6 - input_variable[6]*p - 2*pi/3)), -krc*(math.sin(pi/2 + input_variable[6]*p - 2*pi/3) - (-1)*math.sin(pi/6 - input_variable[6]*p + 2*pi/3))],82[-kcc*((-1)*math.sin(pi/6)-math.sin(-pi/6)-(-1)*math.sin(pi/6+2*pi/3)+math.sin(-pi/6+2*pi/3))-Lcs, -kcc*((-1)*math.sin(pi/6-2*pi/3)-math.sin(-pi/6-2*pi/3)-(-1)*math.sin(pi/6+2*pi/3)+math.sin(-pi/6+2*pi/3))-Lcs-Lcs, -krc*((-1)*math.sin(pi/6 - input_variable[6]*p) - math.sin(-pi/6 - input_variable[6]*p)), -krc*((-1)*math.sin(pi/6 - input_variable[6]*p - 2*pi/3) - math.sin(-pi/6 - input_variable[6]*p - 2*pi/3)), -krc*((-1)*math.sin(pi/6 - input_variable[6]*p + 2*pi/3) - math.sin(-pi/6 - input_variable[6]*p + 2*pi/3))],83[-krc*(math.sin(pi/2-input_variable[6]*p-0)-math.sin(pi/2-input_variable[6]*p-2*pi/3)), -krc*(math.sin(pi/2-input_variable[6]*p+2*pi/3)-math.sin(pi/2-input_variable[6]*p-2*pi/3)), -krr*math.sin(pi/2-0) - Lrs, -krr*math.sin(pi/2+2*pi/3), -krr*math.sin(pi/2-2*pi/3)],84[-krc*((-1)*math.sin(pi/6+input_variable[6]*p-0)-(-1)*math.sin(pi/6+input_variable[6]*p+2*pi/3)), -krc*((-1)*math.sin(pi/6+input_variable[6]*p-2*pi/3)-(-1)*math.sin(pi/6+input_variable[6]*p+2*pi/3)), -krr*(-1)*math.sin(pi/6+0), -krr*(-1)*math.sin(pi/6-2*pi/3) - Lrs, -krr*(-1)*math.sin(pi/6+2*pi/3)],85[-krc*(math.sin(-pi/6+input_variable[6]*p-0)-math.sin(-pi/6+input_variable[6]*p+2*pi/3)), -krc*(math.sin(-pi/6+input_variable[6]*p-2*pi/3)-math.sin(-pi/6+input_variable[6]*p+2*pi/3)), -krr*math.sin(-pi/6+0), -krr*math.sin(-pi/6-2*pi/3), -krr*math.sin(-pi/6+2*pi/3) - Lrs]86[input_variable[0]*Rc - input_variable[1]*Rc + krc*p*input_variable[5]*(input_variable[2]*math.cos(pi/2 + input_variable[6]*p) + input_variable[3]*math.cos(pi/2 + input_variable[6]*p + 2*pi/3) + input_variable[4]*math.cos(pi/2 + input_variable[6]*p - 2*pi/3) + (-1)*input_variable[2]*math.cos(pi/6 - input_variable[6]*p) + (-1)*input_variable[3]*math.cos(pi/6 - input_variable[6]*p - 2*pi/3) + (-1)*input_variable[4]*math.cos(pi/6 - input_variable[6]*p + 2*pi/3)),87input_variable[1]*Rc - (-input_variable[0]-input_variable[1])*Rc + krc*p*input_variable[5]*(input_variable[2]*math.cos(pi/6 - input_variable[6]*p) + input_variable[3]*math.cos(pi/6 - input_variable[6]*p - 2*pi/3) + input_variable[4]*math.cos(pi/6 - input_variable[6]*p + 2*pi/3) + input_variable[2]*math.cos(-pi/6 - input_variable[6]*p) + input_variable[3]*math.cos(-pi/6 - input_variable[6]*p - 2*pi/3) + input_variable[4]*math.cos(-pi/6 - input_variable[6]*p + 2*pi/3)),88input_variable[2]*Rr-input_variable[5]*krc*p*(input_variable[0]*math.cos(pi/2-input_variable[6]*p)+input_variable[1]*math.cos(pi/2-input_variable[6]*p+2*pi/3)+(-input_variable[0]-input_variable[1])*math.cos(pi/2-input_variable[6]*p-2*pi/3)),89input_variable[3]*Rr+input_variable[5]*krc*p*(-1)*(input_variable[0]*math.cos(pi/6+input_variable[6]*p)+input_variable[1]*math.cos(pi/6+input_variable[6]*p-2*pi/3)+(-input_variable[0]-input_variable[1])*math.cos(pi/6+input_variable[6]*p+2*pi/3)),90input_variable[4]*Rr+input_variable[5]*krc*p*(input_variable[0]*math.cos(-pi/6+input_variable[6]*p)+input_variable[1]*math.cos(-pi/6+input_variable[6]*p-2*pi/3)+(-input_variable[0]-input_variable[1])*math.cos(-pi/6+input_variable[6]*p+2*pi/3))...

Full Screen

Full Screen

backbone.py

Source:backbone.py Github

copy

Full Screen

1#! /usr/bin/env python2# coding=utf-834import tensorflow as tf5import core.common as common67def darknet53(input_data):89 input_data = common.convolutional(input_data, (3, 3, 3, 32))10 input_data = common.convolutional(input_data, (3, 3, 32, 64), downsample=True)1112 for i in range(1):13 input_data = common.residual_block(input_data, 64, 32, 64)1415 input_data = common.convolutional(input_data, (3, 3, 64, 128), downsample=True)1617 for i in range(2):18 input_data = common.residual_block(input_data, 128, 64, 128)1920 input_data = common.convolutional(input_data, (3, 3, 128, 256), downsample=True)2122 for i in range(8):23 input_data = common.residual_block(input_data, 256, 128, 256)2425 route_1 = input_data26 input_data = common.convolutional(input_data, (3, 3, 256, 512), downsample=True)2728 for i in range(8):29 input_data = common.residual_block(input_data, 512, 256, 512)3031 route_2 = input_data32 input_data = common.convolutional(input_data, (3, 3, 512, 1024), downsample=True)3334 for i in range(4):35 input_data = common.residual_block(input_data, 1024, 512, 1024)3637 return route_1, route_2, input_data3839def cspdarknet53(input_data):4041 input_data = common.convolutional(input_data, (3, 3, 3, 32), activate_type="mish")42 input_data = common.convolutional(input_data, (3, 3, 32, 64), downsample=True, activate_type="mish")4344 route = input_data45 route = common.convolutional(route, (1, 1, 64, 64), activate_type="mish")46 input_data = common.convolutional(input_data, (1, 1, 64, 64), activate_type="mish")47 for i in range(1):48 input_data = common.residual_block(input_data, 64, 32, 64, activate_type="mish")49 input_data = common.convolutional(input_data, (1, 1, 64, 64), activate_type="mish")5051 input_data = tf.concat([input_data, route], axis=-1)52 input_data = common.convolutional(input_data, (1, 1, 128, 64), activate_type="mish")53 input_data = common.convolutional(input_data, (3, 3, 64, 128), downsample=True, activate_type="mish")54 route = input_data55 route = common.convolutional(route, (1, 1, 128, 64), activate_type="mish")56 input_data = common.convolutional(input_data, (1, 1, 128, 64), activate_type="mish")57 for i in range(2):58 input_data = common.residual_block(input_data, 64, 64, 64, activate_type="mish")59 input_data = common.convolutional(input_data, (1, 1, 64, 64), activate_type="mish")60 input_data = tf.concat([input_data, route], axis=-1)6162 input_data = common.convolutional(input_data, (1, 1, 128, 128), activate_type="mish")63 input_data = common.convolutional(input_data, (3, 3, 128, 256), downsample=True, activate_type="mish")64 route = input_data65 route = common.convolutional(route, (1, 1, 256, 128), activate_type="mish")66 input_data = common.convolutional(input_data, (1, 1, 256, 128), activate_type="mish")67 for i in range(8):68 input_data = common.residual_block(input_data, 128, 128, 128, activate_type="mish")69 input_data = common.convolutional(input_data, (1, 1, 128, 128), activate_type="mish")70 input_data = tf.concat([input_data, route], axis=-1)7172 input_data = common.convolutional(input_data, (1, 1, 256, 256), activate_type="mish")73 route_1 = input_data74 input_data = common.convolutional(input_data, (3, 3, 256, 512), downsample=True, activate_type="mish")75 route = input_data76 route = common.convolutional(route, (1, 1, 512, 256), activate_type="mish")77 input_data = common.convolutional(input_data, (1, 1, 512, 256), activate_type="mish")78 for i in range(8):79 input_data = common.residual_block(input_data, 256, 256, 256, activate_type="mish")80 input_data = common.convolutional(input_data, (1, 1, 256, 256), activate_type="mish")81 input_data = tf.concat([input_data, route], axis=-1)8283 input_data = common.convolutional(input_data, (1, 1, 512, 512), activate_type="mish")84 route_2 = input_data85 input_data = common.convolutional(input_data, (3, 3, 512, 1024), downsample=True, activate_type="mish")86 route = input_data87 route = common.convolutional(route, (1, 1, 1024, 512), activate_type="mish")88 input_data = common.convolutional(input_data, (1, 1, 1024, 512), activate_type="mish")89 for i in range(4):90 input_data = common.residual_block(input_data, 512, 512, 512, activate_type="mish")91 input_data = common.convolutional(input_data, (1, 1, 512, 512), activate_type="mish")92 input_data = tf.concat([input_data, route], axis=-1)9394 input_data = common.convolutional(input_data, (1, 1, 1024, 1024), activate_type="mish")95 input_data = common.convolutional(input_data, (1, 1, 1024, 512))96 input_data = common.convolutional(input_data, (3, 3, 512, 1024))97 input_data = common.convolutional(input_data, (1, 1, 1024, 512))9899 input_data = tf.concat([tf.nn.max_pool(input_data, ksize=13, padding='SAME', strides=1), tf.nn.max_pool(input_data, ksize=9, padding='SAME', strides=1)100 , tf.nn.max_pool(input_data, ksize=5, padding='SAME', strides=1), input_data], axis=-1)101 input_data = common.convolutional(input_data, (1, 1, 2048, 512))102 input_data = common.convolutional(input_data, (3, 3, 512, 1024))103 input_data = common.convolutional(input_data, (1, 1, 1024, 512))104105 return route_1, route_2, input_data106107def cspdarknet53_tiny(input_data):108 input_data = common.convolutional(input_data, (3, 3, 3, 32), downsample=True)109 input_data = common.convolutional(input_data, (3, 3, 32, 64), downsample=True)110 input_data = common.convolutional(input_data, (3, 3, 64, 64))111112 route = input_data113 input_data = common.route_group(input_data, 2, 1)114 input_data = common.convolutional(input_data, (3, 3, 32, 32))115 route_1 = input_data116 input_data = common.convolutional(input_data, (3, 3, 32, 32))117 input_data = tf.concat([input_data, route_1], axis=-1)118 input_data = common.convolutional(input_data, (1, 1, 32, 64))119 input_data = tf.concat([route, input_data], axis=-1)120 input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)121122 input_data = common.convolutional(input_data, (3, 3, 64, 128))123 route = input_data124 input_data = common.route_group(input_data, 2, 1)125 input_data = common.convolutional(input_data, (3, 3, 64, 64))126 route_1 = input_data127 input_data = common.convolutional(input_data, (3, 3, 64, 64))128 input_data = tf.concat([input_data, route_1], axis=-1)129 input_data = common.convolutional(input_data, (1, 1, 64, 128))130 input_data = tf.concat([route, input_data], axis=-1)131 input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)132133 input_data = common.convolutional(input_data, (3, 3, 128, 256))134 route = input_data135 input_data = common.route_group(input_data, 2, 1)136 input_data = common.convolutional(input_data, (3, 3, 128, 128))137 route_1 = input_data138 input_data = common.convolutional(input_data, (3, 3, 128, 128))139 input_data = tf.concat([input_data, route_1], axis=-1)140 input_data = common.convolutional(input_data, (1, 1, 128, 256))141 route_1 = input_data142 input_data = tf.concat([route, input_data], axis=-1)143 input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)144145 input_data = common.convolutional(input_data, (3, 3, 512, 512))146147 return route_1, input_data148149def darknet53_tiny(input_data):150 input_data = common.convolutional(input_data, (3, 3, 3, 16))151 input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)152 input_data = common.convolutional(input_data, (3, 3, 16, 32))153 input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)154 input_data = common.convolutional(input_data, (3, 3, 32, 64))155 input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)156 input_data = common.convolutional(input_data, (3, 3, 64, 128))157 input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)158 input_data = common.convolutional(input_data, (3, 3, 128, 256))159 route_1 = input_data160 input_data = tf.keras.layers.MaxPool2D(2, 2, 'same')(input_data)161 input_data = common.convolutional(input_data, (3, 3, 256, 512))162 input_data = tf.keras.layers.MaxPool2D(2, 1, 'same')(input_data)163 input_data = common.convolutional(input_data, (3, 3, 512, 1024))164165 return route_1, input_data166 ...

Full Screen

Full Screen

ui_base_ime.gyp

Source:ui_base_ime.gyp Github

copy

Full Screen

1# Copyright 2015 The Chromium Authors. All rights reserved.2# Use of this source code is governed by a BSD-style license that can be3# found in the LICENSE file.4{5 'variables': {6 'chromium_code': 1,7 },8 'targets': [9 {10 # GN version: //ui/base/ime11 'target_name': 'ui_base_ime',12 'type': '<(component)',13 'dependencies': [14 '../../../base/base.gyp:base',15 '../../../base/base.gyp:base_i18n',16 '../../../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',17 '../../../skia/skia.gyp:skia',18 '../../../third_party/icu/icu.gyp:icui18n',19 '../../../third_party/icu/icu.gyp:icuuc',20 '../../../url/url.gyp:url_lib',21 '../../events/events.gyp:dom_keycode_converter',22 '../../events/events.gyp:events',23 '../../events/events.gyp:events_base',24 '../../gfx/gfx.gyp:gfx',25 '../../gfx/gfx.gyp:gfx_geometry',26 '../ui_base.gyp:ui_base',27 ],28 'defines': [29 'UI_BASE_IME_IMPLEMENTATION',30 ],31 'sources' : [32 'candidate_window.cc',33 'candidate_window.h',34 'chromeos/character_composer.cc',35 'chromeos/character_composer.h',36 'chromeos/component_extension_ime_manager.cc',37 'chromeos/component_extension_ime_manager.h',38 'chromeos/composition_text_chromeos.cc',39 'chromeos/composition_text_chromeos.h',40 'chromeos/extension_ime_util.cc',41 'chromeos/extension_ime_util.h',42 'chromeos/fake_ime_keyboard.cc',43 'chromeos/fake_ime_keyboard.h',44 'chromeos/fake_input_method_delegate.cc',45 'chromeos/fake_input_method_delegate.h',46 'chromeos/ime_bridge.cc',47 'chromeos/ime_bridge.h',48 'chromeos/ime_keyboard.cc',49 'chromeos/ime_keyboard.h',50 'chromeos/ime_keyboard_ozone.cc',51 'chromeos/ime_keyboard_ozone.h',52 'chromeos/ime_keyboard_x11.cc',53 'chromeos/ime_keyboard_x11.h',54 'chromeos/ime_keymap.cc',55 'chromeos/ime_keymap.h',56 'chromeos/input_method_delegate.h',57 'chromeos/input_method_descriptor.cc',58 'chromeos/input_method_descriptor.h',59 'chromeos/input_method_manager.cc',60 'chromeos/input_method_manager.h',61 'chromeos/input_method_whitelist.cc',62 'chromeos/input_method_whitelist.h',63 'chromeos/mock_component_extension_ime_manager_delegate.cc',64 'chromeos/mock_component_extension_ime_manager_delegate.h',65 'chromeos/mock_ime_candidate_window_handler.cc',66 'chromeos/mock_ime_candidate_window_handler.h',67 'chromeos/mock_ime_engine_handler.cc',68 'chromeos/mock_ime_engine_handler.h',69 'chromeos/mock_ime_input_context_handler.cc',70 'chromeos/mock_ime_input_context_handler.h',71 'composition_text.cc',72 'composition_text.h',73 'composition_text_util_pango.cc',74 'composition_text_util_pango.h',75 'composition_underline.h',76 'infolist_entry.cc',77 'infolist_entry.h',78 'input_method.h',79 'input_method_auralinux.cc',80 'input_method_auralinux.h',81 'input_method_base.cc',82 'input_method_base.h',83 'input_method_chromeos.cc',84 'input_method_chromeos.h',85 'input_method_delegate.h',86 'input_method_factory.cc',87 'input_method_factory.h',88 'input_method_initializer.cc',89 'input_method_initializer.h',90 'input_method_mac.h',91 'input_method_mac.mm',92 'input_method_minimal.cc',93 'input_method_minimal.h',94 'input_method_observer.h',95 'input_method_win.cc',96 'input_method_win.h',97 'linux/fake_input_method_context.cc',98 'linux/fake_input_method_context.h',99 'linux/fake_input_method_context_factory.cc',100 'linux/fake_input_method_context_factory.h',101 'linux/linux_input_method_context.h',102 'linux/linux_input_method_context_factory.cc',103 'linux/linux_input_method_context_factory.h',104 'mock_input_method.cc',105 'mock_input_method.h',106 'remote_input_method_delegate_win.h',107 'remote_input_method_win.cc',108 'remote_input_method_win.h',109 'text_input_client.cc',110 'text_input_client.h',111 'text_input_type.h',112 'ui_base_ime_export.h',113 'win/imm32_manager.cc',114 'win/imm32_manager.h',115 'win/tsf_input_scope.cc',116 'win/tsf_input_scope.h',117 ],118 'conditions': [119 ['use_ozone==1', {120 'dependencies': [121 '../../events/ozone/events_ozone.gyp:events_ozone_layout',122 '../../ozone/ozone.gyp:ozone',123 ],124 }],125 ['use_pango==1', {126 'dependencies': [127 '../../../build/linux/system.gyp:pangocairo',128 ],129 }],130 ['OS=="win"', {131 # TODO(jschuh): C4267: http://crbug.com/167187 size_t -> int132 # C4324 is structure was padded due to __declspec(align()), which is133 # uninteresting.134 'msvs_disabled_warnings': [ 4267, 4324 ],135 'link_settings': {136 'libraries': [137 '-limm32.lib',138 ],139 },140 }],141 ['use_x11==1', {142 'dependencies': [143 '../../../build/linux/system.gyp:x11',144 '../../gfx/x/gfx_x11.gyp:gfx_x11',145 ],146 }],147 ['toolkit_views==0 and use_aura==0', {148 'sources!': [149 'input_method_factory.cc',150 'input_method_factory.h',151 'input_method_minimal.cc',152 'input_method_minimal.h',153 ],154 }],155 ['chromeos==1', {156 'dependencies': [157 '../../../chromeos/chromeos.gyp:chromeos',158 ],159 }],160 ['use_aura==0 or (desktop_linux==0 and use_ozone==0)', {161 'sources!': [162 'input_method_auralinux.cc',163 'input_method_auralinux.h',164 'linux/fake_input_method_context.cc',165 'linux/fake_input_method_context.h',166 'linux/fake_input_method_context_factory.cc',167 'linux/fake_input_method_context_factory.h',168 'linux/linux_input_method_context.h',169 'linux/linux_input_method_context_factory.cc',170 'linux/linux_input_method_context_factory.h',171 ],172 }],173 ['use_x11==0', {174 'sources!': [175 'composition_text_util_pango.cc',176 'composition_text_util_pango.h',177 ],178 }],179 ],180 },181 ],...

Full Screen

Full Screen

makeRsf.py

Source:makeRsf.py Github

copy

Full Screen

1# !/usr/bin/python2import sys3if len(sys.argv) < 2:4 print "Usage:",sys.argv[0],"rsf-output-file-name"5 sys.exit(64)6output_file_name=sys.argv[1]7output_file=open(output_file_name, 'w')8input_file=open("modulesWithIDs.txt", 'r')9for line in input_file:10 output_file.write("Module\t" + line)11input_file.close()12input_file=open("moduleBelongsToModule.txt", 'r')13for line in input_file:14 output_file.write("ModuleBelongsToModule\t" + line)15input_file.close()16input_file=open("filesWithIDs.txt", 'r')17for line in input_file:18 output_file.write("File\t" + line)19input_file.close()20input_file=open("fileBelongsToModule.txt", 'r')21for line in input_file:22 output_file.write("FileBelongsToModule\t" + line)23input_file.close()24input_file=open("includeBelongsToFile.txt", 'r')25for line in input_file:26 output_file.write("Include\t" + line)27input_file.close()28input_file=open("conditionalCompilationBlocks.txt", 'r')29for line in input_file:30 output_file.write("ConditionalCompilation\t" + line)31input_file.close()32input_file=open("classesWithIDs.txt", 'r')33for line in input_file:34 output_file.write("Class\t" + line)35input_file.close()36#input_file=open("typedefsWithIDs.txt", 'r')37#for line in input_file:38# output_file.write("TypeDef\t" + line)39#input_file.close()40input_file=open("classBelongsToFile.txt", 'r')41for line in input_file:42 output_file.write("ClassBelongsToFile\t" + line)43input_file.close()44input_file=open("inheritanceWithIDs.txt", 'r')45for line in input_file:46 output_file.write("InheritsFrom\t" + line)47input_file.close()48input_file=open("methodsWithIDs.txt", 'r')49for line in input_file:50 output_file.write("Method\t" + line)51input_file.close()52input_file=open("methodBelongsToClass.txt", 'r')53for line in input_file:54 output_file.write("MethodBelongsToClass\t" + line)55input_file.close()56input_file = open("methodVisibility.txt", 'r')57for line in input_file:58 output_file.write("Visibility\t" + line)59input_file.close()60input_file = open("methodSignature.txt", 'r')61for line in input_file:62 output_file.write("Signature\t" + line)63input_file.close()64input_file=open("methodHasClassAsReturnType.txt", 'r')65for line in input_file:66 output_file.write("HasType\t" + line)67input_file.close()68input_file=open("attributesWithIDs.txt", 'r')69for line in input_file:70 output_file.write("Attribute\t" + line)71input_file.close()72input_file=open("attributeBelongsToClass.txt", 'r')73for line in input_file:74 output_file.write("AttributeBelongsToClass\t" + line)75input_file.close()76input_file=open("attributeHasClassAsType.txt", 'r')77for line in input_file:78 output_file.write("HasType\t" + line)79input_file.close()80input_file=open("functionsWithIDs.txt", 'r')81for line in input_file:82 output_file.write("Function\t" + line)83input_file.close()84input_file=open("invokableEntityBelongsToFile.txt", 'r')85for line in input_file:86 output_file.write("InvokableEntityBelongsToFile\t" + line)87input_file.close()88input_file=open("functionHasClassAsReturnType.txt", 'r')89for line in input_file:90 output_file.write("HasType\t" + line)91input_file.close()92input_file=open("defsWithAssociation.txt", 'r')93for line in input_file:94 output_file.write("DefinitionForDeclaration\t" + line)95input_file.close()96input_file=open("globalVarsWithIDs.txt", 'r')97for line in input_file:98 output_file.write("GlobalVar\t" + line)99input_file.close()100input_file=open("accessibleEntityBelongsToFile.txt", 'r')101for line in input_file:102 output_file.write("AccessibleEntityBelongsToFile\t" + line)103input_file.close()104input_file=open("globalVarHasClassAsType.txt", 'r')105for line in input_file:106 output_file.write("HasType\t" + line)107input_file.close()108input_file=open("invocationsWithIDs.txt", 'r')109for line in input_file:110 output_file.write("Invokes\t" + line)111input_file.close()112input_file=open("invocationLocations.txt", 'r')113for line in input_file:114 output_file.write("LineNo\t" + line)115input_file.close()116input_file=open("accessesWithIDs.txt", 'r')117for line in input_file:118 output_file.write("Accesses\t" + line)119input_file.close()120input_file=open("accessesLocations.txt", 'r')121for line in input_file:122 output_file.write("LineNo\t" + line)123input_file.close()124input_file=open("leftValueAccesses.txt", 'r')125for line in input_file:126 output_file.write("LeftValueAccess\t" + line)127input_file.close()128input_file=open("entityBelongsToBlock.txt", 'r')129for line in input_file:130 output_file.write("entityBelongsToBlock\t" + line)131input_file.close()132input_file=open("annotations.txt", 'r')133for line in input_file:134 output_file.write("Annotation\t" + line)135input_file.close()136input_file=open("annotationBelongsToEntity.txt", 'r')137for line in input_file:138 output_file.write("AnnotationBelongsToEntity\t" + line)139input_file.close()140input_file=open("metricsWithIDs.txt", 'r')141for line in input_file:142 output_file.write("Measurement\t" + line)143input_file.close()144input_file=open("cfMetricsWithIDs.txt", 'r')145for line in input_file:146 output_file.write("Measurement\t" + line)147input_file.close()...

Full Screen

Full Screen

system_webview_locales_paks.gypi

Source:system_webview_locales_paks.gypi Github

copy

Full Screen

1# Copyright (c) 2015 The Chromium Authors. All rights reserved.2# Use of this source code is governed by a BSD-style license that can be3# found in the LICENSE file.4#5# This file defines the set of locales that should be packed inside the6# System WebView apk.7# TODO: consider unifying this list with the one in chrome_android_paks.gypi8# once Chrome includes all the locales that the WebView needs.9{10 'variables': {11 'webview_locales_input_paks_folder': '<(PRODUCT_DIR)/android_webview_assets/locales/',12 'webview_locales_input_paks': [13 '<(webview_locales_input_paks_folder)/am.pak',14 '<(webview_locales_input_paks_folder)/ar.pak',15 '<(webview_locales_input_paks_folder)/bg.pak',16 '<(webview_locales_input_paks_folder)/bn.pak',17 '<(webview_locales_input_paks_folder)/ca.pak',18 '<(webview_locales_input_paks_folder)/cs.pak',19 '<(webview_locales_input_paks_folder)/da.pak',20 '<(webview_locales_input_paks_folder)/de.pak',21 '<(webview_locales_input_paks_folder)/el.pak',22 '<(webview_locales_input_paks_folder)/en-GB.pak',23 '<(webview_locales_input_paks_folder)/en-US.pak',24 '<(webview_locales_input_paks_folder)/es.pak',25 '<(webview_locales_input_paks_folder)/es-419.pak',26 '<(webview_locales_input_paks_folder)/et.pak',27 '<(webview_locales_input_paks_folder)/fa.pak',28 '<(webview_locales_input_paks_folder)/fi.pak',29 '<(webview_locales_input_paks_folder)/fil.pak',30 '<(webview_locales_input_paks_folder)/fr.pak',31 '<(webview_locales_input_paks_folder)/gu.pak',32 '<(webview_locales_input_paks_folder)/he.pak',33 '<(webview_locales_input_paks_folder)/hi.pak',34 '<(webview_locales_input_paks_folder)/hr.pak',35 '<(webview_locales_input_paks_folder)/hu.pak',36 '<(webview_locales_input_paks_folder)/id.pak',37 '<(webview_locales_input_paks_folder)/it.pak',38 '<(webview_locales_input_paks_folder)/ja.pak',39 '<(webview_locales_input_paks_folder)/kn.pak',40 '<(webview_locales_input_paks_folder)/ko.pak',41 '<(webview_locales_input_paks_folder)/lt.pak',42 '<(webview_locales_input_paks_folder)/lv.pak',43 '<(webview_locales_input_paks_folder)/ml.pak',44 '<(webview_locales_input_paks_folder)/mr.pak',45 '<(webview_locales_input_paks_folder)/ms.pak',46 '<(webview_locales_input_paks_folder)/nb.pak',47 '<(webview_locales_input_paks_folder)/nl.pak',48 '<(webview_locales_input_paks_folder)/pl.pak',49 '<(webview_locales_input_paks_folder)/pt-BR.pak',50 '<(webview_locales_input_paks_folder)/pt-PT.pak',51 '<(webview_locales_input_paks_folder)/ro.pak',52 '<(webview_locales_input_paks_folder)/ru.pak',53 '<(webview_locales_input_paks_folder)/sk.pak',54 '<(webview_locales_input_paks_folder)/sl.pak',55 '<(webview_locales_input_paks_folder)/sr.pak',56 '<(webview_locales_input_paks_folder)/sv.pak',57 '<(webview_locales_input_paks_folder)/sw.pak',58 '<(webview_locales_input_paks_folder)/ta.pak',59 '<(webview_locales_input_paks_folder)/te.pak',60 '<(webview_locales_input_paks_folder)/th.pak',61 '<(webview_locales_input_paks_folder)/tr.pak',62 '<(webview_locales_input_paks_folder)/uk.pak',63 '<(webview_locales_input_paks_folder)/vi.pak',64 '<(webview_locales_input_paks_folder)/zh-CN.pak',65 '<(webview_locales_input_paks_folder)/zh-TW.pak',66 ],67 },...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = function(config) {2 config.set({3 mochaOptions: {4 }5 });6};7function Calculator() {8 this.result = 0;9}10Calculator.prototype.add = function (number) {11 this.result += number;12 return this.result;13};14Calculator.prototype.subtract = function (number) {15 this.result -= number;16 return this.result;17};18Calculator.prototype.divide = function (number) {19 if (number === 0) {20 throw new Error('Cannot divide by zero');21 }22 this.result /= number;23 return this.result;24};25Calculator.prototype.multiply = function (number) {26 this.result *= number;27 return this.result;28};29Calculator.prototype.getResult = function () {30 return this.result;31};32module.exports = Calculator;33const assert = require('assert');34const Calculator = require('../src/Calculator');35describe('Calculator', function () {36 let calculator;37 beforeEach(function () {38 calculator = new Calculator();39 });40 it('should add two numbers', function () {41 assert.equal(3, calculator.add(1).add(2).getResult());42 });43 it('should subtract two numbers', function () {44 assert.equal(-3, calculator.subtract(1).subtract(2).getResult());45 });46 it('should multiply two numbers', function () {47 assert.equal(6, calculator.add(2).multiply(3).getResult());48 });49 it('should divide two numbers', function () {50 assert.equal(2, calculator.add(6).divide(3).getResult());51 });52 it('should throw an error when dividing by zero', function () {53 assert.throws(function () {54 calculator.add(1).divide(0);55 }, /Cannot divide by zero/);56 });57});

Full Screen

Using AI Code Generation

copy

Full Screen

1var input = require('stryker-parent').input;2var input = require('stryker-child').input;3var input = require('stryker-parent').input;4var input = require('stryker-child').input;5var input = require('stryker-parent').input;6var input = require('stryker-child').input;7var input = require('stryker-parent').input;8var input = require('stryker-child').input;9var input = require('stryker-parent').input;10var input = require('stryker-child').input;11var input = require('stryker-parent').input;12var input = require('stryker-child').input;13var input = require('stryker-parent').input;14var input = require('stryker-child').input;15var input = require('stryker-parent').input;16var input = require('stryker-child').input;17var input = require('stryker-parent').input;18var input = require('stryker-child').input;19var input = require('stryker-parent').input;20var input = require('stryker-child').input;21var input = require('stryker-parent').input;22var input = require('stryker-child').input;

Full Screen

Using AI Code Generation

copy

Full Screen

1const input = require('stryker-parent').input;2const input = require('stryker-child').input;3module.exports = function input() {4 const input = require('stryker-child').input;5}6module.exports = function input() {7 const input = require('stryker-parent').input;8}9module.exports = function input() {10 const input = require('stryker-parent').input;11}12module.exports = function input() {13 const input = require('stryker-child').input;14}15const input = require('stryker-parent').input;16const input = require('stryker-child').input;17module.exports = function input() {18 const input = require('stryker-child').input;19}20module.exports = function input() {21 const input = require('stryker-parent').input;22}23module.exports = function input() {24 const input = require('stryker-parent').input;25}26module.exports = function input() {27 const input = require('stryker-child').input;28}29const input = require('stryker-parent').input;30const input = require('stryker-child').input;31module.exports = function input() {

Full Screen

Using AI Code Generation

copy

Full Screen

1module.exports = {2 input: function() {3 }4}5const strykerParent = require('stryker-parent');6module.exports = {7 input: function() {8 strykerParent.input();9 }10}11const input = require('./input');12module.exports = {13}14module.exports = function() {15}16const strykerParent = require('stryker-parent');17module.exports = {18 input: function() {19 strykerParent.input();20 }21}22module.exports = function(input) {23}24const input = require('./input');25describe('input', function() {26 it('should do something', function() {27 input('foo');28 });29});

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 stryker-parent 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