content_type
stringclasses
8 values
main_lang
stringclasses
7 values
message
stringlengths
1
50
sha
stringlengths
40
40
patch
stringlengths
52
962k
file_count
int64
1
300
PHP
PHP
fix more coding style errors
e33dc98124591d158bd7f6965d08b13b278785ff
<ide><path>lib/Cake/Test/Case/I18n/I18nTest.php <ide> private function __domainCategorySingular($domain = 'test_plugin', $category = 3 <ide> private function __domainCategoryPlural($domain = 'test_plugin', $category = 3) { <ide> $plurals = array(); <ide> for ($number = 0; $number <= 25; $number++) { <del> $plurals[] = sprintf(__dcn($domain, '%d = 1', '%d = 0 or > 1', (float)$number, $category), (float)$number); <add> $plurals[] = sprintf(__dcn($domain, '%d = 1', '%d = 0 or > 1', (float)$number, $category), (float)$number); <ide> } <ide> return $plurals; <ide> } <ide> private function __domainSingular($domain = 'test_plugin') { <ide> private function __domainPlural($domain = 'test_plugin') { <ide> $plurals = array(); <ide> for ($number = 0; $number <= 25; $number++) { <del> $plurals[] = sprintf(__dn($domain, '%d = 1', '%d = 0 or > 1', (float)$number), (float)$number ); <add> $plurals[] = sprintf(__dn($domain, '%d = 1', '%d = 0 or > 1', (float)$number), (float)$number ); <ide> } <ide> return $plurals; <ide> } <ide> private function __singular() { <ide> private function __plural() { <ide> $plurals = array(); <ide> for ($number = 0; $number <= 25; $number++) { <del> $plurals[] = sprintf(__n('%d = 1', '%d = 0 or > 1', (float)$number), (float)$number); <add> $plurals[] = sprintf(__n('%d = 1', '%d = 0 or > 1', (float)$number), (float)$number); <ide> } <ide> return $plurals; <ide> } <ide> private function __singularFromCore() { <ide> private function __pluralFromCore() { <ide> $plurals = array(); <ide> for ($number = 0; $number <= 25; $number++) { <del> $plurals[] = sprintf(__n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', (float)$number), (float)$number ); <add> $plurals[] = sprintf(__n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', (float)$number), (float)$number ); <ide> } <ide> return $plurals; <ide> } <ide><path>lib/Cake/Test/Case/I18n/L10nTest.php <ide> public function testGet() { <ide> $l10n->get(''); <ide> $this->assertEquals($l10n->lang, 'en-us'); <ide> <del> <ide> // Using $this->default <ide> $l10n = new L10n(); <ide> <ide> public function testGet() { <ide> * @return void <ide> */ <ide> public function testGetAutoLanguage() { <del> $__SERVER = $_SERVER; <add> $serverBackup = $_SERVER; <ide> $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'inexistent,en-ca'; <ide> <ide> $l10n = new L10n(); <ide> public function testGetAutoLanguage() { <ide> $this->assertEquals($l10n->languagePath, array('eng', 'eng', 'eng')); <ide> $this->assertEquals($l10n->locale, 'eng'); <ide> <del> $_SERVER = $__SERVER; <add> $_SERVER = $serverBackup; <ide> } <ide> <ide> /** <ide> public function testCatalog() { <ide> $result = $l10n->catalog(array('cy')); <ide> $expected = array( <ide> 'cy' => array('language' => 'Welsh', 'locale' => 'cym', 'localeFallback' => 'cym', 'charset' => 'utf-8', <del>'direction' => 'ltr') <add> 'direction' => 'ltr') <ide> ); <ide> $this->assertEquals($expected, $result); <ide> <ide><path>lib/Cake/Test/Case/I18n/MultibyteTest.php <ide> public function testUtf8() { <ide> 65265, 65266, 65267, 65268, 65269, 65270, 65271, 65272, 65273, 65274, 65275, 65276); <ide> $this->assertEquals($expected, $result); <ide> <del> <ide> $string = 'abcdefghijklmnopqrstuvwxyz'; <ide> $result = Multibyte::utf8($string); <ide> $expected = array(65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, 65353, 65354, 65355, 65356, 65357, 65358, 65359, 65360, <ide> 65361, 65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370); <ide> $this->assertEquals($expected, $result); <ide> <del> <ide> $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; <ide> $result = Multibyte::utf8($string); <ide> $expected = array(65377, 65378, 65379, 65380, 65381, 65382, 65383, 65384, 65385, 65386, 65387, 65388, 65389, 65390, 65391, 65392, <ide> public function testUtf8() { <ide> 11489, 11491); <ide> $this->assertEquals($expected, $result); <ide> <del> <ide> $string = 'fffiflffifflſtstﬓﬔﬕﬖﬗ'; <ide> $result = Multibyte::utf8($string); <ide> $expected = array(64256, 64257, 64258, 64259, 64260, 64261, 64262, 64275, 64276, 64277, 64278, 64279); <ide> public function testUsingMbStrtolower() { <ide> $result = mb_strtolower($string); <ide> $expected = 'ἀι'; <ide> $this->assertEquals($expected, $result); <del>/* <del> The tests below are flaky across different platforms. <del> <del> $string = 'ԀԂԄԆԈԊԌԎԐԒ'; <del> $result = mb_strtolower($string); <del> $expected = 'ԁԃԅԇԉԋԍԏԑԓ'; <del> $this->assertEquals($expected, $result); <del> <del> $string = 'ԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖև'; <del> $result = mb_strtolower($string); <del> $expected = 'աբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆև'; <del> $this->assertEquals($expected, $result); <del> <del> $string = 'ḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẖẗẘẙẚẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸ'; <del> $result = mb_strtolower($string); <del> $expected = 'ḁḃḅḇḉḋḍḏḑḓḕḗḙḛḝḟḡḣḥḧḩḫḭḯḱḳḵḷḹḻḽḿṁṃṅṇṉṋṍṏṑṓṕṗṙṛṝṟṡṣṥṧṩṫṭṯṱṳṵṷṹṻṽṿẁẃẅẇẉẋẍẏẑẓẕẖẗẘẙẚạảấầẩẫậắằẳẵặẹẻẽếềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹ'; <del> $this->assertEquals($expected, $result); <del> <del> $string = 'ΩKÅ'; <del> $result = mb_strtolower($string); <del> $expected = 'ωkå'; <del> $this->assertEquals($expected, $result); <del> <del> $string = 'ΩKÅ'; <del> $result = mb_strtolower($string); <del> $expected = 'ωkå'; <del> $this->assertEquals($expected, $result); <del> <del>/* <del>mb_strtolower does not work for these strings. <del> <del> $string = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯↃ'; <del> $result = mb_strtolower($string); <del> $expected = 'ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿↄ'; <del> $this->assertEquals($expected, $result); <ide> <del> $string = 'ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ'; <del> $result = mb_strtolower($string); <del> $expected = 'ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ'; <del> $this->assertEquals($expected, $result); <del> <del> $string = 'ⰀⰁⰂⰃⰄⰅⰆⰇⰈⰉⰊⰋⰌⰍⰎⰏⰐⰑⰒⰓⰔⰕⰖⰗⰘⰙⰚⰛⰜⰝⰞⰟⰠⰡⰢⰣⰤⰥⰦⰧⰨⰩⰪⰫⰬⰭⰮ'; <del> $result = mb_strtolower($string); <del> $expected = 'ⰰⰱⰲⰳⰴⰵⰶⰷⰸⰹⰺⰻⰼⰽⰾⰿⱀⱁⱂⱃⱄⱅⱆⱇⱈⱉⱊⱋⱌⱍⱎⱏⱐⱑⱒⱓⱔⱕⱖⱗⱘⱙⱚⱛⱜⱝⱞ'; <del> $this->assertEquals($expected, $result); <del> <del> $string = 'ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢ'; <del> $result = mb_strtolower($string); <del> $expected = 'ⲁⲃⲅⲇⲉⲋⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⲳⲵⲷⲹⲻⲽⲿⳁⳃⳅⳇⳉⳋⳍⳏⳑⳓⳕⳗⳙⳛⳝⳟⳡⳣ'; <del> $this->assertEquals($expected, $result); <del>*/ <ide> $string = 'fffiflffifflſtstﬓﬔﬕﬖﬗ'; <ide> $result = mb_strtolower($string); <ide> $expected = 'fffiflffifflſtstﬓﬔﬕﬖﬗ'; <ide> public function testUsingMbStrtoupper() { <ide> $expected = 'ΩKÅ'; <ide> $this->assertEquals($expected, $result); <ide> <del>/* <del>mb_strtoupper does not work for these strings. <del> <del> $string = 'ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿↄ'; <del> $result = mb_strtoupper($string); <del> $expected = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯↃ'; <del> $this->assertEquals($expected, $result); <del> <del> $string = 'ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ'; <del> $result = mb_strtoupper($string); <del> $expected = 'ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ'; <del> $this->assertEquals($expected, $result); <del> <del> $string = 'ⰰⰱⰲⰳⰴⰵⰶⰷⰸⰹⰺⰻⰼⰽⰾⰿⱀⱁⱂⱃⱄⱅⱆⱇⱈⱉⱊⱋⱌⱍⱎⱏⱐⱑⱒⱓⱔⱕⱖⱗⱘⱙⱚⱛⱜⱝⱞ'; <del> $result = mb_strtoupper($string); <del> $expected = 'ⰀⰁⰂⰃⰄⰅⰆⰇⰈⰉⰊⰋⰌⰍⰎⰏⰐⰑⰒⰓⰔⰕⰖⰗⰘⰙⰚⰛⰜⰝⰞⰟⰠⰡⰢⰣⰤⰥⰦⰧⰨⰩⰪⰫⰬⰭⰮ'; <del> $this->assertEquals($expected, $result); <del> <del> $string = 'ⲁⲃⲅⲇⲉⲋⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⲳⲵⲷⲹⲻⲽⲿⳁⳃⳅⳇⳉⳋⳍⳏⳑⳓⳕⳗⳙⳛⳝⳟⳡⳣ'; <del> $result = mb_strtoupper($string); <del> $expected = 'ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢ'; <del> $this->assertEquals($expected, $result); <del>*/ <ide> $string = 'fffiflffifflſtstﬓﬔﬕﬖﬗ'; <ide> $result = mb_strtoupper($string); <ide> $expected = 'fffiflffifflſtstﬓﬔﬕﬖﬗ';
3
Python
Python
use asanyarray instead of asarray
072e8a5572f0104c4b28828cb1404bed8682e951
<ide><path>numpy/core/function_base.py <ide> __all__ = ['logspace', 'linspace', 'may_share_memory'] <ide> <ide> from . import numeric as _nx <del>from .numeric import result_type, NaN, shares_memory, MAY_SHARE_BOUNDS, TooHardError <add>from .numeric import result_type, NaN, shares_memory, MAY_SHARE_BOUNDS, TooHardError, asanyarray <ide> <ide> <ide> def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None): <ide> def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None): <ide> <ide> # Convert float/complex array scalars to float, gh-3504 <ide> # Make sure one can use variables that have an __array_interface__, gh-6634 <del> from numpy import asarray <del> start = asarray(start) * 1. <del> stop = asarray(stop) * 1. <add> start = asanyarray(start) * 1. <add> stop = asanyarray(stop) * 1. <ide> <ide> dt = result_type(start, stop, float(num)) <ide> if dtype is None:
1
Javascript
Javascript
remove unused combinereducers
00c5ca9de5d3f1a9bc0843d820369855b5ac0b16
<ide><path>examples/counter/store/configureStore.js <del>import { createStore, applyMiddleware, combineReducers } from 'redux'; <add>import { createStore, applyMiddleware } from 'redux'; <ide> import thunk from 'redux-thunk'; <ide> import rootReducer from '../reducers'; <ide>
1
Javascript
Javascript
fix old comment
7c7890cac0f90dd5cfee664b97b5fbf052a6101d
<ide><path>src/compile-cache.js <ide> 'use strict'; <ide> <del>// For now, we're not using babel or ES6 features like `let` and `const` in <del>// this file, because `apm` requires this file directly in order to pre-warm <del>// Atom's compile-cache when installing or updating packages, using an older <del>// version of node.js <add>// Atom's compile-cache when installing or updating packages, called by apm's Node-js <ide> <ide> const path = require('path'); <ide> const fs = require('fs-plus');
1
Mixed
Ruby
set inverse during has one autosave if necessary
ba99e6d4002e606679567d8e7cf3d56c29f90925
<ide><path>activerecord/CHANGELOG.md <add>* Allow the inverse of a `has_one` association that was previously autosaved to be loaded. <add> <add> Fixes #34255. <add> <add> *Steven Weber* <add> <ide> * Optimise the length of index names for polymorphic references by using the reference name rather than the type and id column names. <ide> <ide> Because the default behaviour when adding an index with multiple columns is to use all column names in the index name, this could frequently lead to overly long index names for polymorphic references which would fail the migration if it exceeded the database limit. <ide><path>activerecord/lib/active_record/autosave_association.rb <ide> def save_has_one_association(reflection) <ide> unless reflection.through_reflection <ide> record[reflection.foreign_key] = key <ide> if inverse_reflection = reflection.inverse_of <del> record.association(inverse_reflection.name).loaded! <add> record.association(inverse_reflection.name).inversed_from(self) <ide> end <ide> end <ide> <ide><path>activerecord/test/cases/associations/inverse_associations_test.rb <ide> def test_inversed_instance_should_not_be_reloaded_after_stale_state_changed_with <ide> assert_same old_inversed_human, new_inversed_human <ide> end <ide> <add> def test_inversed_instance_should_load_after_autosave_if_it_is_not_already_loaded <add> human = Human.create! <add> human.create_autosave_face! <add> <add> human.autosave_face.reload # clear cached load of autosave_human <add> human.autosave_face.description = "new description" <add> human.save! <add> <add> assert_not_nil human.autosave_face.autosave_human <add> end <add> <ide> def test_should_not_try_to_set_inverse_instances_when_the_inverse_is_a_has_many <ide> interest = interests(:llama_wrangling) <ide> human = interest.polymorphic_human <ide><path>activerecord/test/models/face.rb <ide> <ide> class Face < ActiveRecord::Base <ide> belongs_to :human, inverse_of: :face <add> belongs_to :autosave_human, class_name: "Human", foreign_key: :human_id, inverse_of: :autosave_face <ide> belongs_to :super_human, polymorphic: true <ide> belongs_to :polymorphic_human, polymorphic: true, inverse_of: :polymorphic_face <ide> # Oracle identifier length is limited to 30 bytes or less, `polymorphic` renamed `poly` <ide><path>activerecord/test/models/human.rb <ide> class Human < ActiveRecord::Base <ide> self.table_name = "humans" <ide> <ide> has_one :face, inverse_of: :human <add> has_one :autosave_face, class_name: "Face", autosave: true, foreign_key: :human_id, inverse_of: :autosave_human <ide> has_one :polymorphic_face, class_name: "Face", as: :polymorphic_human, inverse_of: :polymorphic_human <ide> has_one :polymorphic_face_without_inverse, class_name: "Face", as: :poly_human_without_inverse <ide> has_many :interests, inverse_of: :human
5
Javascript
Javascript
support 3 levels of navigation
c06d8d01ca774ad55b4bb9982093a6ce3fac524f
<ide><path>packages/rn-tester/js/RNTesterAppShared.js <ide> const RNTesterApp = (): React.Node => { <ide> ); <ide> const colorScheme = useColorScheme(); <ide> <del> const {activeModuleKey, screen, bookmarks, recentlyUsed} = state; <add> const { <add> activeModuleKey, <add> activeModuleExampleKey, <add> screen, <add> bookmarks, <add> recentlyUsed, <add> } = state; <ide> <ide> React.useEffect(() => { <ide> getInitialStateFromAsyncStorage(APP_STATE_KEY).then( <ide> const RNTesterApp = (): React.Node => { <ide> [dispatch], <ide> ); <ide> <add> const handleModuleExampleCardPress = React.useCallback( <add> exampleName => { <add> dispatch({ <add> type: RNTesterActionsType.EXAMPLE_CARD_PRESS, <add> data: {key: exampleName}, <add> }); <add> }, <add> [dispatch], <add> ); <add> <ide> const toggleBookmark = React.useCallback( <ide> ({exampleType, key}) => { <ide> dispatch({ <ide> const RNTesterApp = (): React.Node => { <ide> <ide> const activeModule = <ide> activeModuleKey != null ? RNTesterList.Modules[activeModuleKey] : null; <add> const activeModuleExample = <add> activeModuleExampleKey != null <add> ? activeModule?.examples.find(e => e.name === activeModuleExampleKey) <add> : null; <ide> const title = Screens.COMPONENTS <ide> ? 'Components' <ide> : Screens.APIS <ide> const RNTesterApp = (): React.Node => { <ide> theme={theme} <ide> documentationURL={activeModule.documentationURL} <ide> /> <del> <RNTesterModuleContainer module={activeModule} /> <add> <RNTesterModuleContainer <add> module={activeModule} <add> example={activeModuleExample} <add> onExampleCardPress={handleModuleExampleCardPress} <add> /> <ide> </View> <ide> ) : ( <ide> <ModuleListsContainer <ide><path>packages/rn-tester/js/components/RNTPressableRow.js <ide> export default function RNTPressableRow({ <ide> rightAddOn, <ide> bottomAddOn, <ide> onPress, <del> accessibilityLabel, <ide> style, <add> accessibilityLabel, <ide> }: Props): React.Node { <ide> const theme = React.useContext(RNTesterThemeContext); <ide> const label = accessibilityLabel ?? `${title} ${description ?? ''}`; <ide><path>packages/rn-tester/js/components/RNTesterModuleContainer.js <ide> */ <ide> <ide> const React = require('react'); <del>const {Platform} = require('react-native'); <ide> const RNTesterBlock = require('./RNTesterBlock'); <ide> const RNTesterExampleFilter = require('./RNTesterExampleFilter'); <add>import RNTPressableRow from './RNTPressableRow'; <add>import {RNTesterThemeContext} from './RNTesterTheme'; <add>import {StyleSheet, Platform} from 'react-native'; <ide> <ide> const invariant = require('invariant'); <ide> import ExamplePage from './ExamplePage'; <ide> function getExampleTitle(title, platform) { <ide> } <ide> <ide> export default function RNTesterModuleContainer(props: Props): React.Node { <del> const {module, example} = props; <add> const {module, example, onExampleCardPress} = props; <add> const theme = React.useContext(RNTesterThemeContext); <ide> const renderExample = (e, i) => { <ide> // Filter platform-specific es <ide> const {description, platform} = e; <ide> let {title} = e; <ide> if (platform != null && Platform.OS !== platform) { <ide> return null; <ide> } <del> return ( <add> return module.showIndividualExamples === true ? ( <add> <RNTPressableRow <add> key={e.name} <add> onPress={() => onExampleCardPress(e.name)} <add> title={e.title} <add> description={description} <add> accessibilityLabel={e.name + ' ' + description} <add> style={StyleSheet.compose(styles.separator, { <add> borderBottomColor: theme.SeparatorColor, <add> })} <add> /> <add> ) : ( <ide> <RNTesterBlock <ide> key={i} <ide> title={getExampleTitle(title, platform)} <ide> export default function RNTesterModuleContainer(props: Props): React.Node { <ide> documentationURL={module.documentationURL} <ide> category={module.category}> <ide> {module.showIndividualExamples === true && example != null ? ( <del> <RNTesterBlock <del> key={example.name} <del> title={getExampleTitle(example.title, example.platform)} <del> description={example.description}> <del> {example.render()} <del> </RNTesterBlock> <add> example.render() <ide> ) : ( <ide> <RNTesterExampleFilter <ide> testID="example_search" <ide> export default function RNTesterModuleContainer(props: Props): React.Node { <ide> </ExamplePage> <ide> ); <ide> } <add> <add>const styles = StyleSheet.create({ <add> separator: { <add> borderBottomWidth: Platform.select({ <add> ios: StyleSheet.hairlineWidth, <add> android: 0, <add> }), <add> marginHorizontal: Platform.select({ios: 15, android: 0}), <add> }, <add>}); <ide><path>packages/rn-tester/js/examples/SectionList/SectionList-onEndReached.js <ide> export function SectionList_onEndReached(): React.Node { <ide> export default { <ide> title: 'SectionList Inverted', <ide> name: 'SectionList-onEndReached', <add> description: 'Test onEndReached behavior', <ide> render: function(): React.Element<typeof SectionList_onEndReached> { <ide> return <SectionList_onEndReached />; <ide> }, <ide><path>packages/rn-tester/js/examples/SectionList/SectionList-stickyHeadersEnabled.js <ide> export function SectionList_stickySectionHeadersEnabled(): React.Node { <ide> export default { <ide> title: 'SectionList Sticky Headers Enabled', <ide> name: 'SectionList-stickyHeadersEnabled', <add> description: 'Toggle sticky headers on/off', <ide> render: function(): React.Element< <ide> typeof SectionList_stickySectionHeadersEnabled, <ide> > { <ide><path>packages/rn-tester/js/examples/SectionList/SectionListBaseExample.js <ide> const styles = StyleSheet.create({ <ide> height: 40, <ide> }, <ide> output: { <del> width: '80%', <add> flex: 1, <ide> fontSize: 12, <ide> }, <ide> list: { <ide><path>packages/rn-tester/js/examples/SectionList/SectionListIndex.js <ide> exports.title = 'SectionList'; <ide> exports.category = 'ListView'; <ide> exports.documentationURL = 'https://reactnative.dev/docs/sectionlist'; <ide> exports.description = 'Performant, scrollable list of data.'; <add>exports.showIndividualExamples = true; <ide> exports.examples = [ <ide> ContentInset, <ide> onEndReached, <ide><path>packages/rn-tester/js/types/RNTesterTypes.js <ide> export type ComponentList = null | {components: string[], apis: string[]}; <ide> <ide> export type RNTesterState = { <ide> activeModuleKey: null | string, <add> activeModuleExampleKey: null | string, <ide> screen: ScreenTypes, <ide> bookmarks: ComponentList, <ide> recentlyUsed: ComponentList, <ide><path>packages/rn-tester/js/utils/RNTesterReducer.js <ide> export const RNTesterActionsType = { <ide> BOOKMARK_PRESS: 'BOOKMARK_PRESS', <ide> BACK_BUTTON_PRESS: 'BACK_BUTTON_PRESS', <ide> MODULE_CARD_PRESS: 'MODULE_CARD_PRESS', <add> EXAMPLE_CARD_PRESS: 'EXAMPLE_CARD_PRESS', <ide> }; <ide> <ide> const getUpdatedBookmarks = ({ <ide> export const RNTesterReducer = ( <ide> return { <ide> ...state, <ide> activeModuleKey: null, <add> activeModuleExampleKey: null, <ide> screen: action.data.screen, <ide> }; <ide> case RNTesterActionsType.MODULE_CARD_PRESS: <ide> return { <ide> ...state, <ide> activeModuleKey: action.data.key, <add> activeModuleExampleKey: null, <ide> recentlyUsed: getUpdatedRecentlyUsed({ <ide> exampleType: action.data.exampleType, <ide> key: action.data.key, <ide> recentlyUsed: state.recentlyUsed, <ide> }), <ide> }; <add> case RNTesterActionsType.EXAMPLE_CARD_PRESS: <add> return { <add> ...state, <add> activeModuleExampleKey: action.data.key, <add> }; <ide> case RNTesterActionsType.BOOKMARK_PRESS: <ide> return { <ide> ...state, <ide> export const RNTesterReducer = ( <ide> // Go back to module or list <ide> return { <ide> ...state, <del> activeModuleKey: null, <add> activeModuleExampleKey: null, <add> activeModuleKey: <add> state.activeModuleExampleKey != null ? state.activeModuleKey : null, <ide> }; <ide> default: <ide> throw new Error(`Invalid action type ${action.type}`); <ide><path>packages/rn-tester/js/utils/testerStateUtils.js <ide> export const Screens = { <ide> <ide> export const initialState: RNTesterState = { <ide> activeModuleKey: null, <add> activeModuleExampleKey: null, <ide> screen: null, <ide> bookmarks: null, <ide> recentlyUsed: null, <ide> export const getInitialStateFromAsyncStorage = async ( <ide> if (!initialStateString) { <ide> return { <ide> activeModuleKey: null, <add> activeModuleExampleKey: null, <ide> screen: Screens.COMPONENTS, <ide> bookmarks: {components: [], apis: []}, <ide> recentlyUsed: {components: [], apis: []},
10
Text
Text
add missing accent mark around docker command
809d99ad913fd73ae5da637c26f94879a6eb189c
<ide><path>docs/man/docker-commit.1.md <ide> Using an existing container's name or ID you can create a new image. <ide> ## Creating a new image from an existing container <ide> An existing Fedora based container has had Apache installed while running <ide> in interactive mode with the bash shell. Apache is also running. To <del>create a new image run docker ps to find the container's ID and then run: <add>create a new image run `docker ps` to find the container's ID and then run: <ide> <ide> # docker commit -m="Added Apache to Fedora base image" \ <ide> -a="A D Ministrator" 98bd7fc99854 fedora/fedora_httpd:20 <ide> <ide> ## Apply specified Dockerfile instructions while committing the image <ide> If an existing container was created without the DEBUG environment <ide> variable set to "true", you can create a new image based on that <del>container by first getting the container's ID with docker ps and <add>container by first getting the container's ID with `docker ps` and <ide> then running: <ide> <ide> # docker commit -c="ENV DEBUG true" 98bd7fc99854 debug-image
1
Javascript
Javascript
handle compose with no functions
306094df6ba9136bcba4b8dd6b577b5b3e8ddff5
<ide><path>src/utils/compose.js <ide> * left. For example, compose(f, g, h) is identical to arg => f(g(h(arg))). <ide> */ <ide> export default function compose(...funcs) { <del> return (...args) => funcs.slice(0, -1).reduceRight((composed, f) => <del> f(composed), funcs[funcs.length - 1](...args) <del> ) <add> return (...args) => { <add> return funcs.length ? <add> funcs.slice(0, -1).reduceRight((composed, f) => f(composed), funcs[funcs.length - 1](...args)) : <add> args[0] <add> } <ide> } <ide><path>test/utils/compose.spec.js <ide> describe('Utils', () => { <ide> const add = (x, y) => x + y <ide> expect(compose(square, add)(1, 2)).toBe(9) <ide> }) <add> <add> it('returns the first given argument if given no functions', () => { <add> expect(compose()(1, 2)).toBe(1) <add> expect(compose()(3)).toBe(3) <add> expect(compose()()).toBe(undefined) <add> }) <ide> }) <ide> })
2
Go
Go
fix bug in nvidia device registration
739adb46e4565efae3981c2cb3f886a87a5e4bd2
<ide><path>daemon/nvidia_linux.go <ide> func init() { <ide> capset: capset, <ide> updateSpec: setNvidiaGPUs, <ide> } <del> for c := range capset { <del> nvidiaDriver.capset[c] = struct{}{} <add> for c := range allNvidiaCaps { <add> nvidiaDriver.capset[string(c)] = struct{}{} <ide> } <ide> registerDeviceDriver("nvidia", nvidiaDriver) <ide> } <ide><path>pkg/capabilities/caps.go <ide> anyof: <ide> } <ide> return andList <ide> } <add> // match anything <ide> return nil <ide> }
2
Python
Python
fix marianmt convertion to onnx
c523a86929d26dfa97fad1f50a00f3e5e7f22e1b
<ide><path>src/transformers/models/marian/configuration_marian.py <ide> def _flatten_past_key_values_(self, flattened_output, name, idx, t): <ide> flattened_output = super(OnnxSeq2SeqConfigWithPast, self)._flatten_past_key_values_( <ide> flattened_output, name, idx, t <ide> ) <add> <add> @property <add> def atol_for_validation(self) -> float: <add> return 1e-4 <ide><path>src/transformers/onnx/convert.py <ide> def validate_model_outputs( <ide> <ide> # Values <ide> if not np.allclose(ref_value, ort_value, atol=atol): <add> bad_indices = np.logical_not(np.isclose(ref_value, ort_value, atol=atol)) <ide> logger.info(f"\t\t-[x] values not close enough (atol: {atol})") <ide> raise ValueError( <ide> "Outputs values doesn't match between reference model and ONNX exported model: " <del> f"Got max absolute difference of: {np.amax(np.abs(ref_value - ort_value))}" <add> f"Got max absolute difference of: {np.amax(np.abs(ref_value - ort_value))} for " <add> f"{ref_value[bad_indices]} vs {ort_value[bad_indices]}" <ide> ) <ide> else: <ide> logger.info(f"\t\t-[✓] all values close (atol: {atol})")
2
Javascript
Javascript
move hmr to internal transform
51d8ed92d5c491b1be945f4d86c6e583a77abe38
<ide><path>local-cli/server/runServer.js <ide> function getAppMiddleware(args, config) { <ide> cacheVersion: '3', <ide> getTransformOptionsModulePath: config.getTransformOptionsModulePath, <ide> transformModulePath: transformerPath, <del> enableInternalTransforms: args['enable-internal-transforms'], <ide> assetRoots: args.assetRoots, <ide> assetExts: ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp'], <ide> resetCache: args.resetCache || args['reset-cache'], <ide><path>local-cli/server/server.js <ide> function _server(argv, config, resolve, reject) { <ide> type: 'string', <ide> default: require.resolve('../../packager/transformer'), <ide> description: 'Specify a custom transformer to be used (absolute path)' <del> }, { <del> command: 'enable-internal-transforms', <del> type: 'boolean', <del> default: false <ide> }, { <ide> command: 'resetCache', <ide> description: 'Removes cached files', <ide><path>packager/react-packager/src/Bundler/index.js <ide> const validateOpts = declareOpts({ <ide> type:'string', <ide> required: false, <ide> }, <del> enableInternalTransforms: { <del> type: 'boolean', <del> default: false, <del> }, <ide> nonPersistent: { <ide> type: 'boolean', <ide> default: false, <ide> class Bundler { <ide> blacklistRE: opts.blacklistRE, <ide> cache: this._cache, <ide> transformModulePath: opts.transformModulePath, <del> enableInternalTransforms: opts.enableInternalTransforms, <ide> }); <ide> <ide> this._projectRoots = opts.projectRoots; <ide><path>packager/react-packager/src/JSTransformer/index.js <ide> const validateOpts = declareOpts({ <ide> type: 'number', <ide> default: DEFAULT_MAX_CALL_TIME, <ide> }, <del> enableInternalTransforms: { <del> type: 'boolean', <del> default: false, <del> }, <ide> }); <ide> <ide> class Transformer { <ide> class Transformer { <ide> <ide> this._cache = opts.cache; <ide> this._transformModulePath = opts.transformModulePath; <del> this._enableInternalTransforms = opts.enableInternalTransforms; <ide> <ide> if (opts.transformModulePath != null) { <ide> this._workers = workerFarm({ <ide> class Transformer { <ide> options: { <ide> ...options, <ide> externalTransformModulePath: this._transformModulePath, <del> enableInternalTransforms: this._enableInternalTransforms, <ide> }, <ide> }).then(res => { <ide> if (res.error) { <ide><path>packager/react-packager/src/JSTransformer/worker.js <ide> function internalTransforms(sourceCode, filename, options) { <ide> filename: filename, <ide> sourceFileName: filename, <ide> sourceMaps: false, <del> plugins: Transforms.getAll() <add> plugins: Transforms.getAll(options) <ide> }); <ide> <ide> return { <ide> function onExternalTransformDone(data, callback, error, externalOutput) { <ide> return; <ide> } <ide> <del> var result; <del> if (data.options.enableInternalTransforms) { <del> result = internalTransforms( <del> externalOutput.code, <del> externalOutput.filename, <del> data.options <del> ); <del> } else { <del> result = externalOutput; <del> } <add> var result = internalTransforms( <add> externalOutput.code, <add> externalOutput.filename, <add> data.options <add> ); <ide> <ide> callback(null, result); <ide> } <ide><path>packager/react-packager/src/Server/index.js <ide> const validateOpts = declareOpts({ <ide> type: 'boolean', <ide> default: false, <ide> }, <del> enableInternalTransforms: { <del> type: 'boolean', <del> default: false, <del> }, <ide> assetRoots: { <ide> type: 'array', <ide> required: false, <ide><path>packager/react-packager/src/transforms/index.js <ide> */ <ide> 'use strict'; <ide> <del>exports.getAll = function() { <del> return [ <del> require('./babel-plugin-system-import'), <del> ]; <add>exports.getAll = function(options) { <add> var plugins = []; <add> if (options.hot) { <add> plugins = plugins.concat([ <add> [ <add> 'react-transform', <add> { <add> transforms: [{ <add> transform: 'react-transform-hmr/lib/index.js', <add> imports: ['React'], <add> locals: ['module'], <add> }] <add> }, <add> ], <add> 'transform-es2015-block-scoping', <add> 'transform-es2015-constants', <add> ['transform-es2015-modules-commonjs', {strict: false, allowTopLevelThis: true}], <add> ]); <add> } <add> <add> return plugins; <ide> }; <ide> <ide><path>packager/transformer.js <ide> function transform(src, filename, options) { <ide> return plugin; <ide> }); <ide> <del> config.plugins = config.plugins.concat(ReactPackager.getTransforms()); <del> <ide> const result = babel.transform(src, Object.assign({}, babelRC, config)); <ide> <ide> return {
8
Javascript
Javascript
use actionmanager to register in-template actions
92d564f3a8b1dd0bae32d1c64d63762520776e04
<ide><path>packages/ember-routing-handlebars/lib/helpers/action.js <ide> import { uuid } from "ember-metal/utils"; <ide> import run from "ember-metal/run_loop"; <ide> <ide> import { isSimpleClick } from "ember-views/system/utils"; <add>import ActionManager from "ember-views/system/action_manager"; <ide> import EmberRouter from "ember-routing/system/router"; <ide> <ide> import EmberHandlebars from "ember-handlebars"; <ide> function args(options, actionName) { <ide> return ret.concat(resolveParams(options.context, options.params, { types: types, data: data })); <ide> } <ide> <del>var ActionHelper = { <del> registeredActions: {} <del>}; <add>var ActionHelper = {}; <ide> <ide> export { ActionHelper }; <ide> <ide> function ignoreKeyEvent(eventName, event, keyCode) { <ide> ActionHelper.registerAction = function(actionNameOrPath, options, allowedKeys) { <ide> var actionId = uuid(); <ide> <del> ActionHelper.registeredActions[actionId] = { <add> ActionManager.registeredActions[actionId] = { <ide> eventName: options.eventName, <ide> handler: function handleRegisteredAction(event) { <ide> if (!isAllowedEvent(event, allowedKeys)) { return true; } <ide> ActionHelper.registerAction = function(actionNameOrPath, options, allowedKeys) { <ide> }; <ide> <ide> options.view.on('willClearRender', function() { <del> delete ActionHelper.registeredActions[actionId]; <add> delete ActionManager.registeredActions[actionId]; <ide> }); <ide> <ide> return actionId; <ide><path>packages/ember-routing-handlebars/tests/helpers/action_test.js <ide> import Ember from 'ember-metal/core'; // A, FEATURES, assert, TESTING_DEPRECATIO <ide> import { set } from "ember-metal/property_set"; <ide> import run from "ember-metal/run_loop"; <ide> import EventDispatcher from "ember-views/system/event_dispatcher"; <add>import ActionManager from "ember-views/system/action_manager"; <ide> <ide> import Container from "ember-runtime/system/container"; <ide> import EmberObject from "ember-runtime/system/object"; <ide> test("should register an event handler", function() { <ide> <ide> var actionId = view.$('a[data-ember-action]').attr('data-ember-action'); <ide> <del> ok(ActionHelper.registeredActions[actionId], "The action was registered"); <add> ok(ActionManager.registeredActions[actionId], "The action was registered"); <ide> <ide> view.$('a').trigger('click'); <ide> <ide> test("handles whitelisted modifier keys", function() { <ide> <ide> var actionId = view.$('a[data-ember-action]').attr('data-ember-action'); <ide> <del> ok(ActionHelper.registeredActions[actionId], "The action was registered"); <add> ok(ActionManager.registeredActions[actionId], "The action was registered"); <ide> <ide> var e = jQuery.Event('click'); <ide> e.altKey = true; <ide> test("should unregister event handlers on rerender", function() { <ide> view.rerender(); <ide> }); <ide> <del> ok(!ActionHelper.registeredActions[previousActionId], "On rerender, the event handler was removed"); <add> ok(!ActionManager.registeredActions[previousActionId], "On rerender, the event handler was removed"); <ide> <ide> var newActionId = view.$('a[data-ember-action]').attr('data-ember-action'); <ide> <del> ok(ActionHelper.registeredActions[newActionId], "After rerender completes, a new event handler was added"); <add> ok(ActionManager.registeredActions[newActionId], "After rerender completes, a new event handler was added"); <ide> }); <ide> <ide> test("should unregister event handlers on inside virtual views", function() { <ide> test("should unregister event handlers on inside virtual views", function() { <ide> things.removeAt(0); <ide> }); <ide> <del> ok(!ActionHelper.registeredActions[actionId], "After the virtual view was destroyed, the action was unregistered"); <add> ok(!ActionManager.registeredActions[actionId], "After the virtual view was destroyed, the action was unregistered"); <ide> }); <ide> <ide> test("should properly capture events on child elements of a container with an action", function() { <ide><path>packages/ember-routing-handlebars/tests/helpers/render_test.js <ide> import EmberHandlebars from "ember-handlebars"; <ide> import EmberView from "ember-routing/ext/view"; <ide> import _MetamorphView from "ember-handlebars/views/metamorph_view"; <ide> import jQuery from "ember-views/system/jquery"; <add>import ActionManager from "ember-views/system/action_manager"; <ide> <ide> import renderHelper from "ember-routing-handlebars/helpers/render"; <del>import { <del> ActionHelper, <del> actionHelper <del>} from "ember-routing-handlebars/helpers/action"; <add>import { actionHelper } from "ember-routing-handlebars/helpers/action"; <ide> import { outletHelper } from "ember-routing-handlebars/helpers/outlet"; <ide> <ide> function appendView(view) { <ide> test("{{render}} helper should link child controllers to the parent controller", <ide> <ide> var button = jQuery("#parent-action"), <ide> actionId = button.data('ember-action'), <del> action = ActionHelper.registeredActions[actionId], <add> action = ActionManager.registeredActions[actionId], <ide> handler = action.handler; <ide> <ide> equal(button.text(), "Go to Mom", "The parentController property is set on the child controller"); <ide><path>packages/ember-views/lib/system/action_manager.js <add>/** <add>@module ember <add>@submodule ember-views <add>*/ <add> <add>function ActionManager() {} <add> <add>/** <add> Global action id hash. <add> <add> @private <add> @property registeredActions <add> @type Object <add>*/ <add>ActionManager.registeredActions = {}; <add> <add>export default ActionManager; <ide><path>packages/ember-views/lib/system/event_dispatcher.js <ide> import { typeOf } from "ember-metal/utils"; <ide> import { fmt } from "ember-runtime/system/string"; <ide> import EmberObject from "ember-runtime/system/object"; <ide> import jQuery from "ember-views/system/jquery"; <add>import ActionManager from "ember-views/system/action_manager"; <ide> import View from "ember-views/views/view"; <ide> import merge from "ember-metal/merge"; <ide> <del>var ActionHelper; <del> <ide> //ES6TODO: <ide> // find a better way to do Ember.View.views without global state <ide> <ide> export default EmberObject.extend({ <ide> }); <ide> <ide> rootElement.on(event + '.ember', '[data-ember-action]', function(evt) { <del> //ES6TODO: Needed for ActionHelper (generally not available in ember-views test suite) <del> if (!ActionHelper) { ActionHelper = requireModule("ember-routing-handlebars/helpers/action")["ActionHelper"]; } <del> <ide> var actionId = jQuery(evt.currentTarget).attr('data-ember-action'), <del> action = ActionHelper.registeredActions[actionId]; <add> action = ActionManager.registeredActions[actionId]; <ide> <ide> // We have to check for action here since in some cases, jQuery will trigger <ide> // an event on `removeChild` (i.e. focusout) after we've already torn down the <ide> export default EmberObject.extend({ <ide> }, <ide> <ide> toString: function() { <del> return '(EventDisptacher)'; <add> return '(EventDispatcher)'; <ide> } <ide> }); <ide><path>packages/ember/tests/routing/basic_test.js <ide> import "ember"; <ide> import { forEach } from "ember-metal/enumerable_utils"; <ide> import { get } from "ember-metal/property_get"; <ide> import { set } from "ember-metal/property_set"; <add>import ActionManager from "ember-views/system/action_manager"; <ide> <ide> var Router, App, AppView, templates, router, container, originalLoggerError; <ide> var compile = Ember.Handlebars.compile; <ide> asyncTest("Events are triggered on the controller if a matching action name is i <ide> bootApplication(); <ide> <ide> var actionId = Ember.$("#qunit-fixture a").data("ember-action"); <del> var action = Ember.Handlebars.ActionHelper.registeredActions[actionId]; <add> var action = ActionManager.registeredActions[actionId]; <ide> var event = new Ember.$.Event("click"); <ide> action.handler(event); <ide> }); <ide> asyncTest("Events are triggered on the current state when defined in `actions` o <ide> bootApplication(); <ide> <ide> var actionId = Ember.$("#qunit-fixture a").data("ember-action"); <del> var action = Ember.Handlebars.ActionHelper.registeredActions[actionId]; <add> var action = ActionManager.registeredActions[actionId]; <ide> var event = new Ember.$.Event("click"); <ide> action.handler(event); <ide> }); <ide> asyncTest("Events defined in `actions` object are triggered on the current state <ide> bootApplication(); <ide> <ide> var actionId = Ember.$("#qunit-fixture a").data("ember-action"); <del> var action = Ember.Handlebars.ActionHelper.registeredActions[actionId]; <add> var action = ActionManager.registeredActions[actionId]; <ide> var event = new Ember.$.Event("click"); <ide> action.handler(event); <ide> }); <ide> asyncTest("Events are triggered on the current state when defined in `events` ob <ide> bootApplication(); <ide> <ide> var actionId = Ember.$("#qunit-fixture a").data("ember-action"); <del> var action = Ember.Handlebars.ActionHelper.registeredActions[actionId]; <add> var action = ActionManager.registeredActions[actionId]; <ide> var event = new Ember.$.Event("click"); <ide> action.handler(event); <ide> }); <ide> asyncTest("Events defined in `events` object are triggered on the current state <ide> bootApplication(); <ide> <ide> var actionId = Ember.$("#qunit-fixture a").data("ember-action"); <del> var action = Ember.Handlebars.ActionHelper.registeredActions[actionId]; <add> var action = ActionManager.registeredActions[actionId]; <ide> var event = new Ember.$.Event("click"); <ide> action.handler(event); <ide> }); <ide> if (Ember.FEATURES.isEnabled('ember-routing-drop-deprecated-action-style')) { <ide> bootApplication(); <ide> <ide> var actionId = Ember.$("#qunit-fixture a").data("ember-action"); <del> var action = Ember.Handlebars.ActionHelper.registeredActions[actionId]; <add> var action = ActionManager.registeredActions[actionId]; <ide> var event = new Ember.$.Event("click"); <ide> action.handler(event); <ide> }); <ide> if (Ember.FEATURES.isEnabled('ember-routing-drop-deprecated-action-style')) { <ide> bootApplication(); <ide> <ide> var actionId = Ember.$("#qunit-fixture a").data("ember-action"); <del> var action = Ember.Handlebars.ActionHelper.registeredActions[actionId]; <add> var action = ActionManager.registeredActions[actionId]; <ide> var event = new Ember.$.Event("click"); <ide> action.handler(event); <ide> }); <ide> asyncTest("actions can be triggered with multiple arguments", function() { <ide> bootApplication(); <ide> <ide> var actionId = Ember.$("#qunit-fixture a").data("ember-action"); <del> var action = Ember.Handlebars.ActionHelper.registeredActions[actionId]; <add> var action = ActionManager.registeredActions[actionId]; <ide> var event = new Ember.$.Event("click"); <ide> action.handler(event); <ide> });
6
Javascript
Javascript
add gridarea to unitless css properties
25d48a7281bcb2c51927c562a43295b8ce0bd983
<ide><path>packages/react-dom/src/shared/CSSProperty.js <ide> export const isUnitlessNumber = { <ide> flexShrink: true, <ide> flexNegative: true, <ide> flexOrder: true, <add> gridArea: true, <ide> gridRow: true, <ide> gridRowEnd: true, <ide> gridRowSpan: true,
1
Ruby
Ruby
add tests against resolver
80e2aaa80afc205d223288b85828729cb181f6f2
<ide><path>actionview/test/template/file_system_resolver_test.rb <add># frozen_string_literal: true <add> <add>require "abstract_unit" <add>require "template/resolver_shared_tests" <add> <add>class FileSystemResolverTest < ActiveSupport::TestCase <add> include ResolverSharedTests <add> <add> def resolver <add> ActionView::FileSystemResolver.new(tmpdir) <add> end <add>end <ide><path>actionview/test/template/optimized_file_system_resolver_test.rb <add># frozen_string_literal: true <add> <add>require "abstract_unit" <add>require "template/resolver_shared_tests" <add> <add>class OptimizedFileSystemResolverTest < ActiveSupport::TestCase <add> include ResolverSharedTests <add> <add> def resolver <add> ActionView::OptimizedFileSystemResolver.new(tmpdir) <add> end <add>end <ide><path>actionview/test/template/resolver_shared_tests.rb <add>module ResolverSharedTests <add> attr_reader :tmpdir <add> <add> def run(*args) <add> capture_exceptions do <add> Dir.mktmpdir(nil, __dir__) { |dir| @tmpdir = dir; super } <add> end <add> end <add> <add> def with_file(filename, source="File at #{filename}") <add> path = File.join(tmpdir, filename) <add> FileUtils.mkdir_p(File.dirname(path)) <add> File.write(path, source) <add> end <add> <add> def test_can_find_with_no_extensions <add> with_file "test/hello_world", "Hello default!" <add> <add> templates = resolver.find_all("hello_world", "test", false, locale: [:en], formats: [:html], variants: [:phone], handlers: [:erb]) <add> assert_equal 1, templates.size <add> assert_equal "Hello default!", templates[0].source <add> assert_equal "test/hello_world", templates[0].virtual_path <add> assert_nil templates[0].format <add> assert_nil templates[0].variant <add> assert_kind_of ActionView::Template::Handlers::Raw, templates[0].handler <add> end <add> <add> def test_can_find_with_just_handler <add> with_file "test/hello_world.erb", "Hello erb!" <add> <add> templates = resolver.find_all("hello_world", "test", false, locale: [:en], formats: [:html], variants: [:phone], handlers: [:erb]) <add> assert_equal 1, templates.size <add> assert_equal "Hello erb!", templates[0].source <add> assert_equal "test/hello_world", templates[0].virtual_path <add> assert_nil templates[0].format <add> assert_nil templates[0].variant <add> assert_kind_of ActionView::Template::Handlers::ERB, templates[0].handler <add> end <add> <add> def test_can_find_with_format_and_handler <add> with_file "test/hello_world.text.builder", "Hello plain text!" <add> <add> templates = resolver.find_all("hello_world", "test", false, locale: [:en], formats: [:html, :text], variants: [:phone], handlers: [:erb, :builder]) <add> assert_equal 1, templates.size <add> assert_equal "Hello plain text!", templates[0].source <add> assert_equal "test/hello_world", templates[0].virtual_path <add> assert_equal :text, templates[0].format <add> assert_nil templates[0].variant <add> assert_kind_of ActionView::Template::Handlers::Builder, templates[0].handler <add> end <add> <add> def test_can_find_with_variant_format_and_handler <add> with_file "test/hello_world.html+phone.erb", "Hello plain text!" <add> <add> templates = resolver.find_all("hello_world", "test", false, locale: [:en], formats: [:html], variants: [:phone], handlers: [:erb]) <add> assert_equal 1, templates.size <add> assert_equal "Hello plain text!", templates[0].source <add> assert_equal "test/hello_world", templates[0].virtual_path <add> assert_equal :html, templates[0].format <add> assert_equal "phone", templates[0].variant <add> assert_kind_of ActionView::Template::Handlers::ERB, templates[0].handler <add> end <add> <add> def test_can_find_with_any_variant_format_and_handler <add> with_file "test/hello_world.html+phone.erb", "Hello plain text!" <add> <add> templates = resolver.find_all("hello_world", "test", false, locale: [:en], formats: [:html], variants: :any, handlers: [:erb]) <add> assert_equal 1, templates.size <add> assert_equal "Hello plain text!", templates[0].source <add> assert_equal "test/hello_world", templates[0].virtual_path <add> assert_equal :html, templates[0].format <add> assert_equal "phone", templates[0].variant <add> assert_kind_of ActionView::Template::Handlers::ERB, templates[0].handler <add> end <add> <add> def test_doesnt_find_template_with_wrong_details <add> with_file "test/hello_world.html.erb", "Hello plain text!" <add> <add> templates = resolver.find_all("hello_world", "test", false, locale: [], formats: [:xml], variants: :any, handlers: [:builder]) <add> assert_equal 0, templates.size <add> <add> templates = resolver.find_all("hello_world", "test", false, locale: [], formats: [:xml], variants: :any, handlers: [:erb]) <add> assert_equal 0, templates.size <add> end <add>end
3
Javascript
Javascript
name inner function of iife
386dd4efbfd773a9d335df4cf1a391bd8fd63083
<ide><path>src/animation/PropertyBinding.js <ide> Object.assign( PropertyBinding, { <ide> <ide> var supportedObjectNames = [ 'material', 'materials', 'bones' ]; <ide> <del> return function ( trackName ) { <add> return function parseTrackName( trackName ) { <ide> <ide> var matches = trackRe.exec( trackName ); <ide> <ide><path>src/loaders/JSONLoader.js <ide> Object.assign( JSONLoader.prototype, { <ide> <ide> } <ide> <del> return function ( json, texturePath ) { <add> return function parse( json, texturePath ) { <ide> <ide> if ( json.data !== undefined ) { <ide> <ide><path>src/math/Math.js <ide> var _Math = { <ide> <ide> } <ide> <del> return function () { <add> return function generateUUID() { <ide> <ide> var d0 = Math.random() * 0xffffffff | 0; <ide> var d1 = Math.random() * 0xffffffff | 0;
3
Text
Text
use code markup/markdown in headers
85aed3e01e5c9892219c513cc6862ec2b503b2dc
<ide><path>doc/api/repl.md <ide> function myWriter(output) { <ide> } <ide> ``` <ide> <del>## Class: REPLServer <add>## Class: `REPLServer` <ide> <!-- YAML <ide> added: v0.1.91 <ide> --> <ide> added: v0.1.91 <ide> Instances of `repl.REPLServer` are created using the `repl.start()` method and <ide> *should not* be created directly using the JavaScript `new` keyword. <ide> <del>### Event: 'exit' <add>### Event: `'exit'` <ide> <!-- YAML <ide> added: v0.7.7 <ide> --> <ide> replServer.on('exit', () => { <ide> }); <ide> ``` <ide> <del>### Event: 'reset' <add>### Event: `'reset'` <ide> <!-- YAML <ide> added: v0.11.0 <ide> --> <ide> Clearing context... <ide> > <ide> ``` <ide> <del>### replServer.defineCommand(keyword, cmd) <add>### `replServer.defineCommand(keyword, cmd)` <ide> <!-- YAML <ide> added: v0.3.0 <ide> --> <ide> Hello, Node.js User! <ide> Goodbye! <ide> ``` <ide> <del>### replServer.displayPrompt(\[preserveCursor\]) <add>### `replServer.displayPrompt([preserveCursor])` <ide> <!-- YAML <ide> added: v0.1.91 <ide> --> <ide> The `replServer.displayPrompt` method is primarily intended to be called from <ide> within the action function for commands registered using the <ide> `replServer.defineCommand()` method. <ide> <del>### replServer.clearBufferedCommand() <add>### `replServer.clearBufferedCommand()` <ide> <!-- YAML <ide> added: v9.0.0 <ide> --> <ide> buffered but not yet executed. This method is primarily intended to be <ide> called from within the action function for commands registered using the <ide> `replServer.defineCommand()` method. <ide> <del>### replServer.parseREPLKeyword(keyword\[, rest\]) <add>### `replServer.parseREPLKeyword(keyword[, rest])` <ide> <!-- YAML <ide> added: v0.8.9 <ide> deprecated: v9.0.0 <ide> deprecated: v9.0.0 <ide> An internal method used to parse and execute `REPLServer` keywords. <ide> Returns `true` if `keyword` is a valid keyword, otherwise `false`. <ide> <del>### replServer.setupHistory(historyPath, callback) <add>### `replServer.setupHistory(historyPath, callback)` <ide> <!-- YAML <ide> added: v11.10.0 <ide> --> <ide> by default. However, this is not the case when creating a REPL <ide> programmatically. Use this method to initialize a history log file when working <ide> with REPL instances programmatically. <ide> <del>## repl.start(\[options\]) <add>## `repl.start([options])` <ide> <!-- YAML <ide> added: v0.1.91 <ide> changes:
1
Ruby
Ruby
restore `delivery_method` after test
a28f8b5baf10425f53766cad71701e4c18a22d88
<ide><path>actionmailer/test/parameterized_test.rb <ide> class ParameterizedTest < ActiveSupport::TestCase <ide> @previous_logger = ActiveJob::Base.logger <ide> ActiveJob::Base.logger = Logger.new(nil) <ide> <del> @original_delivery_method = ActionMailer::Base.delivery_method <add> @previous_delivery_method = ActionMailer::Base.delivery_method <ide> ActionMailer::Base.delivery_method = :test <ide> <del> @previous_delivery_method = ActionMailer::Base.delivery_method <ide> @previous_deliver_later_queue_name = ActionMailer::Base.deliver_later_queue_name <ide> ActionMailer::Base.deliver_later_queue_name = :test_queue <ide> ActionMailer::Base.delivery_method = :test <ide> class ParameterizedTest < ActiveSupport::TestCase <ide> ActiveJob::Base.logger = @previous_logger <ide> ParamsMailer.deliveries.clear <ide> <del> ActionMailer::Base.delivery_method = @original_delivery_method <del> <ide> ActionMailer::Base.delivery_method = @previous_delivery_method <ide> ActionMailer::Base.deliver_later_queue_name = @previous_deliver_later_queue_name <ide> end
1
Python
Python
add tests for `display_value`
e9d9cb701163ebef5b43535c39909f953977eb08
<ide><path>tests/test_model_serializer.py <ide> <ide> from rest_framework import serializers <ide> from rest_framework.compat import DurationField as ModelDurationField <del>from rest_framework.compat import unicode_repr <add>from rest_framework.compat import OrderedDict, unicode_repr <ide> <ide> <ide> def dedent(blocktext): <ide> class Meta: <ide> self.assertEqual(unicode_repr(TestSerializer()), expected) <ide> <ide> <add>class DisplayValueTargetModel(models.Model): <add> name = models.CharField(max_length=100) <add> <add> def __str__(self): <add> return '%s Color' % (self.name) <add> <add> <add>class DisplayValueModel(models.Model): <add> color = models.ForeignKey(DisplayValueTargetModel) <add> <add> <add>class TestRelationalFieldDisplayValue(TestCase): <add> def setUp(self): <add> DisplayValueTargetModel.objects.bulk_create([ <add> DisplayValueTargetModel(name='Red'), <add> DisplayValueTargetModel(name='Yellow'), <add> DisplayValueTargetModel(name='Green'), <add> ]) <add> <add> def test_default_display_value(self): <add> class TestSerializer(serializers.ModelSerializer): <add> class Meta: <add> model = DisplayValueModel <add> <add> serializer = TestSerializer() <add> expected = OrderedDict([('1', 'Red Color'), ('2', 'Yellow Color'), ('3', 'Green Color')]) <add> self.assertEqual(serializer.fields['color'].choices, expected) <add> <add> def test_custom_display_value(self): <add> class TestField(serializers.PrimaryKeyRelatedField): <add> def display_value(self, instance): <add> return 'My %s Color' % (instance.name) <add> <add> class TestSerializer(serializers.ModelSerializer): <add> color = TestField(queryset=DisplayValueTargetModel.objects.all()) <add> <add> class Meta: <add> model = DisplayValueModel <add> <add> serializer = TestSerializer() <add> expected = OrderedDict([('1', 'My Red Color'), ('2', 'My Yellow Color'), ('3', 'My Green Color')]) <add> self.assertEqual(serializer.fields['color'].choices, expected) <add> <add> <ide> class TestIntegration(TestCase): <ide> def setUp(self): <ide> self.foreign_key_target = ForeignKeyTargetModel.objects.create(
1
PHP
PHP
fix doc block
41c99e8e47006b5d2dee6e1d728f824b2b23a392
<ide><path>src/Illuminate/View/FileViewFinder.php <ide> public function addExtension($extension) <ide> } <ide> <ide> /** <del> * Returns whether or not the view specify a hint information. <add> * Returns whether or not the view name has any hint information. <ide> * <ide> * @param string $name <ide> * @return bool
1
Java
Java
improve javadoc in autoproxyregistrar
c8c1e61c0ab1d164b182dc9b6abe1f6f91070d8b
<ide><path>spring-context/src/main/java/org/springframework/context/annotation/AutoProxyRegistrar.java <ide> /* <del> * Copyright 2002-2019 the original author or authors. <add> * Copyright 2002-2020 the original author or authors. <ide> * <ide> * Licensed under the Apache License, Version 2.0 (the "License"); <ide> * you may not use this file except in compliance with the License. <ide> * <ide> * @author Chris Beams <ide> * @since 3.1 <del> * @see EnableAspectJAutoProxy <add> * @see org.springframework.cache.annotation.EnableCaching <add> * @see org.springframework.transaction.annotation.EnableTransactionManagement <ide> */ <ide> public class AutoProxyRegistrar implements ImportBeanDefinitionRegistrar { <ide>
1
Javascript
Javascript
make storagefolder.clear async
7c8f73b2d816d928e6fc3094a76c0a35c1a36347
<ide><path>spec/atom-environment-spec.js <ide> const fs = require('fs') <ide> const path = require('path') <ide> const temp = require('temp').track() <ide> const AtomEnvironment = require('../src/atom-environment') <del>const StorageFolder = require('../src/storage-folder') <ide> <ide> describe('AtomEnvironment', () => { <ide> afterEach(() => { <ide><path>src/atom-environment.js <ide> class AtomEnvironment { <ide> this.blobStore = params.blobStore <ide> this.configDirPath = params.configDirPath <ide> <del> const {devMode, safeMode, resourcePath, clearWindowState} = this.getLoadSettings() <del> <del> if (clearWindowState) { <del> this.getStorageFolder().clear() <del> this.stateStore.clear() <del> } <add> const {devMode, safeMode, resourcePath} = this.getLoadSettings() <ide> <ide> ConfigSchema.projectHome = { <ide> type: 'string', <ide> class AtomEnvironment { <ide> } <ide> <ide> // Call this method when establishing a real application window. <del> startEditorWindow () { <add> async startEditorWindow () { <add> if (this.getLoadSettings().clearWindowState) { <add> await Promise.all([ <add> this.getStorageFolder().clear(), <add> this.stateStore.clear() <add> ]) <add> } <add> <ide> this.unloaded = false <ide> <ide> const updateProcessEnvPromise = this.updateProcessEnvAndTriggerHooks() <ide><path>src/storage-folder.js <ide> class StorageFolder { <ide> } <ide> <ide> clear () { <del> if (!this.path) return <del> <del> try { <del> fs.removeSync(this.path) <del> } catch (error) { <del> console.warn(`Error deleting ${this.path}`, error.stack, error) <del> } <add> return new Promise(resolve => { <add> if (!this.path) return <add> fs.remove(this.path, error => { <add> if (error) console.warn(`Error deleting ${this.path}`, error.stack, error) <add> reolve() <add> }) <add> }) <ide> } <ide> <ide> storeSync (name, object) {
3
Python
Python
convert assertion to raised exception in debertav2
fba0b6a8208e13350e8b26f0400a9fd3f5c9382c
<ide><path>src/transformers/models/deberta/modeling_tf_deberta.py <ide> def call( <ide> Returns: <ide> final_embeddings (`tf.Tensor`): output embedding tensor. <ide> """ <del> assert not (input_ids is None and inputs_embeds is None) <add> if input_ids is None and inputs_embeds is None: <add> raise ValueError("Need to provide either `input_ids` or `input_embeds`.") <ide> <ide> if input_ids is not None: <ide> inputs_embeds = tf.gather(params=self.weight, indices=input_ids) <ide><path>src/transformers/models/deberta_v2/modeling_tf_deberta_v2.py <ide> def call( <ide> Returns: <ide> final_embeddings (`tf.Tensor`): output embedding tensor. <ide> """ <del> assert not (input_ids is None and inputs_embeds is None) <add> if input_ids is None and inputs_embeds is None: <add> raise ValueError("Need to provide either `input_ids` or `input_embeds`.") <ide> <ide> if input_ids is not None: <ide> inputs_embeds = tf.gather(params=self.weight, indices=input_ids)
2
PHP
PHP
fix bad merge
545f4d281141951565834c02745a4994c087e749
<ide><path>lib/Cake/Console/Command/TestsuiteShell.php <ide> * <ide> * @package Cake.Console.Command <ide> */ <del><<<<<<< HEAD <ide> class TestsuiteShell extends TestShell { <del>======= <del>class TestsuiteShell extends AppShell { <del> <del>/** <del> * Dispatcher object for the run. <del> * <del> * @var CakeTestDispatcher <del> */ <del> protected $_dispatcher = null; <del>>>>>>>> 2.0 <ide> <ide> /** <ide> * get the option parser for the test suite.
1
Text
Text
add link to docker hub
0c3a4a1fcdbb4b7e14292a871dec4bf6828ae57c
<ide><path>docs/reference/commandline/pull.md <ide> MAINTAINER some maintainer <maintainer@example.com> <ide> <ide> ## Pulling from a different registry <ide> <del>By default, `docker pull` pulls images from Docker Hub. It is also possible to <add>By default, `docker pull` pulls images from [Docker Hub](https://hub.docker.com). It is also possible to <ide> manually specify the path of a registry to pull from. For example, if you have <ide> set up a local registry, you can specify its path to pull from it. A registry <ide> path is similar to a URL, but does not contain a protocol specifier (`https://`).
1
Javascript
Javascript
remove unused variables and functions
6d842897c5966cee1924b5073e273568923c8693
<ide><path>lib/_debugger.js <ide> function SourceInfo(body) { <ide> // This class is the repl-enabled debugger interface which is invoked on <ide> // "node debug" <ide> function Interface(stdin, stdout, args) { <del> var self = this, <del> child; <add> var self = this; <ide> <ide> this.stdin = stdin; <ide> this.stdout = stdout; <ide><path>lib/_http_agent.js <ide> Agent.prototype.addRequest = function(req, options) { <ide> }; <ide> } <ide> <del> var host = options.host; <del> var port = options.port; <del> var localAddress = options.localAddress; <del> <ide> var name = this.getName(options); <ide> if (!this.sockets[name]) { <ide> this.sockets[name] = []; <ide><path>lib/_http_client.js <ide> var IncomingMessage = require('_http_incoming').IncomingMessage; <ide> var OutgoingMessage = require('_http_outgoing').OutgoingMessage; <ide> <ide> var agent = require('_http_agent'); <del>var Agent = agent.Agent; <ide> var globalAgent = agent.globalAgent; <ide> <ide> <ide> function socketOnData(d) { <ide> <ide> // client <ide> function parserOnIncomingClient(res, shouldKeepAlive) { <del> var parser = this; <ide> var socket = this.socket; <ide> var req = socket._httpMessage; <ide> <ide><path>lib/_http_outgoing.js <ide> var common = require('_http_common'); <ide> <ide> var CRLF = common.CRLF; <ide> var chunkExpression = common.chunkExpression; <del>var continueExpression = common.continueExpression; <ide> var debug = common.debug; <ide> <ide> <ide> OutgoingMessage.prototype._storeHeader = function(firstLine, headers) { <ide> }; <ide> <ide> var field, value; <del> var self = this; <ide> <ide> if (headers) { <ide> var keys = Object.keys(headers); <ide> OutgoingMessage.prototype.addTrailers = function(headers) { <ide> }; <ide> <ide> <del>var zero_chunk_buf = new Buffer('\r\n0\r\n'); <ide> var crlf_buf = new Buffer('\r\n'); <ide> <ide> <ide><path>lib/_stream_readable.js <ide> Readable.prototype.pipe = function(dest, pipeOpts) { <ide> <ide> function pipeOnDrain(src) { <ide> return function() { <del> var dest = this; <ide> var state = src._readableState; <ide> debug('pipeOnDrain', state.awaitDrain); <ide> if (state.awaitDrain) <ide><path>lib/_stream_transform.js <ide> function Transform(options) { <ide> <ide> Duplex.call(this, options); <ide> <del> var ts = this._transformState = new TransformState(options, this); <add> this._transformState = new TransformState(options, this); <ide> <ide> // when the writable side finishes, then flush out anything remaining. <ide> var stream = this; <ide> function done(stream, er) { <ide> // if there's nothing in the write buffer, then that means <ide> // that nothing more will ever be provided <ide> var ws = stream._writableState; <del> var rs = stream._readableState; <ide> var ts = stream._transformState; <ide> <ide> if (ws.length) <ide><path>lib/_stream_writable.js <ide> module.exports = Writable; <ide> Writable.WritableState = WritableState; <ide> <ide> var util = require('util'); <del>var assert = require('assert'); <ide> var Stream = require('stream'); <ide> <ide> util.inherits(Writable, Stream); <ide><path>lib/_tls_wrap.js <ide> var assert = require('assert'); <ide> var constants = require('constants'); <ide> var crypto = require('crypto'); <del>var events = require('events'); <ide> var net = require('net'); <ide> var tls = require('tls'); <ide> var util = require('util'); <ide> function TLSSocket(socket, options) { <ide> writable: socket.writable <ide> }); <ide> <del> var self = this; <del> <ide> this._tlsOptions = options; <ide> this._secureEstablished = false; <ide> this._controlReleased = false; <ide><path>lib/buffer.js <ide> <ide> var buffer = process.binding('buffer'); <ide> var smalloc = process.binding('smalloc'); <del>var assert = require('assert'); <ide> var util = require('util'); <ide> var alloc = smalloc.alloc; <ide> var sliceOnto = smalloc.sliceOnto; <ide><path>lib/child_process.js <ide> var handleConversion = { <ide> }, <ide> <ide> got: function(message, handle, emit) { <del> var self = this; <del> <ide> var server = new net.Server(); <ide> server.listen(handle, function() { <ide> emit(server); <ide> var handleConversion = { <ide> function SocketListSend(slave, key) { <ide> EventEmitter.call(this); <ide> <del> var self = this; <del> <ide> this.key = key; <ide> this.slave = slave; <ide> } <ide> exports.exec = function(command /*, options, callback */) { <ide> <ide> <ide> exports.execFile = function(file /* args, options, callback */) { <del> var args, optionArg, callback; <add> var args, callback; <ide> var options = { <ide> encoding: 'utf8', <ide> timeout: 0, <ide><path>lib/dgram.js <ide> var BIND_STATE_BOUND = 2; <ide> // lazily loaded <ide> var cluster = null; <ide> var dns = null; <del>var net = null; <ide> <ide> var errnoException = util._errnoException; <ide> <del>function isIP(address) { <del> if (!net) <del> net = require('net'); <del> <del> return net.isIP(address); <del>} <del> <del> <ide> function lookup(address, family, callback) { <ide> if (!dns) <ide> dns = require('dns'); <ide><path>lib/fs.js <ide> fs.unwatchFile = function(filename, listener) { <ide> } <ide> }; <ide> <del>// Realpath <del>// Not using realpath(2) because it's bad. <del>// See: http://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html <del> <del>var normalize = pathModule.normalize; <del> <ide> // Regexp that finds the next partion of a (partial) path <ide> // result is [base_with_slash, base], e.g. ['somedir/', 'somedir'] <ide> if (isWindows) { <ide><path>lib/http.js <ide> var IncomingMessage = exports.IncomingMessage = incoming.IncomingMessage; <ide> <ide> <ide> var common = require('_http_common'); <del>var parsers = exports.parsers = common.parsers; <add>exports.parsers = common.parsers; <ide> <ide> <ide> var outgoing = require('_http_outgoing'); <ide> exports.get = function(options, cb) { <ide> return globalAgent.get(options, cb); <ide> }; <ide> <del>var httpSocketSetup = common.httpSocketSetup; <del> <ide> exports._connectionListener = server._connectionListener; <ide> var Server = exports.Server = server.Server; <ide> <ide><path>lib/https.js <ide> var tls = require('tls'); <ide> var http = require('http'); <ide> var util = require('util'); <del>var url = require('url'); <ide> var inherits = require('util').inherits; <ide> var debug = util.debuglog('https'); <ide> <ide><path>lib/net.js <ide> Socket.prototype.__defineGetter__('bytesWritten', function() { <ide> <ide> function afterWrite(status, handle, req) { <ide> var self = handle.owner; <del> var state = self._writableState; <ide> if (self !== process.stderr && self !== process.stdout) <ide> debug('afterWrite', status); <ide> <ide><path>lib/punycode.js <ide> k, <ide> digit, <ide> t, <del> length, <ide> /** Cached calculation results */ <ide> baseMinusT; <ide> <ide><path>lib/readline.js <ide> // * http://www.3waylabs.com/nw/WWW/products/wizcon/vt220.html <ide> <ide> var kHistorySize = 30; <del>var kBufSize = 10 * 1024; <ide> <ide> var util = require('util'); <ide> var inherits = require('util').inherits; <ide> Interface.prototype._addHistory = function() { <ide> <ide> <ide> Interface.prototype._refreshLine = function() { <del> var columns = this.columns; <del> <ide> // line length <ide> var line = this._prompt + this.line; <ide> var dispPos = this._getDisplayPos(line); <ide><path>lib/repl.js <ide> REPLServer.prototype.complete = function(line, callback) { <ide> // list of completion lists, one for each inheritance "level" <ide> var completionGroups = []; <ide> <del> var completeOn, match, filter, i, j, group, c; <add> var completeOn, match, filter, i, group, c; <ide> <ide> // REPL commands (e.g. ".break"). <ide> var match = null; <ide><path>lib/tty.js <ide> // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE <ide> // USE OR OTHER DEALINGS IN THE SOFTWARE. <ide> <del>var assert = require('assert'); <ide> var inherits = require('util').inherits; <ide> var net = require('net'); <ide> var TTY = process.binding('tty_wrap').TTY;
19
Text
Text
fix typo in documentation
68e48a0809f5065d03d545fed03787690badb743
<ide><path>docs/advanced-features/custom-document.md <ide> Or add a `className` to the `body` tag: <ide> ## Caveats <ide> <ide> - The `<Head />` component used in `_document` is not the same as [`next/head`](/docs/api-reference/next/head.md). The `<Head />` component used here should only be used for any `<head>` code that is common for all pages. For all other cases, such as `<title>` tags, we recommend using [`next/head`](/docs/api-reference/next/head.md) in your pages or components. <del>- React components outside of `<Main />` will not be initialized by the browser. Do _not_ add application logic here or custom CSS (like `styled-jsx`). If you need shared components in all your pages (like a menu or a toolbar), read [Layouts](/docs/basic-features/layouts.md) intead. <add>- React components outside of `<Main />` will not be initialized by the browser. Do _not_ add application logic here or custom CSS (like `styled-jsx`). If you need shared components in all your pages (like a menu or a toolbar), read [Layouts](/docs/basic-features/layouts.md) instead. <ide> - `Document` currently does not support Next.js [Data Fetching methods](/docs/basic-features/data-fetching/overview.md) like [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md) or [`getServerSideProps`](/docs/basic-features/data-fetching/get-server-side-props.md). <ide> <ide> ## Customizing `renderPage`
1
Text
Text
add mobile context for fitt's law
76f1d8e2050b8fb07431186ecccb09df582addc1
<ide><path>guide/english/user-experience-design/fitts-law/index.md <ide> title: Fitts Law <ide> --- <ide> <ide> ## Fitts Law <del>Fitts's Law provides a model of human movement which can accurately predict the amount of time taken to move to and select a target. In human-computer interaction Fitts's Law is typically applied to movement through the graphical user interface using a cursor or other type of pointer. <add>Fitts's Law provides a model of human movement which can accurately predict the amount of time taken to move to and select a target. In human-computer interaction, Fitts's Law is typically applied to movement across the graphical user interface using a cursor or other type of pointer. In mobile screens, this could be the distance the finger has to travel from its current position to reach its target. <ide> <ide> The law describes a simple rule of UI design that the distance from one point to the next should be reduced, while having the target object be larger to reduce the amount of time for selecting a target. Ideally, the further the user has to traverse towards a target, the larger that target should be in order to make the interaction more smooth. <ide> <del><img src="http://cdn.sixrevisions.com/0128-05_chart.jpg" class="layzr-loaded"> <del> <ide> #### More Information: <del>A very robust article about Fitts law: https://www.interaction-design.org/literature/article/fitts-s-law-the-importance-of-size-and-distance-in-ui-design <add>[A very robust article about Fitts law](https://www.interaction-design.org/literature/article/fitts-s-law-the-importance-of-size-and-distance-in-ui-design)
1
Javascript
Javascript
fix paths when built on windows
c867b0ce9ce4a42896b6362c6ec43630e398de0a
<ide><path>build/webpack/plugins/pages-manifest-plugin.js <ide> export default class PagesManifestPlugin { <ide> } <ide> <ide> const {name} = entry <del> pages[`/${pagePath.replace(/\\/g, '/')}`] = name <add> // Write filename, replace any backslashes in path (on windows) with forwardslashes for cross-platform consistency. <add> pages[`/${pagePath.replace(/\\/g, '/')}`] = name.replace(/\\/g, '/') <ide> } <ide> <ide> if (typeof pages['/index'] !== 'undefined') { <ide><path>test/integration/production/test/index.test.js <ide> import fetch from 'node-fetch' <ide> import dynamicImportTests from './dynamic' <ide> import processEnv from './process-env' <ide> import security from './security' <del>import {BUILD_MANIFEST, REACT_LOADABLE_MANIFEST} from 'next/constants' <add>import {BUILD_MANIFEST, REACT_LOADABLE_MANIFEST, PAGES_MANIFEST} from 'next/constants' <ide> <ide> const appDir = join(__dirname, '../') <ide> let appPort <ide> describe('Production Usage', () => { <ide> expect(serverSideJsBody).toMatch(/404/) <ide> }) <ide> <add> it('should not put backslashes in pages-manifest.json', () => { <add> // Whatever platform you build on, pages-manifest.json should use forward slash (/) <add> // See: https://github.com/zeit/next.js/issues/4920 <add> const pagesManifest = require(join('..', '.next', 'server', PAGES_MANIFEST)) <add> <add> for (let key of Object.keys(pagesManifest)) { <add> expect(key).not.toMatch(/\\/) <add> expect(pagesManifest[key]).not.toMatch(/\\/) <add> } <add> }) <add> <ide> dynamicImportTests(context, (p, q) => renderViaHTTP(context.appPort, p, q)) <ide> <ide> processEnv(context)
2
Text
Text
add config section to creating a package
74ba3c6a4958c3e161b4acc92cfbf1e9bea55078
<ide><path>docs/creating-a-package.md <ide> extensions your grammar supports: <ide> ] <ide> ``` <ide> <add>## Adding Configuration Settings <add> <add>You can support config options in your package that the user can edit in the <add>settings view. So do this you specify a `config` key in your package main <add>specifying the configuration. <add> <add>```coffeescript <add>module.exports = <add> config: # < Your config schema goes here! <add> #... <add> activate: (state) -> # ... <add> # ... <add>``` <add> <add>To specify the configuration, we use [json schema][json-schema] which allows you <add>to specify your value, the type it should be, etc. A simple example: <add> <add>```coffee <add># We want to provide an `enableThing`, and a `thingVolume` <add>config: <add> enableThing: <add> type: 'boolean' <add> default: false <add> thingVolume: <add> type: 'integer' <add> default: 5 <add> minimum: 1 <add> maximum: 11 <add>``` <add> <add>The type keyword allows for type coercion and validation. If a `thingVolume` is <add>set to a string `'10'`, it will be coerced into an integer. <add> <add>```coffee <add>atom.config.set('my-package.thingVolume', '10') <add>atom.config.get('my-package.thingVolume') # -> 10 <add> <add># It respects the min / max <add>atom.config.set('my-package.thingVolume', '400') <add>atom.config.get('my-package.thingVolume') # -> 11 <add> <add># If it cannot be coerced, the value will not be set <add>atom.config.set('my-package.thingVolume', 'cats') <add>atom.config.get('my-package.thingVolume') # -> 11 <add>``` <add> <add>### Supported Types <add> <add>* `string` Values must be a string <add> ```coffee <add> config: <add> someSetting: <add> type: 'string' <add> default: 'hello' <add> ``` <add>* `integer` Values will be coerced into integer. Supports the `minimum` and `maximum` keys. <add> ```coffee <add> config: <add> someSetting: <add> type: 'integer' <add> default: 5 <add> minimum: 1 <add> maximum: 11 <add> ``` <add>* `number` Values will be coerced into a number, including real numbers. Supports the `minimum` and `maximum` keys. <add> ```coffee <add> config: <add> someSetting: <add> type: 'number' <add> default: 5.3 <add> minimum: 1.5 <add> maximum: 11.5 <add> ``` <add>* `boolean` Values will be coerced into a Boolean <add> ```coffee <add> config: <add> someSetting: <add> type: 'boolean' <add> default: false <add> ``` <add>* `array` Value must be an Array. The types of the values can be specified by a subschema in the `items` key. <add> ```coffee <add> config: <add> someSetting: <add> type: 'array' <add> default: [1, 2, 3] <add> items: <add> type: 'integer' <add> minimum: 1.5 <add> maximum: 11.5 <add> ``` <add>* `object` Value must be an object. This allows you to nest config options. Sub options must be under a `properties key` <add> ```coffee <add> config: <add> someSetting: <add> type: 'object' <add> properties: <add> myChildIntOption: <add> type: 'integer' <add> minimum: 1.5 <add> maximum: 11.5 <add> ``` <add> <add>### Other Supported Keys <add> <add>All schemas support an `enum` key. The enum key lets you specify all values that <add>the config setting can possibly be. <add> <add>```coffee <add>config: <add> someSetting: <add> type: 'integer' <add> default: 4 <add> enum: [2, 4, 6, 8] <add>``` <add> <ide> ## Bundle External Resources <ide> <ide> It's common to ship external resources like images and fonts in the package, to <ide> all the other available commands. <ide> [first-package]: your-first-package.html <ide> [convert-bundle]: converting-a-text-mate-bundle.html <ide> [convert-theme]: converting-a-text-mate-theme.html <add>[json-schema]: http://json-schema.org/
1
Ruby
Ruby
parse argv properly
f640cbac9ed83abab64e4dcb4b630f6765fd2962
<ide><path>Library/Homebrew/cmd/uses.rb <ide> def uses <ide> formulae = (ARGV.include? "--installed") ? Formula.installed : Formula <ide> recursive = ARGV.flag? "--recursive" <ide> ignores = [] <del> ignores << "build?" if ARGV.flag? "--skip-build" <del> ignores << "optional?" if ARGV.flag? "--skip-optional" <add> ignores << "build?" if ARGV.include? "--skip-build" <add> ignores << "optional?" if ARGV.include? "--skip-optional" <ide> <ide> uses = formulae.select do |f| <ide> used_formulae.all? do |ff|
1
Python
Python
create lxmertmodelintegrationtest pytorch
0e1718afb61c1acb786d120af4c32341b454eed5
<ide><path>tests/test_modeling_lxmert.py <ide> import copy <ide> import unittest <ide> <add>import numpy as np <add> <ide> from transformers import is_torch_available <ide> from transformers.models.auto import get_values <ide> from transformers.testing_utils import require_torch, slow, torch_device <ide> def test_retain_grad_hidden_states_attentions(self): <ide> self.assertIsNotNone(attentions_vision.grad) <ide> self.assertIsNotNone(hidden_states_vision.grad) <ide> self.assertIsNotNone(attentions_vision.grad) <add> <add> <add>@require_torch <add>class LxmertModelIntegrationTest(unittest.TestCase): <add> @slow <add> def test_inference_no_head_absolute_embedding(self): <add> model = LxmertModel.from_pretrained(LXMERT_PRETRAINED_MODEL_ARCHIVE_LIST[0]) <add> input_ids = torch.tensor([[101, 345, 232, 328, 740, 140, 1695, 69, 6078, 1588, 102]]) <add> num_visual_features = 10 <add> _, visual_feats = np.random.seed(0), np.random.rand(1, num_visual_features, LxmertModel.config.visual_feat_dim) <add> _, visual_pos = np.random.seed(0), np.random.rand(1, num_visual_features, 4) <add> visual_feats = torch.as_tensor(visual_feats, dtype=torch.float32) <add> visual_pos = torch.as_tensor(visual_pos, dtype=torch.float32) <add> output = model(input_ids, visual_feats=visual_feats, visual_pos=visual_pos)[0] <add> expected_shape = torch.Size([1, 11, 768]) <add> self.assertEqual(expected_shape, output.shape) <add> expected_slice = torch.tensor( <add> [[[0.2417, -0.9807, 0.1480], [1.2541, -0.8320, 0.5112], [1.4070, -1.1052, 0.6990]]] <add> ) <add> <add> self.assertTrue(torch.allclose(output[:, :3, :3], expected_slice, atol=1e-4))
1
Ruby
Ruby
make mocklogger work with blocks
a8f568e1ec4ce7c2346e98174466a616dc0cc3f3
<ide><path>activesupport/lib/active_support/log_subscriber/test_helper.rb <ide> def initialize(level = DEBUG) <ide> @logged = Hash.new { |h,k| h[k] = [] } <ide> end <ide> <del> def method_missing(level, message) <add> def method_missing(level, message = nil) <ide> if block_given? <ide> @logged[level] << yield <ide> else
1
Javascript
Javascript
fix meta+character keys on mac
8da7202d0bb6a092bbdc3349840a81603ce64ccd
<ide><path>lib/tty_posix.js <ide> ReadStream.prototype.isTTY = true; <ide> Some patterns seen in terminal key escape codes, derived from combos seen <ide> at http://www.midnight-commander.org/browser/lib/tty/key.c <ide> <add> ESC letter <ide> ESC [ letter <ide> ESC [ modifier letter <ide> ESC [ 1 ; modifier letter <ide> ReadStream.prototype.isTTY = true; <ide> - two leading ESCs apparently mean the same as one leading ESC <ide> */ <ide> <del>// Regex used for ansi escape code splitting <del>var splitKeyCodeRe = <del> /^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;(\d+))?([a-zA-Z]))/; <add>// Regexes used for ansi escape code splitting <add>var metaKeyCodeRe = /^(?:\x1b)([a-zA-Z0-9])$/, <add> functionKeyCodeRe = <add> /^(?:\x1b+)(O|N|\[|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;(\d+))?([a-zA-Z]))/; <ide> <ide> ReadStream.prototype._emitKey = function(s) { <ide> var char, <ide> ReadStream.prototype._emitKey = function(s) { <ide> key.name = s.toLowerCase(); <ide> key.shift = true; <ide> <del> } else if (parts = splitKeyCodeRe.exec(s)) { <add> } else if (parts = metaKeyCodeRe.exec(s)) { <add> // meta+character key <add> key.name = parts[1].toLowerCase(); <add> key.meta = true; <add> key.shift = /^[A-Z]$/.test(parts[1]); <add> <add> } else if (parts = functionKeyCodeRe.exec(s)) { <ide> // ansi escape sequence <ide> <ide> // reassemble the key code leaving out leading \x1b's,
1
Ruby
Ruby
add more tests for current behavior
5e1cbb50c1a9e566404f8401aea35d6d29028720
<ide><path>Library/Homebrew/test/test_cleaner.rb <ide> def test_skip_clean_symlink_when_target_pruned <ide> assert symlink.symlink? <ide> assert !symlink.exist? <ide> end <add> <add> def test_removes_la_files <add> file = @f.lib/'foo.la' <add> <add> @f.lib.mkpath <add> touch file <add> <add> Cleaner.new @f <add> <add> assert !file.exist? <add> end <add> <add> def test_skip_clean_la <add> file = @f.lib/'foo.la' <add> <add> @f.class.skip_clean :la <add> @f.lib.mkpath <add> touch file <add> <add> Cleaner.new @f <add> <add> assert file.exist? <add> end <add> <add> def test_remove_charset_alias <add> file = @f.lib/'charset.alias' <add> <add> @f.lib.mkpath <add> touch file <add> <add> Cleaner.new @f <add> <add> assert !file.exist? <add> end <add> <add> def test_skip_clean_subdir <add> dir = @f.lib/'subdir' <add> @f.class.skip_clean 'lib/subdir' <add> <add> dir.mkpath <add> <add> Cleaner.new @f <add> <add> assert dir.directory? <add> end <add> <add> def test_skip_clean_paths_are_anchored_to_prefix <add> dir1 = @f.bin/'a' <add> dir2 = @f.lib/'bin/a' <add> <add> @f.class.skip_clean 'bin/a' <add> dir1.mkpath <add> dir2.mkpath <add> <add> Cleaner.new @f <add> <add> assert dir1.exist? <add> assert !dir2.exist? <add> end <ide> end
1
Python
Python
add special tokens to unique_added_tokens_encoder
b262577d17efe0beea88d2bb4f78f1c4a25f2636
<ide><path>src/transformers/tokenization_utils.py <ide> def _from_pretrained(cls, pretrained_model_name_or_path, *init_inputs, **kwargs) <ide> tokenizer.init_inputs = init_inputs <ide> tokenizer.init_kwargs = init_kwargs <ide> <add> # update unique_added_tokens_encoder with special tokens for correct tokenization <add> tokenizer.unique_added_tokens_encoder.update(set(tokenizer.all_special_tokens)) <add> <ide> # Add supplementary tokens. <ide> if added_tokens_file is not None: <ide> with open(added_tokens_file, encoding="utf-8") as added_tokens_handle: <ide> added_tok_encoder = json.load(added_tokens_handle) <ide> added_tok_decoder = {v: k for k, v in added_tok_encoder.items()} <ide> tokenizer.added_tokens_encoder.update(added_tok_encoder) <ide> tokenizer.added_tokens_decoder.update(added_tok_decoder) <del> tokenizer.unique_added_tokens_encoder.update(set(tokenizer.added_tokens_encoder.keys()).union(set(tokenizer.all_special_tokens))) <add> tokenizer.unique_added_tokens_encoder.update(set(tokenizer.added_tokens_encoder.keys())) <ide> <ide> return tokenizer <ide>
1
Text
Text
update example for conditional applymiddleware
46028a584ef6e1a792b6f8a56b4bfa5dd0afdbc0
<ide><path>docs/api/applyMiddleware.md <ide> export default connect( <ide> const store = createStore( <ide> reducer, <ide> initialState, <del> applyMiddleware(middleware) <add> applyMiddleware(...middleware) <ide> ) <ide> ``` <ide>
1
PHP
PHP
remove mutating methods from lazy collection
4365561e5e5ad3b088d1752c6c6bb5bab652a5db
<ide><path>src/Illuminate/Support/Collection.php <ide> public function prepend($value, $key = null) <ide> return $this; <ide> } <ide> <add> /** <add> * Push an item onto the end of the collection. <add> * <add> * @param mixed $value <add> * @return $this <add> */ <add> public function push($value) <add> { <add> $this->items[] = $value; <add> <add> return $this; <add> } <add> <ide> /** <ide> * Push all of the given items onto the collection. <ide> * <ide><path>src/Illuminate/Support/Enumerable.php <ide> public function firstWhere($key, $operator = null, $value = null); <ide> */ <ide> public function flip(); <ide> <del> /** <del> * Remove an item by key. <del> * <del> * @param string|array $keys <del> * @return $this <del> */ <del> public function forget($keys); <del> <ide> /** <ide> * Get an item from the collection by key. <ide> * <ide> public function forPage($page, $perPage); <ide> */ <ide> public function partition($key, $operator = null, $value = null); <ide> <del> /** <del> * Get and remove the last item from the collection. <del> * <del> * @return mixed <del> */ <del> public function pop(); <del> <del> /** <del> * Push an item onto the beginning of the collection. <del> * <del> * @param mixed $value <del> * @param mixed $key <del> * @return $this <del> */ <del> public function prepend($value, $key = null); <del> <del> /** <del> * Push an item onto the end of the collection. <del> * <del> * @param mixed $value <del> * @return $this <del> */ <del> public function push($value); <del> <ide> /** <ide> * Push all of the given items onto the collection. <ide> * <ide> public function push($value); <ide> */ <ide> public function concat($source); <ide> <del> /** <del> * Put an item in the collection by key. <del> * <del> * @param mixed $key <del> * @param mixed $value <del> * @return $this <del> */ <del> public function put($key, $value); <del> <ide> /** <ide> * Get one or a specified number of items randomly from the collection. <ide> * <ide> public function reverse(); <ide> */ <ide> public function search($value, $strict = false); <ide> <del> /** <del> * Get and remove the first item from the collection. <del> * <del> * @return mixed <del> */ <del> public function shift(); <del> <ide> /** <ide> * Shuffle the items in the collection. <ide> * <ide> public function sortKeys($options = SORT_REGULAR, $descending = false); <ide> */ <ide> public function sortKeysDesc($options = SORT_REGULAR); <ide> <del> /** <del> * Splice a portion of the underlying collection array. <del> * <del> * @param int $offset <del> * @param int|null $length <del> * @param mixed $replacement <del> * @return static <del> */ <del> public function splice($offset, $length = null, $replacement = []); <del> <ide> /** <ide> * Get the sum of the given values. <ide> * <ide> public function take($limit); <ide> */ <ide> public function tap(callable $callback); <ide> <del> /** <del> * Transform each item in the collection using a callback. <del> * <del> * @param callable $callback <del> * @return $this <del> */ <del> public function transform(callable $callback); <del> <ide> /** <ide> * Pass the enumerable to the given callback and return the result. <ide> * <ide> public function pad($size, $value); <ide> */ <ide> public function countBy($callback = null); <ide> <del> /** <del> * Add an item to the collection. <del> * <del> * @param mixed $item <del> * @return $this <del> */ <del> public function add($item); <del> <ide> /** <ide> * Convert the collection to its string representation. <ide> * <ide><path>src/Illuminate/Support/LazyCollection.php <ide> public function flip() <ide> }); <ide> } <ide> <del> /** <del> * Remove an item by key. <del> * <del> * @param string|array $keys <del> * @return $this <del> */ <del> public function forget($keys) <del> { <del> $original = clone $this; <del> <del> $this->source = function () use ($original, $keys) { <del> $keys = array_flip((array) $keys); <del> <del> foreach ($original as $key => $value) { <del> if (! array_key_exists($key, $keys)) { <del> yield $key => $value; <del> } <del> } <del> }; <del> <del> return $this; <del> } <del> <ide> /** <ide> * Get an item by key. <ide> * <ide> public function only($keys) <ide> }); <ide> } <ide> <del> /** <del> * Get and remove the last item from the collection. <del> * <del> * @return mixed <del> */ <del> public function pop() <del> { <del> $items = $this->collect(); <del> <del> $result = $items->pop(); <del> <del> $this->source = $items; <del> <del> return $result; <del> } <del> <del> /** <del> * Push an item onto the beginning of the collection. <del> * <del> * @param mixed $value <del> * @param mixed $key <del> * @return $this <del> */ <del> public function prepend($value, $key = null) <del> { <del> $original = clone $this; <del> <del> $this->source = function () use ($original, $value, $key) { <del> $instance = new static(function () use ($original, $value, $key) { <del> yield $key => $value; <del> <del> yield from $original; <del> }); <del> <del> if (is_null($key)) { <del> $instance = $instance->values(); <del> } <del> <del> yield from $instance; <del> }; <del> <del> return $this; <del> } <del> <ide> /** <ide> * Push all of the given items onto the collection. <ide> * <ide> public function concat($source) <ide> }))->values(); <ide> } <ide> <del> /** <del> * Put an item in the collection by key. <del> * <del> * @param mixed $key <del> * @param mixed $value <del> * @return $this <del> */ <del> public function put($key, $value) <del> { <del> $original = clone $this; <del> <del> if (is_null($key)) { <del> $this->source = function () use ($original, $value) { <del> foreach ($original as $innerKey => $innerValue) { <del> yield $innerKey => $innerValue; <del> } <del> <del> yield $value; <del> }; <del> } else { <del> $this->source = function () use ($original, $key, $value) { <del> $found = false; <del> <del> foreach ($original as $innerKey => $innerValue) { <del> if ($innerKey == $key) { <del> yield $key => $value; <del> <del> $found = true; <del> } else { <del> yield $innerKey => $innerValue; <del> } <del> } <del> <del> if (! $found) { <del> yield $key => $value; <del> } <del> }; <del> } <del> <del> return $this; <del> } <del> <ide> /** <ide> * Get one or a specified number of items randomly from the collection. <ide> * <ide> public function search($value, $strict = false) <ide> return false; <ide> } <ide> <del> /** <del> * Get and remove the first item from the collection. <del> * <del> * @return mixed <del> */ <del> public function shift() <del> { <del> return tap($this->first(), function () { <del> $this->source = $this->skip(1); <del> }); <del> } <del> <ide> /** <ide> * Shuffle the items in the collection. <ide> * <ide> public function sortKeysDesc($options = SORT_REGULAR) <ide> return $this->passthru('sortKeysDesc', func_get_args()); <ide> } <ide> <del> /** <del> * Splice a portion of the underlying collection array. <del> * <del> * @param int $offset <del> * @param int|null $length <del> * @param mixed $replacement <del> * @return static <del> */ <del> public function splice($offset, $length = null, $replacement = []) <del> { <del> $items = $this->collect(); <del> <del> $extracted = $items->splice(...func_get_args()); <del> <del> $this->source = function () use ($items) { <del> yield from $items; <del> }; <del> <del> return new static($extracted); <del> } <del> <ide> /** <ide> * Take the first or last {$limit} items. <ide> * <ide> public function tapEach(callable $callback) <ide> }); <ide> } <ide> <del> /** <del> * Transform each item in the collection using a callback. <del> * <del> * @param callable $callback <del> * @return $this <del> */ <del> public function transform(callable $callback) <del> { <del> $original = clone $this; <del> <del> $this->source = function () use ($original, $callback) { <del> yield from $original->map($callback); <del> }; <del> <del> return $this; <del> } <del> <ide> /** <ide> * Reset the keys on the underlying array. <ide> * <ide> public function count() <ide> return iterator_count($this->getIterator()); <ide> } <ide> <del> /** <del> * Add an item to the collection. <del> * <del> * @param mixed $item <del> * @return $this <del> */ <del> public function add($item) <del> { <del> $original = clone $this; <del> <del> $this->source = function () use ($original, $item) { <del> foreach ($original as $value) { <del> yield $value; <del> } <del> <del> yield $item; <del> }; <del> <del> return $this; <del> } <del> <ide> /** <ide> * Make an iterator from the given source. <ide> * <ide><path>src/Illuminate/Support/Traits/EnumeratesValues.php <ide> public function partition($key, $operator = null, $value = null) <ide> return new static([new static($passed), new static($failed)]); <ide> } <ide> <del> /** <del> * Push an item onto the end. <del> * <del> * @param mixed $value <del> * @return $this <del> */ <del> public function push($value) <del> { <del> return $this->add($value); <del> } <del> <ide> /** <ide> * Get the sum of the given values. <ide> * <ide><path>tests/Support/SupportCollectionTest.php <ide> public function testLastWithDefaultAndWithoutCallback($collection) <ide> $this->assertEquals('default', $result); <ide> } <ide> <del> /** <del> * @dataProvider collectionClassProvider <del> */ <del> public function testPopReturnsAndRemovesLastItemInCollection($collection) <add> public function testPopReturnsAndRemovesLastItemInCollection() <ide> { <del> $c = new $collection(['foo', 'bar']); <add> $c = new Collection(['foo', 'bar']); <ide> <ide> $this->assertEquals('bar', $c->pop()); <ide> $this->assertEquals('foo', $c->first()); <ide> } <ide> <del> /** <del> * @dataProvider collectionClassProvider <del> */ <del> public function testShiftReturnsAndRemovesFirstItemInCollection($collection) <add> public function testShiftReturnsAndRemovesFirstItemInCollection() <ide> { <del> $data = new $collection(['Taylor', 'Otwell']); <add> $data = new Collection(['Taylor', 'Otwell']); <ide> <ide> $this->assertEquals('Taylor', $data->shift()); <ide> $this->assertEquals('Otwell', $data->first()); <ide> public function testArrayAccessOffsetUnset() <ide> $this->assertFalse(isset($c[1])); <ide> } <ide> <del> /** <del> * @dataProvider collectionClassProvider <del> */ <del> public function testForgetSingleKey($collection) <add> public function testForgetSingleKey() <ide> { <del> $c = new $collection(['foo', 'bar']); <add> $c = new Collection(['foo', 'bar']); <ide> $c = $c->forget(0)->all(); <ide> $this->assertFalse(isset($c['foo'])); <ide> <del> $c = new $collection(['foo' => 'bar', 'baz' => 'qux']); <add> $c = new Collection(['foo' => 'bar', 'baz' => 'qux']); <ide> $c = $c->forget('foo')->all(); <ide> $this->assertFalse(isset($c['foo'])); <ide> } <ide> <del> /** <del> * @dataProvider collectionClassProvider <del> */ <del> public function testForgetArrayOfKeys($collection) <add> public function testForgetArrayOfKeys() <ide> { <del> $c = new $collection(['foo', 'bar', 'baz']); <add> $c = new Collection(['foo', 'bar', 'baz']); <ide> $c = $c->forget([0, 2])->all(); <ide> $this->assertFalse(isset($c[0])); <ide> $this->assertFalse(isset($c[2])); <ide> $this->assertTrue(isset($c[1])); <ide> <del> $c = new $collection(['name' => 'taylor', 'foo' => 'bar', 'baz' => 'qux']); <add> $c = new Collection(['name' => 'taylor', 'foo' => 'bar', 'baz' => 'qux']); <ide> $c = $c->forget(['foo', 'baz'])->all(); <ide> $this->assertFalse(isset($c['foo'])); <ide> $this->assertFalse(isset($c['baz'])); <ide> public function testEvery($collection) <ide> $c = new $collection([['active' => true], ['active' => true]]); <ide> $this->assertTrue($c->every('active')); <ide> $this->assertTrue($c->every->active); <del> $this->assertFalse($c->push(['active' => false])->every->active); <add> $this->assertFalse($c->concat([['active' => false]])->every->active); <ide> } <ide> <ide> /** <ide> public function testTake($collection) <ide> $this->assertEquals(['taylor', 'dayle'], $data->all()); <ide> } <ide> <del> /** <del> * @dataProvider collectionClassProvider <del> */ <del> public function testPut($collection) <add> public function testPut() <ide> { <del> $data = new $collection(['name' => 'taylor', 'email' => 'foo']); <add> $data = new Collection(['name' => 'taylor', 'email' => 'foo']); <ide> $data = $data->put('name', 'dayle'); <ide> $this->assertEquals(['name' => 'dayle', 'email' => 'foo'], $data->all()); <ide> } <ide> <del> /** <del> * @dataProvider collectionClassProvider <del> */ <del> public function testPutWithNoKey($collection) <add> public function testPutWithNoKey() <ide> { <del> $data = new $collection(['taylor', 'shawn']); <add> $data = new Collection(['taylor', 'shawn']); <ide> $data = $data->put(null, 'dayle'); <ide> $this->assertEquals(['taylor', 'shawn', 'dayle'], $data->all()); <ide> } <ide> public function testConstructMethodFromObject($collection) <ide> $this->assertEquals(['foo' => 'bar'], $data->all()); <ide> } <ide> <del> /** <del> * @dataProvider collectionClassProvider <del> */ <del> public function testSplice($collection) <add> public function testSplice() <ide> { <del> $data = new $collection(['foo', 'baz']); <add> $data = new Collection(['foo', 'baz']); <ide> $data->splice(1); <ide> $this->assertEquals(['foo'], $data->all()); <ide> <del> $data = new $collection(['foo', 'baz']); <add> $data = new Collection(['foo', 'baz']); <ide> $data->splice(1, 0, 'bar'); <ide> $this->assertEquals(['foo', 'bar', 'baz'], $data->all()); <ide> <del> $data = new $collection(['foo', 'baz']); <add> $data = new Collection(['foo', 'baz']); <ide> $data->splice(1, 1); <ide> $this->assertEquals(['foo'], $data->all()); <ide> <del> $data = new $collection(['foo', 'baz']); <add> $data = new Collection(['foo', 'baz']); <ide> $cut = $data->splice(1, 1, 'bar'); <ide> $this->assertEquals(['foo', 'bar'], $data->all()); <ide> $this->assertEquals(['baz'], $cut->all()); <ide> public function testMapWithKeysOverwritingKeys($collection) <ide> ); <ide> } <ide> <del> /** <del> * @dataProvider collectionClassProvider <del> */ <del> public function testTransform($collection) <add> public function testTransform() <ide> { <del> $data = new $collection(['first' => 'taylor', 'last' => 'otwell']); <add> $data = new Collection(['first' => 'taylor', 'last' => 'otwell']); <ide> $data->transform(function ($item, $key) { <ide> return $key.'-'.strrev($item); <ide> }); <ide> public function testPaginate($collection) <ide> $this->assertEquals([], $c->forPage(3, 2)->all()); <ide> } <ide> <del> /** <del> * @dataProvider collectionClassProvider <del> */ <del> public function testPrepend($collection) <add> public function testPrepend() <ide> { <del> $c = new $collection(['one', 'two', 'three', 'four']); <add> $c = new Collection(['one', 'two', 'three', 'four']); <ide> $this->assertEquals(['zero', 'one', 'two', 'three', 'four'], $c->prepend('zero')->all()); <ide> <del> $c = new $collection(['one' => 1, 'two' => 2]); <add> $c = new Collection(['one' => 1, 'two' => 2]); <ide> $this->assertEquals(['zero' => 0, 'one' => 1, 'two' => 2], $c->prepend(0, 'zero')->all()); <ide> } <ide> <ide> public function testWhen($collection) <ide> { <ide> $data = new $collection(['michael', 'tom']); <ide> <del> $data->when('adam', function ($data, $newName) { <del> return $data->push($newName); <add> $data = $data->when('adam', function ($data, $newName) { <add> return $data->concat([$newName]); <ide> }); <ide> <ide> $this->assertSame(['michael', 'tom', 'adam'], $data->toArray()); <ide> <ide> $data = new $collection(['michael', 'tom']); <ide> <del> $data->when(false, function ($collection) { <del> return $data->push('adam'); <add> $data = $data->when(false, function ($data) { <add> return $data->concat(['adam']); <ide> }); <ide> <ide> $this->assertSame(['michael', 'tom'], $data->toArray()); <ide> public function testWhenDefault($collection) <ide> { <ide> $data = new $collection(['michael', 'tom']); <ide> <del> $data->when(false, function ($data) { <del> return $data->push('adam'); <add> $data = $data->when(false, function ($data) { <add> return $data->concat(['adam']); <ide> }, function ($data) { <del> return $data->push('taylor'); <add> return $data->concat(['taylor']); <ide> }); <ide> <ide> $this->assertSame(['michael', 'tom', 'taylor'], $data->toArray()); <ide> public function testWhenEmpty($collection) <ide> { <ide> $data = new $collection(['michael', 'tom']); <ide> <del> $data->whenEmpty(function ($collection) { <del> return $data->push('adam'); <add> $data = $data->whenEmpty(function ($collection) { <add> return $data->concat(['adam']); <ide> }); <ide> <ide> $this->assertSame(['michael', 'tom'], $data->toArray()); <ide> <ide> $data = new $collection; <ide> <del> $data->whenEmpty(function ($data) { <del> return $data->push('adam'); <add> $data = $data->whenEmpty(function ($data) { <add> return $data->concat(['adam']); <ide> }); <ide> <ide> $this->assertSame(['adam'], $data->toArray()); <ide> public function testWhenEmptyDefault($collection) <ide> { <ide> $data = new $collection(['michael', 'tom']); <ide> <del> $data->whenEmpty(function ($data) { <del> return $data->push('adam'); <add> $data = $data->whenEmpty(function ($data) { <add> return $data->concat(['adam']); <ide> }, function ($data) { <del> return $data->push('taylor'); <add> return $data->concat(['taylor']); <ide> }); <ide> <ide> $this->assertSame(['michael', 'tom', 'taylor'], $data->toArray()); <ide> public function testWhenNotEmpty($collection) <ide> { <ide> $data = new $collection(['michael', 'tom']); <ide> <del> $data->whenNotEmpty(function ($data) { <del> return $data->push('adam'); <add> $data = $data->whenNotEmpty(function ($data) { <add> return $data->concat(['adam']); <ide> }); <ide> <ide> $this->assertSame(['michael', 'tom', 'adam'], $data->toArray()); <ide> <ide> $data = new $collection; <ide> <del> $data->whenNotEmpty(function ($data) { <del> return $data->push('adam'); <add> $data = $data->whenNotEmpty(function ($data) { <add> return $data->concat(['adam']); <ide> }); <ide> <ide> $this->assertSame([], $data->toArray()); <ide> public function testWhenNotEmptyDefault($collection) <ide> { <ide> $data = new $collection(['michael', 'tom']); <ide> <del> $data->whenNotEmpty(function ($data) { <del> return $data->push('adam'); <add> $data = $data->whenNotEmpty(function ($data) { <add> return $data->concat(['adam']); <ide> }, function ($data) { <del> return $data->push('taylor'); <add> return $data->concat(['taylor']); <ide> }); <ide> <ide> $this->assertSame(['michael', 'tom', 'adam'], $data->toArray()); <ide> public function testUnless($collection) <ide> { <ide> $data = new $collection(['michael', 'tom']); <ide> <del> $data->unless(false, function ($data) { <del> return $data->push('caleb'); <add> $data = $data->unless(false, function ($data) { <add> return $data->concat(['caleb']); <ide> }); <ide> <ide> $this->assertSame(['michael', 'tom', 'caleb'], $data->toArray()); <ide> <ide> $data = new $collection(['michael', 'tom']); <ide> <del> $data->unless(true, function ($data) { <del> return $data->push('caleb'); <add> $data = $data->unless(true, function ($data) { <add> return $data->concat(['caleb']); <ide> }); <ide> <ide> $this->assertSame(['michael', 'tom'], $data->toArray()); <ide> public function testUnlessDefault($collection) <ide> { <ide> $data = new $collection(['michael', 'tom']); <ide> <del> $data->unless(true, function ($data) { <del> return $data->push('caleb'); <add> $data = $data->unless(true, function ($data) { <add> return $data->concat(['caleb']); <ide> }, function ($data) { <del> return $data->push('taylor'); <add> return $data->concat(['taylor']); <ide> }); <ide> <ide> $this->assertSame(['michael', 'tom', 'taylor'], $data->toArray()); <ide> public function testUnlessEmpty($collection) <ide> { <ide> $data = new $collection(['michael', 'tom']); <ide> <del> $data->unlessEmpty(function ($data) { <del> return $data->push('adam'); <add> $data = $data->unlessEmpty(function ($data) { <add> return $data->concat(['adam']); <ide> }); <ide> <ide> $this->assertSame(['michael', 'tom', 'adam'], $data->toArray()); <ide> <ide> $data = new $collection; <ide> <del> $data->unlessEmpty(function ($data) { <del> return $data->push('adam'); <add> $data = $data->unlessEmpty(function ($data) { <add> return $data->concat(['adam']); <ide> }); <ide> <ide> $this->assertSame([], $data->toArray()); <ide> public function testUnlessEmptyDefault($collection) <ide> { <ide> $data = new $collection(['michael', 'tom']); <ide> <del> $data->unlessEmpty(function ($data) { <del> return $data->push('adam'); <add> $data = $data->unlessEmpty(function ($data) { <add> return $data->concat(['adam']); <ide> }, function ($data) { <del> return $data->push('taylor'); <add> return $data->concat(['taylor']); <ide> }); <ide> <ide> $this->assertSame(['michael', 'tom', 'adam'], $data->toArray()); <ide> public function testUnlessNotEmpty($collection) <ide> { <ide> $data = new $collection(['michael', 'tom']); <ide> <del> $data->unlessNotEmpty(function ($data) { <del> return $data->push('adam'); <add> $data = $data->unlessNotEmpty(function ($data) { <add> return $data->concat(['adam']); <ide> }); <ide> <ide> $this->assertSame(['michael', 'tom'], $data->toArray()); <ide> <ide> $data = new $collection; <ide> <del> $data->unlessNotEmpty(function ($data) { <del> return $data->push('adam'); <add> $data = $data->unlessNotEmpty(function ($data) { <add> return $data->concat(['adam']); <ide> }); <ide> <ide> $this->assertSame(['adam'], $data->toArray()); <ide> public function testUnlessNotEmptyDefault($collection) <ide> { <ide> $data = new $collection(['michael', 'tom']); <ide> <del> $data->unlessNotEmpty(function ($data) { <del> return $data->push('adam'); <add> $data = $data->unlessNotEmpty(function ($data) { <add> return $data->concat(['adam']); <ide> }, function ($data) { <del> return $data->push('taylor'); <add> return $data->concat(['taylor']); <ide> }); <ide> <ide> $this->assertSame(['michael', 'tom', 'taylor'], $data->toArray()); <ide> public function testHasReturnsValidResults($collection) <ide> $this->assertFalse($data->has('baz')); <ide> } <ide> <del> /** <del> * @dataProvider collectionClassProvider <del> */ <del> public function testPutAddsItemToCollection($collection) <add> public function testPutAddsItemToCollection() <ide> { <del> $data = new $collection; <add> $data = new Collection; <ide> $this->assertSame([], $data->toArray()); <ide> $data->put('foo', 1); <ide> $this->assertSame(['foo' => 1], $data->toArray()); <ide><path>tests/Support/SupportLazyCollectionIsLazyTest.php <ide> <ide> class SupportLazyCollectionIsLazyTest extends TestCase <ide> { <del> public function testAddIsLazy() <del> { <del> $this->assertDoesNotEnumerate(function ($collection) { <del> $collection->add(11); <del> }); <del> <del> $this->assertEnumerates(2, function ($collection) { <del> $collection->add(11)->take(2)->all(); <del> }); <del> } <del> <ide> public function testChunkIsLazy() <ide> { <ide> $this->assertDoesNotEnumerate(function ($collection) { <ide> public function testFlipIsLazy() <ide> }); <ide> } <ide> <del> public function testForgetIsLazy() <del> { <del> $this->assertDoesNotEnumerate(function ($collection) { <del> $collection->forget(5); <del> }); <del> <del> $this->assertEnumeratesOnce(function ($collection) { <del> $collection->forget(5)->all(); <del> }); <del> } <del> <ide> public function testForPageIsLazy() <ide> { <ide> $this->assertDoesNotEnumerate(function ($collection) { <ide> public function testPluckIsLazy() <ide> }); <ide> } <ide> <del> public function testPopEnumeratesOnce() <del> { <del> $this->assertEnumeratesOnce(function ($collection) { <del> $collection->pop(); <del> $collection->all(); <del> }); <del> } <del> <del> public function testPrependIsLazy() <del> { <del> $this->assertDoesNotEnumerate(function ($collection) { <del> $collection->prepend(0); <del> }); <del> <del> $this->assertEnumeratesOnce(function ($collection) { <del> $collection->prepend(0)->all(); <del> }); <del> } <del> <del> public function testPushIsLazy() <del> { <del> $this->assertDoesNotEnumerate(function ($collection) { <del> $collection->push(11); <del> }); <del> <del> $this->assertEnumerates(2, function ($collection) { <del> $collection->push(11)->take(2)->all(); <del> }); <del> } <del> <del> public function testPutIsLazy() <del> { <del> $this->assertDoesNotEnumerate(function ($collection) { <del> $collection->put(20, 'a'); <del> }); <del> <del> $this->assertEnumeratesOnce(function ($collection) { <del> $collection->put(20, 'a')->all(); <del> }); <del> } <del> <ide> public function testRandomEnumeratesOnce() <ide> { <ide> $this->assertEnumeratesOnce(function ($collection) { <ide> public function testSearchIsLazy() <ide> }); <ide> } <ide> <del> public function testShiftIsLazy() <del> { <del> $this->assertEnumerates(1, function ($collection) { <del> $collection->shift(); <del> }); <del> <del> $data = $this->make([1, 2, 3, 4, 5]); <del> <del> $this->assertEnumeratesCollection($data, 6, function ($collection) { <del> $collection->shift(); <del> $collection->all(); <del> }); <del> } <del> <ide> public function testShuffleIsLazy() <ide> { <ide> $this->assertDoesNotEnumerate(function ($collection) { <ide> public function testSortKeysDescIsLazy() <ide> }); <ide> } <ide> <del> public function testSpliceEnumeratesOnce() <del> { <del> $this->assertEnumeratesOnce(function ($collection) { <del> $collection->splice(2); <del> }); <del> } <del> <ide> public function testSplitIsLazy() <ide> { <ide> $this->assertDoesNotEnumerate(function ($collection) { <ide> public function testToJsonEnumeratesOnce() <ide> }); <ide> } <ide> <del> public function testTransformIsLazy() <del> { <del> $this->assertDoesNotEnumerate(function ($collection) { <del> $collection->transform(function ($value) { <del> return $value * 2; <del> }); <del> }); <del> <del> $this->assertEnumeratesOnce(function ($collection) { <del> $collection->transform(function ($value) { <del> return $value * 2; <del> })->all(); <del> }); <del> } <del> <ide> public function testUnionIsLazy() <ide> { <ide> $this->assertDoesNotEnumerate(function ($collection) { <ide> public function testWhereInIsLazy() <ide> <ide> public function testWhereInstanceOfIsLazy() <ide> { <del> $data = $this->make([['a' => 1], ['a' => 2], ['a' => 3], ['a' => 4]]) <del> ->mapInto(stdClass::class) <del> ->prepend(['a' => 0]); <add> $data = $this->make(['a' => 0])->concat( <add> $this->make([['a' => 1], ['a' => 2], ['a' => 3], ['a' => 4]]) <add> ->mapInto(stdClass::class) <add> ); <ide> <ide> $this->assertDoesNotEnumerateCollection($data, function ($collection) { <ide> $collection->whereInstanceOf(stdClass::class);
6
Javascript
Javascript
revert incorrect change
b146c7ac413b00f3bee887e48f4bb9e797273537
<ide><path>lib/wasm/WebAssemblyGenerator.js <ide> class WebAssemblyGenerator extends Generator { <ide> // TODO remove this casts when webpack-sources is fixed <ide> // source() should have return type (string | Buffer) <ide> const sourceAsAny = /** @type {TODO} */ (source); <del> const buf = /** @type {Buffer} */ (sourceAsAny); <del> const bin = buf.buffer; <add> const bin = /** @type {Buffer} */ (sourceAsAny); <ide> <ide> const usedExports = moduleGraph.getUsedExports(module); <ide> const initFuncId = t.identifier(
1
PHP
PHP
use backslash in plugin name when loading
555d941a404fff4d6ee804eef6d0912e2e446d3a
<ide><path>src/Core/Plugin.php <ide> class Plugin { <ide> * <ide> * - `bootstrap` - array - Whether or not you want the $plugin/config/bootstrap.php file loaded. <ide> * - `routes` - boolean - Whether or not you want to load the $plugin/config/routes.php file. <del> * - `namespace` - string - A custom namespace for the plugin. It will default to the plugin name. <ide> * - `ignoreMissing` - boolean - Set to true to ignore missing bootstrap/routes files. <ide> * - `path` - string - The path the plugin can be found on. If empty the default plugin path (App.pluginPaths) will be used. <ide> * - `classBase` - The path relative to `path` which contains the folders with class files. <ide> public static function load($plugin, array $config = []) { <ide> 'autoload' => false, <ide> 'bootstrap' => false, <ide> 'routes' => false, <del> 'namespace' => str_replace('/', '\\', $plugin), <add> 'namespace' => $plugin, <ide> 'classBase' => 'src', <ide> 'ignoreMissing' => false <ide> ]; <ide> if (empty($config['path'])) { <ide> $paths = App::path('Plugin'); <ide> foreach ($paths as $path) { <ide> $namespacePath = str_replace('\\', DS, $config['namespace']); <del> $pluginPath = str_replace('/', DS, $plugin); <add> $pluginPath = str_replace('\\', DS, $plugin); <ide> if (is_dir($path . $pluginPath)) { <ide> $config += ['path' => $path . $pluginPath . DS]; <ide> break; <ide><path>tests/TestCase/Core/PluginTest.php <ide> public function testGetNamespace() { <ide> <ide> $this->assertEquals('TestPluginTwo', Plugin::getNamespace('TestPluginTwo')); <ide> <del> Plugin::load('Company/TestPluginThree'); <del> $this->assertEquals('Company\TestPluginThree', Plugin::getNamespace('Company/TestPluginThree')); <add> Plugin::load('Company\TestPluginThree'); <add> $this->assertEquals('Company\TestPluginThree', Plugin::getNamespace('Company\TestPluginThree')); <ide> <ide> Plugin::load('CustomPlugin', array('namespace' => 'Company\TestPluginThree')); <ide> $this->assertEquals('Company\TestPluginThree', Plugin::getNamespace('CustomPlugin')); <ide> public function testUnload() { <ide> */ <ide> public function testLoadSingleWithAutoload() { <ide> $this->assertFalse(class_exists('Company\TestPluginThree\Utility\Hello')); <del> Plugin::load('Company/TestPluginThree', [ <add> Plugin::load('Company\TestPluginThree', [ <ide> 'autoload' => true, <ide> ]); <ide> $this->assertTrue( <ide> public function testLoadSingleWithBootstrap() { <ide> $this->assertTrue(Plugin::loaded('TestPlugin')); <ide> $this->assertEquals('loaded plugin bootstrap', Configure::read('PluginTest.test_plugin.bootstrap')); <ide> <del> Plugin::load('Company/TestPluginThree', array('bootstrap' => true)); <del> $this->assertTrue(Plugin::loaded('Company/TestPluginThree')); <add> Plugin::load('Company\TestPluginThree', array('bootstrap' => true)); <add> $this->assertTrue(Plugin::loaded('Company\TestPluginThree')); <ide> $this->assertEquals('loaded plugin three bootstrap', Configure::read('PluginTest.test_plugin_three.bootstrap')); <ide> <ide> Configure::delete('PluginTest.test_plugin_three.bootstrap'); <ide> public function testLoadNotFound() { <ide> * @return void <ide> */ <ide> public function testPath() { <del> Plugin::load(array('TestPlugin', 'TestPluginTwo', 'Company/TestPluginThree')); <add> Plugin::load(array('TestPlugin', 'TestPluginTwo', 'Company\TestPluginThree')); <ide> $expected = TEST_APP . 'Plugin' . DS . 'TestPlugin' . DS; <ide> $this->assertPathEquals(Plugin::path('TestPlugin'), $expected); <ide> <ide> $expected = TEST_APP . 'Plugin' . DS . 'TestPluginTwo' . DS; <ide> $this->assertPathEquals(Plugin::path('TestPluginTwo'), $expected); <ide> <ide> $expected = TEST_APP . 'Plugin' . DS . 'Company' . DS . 'TestPluginThree' . DS; <del> $this->assertPathEquals(Plugin::path('Company/TestPluginThree'), $expected); <add> $this->assertPathEquals(Plugin::path('Company\TestPluginThree'), $expected); <ide> } <ide> <ide> /** <ide> public function testPathNotFound() { <ide> * @return void <ide> */ <ide> public function testClassPath() { <del> Plugin::load(array('TestPlugin', 'TestPluginTwo', 'Company/TestPluginThree')); <add> Plugin::load(array('TestPlugin', 'TestPluginTwo', 'Company\TestPluginThree')); <ide> $expected = TEST_APP . 'Plugin' . DS . 'TestPlugin' . DS . 'src' . DS; <ide> $this->assertPathEquals(Plugin::classPath('TestPlugin'), $expected); <ide> <ide> $expected = TEST_APP . 'Plugin' . DS . 'TestPluginTwo' . DS . 'src' . DS; <ide> $this->assertPathEquals(Plugin::classPath('TestPluginTwo'), $expected); <ide> <ide> $expected = TEST_APP . 'Plugin' . DS . 'Company' . DS . 'TestPluginThree' . DS . 'src' . DS; <del> $this->assertPathEquals(Plugin::classPath('Company/TestPluginThree'), $expected); <add> $this->assertPathEquals(Plugin::classPath('Company\TestPluginThree'), $expected); <ide> } <ide> <ide> /**
2
Javascript
Javascript
add rows prop to textinput component
49c9ccd3f8150c5478b502cd5ee158f44750a549
<ide><path>Libraries/Components/TextInput/TextInput.js <ide> type AndroidProps = $ReadOnly<{| <ide> */ <ide> returnKeyLabel?: ?string, <ide> <add> /** <add> * Sets the number of rows for a `TextInput`. Use it with multiline set to <add> * `true` to be able to fill the lines. <add> * @platform android <add> */ <add> rows?: ?number, <add> <ide> /** <ide> * When `false`, it will prevent the soft keyboard from showing when the field is focused. <ide> * Defaults to `true`. <ide> function InternalTextInput(props: Props): React.Node { <ide> disableFullscreenUI={props.disableFullscreenUI} <ide> focusable={focusable} <ide> mostRecentEventCount={mostRecentEventCount} <add> numberOfLines={props.rows ?? props.numberOfLines} <ide> onBlur={_onBlur} <ide> onChange={_onChange} <ide> onFocus={_onFocus} <ide><path>packages/rn-tester/js/examples/TextInput/TextInputExample.android.js <ide> exports.examples = ([ <ide> <TextInput <ide> numberOfLines={2} <ide> multiline={true} <del> placeholder="Two line input" <add> placeholder="Two line input using numberOfLines prop" <ide> /> <ide> <TextInput <ide> numberOfLines={5} <ide> multiline={true} <del> placeholder="Five line input" <add> placeholder="Five line input using numberOfLines prop" <add> /> <add> <TextInput <add> rows={2} <add> multiline={true} <add> placeholder="Two line input using rows prop" <add> /> <add> <TextInput <add> rows={5} <add> multiline={true} <add> placeholder="Five line input using rows prop" <ide> /> <ide> </View> <ide> );
2
Text
Text
ensure collaborators validate commits
eb3fee1b87baa85c7792bf1e01cac4396db6dd14
<ide><path>COLLABORATOR_GUIDE.md <ide> Run tests (`make -j4 test` or `vcbuild test`). Even though there was a <ide> successful continuous integration run, other changes may have landed on master <ide> since then, so running the tests one last time locally is a good practice. <ide> <add>Validate that the commit message is properly formatted using <add>[core-validate-commit](https://github.com/evanlucas/core-validate-commit). <add> <add>```text <add>$ git rev-list upstream/master...HEAD | xargs core-validate-commit <add>``` <add> <ide> Time to push it: <ide> <ide> ```text
1
Go
Go
use dummy driver for volumes
10f23a94f6daaf03c684937daea67d10205b4b89
<ide><path>graphdriver/driver.go <ide> func Register(name string, initFunc InitFunc) error { <ide> return nil <ide> } <ide> <del>func getDriver(name, home string) (Driver, error) { <add>func GetDriver(name, home string) (Driver, error) { <ide> if initFunc, exists := drivers[name]; exists { <ide> return initFunc(path.Join(home, name)) <ide> } <ide> func New(root string) (Driver, error) { <ide> var lastError error <ide> // Use environment variable DOCKER_DRIVER to force a choice of driver <ide> if name := os.Getenv("DOCKER_DRIVER"); name != "" { <del> return getDriver(name, root) <add> return GetDriver(name, root) <ide> } <ide> // Check for priority drivers first <ide> for _, name := range priority { <del> driver, lastError = getDriver(name, root) <add> driver, lastError = GetDriver(name, root) <ide> if lastError != nil { <ide> utils.Debugf("Error loading driver %s: %s", name, lastError) <ide> continue <ide><path>runtime.go <ide> func NewRuntimeFromDirectory(config *DaemonConfig) (*Runtime, error) { <ide> if err != nil { <ide> return nil, err <ide> } <del> volumes, err := NewGraph(path.Join(config.Root, "volumes"), driver) <add> <add> // We don't want to use a complex driver like aufs or devmapper <add> // for volumes, just a plain filesystem <add> volumesDriver, err := graphdriver.GetDriver("dummy", config.Root) <add> if err != nil { <add> return nil, err <add> } <add> volumes, err := NewGraph(path.Join(config.Root, "volumes"), volumesDriver) <ide> if err != nil { <ide> return nil, err <ide> }
2
Text
Text
remove experimental status for whatwg url as path
fa1a842a08aa0be1cbc7b6a0e5517340c6768986
<ide><path>doc/api/fs.md <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> - version: v6.3.0 <ide> pr-url: https://github.com/nodejs/node/pull/6534 <ide> description: The constants like `fs.R_OK`, etc which were present directly <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> - version: v7.0.0 <ide> pr-url: https://github.com/nodejs/node/pull/7897 <ide> description: The `callback` parameter is no longer optional. Not passing <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> - version: v7.0.0 <ide> pr-url: https://github.com/nodejs/node/pull/7897 <ide> description: The `callback` parameter is no longer optional. Not passing <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using <del> `file:` protocol. Support is currently still *experimental*. <add> `file:` protocol. <ide> - version: v7.0.0 <ide> pr-url: https://github.com/nodejs/node/pull/7831 <ide> description: The passed `options` object will never be modified. <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using <del> `file:` protocol. Support is currently still *experimental*. <add> `file:` protocol. <ide> - version: v7.0.0 <ide> pr-url: https://github.com/nodejs/node/pull/7831 <ide> description: The passed `options` object will never be modified. <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using <del> `file:` protocol. Support is currently still *experimental*. <add> `file:` protocol. <ide> --> <ide> <ide> > Stability: 0 - Deprecated: Use [`fs.stat()`][] or [`fs.access()`][] instead. <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> - version: v7.0.0 <ide> pr-url: https://github.com/nodejs/node/pull/7897 <ide> description: The `callback` parameter is no longer optional. Not passing <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> - version: v7.0.0 <ide> pr-url: https://github.com/nodejs/node/pull/7897 <ide> description: The `callback` parameter is no longer optional. Not passing <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> --> <ide> <ide> * `path` {string|Buffer|URL} <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> - version: v7.0.0 <ide> pr-url: https://github.com/nodejs/node/pull/7897 <ide> description: The `callback` parameter is no longer optional. Not passing <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> - version: v7.0.0 <ide> pr-url: https://github.com/nodejs/node/pull/7897 <ide> description: The `callback` parameter is no longer optional. Not passing <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> - version: v7.0.0 <ide> pr-url: https://github.com/nodejs/node/pull/7897 <ide> description: The `callback` parameter is no longer optional. Not passing <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using <del> `file:` protocol. Support is currently still *experimental*. <add> `file:` protocol. <ide> - version: v7.0.0 <ide> pr-url: https://github.com/nodejs/node/pull/7897 <ide> description: The `callback` parameter is no longer optional. Not passing <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameters can be a WHATWG `URL` object using <del> `file:` protocol. Support is currently still *experimental*. <add> `file:` protocol. <ide> - version: v7.0.0 <ide> pr-url: https://github.com/nodejs/node/pull/7897 <ide> description: The `callback` parameter is no longer optional. Not passing <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> - version: v7.0.0 <ide> pr-url: https://github.com/nodejs/node/pull/7897 <ide> description: The `callback` parameter is no longer optional. Not passing <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> - version: v7.0.0 <ide> pr-url: https://github.com/nodejs/node/pull/7897 <ide> description: The `callback` parameter is no longer optional. Not passing <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> - version: v7.0.0 <ide> pr-url: https://github.com/nodejs/node/pull/7897 <ide> description: The `callback` parameter is no longer optional. Not passing <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `filename` parameter can be a WHATWG `URL` object using <del> `file:` protocol. Support is currently still *experimental*. <add> `file:` protocol. <ide> - version: v7.0.0 <ide> pr-url: https://github.com/nodejs/node/pull/7831 <ide> description: The passed `options` object will never be modified. <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `filename` parameter can be a WHATWG `URL` object using <del> `file:` protocol. Support is currently still *experimental*. <add> `file:` protocol. <ide> --> <ide> <ide> * `filename` {string|Buffer|URL} <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> --> <ide> <ide> * `path` {string|Buffer|URL} <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> --> <ide> <ide> * `path` {string|Buffer|URL} <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> --> <ide> <ide> * `path` {string|Buffer|URL} <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using <del> `file:` protocol. Support is currently still *experimental*. <add> `file:` protocol. <ide> --> <ide> <ide> * `path` {string|Buffer|URL} <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> --> <ide> <ide> * `path` {string|Buffer|URL} <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> --> <ide> <ide> * `path` {string|Buffer|URL} <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> --> <ide> <ide> * `path` {string|Buffer|URL} <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> --> <ide> <ide> * `path` {string|Buffer|URL} <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> - version: v5.0.0 <ide> pr-url: https://github.com/nodejs/node/pull/3163 <ide> description: The `path` parameter can be a file descriptor now. <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> --> <ide> <ide> * `path` {string|Buffer|URL} <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using <del> `file:` protocol. Support is currently still *experimental*. <add> `file:` protocol. <ide> - version: v6.4.0 <ide> pr-url: https://github.com/nodejs/node/pull/7899 <ide> description: Calling `realpathSync` now works again for various edge cases <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameters can be a WHATWG `URL` object using <del> `file:` protocol. Support is currently still *experimental*. <add> `file:` protocol. <ide> --> <ide> <ide> * `path` {string|Buffer|URL} <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> --> <ide> <ide> * `path` {string|Buffer|URL} <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> --> <ide> <ide> * `path` {string|Buffer|URL} <ide> changes: <ide> - version: v7.6.0 <ide> pr-url: https://github.com/nodejs/node/pull/10739 <ide> description: The `path` parameter can be a WHATWG `URL` object using `file:` <del> protocol. Support is currently still *experimental*. <add> protocol. <ide> - version: v4.1.0 <ide> pr-url: https://github.com/nodejs/node/pull/2387 <ide> description: Numeric strings, `NaN` and `Infinity` are now allowed
1
Ruby
Ruby
add failing tests according to #479
7c353d576a5c302f50d5a72768e36f7a04e71add
<ide><path>activerecord/test/cases/associations/has_many_associations_test.rb <ide> def test_create_from_association_with_nil_values_should_work <ide> assert_equal 'defaulty', bulb.name <ide> end <ide> <add> def test_create_from_association_set_owner_attributes_by_passing_protection <add> Bulb.attr_protected :car_id <add> car = Car.create(:name => 'honda') <add> <add> bulb = car.bulbs.new <add> assert_equal car.id, bulb.car_id <add> <add> bulb = car.bulbs.build <add> assert_equal car.id, bulb.car_id <add> <add> bulb = car.bulbs.create <add> assert_equal car.id, bulb.car_id <add> ensure <add> Bulb.attr_protected :id <add> end <ide> <ide> # When creating objects on the association, we must not do it within a scope (even though it <ide> # would be convenient), because this would cause that scope to be applied to any callbacks etc.
1
Javascript
Javascript
use separators api in uiexplorer list
eeddef18b8d3d624ae8027104790c963bdc586be
<ide><path>Examples/UIExplorer/js/UIExplorerExampleList.js <ide> class RowComponent extends React.PureComponent { <ide> item: Object, <ide> onNavigate: Function, <ide> onPress?: Function, <add> onShowUnderlay?: Function, <add> onHideUnderlay?: Function, <ide> }; <ide> _onPress = () => { <ide> if (this.props.onPress) { <ide> class RowComponent extends React.PureComponent { <ide> render() { <ide> const {item} = this.props; <ide> return ( <del> <View> <del> <TouchableHighlight onPress={this._onPress}> <del> <View style={styles.row}> <del> <Text style={styles.rowTitleText}> <del> {item.module.title} <del> </Text> <del> <Text style={styles.rowDetailText}> <del> {item.module.description} <del> </Text> <del> </View> <del> </TouchableHighlight> <del> <View style={styles.separator} /> <del> </View> <add> <TouchableHighlight {...this.props} onPress={this._onPress}> <add> <View style={styles.row}> <add> <Text style={styles.rowTitleText}> <add> {item.module.title} <add> </Text> <add> <Text style={styles.rowDetailText}> <add> {item.module.description} <add> </Text> <add> </View> <add> </TouchableHighlight> <ide> ); <ide> } <ide> } <ide> class UIExplorerExampleList extends React.Component { <ide> {this._renderTitleRow()} <ide> {this._renderTextInput()} <ide> <SectionList <add> ItemSeparatorComponent={ItemSeparator} <add> contentContainerStyle={{backgroundColor: 'white'}} <ide> style={styles.list} <ide> sections={sections} <ide> renderItem={this._renderItem} <ide> class UIExplorerExampleList extends React.Component { <ide> return curr.item !== prev.item; <ide> } <ide> <del> _renderItem = ({item}) => <RowComponent item={item} onNavigate={this.props.onNavigate} />; <add> _renderItem = ({item, separators}) => ( <add> <RowComponent <add> item={item} <add> onNavigate={this.props.onNavigate} <add> onShowUnderlay={separators.highlight} <add> onHideUnderlay={separators.unhighlight} <add> /> <add> ); <ide> <ide> _renderTitleRow(): ?React.Element<any> { <ide> if (!this.props.displayTitleRow) { <ide> class UIExplorerExampleList extends React.Component { <ide> } <ide> } <ide> <add>const ItemSeparator = ({highlighted}) => ( <add> <View style={highlighted ? styles.separatorHighlighted : styles.separator} /> <add>); <add> <ide> UIExplorerExampleList = UIExplorerStatePersister.createContainer(UIExplorerExampleList, { <ide> cacheKeySuffix: () => 'mainList', <ide> getInitialState: () => ({filter: ''}), <ide> const styles = StyleSheet.create({ <ide> backgroundColor: '#bbbbbb', <ide> marginLeft: 15, <ide> }, <add> separatorHighlighted: { <add> height: StyleSheet.hairlineWidth, <add> backgroundColor: 'rgb(217, 217, 217)', <add> }, <ide> rowTitleText: { <ide> fontSize: 17, <ide> fontWeight: '500',
1
Java
Java
remove unused param comments
089794cb42ca338037948d4e0cfc2cf511a9343e
<ide><path>language-adaptors/rxjava-jruby/src/main/java/rx/lang/jruby/JRubyActionWrapper.java <ide> <ide> /** <ide> * Concrete wrapper that accepts a {@link RubyProc} and produces any needed Rx {@link Action}. <del> * <del> * @param <T1> <del> * @param <T2> <del> * @param <T3> <del> * @param <T4> <ide> */ <ide> public class JRubyActionWrapper<T1, T2, T3, T4> implements Action, Action0, Action1<T1>, Action2<T1, T2>, Action3<T1, T2, T3> { <ide> <ide><path>language-adaptors/rxjava-jruby/src/main/java/rx/lang/jruby/JRubyFunctionWrapper.java <ide> <ide> /** <ide> * Concrete wrapper that accepts a {@link RubyProc} and produces any needed Rx {@link Function}. <del> * <del> * @param <T1> <del> * @param <T2> <del> * @param <T3> <del> * @param <T4> <del> * @param <T5> <del> * @param <T6> <del> * @param <T7> <del> * @param <T8> <del> * @param <T9> <del> * @param <R> <ide> */ <ide> public class JRubyFunctionWrapper<T1, T2, T3, T4, T5, T6, T7, T8, T9, R> implements <ide> Func0<R>,
2
Go
Go
add build command
96069de4e0818f9d513f6ea495e03d8e67eb1e98
<ide><path>builder.go <ide> import ( <ide> "bufio" <ide> "fmt" <ide> "io" <del> "os" <del> "path" <ide> "strings" <del> "time" <ide> ) <ide> <ide> type Builder struct { <del> runtime *Runtime <del> repositories *TagStore <del> graph *Graph <add> runtime *Runtime <ide> } <ide> <ide> func NewBuilder(runtime *Runtime) *Builder { <ide> return &Builder{ <del> runtime: runtime, <del> graph: runtime.graph, <del> repositories: runtime.repositories, <add> runtime: runtime, <ide> } <ide> } <ide> <del>func (builder *Builder) mergeConfig(userConf, imageConf *Config) { <del> if userConf.Hostname != "" { <del> userConf.Hostname = imageConf.Hostname <add>func (builder *Builder) run(image *Image, cmd string) (*Container, error) { <add> // FIXME: pass a NopWriter instead of nil <add> config, err := ParseRun([]string{"-d", image.Id, "/bin/sh", "-c", cmd}, nil, builder.runtime.capabilities) <add> if config.Image == "" { <add> return nil, fmt.Errorf("Image not specified") <ide> } <del> if userConf.User != "" { <del> userConf.User = imageConf.User <add> if len(config.Cmd) == 0 { <add> return nil, fmt.Errorf("Command not specified") <ide> } <del> if userConf.Memory == 0 { <del> userConf.Memory = imageConf.Memory <add> if config.Tty { <add> return nil, fmt.Errorf("The tty mode is not supported within the builder") <ide> } <del> if userConf.MemorySwap == 0 { <del> userConf.MemorySwap = imageConf.MemorySwap <del> } <del> if userConf.PortSpecs == nil || len(userConf.PortSpecs) == 0 { <del> userConf.PortSpecs = imageConf.PortSpecs <del> } <del> if !userConf.Tty { <del> userConf.Tty = userConf.Tty <del> } <del> if !userConf.OpenStdin { <del> userConf.OpenStdin = imageConf.OpenStdin <del> } <del> if !userConf.StdinOnce { <del> userConf.StdinOnce = imageConf.StdinOnce <del> } <del> if userConf.Env == nil || len(userConf.Env) == 0 { <del> userConf.Env = imageConf.Env <del> } <del> if userConf.Cmd == nil || len(userConf.Cmd) == 0 { <del> userConf.Cmd = imageConf.Cmd <del> } <del> if userConf.Dns == nil || len(userConf.Dns) == 0 { <del> userConf.Dns = imageConf.Dns <del> } <del>} <ide> <del>func (builder *Builder) Create(config *Config) (*Container, error) { <del> // Lookup image <del> img, err := builder.repositories.LookupImage(config.Image) <add> // Create new container <add> container, err := builder.runtime.Create(config) <ide> if err != nil { <ide> return nil, err <ide> } <del> <del> if img.Config != nil { <del> builder.mergeConfig(config, img.Config) <del> } <del> <del> if config.Cmd == nil { <del> return nil, fmt.Errorf("No command specified") <del> } <del> <del> // Generate id <del> id := GenerateId() <del> // Generate default hostname <del> // FIXME: the lxc template no longer needs to set a default hostname <del> if config.Hostname == "" { <del> config.Hostname = id[:12] <del> } <del> <del> container := &Container{ <del> // FIXME: we should generate the ID here instead of receiving it as an argument <del> Id: id, <del> Created: time.Now(), <del> Path: config.Cmd[0], <del> Args: config.Cmd[1:], //FIXME: de-duplicate from config <del> Config: config, <del> Image: img.Id, // Always use the resolved image id <del> NetworkSettings: &NetworkSettings{}, <del> // FIXME: do we need to store this in the container? <del> SysInitPath: sysInitPath, <del> } <del> container.root = builder.runtime.containerRoot(container.Id) <del> // Step 1: create the container directory. <del> // This doubles as a barrier to avoid race conditions. <del> if err := os.Mkdir(container.root, 0700); err != nil { <del> return nil, err <del> } <del> <del> // If custom dns exists, then create a resolv.conf for the container <del> if len(config.Dns) > 0 { <del> container.ResolvConfPath = path.Join(container.root, "resolv.conf") <del> f, err := os.Create(container.ResolvConfPath) <del> if err != nil { <del> return nil, err <del> } <del> defer f.Close() <del> for _, dns := range config.Dns { <del> if _, err := f.Write([]byte("nameserver " + dns + "\n")); err != nil { <del> return nil, err <del> } <del> } <del> } else { <del> container.ResolvConfPath = "/etc/resolv.conf" <del> } <del> <del> // Step 2: save the container json <del> if err := container.ToDisk(); err != nil { <del> return nil, err <del> } <del> // Step 3: register the container <del> if err := builder.runtime.Register(container); err != nil { <add> if err := container.Start(); err != nil { <ide> return nil, err <ide> } <ide> return container, nil <ide> } <ide> <del>// Commit creates a new filesystem image from the current state of a container. <del>// The image can optionally be tagged into a repository <del>func (builder *Builder) Commit(container *Container, repository, tag, comment, author string, config *Config) (*Image, error) { <del> // FIXME: freeze the container before copying it to avoid data corruption? <del> // FIXME: this shouldn't be in commands. <del> rwTar, err := container.ExportRw() <add>func (builder *Builder) runCommit(image *Image, cmd string) (*Image, error) { <add> c, err := builder.run(image, cmd) <ide> if err != nil { <ide> return nil, err <ide> } <del> // Create a new image from the container's base layers + a new layer from container changes <del> img, err := builder.graph.Create(rwTar, container, comment, author, config) <add> if result := c.Wait(); result != 0 { <add> return nil, fmt.Errorf("!!! '%s' return non-zero exit code '%d'. Aborting.", cmd, result) <add> } <add> img, err := builder.runtime.Commit(c.Id, "", "", "", "") <ide> if err != nil { <ide> return nil, err <ide> } <del> // Register the image if needed <del> if repository != "" { <del> if err := builder.repositories.Set(repository, tag, img.Id, true); err != nil { <del> return img, err <del> } <del> } <ide> return img, nil <ide> } <ide> <del>func (builder *Builder) clearTmp(containers, images map[string]struct{}) { <del> for c := range containers { <del> tmp := builder.runtime.Get(c) <del> builder.runtime.Destroy(tmp) <del> Debugf("Removing container %s", c) <del> } <del> for i := range images { <del> builder.runtime.graph.Delete(i) <del> Debugf("Removing image %s", i) <del> } <del>} <del> <del>func (builder *Builder) Build(dockerfile io.Reader, stdout io.Writer) (*Image, error) { <del> var ( <del> image, base *Image <del> maintainer string <del> tmpContainers map[string]struct{} = make(map[string]struct{}) <del> tmpImages map[string]struct{} = make(map[string]struct{}) <del> ) <del> defer builder.clearTmp(tmpContainers, tmpImages) <add>func (builder *Builder) Build(dockerfile io.Reader, stdout io.Writer) error { <add> var image, base *Image <ide> <ide> file := bufio.NewReader(dockerfile) <ide> for { <ide> func (builder *Builder) Build(dockerfile io.Reader, stdout io.Writer) (*Image, e <ide> if err == io.EOF { <ide> break <ide> } <del> return nil, err <add> return err <ide> } <ide> line = strings.TrimSpace(line) <ide> // Skip comments and empty line <ide> if len(line) == 0 || line[0] == '#' { <ide> continue <ide> } <del> tmp := strings.SplitN(line, " ", 2) <add> tmp := strings.SplitN(line, " ", 2) <ide> if len(tmp) != 2 { <del> return nil, fmt.Errorf("Invalid Dockerfile format") <add> return fmt.Errorf("Invalid Dockerfile format") <ide> } <del> instruction := strings.Trim(tmp[0], " ") <del> arguments := strings.Trim(tmp[1], " ") <del> switch strings.ToLower(instruction) { <add> switch tmp[0] { <ide> case "from": <del> fmt.Fprintf(stdout, "FROM %s\n", arguments) <del> image, err = builder.runtime.repositories.LookupImage(arguments) <add> fmt.Fprintf(stdout, "FROM %s\n", tmp[1]) <add> image, err = builder.runtime.repositories.LookupImage(tmp[1]) <ide> if err != nil { <ide> if builder.runtime.graph.IsNotExist(err) { <ide> <ide> func (builder *Builder) Build(dockerfile io.Reader, stdout io.Writer) (*Image, e <ide> return nil, err <ide> } <ide> } <del> <del> break <del> case "mainainer": <del> fmt.Fprintf(stdout, "MAINTAINER %s\n", arguments) <del> maintainer = arguments <ide> break <ide> case "run": <del> fmt.Fprintf(stdout, "RUN %s\n", arguments) <del> if image == nil { <del> return nil, fmt.Errorf("Please provide a source image with `from` prior to run") <del> } <del> config, err := ParseRun([]string{image.Id, "/bin/sh", "-c", arguments}, nil, builder.runtime.capabilities) <del> if err != nil { <del> return nil, err <del> } <del> <del> // Create the container and start it <del> c, err := builder.Create(config) <del> if err != nil { <del> return nil, err <del> } <del> if err := c.Start(); err != nil { <del> return nil, err <del> } <del> tmpContainers[c.Id] = struct{}{} <del> <del> // Wait for it to finish <del> if result := c.Wait(); result != 0 { <del> return nil, fmt.Errorf("!!! '%s' return non-zero exit code '%d'. Aborting.", arguments, result) <del> } <del> <del> // Commit the container <del> base, err = builder.Commit(c, "", "", "", maintainer, nil) <del> if err != nil { <del> return nil, err <del> } <del> tmpImages[base.Id] = struct{}{} <del> <del> fmt.Fprintf(stdout, "===> %s\n", base.ShortId()) <del> <del> // use the base as the new image <del> image = base <del> <del> break <del> case "expose": <del> ports := strings.Split(arguments, " ") <del> <del> fmt.Fprintf(stdout, "EXPOSE %v\n", ports) <del> if image == nil { <del> return nil, fmt.Errorf("Please provide a source image with `from` prior to copy") <del> } <del> <del> // Create the container and start it <del> c, err := builder.Create(&Config{Image: image.Id, Cmd: []string{"", ""}}) <del> if err != nil { <del> return nil, err <del> } <del> if err := c.Start(); err != nil { <del> return nil, err <del> } <del> tmpContainers[c.Id] = struct{}{} <del> <del> // Commit the container <del> base, err = builder.Commit(c, "", "", "", maintainer, &Config{PortSpecs: ports}) <del> if err != nil { <del> return nil, err <del> } <del> tmpImages[base.Id] = struct{}{} <del> <del> fmt.Fprintf(stdout, "===> %s\n", base.ShortId()) <del> <del> image = base <del> break <del> case "insert": <add> fmt.Fprintf(stdout, "RUN %s\n", tmp[1]) <ide> if image == nil { <del> return nil, fmt.Errorf("Please provide a source image with `from` prior to copy") <del> } <del> tmp = strings.SplitN(arguments, " ", 2) <del> if len(tmp) != 2 { <del> return nil, fmt.Errorf("Invalid INSERT format") <del> } <del> sourceUrl := strings.Trim(tmp[0], " ") <del> destPath := strings.Trim(tmp[1], " ") <del> fmt.Fprintf(stdout, "COPY %s to %s in %s\n", sourceUrl, destPath, base.ShortId()) <del> <del> file, err := Download(sourceUrl, stdout) <del> if err != nil { <del> return nil, err <del> } <del> defer file.Body.Close() <del> <del> config, err := ParseRun([]string{base.Id, "echo", "insert", sourceUrl, destPath}, nil, builder.runtime.capabilities) <del> if err != nil { <del> return nil, err <del> } <del> c, err := builder.Create(config) <del> if err != nil { <del> return nil, err <add> return fmt.Errorf("Please provide a source image with `from` prior to run") <ide> } <del> <del> if err := c.Start(); err != nil { <del> return nil, err <del> } <del> <del> // Wait for echo to finish <del> if result := c.Wait(); result != 0 { <del> return nil, fmt.Errorf("!!! '%s' return non-zero exit code '%d'. Aborting.", arguments, result) <del> } <del> <del> if err := c.Inject(file.Body, destPath); err != nil { <del> return nil, err <del> } <del> <del> base, err = builder.Commit(c, "", "", "", maintainer, nil) <add> base, err = builder.runCommit(image, tmp[1]) <ide> if err != nil { <del> return nil, err <add> return err <ide> } <del> fmt.Fprintf(stdout, "===> %s\n", base.ShortId()) <del> <del> image = base <del> <add> fmt.Fprintf(stdout, "===> %s\n", base.Id) <ide> break <add> case "copy": <add> return fmt.Errorf("The copy operator has not yet been implemented") <ide> default: <del> fmt.Fprintf(stdout, "Skipping unknown instruction %s\n", instruction) <add> fmt.Fprintf(stdout, "Skipping unknown op %s\n", tmp[0]) <ide> } <ide> } <ide> if base != nil { <del> // The build is successful, keep the temporary containers and images <del> for i := range tmpImages { <del> delete(tmpImages, i) <del> } <del> for i := range tmpContainers { <del> delete(tmpContainers, i) <del> } <del> fmt.Fprintf(stdout, "Build finished. image id: %s\n", base.ShortId()) <add> fmt.Fprintf(stdout, "Build finished. image id: %s\n", base.Id) <ide> } else { <ide> fmt.Fprintf(stdout, "An error occured during the build\n") <ide> } <del> return base, nil <add> return nil <ide> } <ide><path>commands.go <ide> import ( <ide> "net/http" <ide> "net/url" <ide> "path/filepath" <add> "os" <ide> "runtime" <ide> "strconv" <ide> "strings"
2
Javascript
Javascript
move eslint no-console; now in one place
81d27091ebfbdc0b3538a09704b252d534e035ef
<ide><path>src/utils/combineReducers.js <ide> import isPlainObject from '../utils/isPlainObject'; <ide> import mapValues from '../utils/mapValues'; <ide> import pick from '../utils/pick'; <ide> <add>/* eslint-disable no-console */ <add> <ide> function getErrorMessage(key, action) { <ide> var actionType = action && action.type; <ide> var actionName = actionType && `"${actionType.toString()}"` || 'an action'; <ide> function verifyStateShape(initialState, currentState) { <ide> var reducerKeys = Object.keys(currentState); <ide> <ide> if (reducerKeys.length === 0) { <del> console.error( // eslint-disable-line no-console <add> console.error( <ide> 'Store does not have a valid reducer. Make sure the argument passed ' + <ide> 'to combineReducers is an object whose values are reducers.' <ide> ); <ide> return; <ide> } <ide> <ide> if (!isPlainObject(initialState)) { <del> console.error( // eslint-disable-line no-console <add> console.error( <ide> 'initialState has unexpected type of "' + <ide> ({}).toString.call(initialState).match(/\s([a-z|A-Z]+)/)[1] + <ide> '". Expected initialState to be an object with the following ' + <ide> function verifyStateShape(initialState, currentState) { <ide> ); <ide> <ide> if (unexpectedKeys.length > 0) { <del> console.error( // eslint-disable-line no-console <add> console.error( <ide> `Unexpected ${unexpectedKeys.length > 1 ? 'keys' : 'key'} ` + <ide> `"${unexpectedKeys.join('", "')}" in initialState will be ignored. ` + <ide> `Expected to find one of the known reducer keys instead: "${reducerKeys.join('", "')}"`
1
Text
Text
fix the example for using a cdn with activestorage
35e21fcff9d756090d5ab16b1c5ebaa204196022
<ide><path>guides/source/active_storage_overview.md <ide> You should also make sure that the generated URLs use the CDN host instead of yo <ide> ```ruby <ide> # config/routes.rb <ide> direct :cdn_image do |model, options| <add> expires_in = options.delete(:expires_in) { ActiveStorage.urls_expire_in } <add> <ide> if model.respond_to?(:signed_id) <ide> route_for( <ide> :rails_service_blob_proxy, <del> model.signed_id, <add> model.signed_id(expires_in: expires_in), <ide> model.filename, <ide> options.merge(host: ENV['CDN_HOST']) <ide> ) <ide> else <del> signed_blob_id = model.blob.signed_id <add> signed_blob_id = model.blob.signed_id(expires_in: expires_in) <ide> variation_key = model.variation.key <ide> filename = model.blob.filename <ide>
1
Text
Text
add periods to the bullet points in guides
6dcae8ae9c21abd95cc119dd5625b4fb44fd4350
<ide><path>guides/source/action_controller_overview.md <ide> Action Controller Overview <ide> <ide> In this guide you will learn how controllers work and how they fit into the request cycle in your application. After reading this guide, you will be able to: <ide> <del>* Follow the flow of a request through a controller <del>* Understand why and how to store data in the session or cookies <del>* Work with filters to execute code during request processing <del>* Use Action Controller's built-in HTTP authentication <del>* Stream data directly to the user's browser <del>* Filter sensitive parameters so they do not appear in the application's log <del>* Deal with exceptions that may be raised during request processing <add>* Follow the flow of a request through a controller. <add>* Understand why and how to store data in the session or cookies. <add>* Work with filters to execute code during request processing. <add>* Use Action Controller's built-in HTTP authentication. <add>* Stream data directly to the user's browser. <add>* Filter sensitive parameters so they do not appear in the application's log. <add>* Deal with exceptions that may be raised during request processing. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/action_view_overview.md <ide> Action View Overview <ide> <ide> In this guide you will learn: <ide> <del>* What Action View is and how to use it with Rails <del>* How best to use templates, partials, and layouts <del>* What helpers are provided by Action View and how to make your own <del>* How to use localized views <del>* How to use Action View outside of Rails <add>* What Action View is and how to use it with Rails. <add>* How best to use templates, partials, and layouts. <add>* What helpers are provided by Action View and how to make your own. <add>* How to use localized views. <add>* How to use Action View outside of Rails. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/active_record_basics.md <ide> Active Record Basics <ide> <ide> This guide is an introduction to Active Record. After reading this guide we hope that you'll learn: <ide> <del>* What Object Relational Mapping and Active Record are and how they are used in Rails <del>* How Active Record fits into the Model-View-Controller paradigm <del>* How to use Active Record models to manipulate data stored in a relational database <del>* Active Record schema naming conventions <del>* The concepts of database migrations, validations and callbacks <add>* What Object Relational Mapping and Active Record are and how they are used in Rails. <add>* How Active Record fits into the Model-View-Controller paradigm. <add>* How to use Active Record models to manipulate data stored in a relational database. <add>* Active Record schema naming conventions. <add>* The concepts of database migrations, validations and callbacks. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/active_record_querying.md <ide> Active Record Query Interface <ide> <ide> This guide covers different ways to retrieve data from the database using Active Record. By referring to this guide, you will be able to: <ide> <del>* Find records using a variety of methods and conditions <del>* Specify the order, retrieved attributes, grouping, and other properties of the found records <del>* Use eager loading to reduce the number of database queries needed for data retrieval <del>* Use dynamic finders methods <del>* Check for the existence of particular records <del>* Perform various calculations on Active Record models <del>* Run EXPLAIN on relations <add>* Find records using a variety of methods and conditions. <add>* Specify the order, retrieved attributes, grouping, and other properties of the found records. <add>* Use eager loading to reduce the number of database queries needed for data retrieval. <add>* Use dynamic finders methods. <add>* Check for the existence of particular records. <add>* Perform various calculations on Active Record models. <add>* Run EXPLAIN on relations. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/active_record_validations_callbacks.md <ide> This guide teaches you how to hook into the life cycle of your Active Record obj <ide> <ide> After reading this guide and trying out the presented concepts, we hope that you'll be able to: <ide> <del>* Understand the life cycle of Active Record objects <del>* Use the built-in Active Record validation helpers <del>* Create your own custom validation methods <del>* Work with the error messages generated by the validation process <del>* Create callback methods that respond to events in the object life cycle <del>* Create special classes that encapsulate common behavior for your callbacks <del>* Create Observers that respond to life cycle events outside of the original class <add>* Understand the life cycle of Active Record objects. <add>* Use the built-in Active Record validation helpers. <add>* Create your own custom validation methods. <add>* Work with the error messages generated by the validation process. <add>* Create callback methods that respond to events in the object life cycle. <add>* Create special classes that encapsulate common behavior for your callbacks. <add>* Create Observers that respond to life cycle events outside of the original class. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/active_support_instrumentation.md <ide> Active Support is a part of core Rails that provides Ruby language extensions, u <ide> <ide> In this guide, you will learn how to use the instrumentation API inside of Active Support to measure events inside of Rails and other Ruby code. We cover: <ide> <del>* What instrumentation can provide <del>* The hooks inside the Rails framework for instrumentation <del>* Adding a subscriber to a hook <del>* Building a custom instrumentation implementation <add>* What instrumentation can provide. <add>* The hooks inside the Rails framework for instrumentation. <add>* Adding a subscriber to a hook. <add>* Building a custom instrumentation implementation. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/asset_pipeline.md <ide> Asset Pipeline <ide> This guide covers the asset pipeline introduced in Rails 3.1. <ide> By referring to this guide you will be able to: <ide> <del>* Understand what the asset pipeline is and what it does <del>* Properly organize your application assets <del>* Understand the benefits of the asset pipeline <del>* Add a pre-processor to the pipeline <del>* Package assets with a gem <add>* Understand what the asset pipeline is and what it does. <add>* Properly organize your application assets. <add>* Understand the benefits of the asset pipeline. <add>* Add a pre-processor to the pipeline. <add>* Package assets with a gem. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/association_basics.md <ide> A Guide to Active Record Associations <ide> <ide> This guide covers the association features of Active Record. By referring to this guide, you will be able to: <ide> <del>* Declare associations between Active Record models <del>* Understand the various types of Active Record associations <del>* Use the methods added to your models by creating associations <add>* Declare associations between Active Record models. <add>* Understand the various types of Active Record associations. <add>* Use the methods added to your models by creating associations. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/caching_with_rails.md <ide> This guide will teach you what you need to know about avoiding that expensive ro <ide> <ide> After reading this guide, you should be able to use and configure: <ide> <del>* Page, action, and fragment caching <del>* Sweepers <del>* Alternative cache stores <del>* Conditional GET support <add>* Page, action, and fragment caching. <add>* Sweepers. <add>* Alternative cache stores. <add>* Conditional GET support. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/command_line.md <ide> A Guide to The Rails Command Line <ide> <ide> Rails comes with every command line tool you'll need to <ide> <del>* Create a Rails application <del>* Generate models, controllers, database migrations, and unit tests <del>* Start a development server <del>* Experiment with objects through an interactive shell <del>* Profile and benchmark your new creation <add>* Create a Rails application. <add>* Generate models, controllers, database migrations, and unit tests. <add>* Start a development server. <add>* Experiment with objects through an interactive shell. <add>* Profile and benchmark your new creation. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/configuring.md <ide> Configuring Rails Applications <ide> <ide> This guide covers the configuration and initialization features available to Rails applications. By referring to this guide, you will be able to: <ide> <del>* Adjust the behavior of your Rails applications <del>* Add additional code to be run at application start time <add>* Adjust the behavior of your Rails applications. <add>* Add additional code to be run at application start time. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/contributing_to_ruby_on_rails.md <ide> Contributing to Ruby on Rails <ide> <ide> This guide covers ways in which _you_ can become a part of the ongoing development of Ruby on Rails. After reading it, you should be familiar with: <ide> <del>* Using GitHub to report issues <del>* Cloning master and running the test suite <del>* Helping to resolve existing issues <del>* Contributing to the Ruby on Rails documentation <del>* Contributing to the Ruby on Rails code <add>* Using GitHub to report issues. <add>* Cloning master and running the test suite. <add>* Helping to resolve existing issues. <add>* Contributing to the Ruby on Rails documentation. <add>* Contributing to the Ruby on Rails code. <ide> <ide> Ruby on Rails is not "someone else's framework." Over the years, hundreds of people have contributed to Ruby on Rails ranging from a single character to massive architectural changes or significant documentation — all with the goal of making Ruby on Rails better for everyone. Even if you don't feel up to writing code or documentation yet, there are a variety of other ways that you can contribute, from reporting issues to testing patches. <ide> <ide><path>guides/source/debugging_rails_applications.md <ide> Debugging Rails Applications <ide> <ide> This guide introduces techniques for debugging Ruby on Rails applications. By referring to this guide, you will be able to: <ide> <del>* Understand the purpose of debugging <del>* Track down problems and issues in your application that your tests aren't identifying <del>* Learn the different ways of debugging <del>* Analyze the stack trace <add>* Understand the purpose of debugging. <add>* Track down problems and issues in your application that your tests aren't identifying. <add>* Learn the different ways of debugging. <add>* Analyze the stack trace. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/engines.md <ide> Getting Started with Engines <ide> <ide> In this guide you will learn about engines and how they can be used to provide additional functionality to their host applications through a clean and very easy-to-use interface. You will learn the following things in this guide: <ide> <del>* What makes an engine <del>* How to generate an engine <del>* Building features for the engine <del>* Hooking the engine into an application <del>* Overriding engine functionality in the application <add>* What makes an engine. <add>* How to generate an engine. <add>* Building features for the engine. <add>* Hooking the engine into an application. <add>* Overriding engine functionality in the application. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/form_helpers.md <ide> Forms in web applications are an essential interface for user input. However, fo <ide> <ide> In this guide you will: <ide> <del>* Create search forms and similar kind of generic forms not representing any specific model in your application <del>* Make model-centric forms for creation and editing of specific database records <del>* Generate select boxes from multiple types of data <del>* Understand the date and time helpers Rails provides <del>* Learn what makes a file upload form different <del>* Learn some cases of building forms to external resources <del>* Find out how to build complex forms <add>* Create search forms and similar kind of generic forms not representing any specific model in your application. <add>* Make model-centric forms for creation and editing of specific database records. <add>* Generate select boxes from multiple types of data. <add>* Understand the date and time helpers Rails provides. <add>* Learn what makes a file upload form different. <add>* Learn some cases of building forms to external resources. <add>* Find out how to build complex forms. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/generators.md <ide> Rails generators are an essential tool if you plan to improve your workflow. Wit <ide> <ide> In this guide you will: <ide> <del>* Learn how to see which generators are available in your application <del>* Create a generator using templates <del>* Learn how Rails searches for generators before invoking them <del>* Customize your scaffold by creating new generators <del>* Customize your scaffold by changing generator templates <del>* Learn how to use fallbacks to avoid overwriting a huge set of generators <del>* Learn how to create an application template <add>* Learn how to see which generators are available in your application. <add>* Create a generator using templates. <add>* Learn how Rails searches for generators before invoking them. <add>* Customize your scaffold by creating new generators. <add>* Customize your scaffold by changing generator templates. <add>* Learn how to use fallbacks to avoid overwriting a huge set of generators. <add>* Learn how to create an application template. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/i18n.md <ide> The process of "internationalization" usually means to abstract all strings and <ide> <ide> So, in the process of _internationalizing_ your Rails application you have to: <ide> <del>* Ensure you have support for i18n <del>* Tell Rails where to find locale dictionaries <del>* Tell Rails how to set, preserve and switch locales <add>* Ensure you have support for i18n. <add>* Tell Rails where to find locale dictionaries. <add>* Tell Rails how to set, preserve and switch locales. <ide> <ide> In the process of _localizing_ your application you'll probably want to do the following three things: <ide> <ide> * Replace or supplement Rails' default locale — e.g. date and time formats, month names, Active Record model names, etc. <ide> * Abstract strings in your application into keyed dictionaries — e.g. flash messages, static text in your views, etc. <del>* Store the resulting dictionaries somewhere <add>* Store the resulting dictionaries somewhere. <ide> <ide> This guide will walk you through the I18n API and contains a tutorial on how to internationalize a Rails application from the start. <ide> <ide><path>guides/source/initialization.md <ide> The Rails Initialization Process <ide> This guide explains the internals of the initialization process in Rails <ide> as of Rails 4. It is an extremely in-depth guide and recommended for advanced Rails developers. <ide> <del>* Using `rails server` <add>* Using `rails server`. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/layouts_and_rendering.md <ide> Layouts and Rendering in Rails <ide> <ide> This guide covers the basic layout features of Action Controller and Action View. By referring to this guide, you will be able to: <ide> <del>* Use the various rendering methods built into Rails <del>* Create layouts with multiple content sections <del>* Use partials to DRY up your views <del>* Use nested layouts (sub-templates) <add>* Use the various rendering methods built into Rails. <add>* Create layouts with multiple content sections. <add>* Use partials to DRY up your views. <add>* Use nested layouts (sub-templates). <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/migrations.md <ide> tables. <ide> <ide> In this guide, you'll learn all about migrations including: <ide> <del>* The generators you can use to create them <del>* The methods Active Record provides to manipulate your database <del>* The Rake tasks that manipulate migrations and your schema <del>* How migrations relate to `schema.rb` <add>* The generators you can use to create them. <add>* The methods Active Record provides to manipulate your database. <add>* The Rake tasks that manipulate migrations and your schema. <add>* How migrations relate to `schema.rb`. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/nested_model_forms.md <ide> Creating a form for a model _and_ its associations can become quite tedious. The <ide> <ide> In this guide you will: <ide> <del>* do stuff <add>* do stuff. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/plugins.md <ide> A Rails plugin is either an extension or a modification of the core framework. P <ide> <ide> After reading this guide you should be familiar with: <ide> <del>* Creating a plugin from scratch <del>* Writing and running tests for the plugin <add>* Creating a plugin from scratch. <add>* Writing and running tests for the plugin. <ide> <ide> This guide describes how to build a test-driven plugin that will: <ide> <del>* Extend core Ruby classes like Hash and String <del>* Add methods to ActiveRecord::Base in the tradition of the 'acts_as' plugins <add>* Extend core Ruby classes like Hash and String. <add>* Add methods to ActiveRecord::Base in the tradition of the 'acts_as' plugins. <ide> * Give you information about where to put generators in your plugin. <ide> <ide> For the purpose of this guide pretend for a moment that you are an avid bird watcher. <ide><path>guides/source/rails_application_templates.md <ide> Application templates are simple Ruby files containing DSL for adding gems/initi <ide> <ide> By referring to this guide, you will be able to: <ide> <del>* Use templates to generate/customize Rails applications <del>* Write your own reusable application templates using the Rails template API <add>* Use templates to generate/customize Rails applications. <add>* Write your own reusable application templates using the Rails template API. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/rails_on_rack.md <ide> Rails on Rack <ide> <ide> This guide covers Rails integration with Rack and interfacing with other Rack components. By referring to this guide, you will be able to: <ide> <del>* Create Rails Metal applications <del>* Use Rack Middlewares in your Rails applications <del>* Understand Action Pack's internal Middleware stack <del>* Define a custom Middleware stack <add>* Create Rails Metal applications. <add>* Use Rack Middlewares in your Rails applications. <add>* Understand Action Pack's internal Middleware stack. <add>* Define a custom Middleware stack. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/routing.md <ide> Rails Routing from the Outside In <ide> <ide> This guide covers the user-facing features of Rails routing. By referring to this guide, you will be able to: <ide> <del>* Understand the code in `routes.rb` <del>* Construct your own routes, using either the preferred resourceful style or the `match` method <del>* Identify what parameters to expect an action to receive <del>* Automatically create paths and URLs using route helpers <del>* Use advanced techniques such as constraints and Rack endpoints <add>* Understand the code in `routes.rb`. <add>* Construct your own routes, using either the preferred resourceful style or the `match` method. <add>* Identify what parameters to expect an action to receive. <add>* Automatically create paths and URLs using route helpers. <add>* Use advanced techniques such as constraints and Rack endpoints. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/security.md <ide> Ruby On Rails Security Guide <ide> <ide> This manual describes common security problems in web applications and how to avoid them with Rails. After reading it, you should be familiar with: <ide> <del>* All countermeasures _that are highlighted_ <del>* The concept of sessions in Rails, what to put in there and popular attack methods <del>* How just visiting a site can be a security problem (with CSRF) <del>* What you have to pay attention to when working with files or providing an administration interface <del>* The Rails-specific mass assignment problem <del>* How to manage users: Logging in and out and attack methods on all layers <del>* And the most popular injection attack methods <add>* All countermeasures _that are highlighted_. <add>* The concept of sessions in Rails, what to put in there and popular attack methods. <add>* How just visiting a site can be a security problem (with CSRF). <add>* What you have to pay attention to when working with files or providing an administration interface. <add>* The Rails-specific mass assignment problem. <add>* How to manage users: Logging in and out and attack methods on all layers. <add>* And the most popular injection attack methods. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/testing.md <ide> A Guide to Testing Rails Applications <ide> This guide covers built-in mechanisms offered by Rails to test your <ide> application. By referring to this guide, you will be able to: <ide> <del>* Understand Rails testing terminology <del>* Write unit, functional, and integration tests for your application <del>* Identify other popular testing approaches and plugins <add>* Understand Rails testing terminology. <add>* Write unit, functional, and integration tests for your application. <add>* Identify other popular testing approaches and plugins. <ide> <ide> -------------------------------------------------------------------------------- <ide> <ide><path>guides/source/working_with_javascript_in_rails.md <ide> This guide covers the built-in Ajax/JavaScript functionality of Rails (and <ide> more); it will enable you to create rich and dynamic Ajax applications with <ide> ease! We will cover the following topics: <ide> <del>* Quick introduction to Ajax <del>* Unobtrusive JavaScript <del>* How Rails' built-in helpers assist you <del>* Handling Ajax on the server side <del>* The Turbolinks gem <add>* Quick introduction to Ajax. <add>* Unobtrusive JavaScript. <add>* How Rails' built-in helpers assist you. <add>* Handling Ajax on the server side. <add>* The Turbolinks gem. <ide> <ide> ------------------------------------------------------------------------------- <ide>
28
Ruby
Ruby
ensure numericality validations work with mutation
704c658531ae202715cba29d6b2ba64651f220fd
<ide><path>activemodel/lib/active_model/validations/numericality.rb <ide> def validate_each(record, attr_name, value) <ide> raw_value = record.send(before_type_cast) if record.respond_to?(before_type_cast) <ide> raw_value ||= value <ide> <add> if record_attribute_changed_in_place?(record, attr_name) <add> raw_value = value <add> end <add> <ide> return if options[:allow_nil] && raw_value.nil? <ide> <ide> unless value = parse_raw_value_as_a_number(raw_value) <ide> def allow_only_integer?(record) <ide> options[:only_integer] <ide> end <ide> end <add> <add> private <add> <add> def record_attribute_changed_in_place?(record, attr_name) <add> record.respond_to?(:attribute_changed_in_place?) && <add> record.attribute_changed_in_place?(attr_name.to_s) <add> end <ide> end <ide> <ide> module HelperMethods <ide><path>activerecord/lib/active_record/attribute_methods/dirty.rb <ide> def changes <ide> end <ide> end <ide> <add> def attribute_changed_in_place?(attr_name) <add> old_value = original_raw_attribute(attr_name) <add> @attributes[attr_name].changed_in_place_from?(old_value) <add> end <add> <ide> private <ide> <ide> def calculate_changes_from_defaults <ide> def attributes_changed_in_place <ide> <ide> def changed_in_place <ide> self.class.attribute_names.select do |attr_name| <del> changed_in_place?(attr_name) <add> attribute_changed_in_place?(attr_name) <ide> end <ide> end <ide> <del> def changed_in_place?(attr_name) <del> old_value = original_raw_attribute(attr_name) <del> @attributes[attr_name].changed_in_place_from?(old_value) <del> end <del> <ide> def original_raw_attribute(attr_name) <ide> original_raw_attributes.fetch(attr_name) do <ide> read_attribute_before_type_cast(attr_name) <ide><path>activerecord/test/cases/validations_test.rb <ide> def test_validators <ide> assert_equal 1, Company.validators_on(:name).size <ide> end <ide> <add> def test_numericality_validation_with_mutation <add> Topic.class_eval do <add> attribute :wibble, ActiveRecord::Type::String.new <add> validates_numericality_of :wibble, only_integer: true <add> end <add> <add> topic = Topic.new(wibble: '123-4567') <add> topic.wibble.gsub!('-', '') <add> <add> assert topic.valid? <add> ensure <add> Topic.reset_column_information <add> end <ide> end
3
Javascript
Javascript
add test for spawnsync() env option
8e272dffa24df43b4139768d9c389eb7d239d8d7
<ide><path>test/simple/test-child-process-spawnsync-env.js <add>// Copyright Joyent, Inc. and other Node contributors. <add>// <add>// Permission is hereby granted, free of charge, to any person obtaining a <add>// copy of this software and associated documentation files (the <add>// "Software"), to deal in the Software without restriction, including <add>// without limitation the rights to use, copy, modify, merge, publish, <add>// distribute, sublicense, and/or sell copies of the Software, and to permit <add>// persons to whom the Software is furnished to do so, subject to the <add>// following conditions: <add>// <add>// The above copyright notice and this permission notice shall be included <add>// in all copies or substantial portions of the Software. <add>// <add>// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS <add>// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF <add>// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN <add>// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, <add>// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR <add>// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE <add>// USE OR OTHER DEALINGS IN THE SOFTWARE. <add> <add>var common = require('../common'); <add>var assert = require('assert'); <add>var cp = require('child_process'); <add> <add>if (process.argv[2] === 'child') { <add> console.log(process.env.foo); <add>} else { <add> var expected = 'bar'; <add> var child = cp.spawnSync(process.execPath, [__filename, 'child'], { <add> env: {foo: expected} <add> }); <add> <add> assert.equal(child.stdout.toString().trim(), expected); <add>}
1
Javascript
Javascript
use 0 instead of null in property config
37fc21f1e899622633d6f5e3cb069f1541631874
<ide><path>src/renderers/dom/shared/HTMLDOMPropertyConfig.js <ide> var HTMLDOMPropertyConfig = { <ide> /** <ide> * Standard Properties <ide> */ <del> accept: null, <del> acceptCharset: null, <del> accessKey: null, <del> action: null, <add> accept: 0, <add> acceptCharset: 0, <add> accessKey: 0, <add> action: 0, <ide> allowFullScreen: HAS_BOOLEAN_VALUE, <del> allowTransparency: null, <del> alt: null, <add> allowTransparency: 0, <add> alt: 0, <ide> async: HAS_BOOLEAN_VALUE, <del> autoComplete: null, <add> autoComplete: 0, <ide> // autoFocus is polyfilled/normalized by AutoFocusUtils <ide> // autoFocus: HAS_BOOLEAN_VALUE, <ide> autoPlay: HAS_BOOLEAN_VALUE, <ide> capture: HAS_BOOLEAN_VALUE, <del> cellPadding: null, <del> cellSpacing: null, <del> charSet: null, <del> challenge: null, <add> cellPadding: 0, <add> cellSpacing: 0, <add> charSet: 0, <add> challenge: 0, <ide> checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, <del> cite: null, <del> classID: null, <del> className: null, <add> cite: 0, <add> classID: 0, <add> className: 0, <ide> cols: HAS_POSITIVE_NUMERIC_VALUE, <del> colSpan: null, <del> content: null, <del> contentEditable: null, <del> contextMenu: null, <add> colSpan: 0, <add> content: 0, <add> contentEditable: 0, <add> contextMenu: 0, <ide> controls: HAS_BOOLEAN_VALUE, <del> coords: null, <del> crossOrigin: null, <del> data: null, // For `<object />` acts as `src`. <del> dateTime: null, <add> coords: 0, <add> crossOrigin: 0, <add> data: 0, // For `<object />` acts as `src`. <add> dateTime: 0, <ide> default: HAS_BOOLEAN_VALUE, <ide> defer: HAS_BOOLEAN_VALUE, <del> dir: null, <add> dir: 0, <ide> disabled: HAS_BOOLEAN_VALUE, <ide> download: HAS_OVERLOADED_BOOLEAN_VALUE, <del> draggable: null, <del> encType: null, <del> form: null, <del> formAction: null, <del> formEncType: null, <del> formMethod: null, <add> draggable: 0, <add> encType: 0, <add> form: 0, <add> formAction: 0, <add> formEncType: 0, <add> formMethod: 0, <ide> formNoValidate: HAS_BOOLEAN_VALUE, <del> formTarget: null, <del> frameBorder: null, <del> headers: null, <del> height: null, <add> formTarget: 0, <add> frameBorder: 0, <add> headers: 0, <add> height: 0, <ide> hidden: HAS_BOOLEAN_VALUE, <del> high: null, <del> href: null, <del> hrefLang: null, <del> htmlFor: null, <del> httpEquiv: null, <del> icon: null, <del> id: null, <del> inputMode: null, <del> integrity: null, <del> is: null, <del> keyParams: null, <del> keyType: null, <del> kind: null, <del> label: null, <del> lang: null, <del> list: null, <add> high: 0, <add> href: 0, <add> hrefLang: 0, <add> htmlFor: 0, <add> httpEquiv: 0, <add> icon: 0, <add> id: 0, <add> inputMode: 0, <add> integrity: 0, <add> is: 0, <add> keyParams: 0, <add> keyType: 0, <add> kind: 0, <add> label: 0, <add> lang: 0, <add> list: 0, <ide> loop: HAS_BOOLEAN_VALUE, <del> low: null, <del> manifest: null, <del> marginHeight: null, <del> marginWidth: null, <del> max: null, <del> maxLength: null, <del> media: null, <del> mediaGroup: null, <del> method: null, <del> min: null, <del> minLength: null, <add> low: 0, <add> manifest: 0, <add> marginHeight: 0, <add> marginWidth: 0, <add> max: 0, <add> maxLength: 0, <add> media: 0, <add> mediaGroup: 0, <add> method: 0, <add> min: 0, <add> minLength: 0, <ide> // Caution; `option.selected` is not updated if `select.multiple` is <ide> // disabled with `removeAttribute`. <ide> multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, <ide> muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, <del> name: null, <del> nonce: null, <add> name: 0, <add> nonce: 0, <ide> noValidate: HAS_BOOLEAN_VALUE, <ide> open: HAS_BOOLEAN_VALUE, <del> optimum: null, <del> pattern: null, <del> placeholder: null, <del> poster: null, <del> preload: null, <del> profile: null, <del> radioGroup: null, <add> optimum: 0, <add> pattern: 0, <add> placeholder: 0, <add> poster: 0, <add> preload: 0, <add> profile: 0, <add> radioGroup: 0, <ide> readOnly: HAS_BOOLEAN_VALUE, <del> rel: null, <add> rel: 0, <ide> required: HAS_BOOLEAN_VALUE, <ide> reversed: HAS_BOOLEAN_VALUE, <del> role: null, <add> role: 0, <ide> rows: HAS_POSITIVE_NUMERIC_VALUE, <ide> rowSpan: HAS_NUMERIC_VALUE, <del> sandbox: null, <del> scope: null, <add> sandbox: 0, <add> scope: 0, <ide> scoped: HAS_BOOLEAN_VALUE, <del> scrolling: null, <add> scrolling: 0, <ide> seamless: HAS_BOOLEAN_VALUE, <ide> selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE, <del> shape: null, <add> shape: 0, <ide> size: HAS_POSITIVE_NUMERIC_VALUE, <del> sizes: null, <add> sizes: 0, <ide> span: HAS_POSITIVE_NUMERIC_VALUE, <del> spellCheck: null, <del> src: null, <del> srcDoc: null, <del> srcLang: null, <del> srcSet: null, <add> spellCheck: 0, <add> src: 0, <add> srcDoc: 0, <add> srcLang: 0, <add> srcSet: 0, <ide> start: HAS_NUMERIC_VALUE, <del> step: null, <del> style: null, <del> summary: null, <del> tabIndex: null, <del> target: null, <del> title: null, <add> step: 0, <add> style: 0, <add> summary: 0, <add> tabIndex: 0, <add> target: 0, <add> title: 0, <ide> // Setting .type throws on non-<input> tags <del> type: null, <del> useMap: null, <add> type: 0, <add> useMap: 0, <ide> value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS, <del> width: null, <del> wmode: null, <del> wrap: null, <add> width: 0, <add> wmode: 0, <add> wrap: 0, <ide> <ide> /** <ide> * RDFa Properties <ide> */ <del> about: null, <del> datatype: null, <del> inlist: null, <del> prefix: null, <add> about: 0, <add> datatype: 0, <add> inlist: 0, <add> prefix: 0, <ide> // property is also supported for OpenGraph in meta tags. <del> property: null, <del> resource: null, <del> typeof: null, <del> vocab: null, <add> property: 0, <add> resource: 0, <add> typeof: 0, <add> vocab: 0, <ide> <ide> /** <ide> * Non-standard Properties <ide> */ <ide> // autoCapitalize and autoCorrect are supported in Mobile Safari for <ide> // keyboard hints. <del> autoCapitalize: null, <del> autoCorrect: null, <add> autoCapitalize: 0, <add> autoCorrect: 0, <ide> // autoSave allows WebKit/Blink to persist values of input fields on page reloads <del> autoSave: null, <add> autoSave: 0, <ide> // color is for Safari mask-icon link <del> color: null, <add> color: 0, <ide> // itemProp, itemScope, itemType are for <ide> // Microdata support. See http://schema.org/docs/gs.html <del> itemProp: null, <add> itemProp: 0, <ide> itemScope: HAS_BOOLEAN_VALUE, <del> itemType: null, <add> itemType: 0, <ide> // itemID and itemRef are for Microdata support as well but <ide> // only specified in the WHATWG spec document. See <ide> // https://html.spec.whatwg.org/multipage/microdata.html#microdata-dom-api <del> itemID: null, <del> itemRef: null, <add> itemID: 0, <add> itemRef: 0, <ide> // results show looking glass icon and recent searches on input <ide> // search fields in WebKit/Blink <del> results: null, <add> results: 0, <ide> // IE-only attribute that specifies security restrictions on an iframe <ide> // as an alternative to the sandbox attribute on IE<10 <del> security: null, <add> security: 0, <ide> // IE-only attribute that controls focus behavior <del> unselectable: null, <add> unselectable: 0, <ide> }, <ide> DOMAttributeNames: { <ide> acceptCharset: 'accept-charset', <ide><path>src/renderers/dom/shared/SVGDOMPropertyConfig.js <ide> var NS = { <ide> <ide> var ATTRS = { <ide> accentHeight: 'accent-height', <del> accumulate: null, <del> additive: null, <add> accumulate: 0, <add> additive: 0, <ide> alignmentBaseline: 'alignment-baseline', <ide> allowReorder: 'allowReorder', <del> alphabetic: null, <del> amplitude: null, <add> alphabetic: 0, <add> amplitude: 0, <ide> arabicForm: 'arabic-form', <del> ascent: null, <add> ascent: 0, <ide> attributeName: 'attributeName', <ide> attributeType: 'attributeType', <ide> autoReverse: 'autoReverse', <del> azimuth: null, <add> azimuth: 0, <ide> baseFrequency: 'baseFrequency', <ide> baseProfile: 'baseProfile', <ide> baselineShift: 'baseline-shift', <del> bbox: null, <del> begin: null, <del> bias: null, <del> by: null, <add> bbox: 0, <add> begin: 0, <add> bias: 0, <add> by: 0, <ide> calcMode: 'calcMode', <ide> capHeight: 'cap-height', <del> class: null, <del> clip: null, <add> class: 0, <add> clip: 0, <ide> clipPath: 'clip-path', <ide> clipRule: 'clip-rule', <ide> clipPathUnits: 'clipPathUnits', <del> color: null, <add> color: 0, <ide> colorInterpolation: 'color-interpolation', <ide> colorInterpolationFilters: 'color-interpolation-filters', <ide> colorProfile: 'color-profile', <ide> colorRendering: 'color-rendering', <ide> contentScriptType: 'contentScriptType', <ide> contentStyleType: 'contentStyleType', <del> cursor: null, <del> cx: null, <del> cy: null, <del> d: null, <del> decelerate: null, <del> descent: null, <add> cursor: 0, <add> cx: 0, <add> cy: 0, <add> d: 0, <add> decelerate: 0, <add> descent: 0, <ide> diffuseConstant: 'diffuseConstant', <del> direction: null, <del> display: null, <del> divisor: null, <add> direction: 0, <add> display: 0, <add> divisor: 0, <ide> dominantBaseline: 'dominant-baseline', <del> dur: null, <del> dx: null, <del> dy: null, <add> dur: 0, <add> dx: 0, <add> dy: 0, <ide> edgeMode: 'edgeMode', <del> elevation: null, <add> elevation: 0, <ide> enableBackground: 'enable-background', <del> end: null, <del> exponent: null, <add> end: 0, <add> exponent: 0, <ide> externalResourcesRequired: 'externalResourcesRequired', <del> fill: null, <add> fill: 0, <ide> fillOpacity: 'fill-opacity', <ide> fillRule: 'fill-rule', <del> filter: null, <add> filter: 0, <ide> filterRes: 'filterRes', <ide> filterUnits: 'filterUnits', <ide> floodColor: 'flood-color', <ide> var ATTRS = { <ide> fontStyle: 'font-style', <ide> fontVariant: 'font-variant', <ide> fontWeight: 'font-weight', <del> format: null, <del> from: null, <del> fx: null, <del> fy: null, <del> g1: null, <del> g2: null, <add> format: 0, <add> from: 0, <add> fx: 0, <add> fy: 0, <add> g1: 0, <add> g2: 0, <ide> glyphName: 'glyph-name', <ide> glyphOrientationHorizontal: 'glyph-orientation-horizontal', <ide> glyphOrientationVertical: 'glyph-orientation-vertical', <ide> glyphRef: 'glyphRef', <ide> gradientTransform: 'gradientTransform', <ide> gradientUnits: 'gradientUnits', <del> hanging: null, <del> height: null, <add> hanging: 0, <add> height: 0, <ide> horizAdvX: 'horiz-adv-x', <ide> horizOriginX: 'horiz-origin-x', <del> id: null, <del> ideographic: null, <add> id: 0, <add> ideographic: 0, <ide> imageRendering: 'image-rendering', <del> in: null, <del> in2: null, <del> intercept: null, <del> k: null, <del> k1: null, <del> k2: null, <del> k3: null, <del> k4: null, <add> in: 0, <add> in2: 0, <add> intercept: 0, <add> k: 0, <add> k1: 0, <add> k2: 0, <add> k3: 0, <add> k4: 0, <ide> kernelMatrix: 'kernelMatrix', <ide> kernelUnitLength: 'kernelUnitLength', <del> kerning: null, <add> kerning: 0, <ide> keyPoints: 'keyPoints', <ide> keySplines: 'keySplines', <ide> keyTimes: 'keyTimes', <del> lang: null, <add> lang: 0, <ide> lengthAdjust: 'lengthAdjust', <ide> letterSpacing: 'letter-spacing', <ide> lightingColor: 'lighting-color', <ide> limitingConeAngle: 'limitingConeAngle', <del> local: null, <add> local: 0, <ide> markerEnd: 'marker-end', <ide> markerMid: 'marker-mid', <ide> markerStart: 'marker-start', <ide> markerHeight: 'markerHeight', <ide> markerUnits: 'markerUnits', <ide> markerWidth: 'markerWidth', <del> mask: null, <add> mask: 0, <ide> maskContentUnits: 'maskContentUnits', <ide> maskUnits: 'maskUnits', <del> mathematical: null, <del> max: null, <del> media: null, <del> method: null, <del> min: null, <del> mode: null, <del> name: null, <add> mathematical: 0, <add> max: 0, <add> media: 0, <add> method: 0, <add> min: 0, <add> mode: 0, <add> name: 0, <ide> numOctaves: 'numOctaves', <del> offset: null, <del> opacity: null, <del> operator: null, <del> order: null, <del> orient: null, <del> orientation: null, <del> origin: null, <del> overflow: null, <add> offset: 0, <add> opacity: 0, <add> operator: 0, <add> order: 0, <add> orient: 0, <add> orientation: 0, <add> origin: 0, <add> overflow: 0, <ide> overlinePosition: 'overline-position', <ide> overlineThickness: 'overline-thickness', <ide> paintOrder: 'paint-order', <ide> var ATTRS = { <ide> patternTransform: 'patternTransform', <ide> patternUnits: 'patternUnits', <ide> pointerEvents: 'pointer-events', <del> points: null, <add> points: 0, <ide> pointsAtX: 'pointsAtX', <ide> pointsAtY: 'pointsAtY', <ide> pointsAtZ: 'pointsAtZ', <ide> preserveAlpha: 'preserveAlpha', <ide> preserveAspectRatio: 'preserveAspectRatio', <ide> primitiveUnits: 'primitiveUnits', <del> r: null, <del> radius: null, <add> r: 0, <add> radius: 0, <ide> refX: 'refX', <ide> refY: 'refY', <ide> renderingIntent: 'rendering-intent', <ide> repeatCount: 'repeatCount', <ide> repeatDur: 'repeatDur', <ide> requiredExtensions: 'requiredExtensions', <ide> requiredFeatures: 'requiredFeatures', <del> restart: null, <del> result: null, <del> rotate: null, <del> rx: null, <del> ry: null, <del> scale: null, <del> seed: null, <add> restart: 0, <add> result: 0, <add> rotate: 0, <add> rx: 0, <add> ry: 0, <add> scale: 0, <add> seed: 0, <ide> shapeRendering: 'shape-rendering', <del> slope: null, <del> spacing: null, <add> slope: 0, <add> spacing: 0, <ide> specularConstant: 'specularConstant', <ide> specularExponent: 'specularExponent', <del> speed: null, <add> speed: 0, <ide> spreadMethod: 'spreadMethod', <ide> startOffset: 'startOffset', <ide> stdDeviation: 'stdDeviation', <del> stemh: null, <del> stemv: null, <add> stemh: 0, <add> stemv: 0, <ide> stitchTiles: 'stitchTiles', <ide> stopColor: 'stop-color', <ide> stopOpacity: 'stop-opacity', <ide> strikethroughPosition: 'strikethrough-position', <ide> strikethroughThickness: 'strikethrough-thickness', <del> string: null, <del> stroke: null, <add> string: 0, <add> stroke: 0, <ide> strokeDasharray: 'stroke-dasharray', <ide> strokeDashoffset: 'stroke-dashoffset', <ide> strokeLinecap: 'stroke-linecap', <ide> strokeLinejoin: 'stroke-linejoin', <ide> strokeMiterlimit: 'stroke-miterlimit', <ide> strokeOpacity: 'stroke-opacity', <ide> strokeWidth: 'stroke-width', <del> style: null, <add> style: 0, <ide> surfaceScale: 'surfaceScale', <ide> systemLanguage: 'systemLanguage', <ide> tableValues: 'tableValues', <del> target: null, <add> target: 0, <ide> targetX: 'targetX', <ide> targetY: 'targetY', <ide> textAnchor: 'text-anchor', <ide> textDecoration: 'text-decoration', <ide> textRendering: 'text-rendering', <ide> textLength: 'textLength', <del> to: null, <del> transform: null, <del> type: null, <del> u1: null, <del> u2: null, <add> to: 0, <add> transform: 0, <add> type: 0, <add> u1: 0, <add> u2: 0, <ide> underlinePosition: 'underline-position', <ide> underlineThickness: 'underline-thickness', <del> unicode: null, <add> unicode: 0, <ide> unicodeBidi: 'unicode-bidi', <ide> unicodeRange: 'unicode-range', <ide> unitsPerEm: 'units-per-em', <ide> vAlphabetic: 'v-alphabetic', <ide> vHanging: 'v-hanging', <ide> vIdeographic: 'v-ideographic', <ide> vMathematical: 'v-mathematical', <del> values: null, <del> version: null, <add> values: 0, <add> version: 0, <ide> vertAdvY: 'vert-adv-y', <ide> vertOriginX: 'vert-origin-x', <ide> vertOriginY: 'vert-origin-y', <ide> viewBox: 'viewBox', <ide> viewTarget: 'viewTarget', <del> visibility: null, <del> width: null, <del> widths: null, <add> visibility: 0, <add> width: 0, <add> widths: 0, <ide> wordSpacing: 'word-spacing', <ide> writingMode: 'writing-mode', <del> x: null, <add> x: 0, <ide> xHeight: 'x-height', <del> x1: null, <del> x2: null, <add> x1: 0, <add> x2: 0, <ide> xChannelSelector: 'xChannelSelector', <ide> xlinkActuate: 'xlink:actuate', <ide> xlinkArcrole: 'xlink:arcrole', <ide> var ATTRS = { <ide> xmlBase: 'xml:base', <ide> xmlLang: 'xml:lang', <ide> xmlSpace: 'xml:space', <del> y: null, <del> y1: null, <del> y2: null, <add> y: 0, <add> y1: 0, <add> y2: 0, <ide> yChannelSelector: 'yChannelSelector', <del> z: null, <add> z: 0, <ide> zoomAndPan: 'zoomAndPan', <ide> }; <ide> <ide> var SVGDOMPropertyConfig = { <ide> }; <ide> <ide> Object.keys(ATTRS).map((key) => { <del> SVGDOMPropertyConfig.Properties[key] = null; <add> SVGDOMPropertyConfig.Properties[key] = 0; <ide> if (ATTRS[key]) { <ide> SVGDOMPropertyConfig.DOMAttributeNames[key] = ATTRS[key]; <ide> }
2
Text
Text
convert table in test doc to markdown table
85939bd251bc12e7e376fdafde1ce644f8a8013c
<ide><path>test/README.md <ide> On how to run tests in this directory, see <ide> <ide> ## Test Directories <ide> <del><table> <del> <thead> <del> <tr> <del> <th>Directory</th> <del> <th>Runs on CI</th> <del> <th>Purpose</th> <del> </tr> <del> </thead> <del> <tbody> <del> <tr> <del> <td>abort</td> <del> <td>No</td> <del> <td> <del> Tests for when the <code>--abort-on-uncaught-exception</code> <del> flag is used. <del> </td> <del> </tr> <del> <tr> <del> <td>addons</td> <del> <td>Yes</td> <del> <td> <del> Tests for <a href="https://nodejs.org/api/addons.html">addon</a> <del> functionality along with some tests that require an addon to function <del> properly. <del> </td> <del> </tr> <del> <tr> <del> <td>cctest</td> <del> <td>Yes</td> <del> <td> <del> C++ test that is run as part of the build process. <del> </td> <del> </tr> <del> <tr> <del> <td>common</td> <del> <td></td> <del> <td> <del> Common modules shared among many tests. <del> <a href="./common/README.md">[Documentation]</a> <del> </td> <del> </tr> <del> <tr> <del> <td>debugger</td> <del> <td>No</td> <del> <td> <del> Tests for <a href="https://nodejs.org/api/debugger.html">debugger</a> <del> functionality along with some tests that require an addon to function <del> properly. <del> </td> <del> </tr> <del> <tr> <del> <td>disabled</td> <del> <td>No</td> <del> <td> <del> Tests that have been disabled from running for various reasons. <del> </td> <del> </tr> <del> <tr> <del> <td>fixtures</td> <del> <td></td> <del> <td>Test fixtures used in various tests throughout the test suite.</td> <del> </tr> <del> <tr> <del> <td>gc</td> <del> <td>No</td> <del> <td>Tests for garbage collection related functionality.</td> <del> </tr> <del> <tr> <del> <td>inspector</td> <del> <td>Yes</td> <del> <td>Tests for the V8 inspector integration.</td> <del> </tr> <del> <tr> <del> <td>internet</td> <del> <td>No</td> <del> <td> <del> Tests that make real outbound connections (mainly networking related <del> modules). Tests for networking related modules may also be present in <del> other directories, but those tests do not make outbound connections. <del> </td> <del> </tr> <del> <tr> <del> <td>known_issues</td> <del> <td>Yes</td> <del> <td> <del> Tests reproducing known issues within the system. All tests inside of <del> this directory are expected to fail consistently. If a test doesn't fail <del> on certain platforms, those should be skipped via `known_issues.status`. <del> </td> <del> </tr> <del> <tr> <del> <td>message</td> <del> <td>Yes</td> <del> <td> <del> Tests for messages that are output for various conditions <del> (<code>console.log</code>, error messages etc.)</td> <del> </tr> <del> <tr> <del> <td>parallel</td> <del> <td>Yes</td> <del> <td>Various tests that are able to be run in parallel.</td> <del> </tr> <del> <tr> <del> <td>pseudo-tty</td> <del> <td>Yes</td> <del> <td>Tests that require stdin/stdout/stderr to be a TTY.</td> <del> </tr> <del> <tr> <del> <td>pummel</td> <del> <td>No</td> <del> <td> <del> Various tests for various modules / system functionality operating <del> under load. <del> </td> <del> </tr> <del> <tr> <del> <td>sequential</td> <del> <td>Yes</td> <del> <td> <del> Various tests that are run sequentially. <del> </td> <del> </tr> <del> <tr> <del> <td>testpy</td> <del> <td></td> <del> <td> <del> Test configuration utility used by various test suites. <del> </td> <del> </tr> <del> <tr> <del> <td>tick-processor</td> <del> <td>No</td> <del> <td> <del> Tests for the V8 tick processor integration. The tests are for the <del> logic in <code>lib/internal/v8_prof_processor.js</code> and <del> <code>lib/internal/v8_prof_polyfill.js</code>. The tests confirm that <del> the profile processor packages the correct set of scripts from V8 and <del> introduces the correct platform specific logic. <del> </td> <del> </tr> <del> <tr> <del> <td>timers</td> <del> <td>No</td> <del> <td> <del> Tests for <del> <a href="https://nodejs.org/api/timers.html">timing utilities</a> <del> (<code>setTimeout</code> and <code>setInterval</code>). <del> </td> <del> </tr> <del> </tbody> <del></table> <add>|Directory |Runs on CI |Purpose | <add>|-------------------|---------------|---------------| <add>|abort |No |Tests for when the ``` --abort-on-uncaught-exception ``` flag is used.| <add>|addons |Yes |Tests for [addon](https://nodejs.org/api/addons.html) functionality along with some tests that require an addon to function properly.| <add>|cctest |Yes |C++ test that is run as part of the build process.| <add>|common | |Common modules shared among many tests. [Documentation](./common/README.md)| <add>|debugger |No |Tests for [debugger](https://nodejs.org/api/debugger.html)functionality along with some tests that require an addon to function properly.| <add>|disabled |No |Tests that have been disabled from running for various reasons.| <add>|fixtures | |Test fixtures used in various tests throughout the test suite.| <add>|gc |No |Tests for garbage collection related functionality.| <add>|inspector |Yes |Tests for the V8 inspector integration.| <add>|internet |No |Tests that make real outbound connections (mainly networking related modules). Tests for networking related modules may also be present in other directories, but those tests do not make outbound connections.| <add>|known_issues |Yes |Tests reproducing known issues within the system. All tests inside of this directory are expected to fail consistently. If a test doesn't fail on certain platforms, those should be skipped via `known_issues.status`.| <add>|message |Yes |Tests for messages that are output for various conditions (```console.log```, error messages etc.)| <add>|parallel |Yes |Various tests that are able to be run in parallel.| <add>|pseudo-tty |Yes |Tests that require stdin/stdout/stderr to be a TTY.| <add>|pummel |No |Various tests for various modules / system functionality operating under load.| <add>|sequential |Yes |Various tests that are run sequentially.| <add>|testpy | |Test configuration utility used by various test suites.| <add>|tick-processor |No |Tests for the V8 tick processor integration. The tests are for the logic in ```lib/internal/v8_prof_processor.js``` and ```lib/internal/v8_prof_polyfill.js```. The tests confirm that the profile processor packages the correct set of scripts from V8 and introduces the correct platform specific logic.| <add>|timers |No |Tests for [timing utilities](https://nodejs.org/api/timers.html) (```setTimeout``` and ```setInterval```).|
1
PHP
PHP
resolve exception namespace
e40d9bc9638d0951c1b82c98ceab800bd5fbabf0
<ide><path>src/Core/Configure.php <ide> use Cake\Cache\Cache; <ide> use Cake\Configure\ConfigEngineInterface; <ide> use Cake\Configure\Engine\PhpConfig; <del>use Cake\Error; <add>use Cake\Error\Exception; <ide> use Cake\Utility\Hash; <ide> <ide> /** <ide> public static function load($key, $config = 'default', $merge = true) { <ide> public static function dump($key, $config = 'default', $keys = []) { <ide> $engine = static::_getEngine($config); <ide> if (!$engine) { <del> throw new Error\Exception(sprintf('There is no "%s" config engine.', $config)); <add> throw new Exception(sprintf('There is no "%s" config engine.', $config)); <ide> } <ide> if (!method_exists($engine, 'dump')) { <del> throw new Error\Exception(sprintf('The "%s" config engine, does not have a dump() method.', $config)); <add> throw new Exception(sprintf('The "%s" config engine, does not have a dump() method.', $config)); <ide> } <ide> $values = static::$_values; <ide> if (!empty($keys) && is_array($keys)) { <ide><path>src/Core/InstanceConfigTrait.php <ide> */ <ide> namespace Cake\Core; <ide> <del>use Cake\Error; <add>use Cake\Error\Exception; <ide> use Cake\Utility\Hash; <ide> <ide> /** <ide> protected function _configWrite($key, $value, $merge = null) { <ide> <ide> foreach ($stack as $k) { <ide> if (!is_array($update)) { <del> throw new Error\Exception(sprintf('Cannot set %s value', $key)); <add> throw new Exception(sprintf('Cannot set %s value', $key)); <ide> } <ide> <ide> if (!isset($update[$k])) { <ide> protected function _configDelete($key) { <ide> <ide> foreach ($stack as $i => $k) { <ide> if (!is_array($update)) { <del> throw new Error\Exception(sprintf('Cannot unset %s value', $key)); <add> throw new Exception(sprintf('Cannot unset %s value', $key)); <ide> } <ide> <ide> if (!isset($update[$k])) { <ide><path>src/Core/StaticConfigTrait.php <ide> */ <ide> namespace Cake\Core; <ide> <del>use Cake\Error; <add>use Cake\Error\Exception; <ide> <ide> /** <ide> * A trait that provides a set of static methods to manage configuration <ide> public static function config($key, $config = null) { <ide> return; <ide> } <ide> if (isset(static::$_config[$key])) { <del> throw new Error\Exception(sprintf('Cannot reconfigure existing key "%s"', $key)); <add> throw new Exception(sprintf('Cannot reconfigure existing key "%s"', $key)); <ide> } <ide> if (is_object($config)) { <ide> $config = ['className' => $config]; <ide><path>src/I18n/I18n.php <ide> use Cake\Core\App; <ide> use Cake\Core\Configure; <ide> use Cake\Core\Plugin; <del>use Cake\Error; <add>use Cake\Error\Exception; <ide> use Cake\Network\Request; <ide> use Cake\Network\Session; <ide> use Cake\Utility\Hash; <ide> public static function translate($singular, $plural = null, $domain = null, $cat <ide> $domain = static::$defaultDomain; <ide> } <ide> if ($domain === '') { <del> throw new Error\Exception('You cannot use "" as a domain.'); <add> throw new Exception('You cannot use "" as a domain.'); <ide> } <ide> <ide> $_this->domain = $domain . '_' . $_this->l10n->lang; <ide><path>src/Utility/Debugger.php <ide> namespace Cake\Utility; <ide> <ide> use Cake\Core\Configure; <del>use Cake\Error; <add>use Cake\Error\Exception; <ide> use Cake\Log\Log; <ide> <ide> /** <ide> public static function outputAs($format = null) { <ide> return $self->_outputFormat; <ide> } <ide> if ($format !== false && !isset($self->_templates[$format])) { <del> throw new Error\Exception('Invalid Debugger output format.'); <add> throw new Exception('Invalid Debugger output format.'); <ide> } <ide> $self->_outputFormat = $format; <ide> } <ide><path>src/Utility/Number.php <ide> */ <ide> namespace Cake\Utility; <ide> <del>use Cake\Error; <add>use Cake\Error\Exception; <ide> <ide> /** <ide> * Number helper library. <ide> public static function fromReadableSize($size, $default = false) { <ide> if ($default !== false) { <ide> return $default; <ide> } <del> throw new Error\Exception('No unit type.'); <add> throw new Exception('No unit type.'); <ide> } <ide> <ide> /** <ide><path>src/Utility/Security.php <ide> namespace Cake\Utility; <ide> <ide> use Cake\Core\Configure; <del>use Cake\Error; <add>use Cake\Error\Exception; <ide> <ide> /** <ide> * Security Library contains utility methods related to security <ide> public static function setHash($hash) { <ide> */ <ide> public static function setCost($cost) { <ide> if ($cost < 4 || $cost > 31) { <del> throw new Error\Exception(vsprintf( <add> throw new Exception(vsprintf( <ide> 'Invalid value, cost must be between %s and %s', <ide> array(4, 31) <ide> )); <ide> public static function setCost($cost) { <ide> */ <ide> public static function rijndael($text, $key, $operation) { <ide> if (empty($key)) { <del> throw new Error\Exception('You cannot use an empty key for Security::rijndael()'); <add> throw new Exception('You cannot use an empty key for Security::rijndael()'); <ide> } <ide> if (empty($operation) || !in_array($operation, array('encrypt', 'decrypt'))) { <del> throw new Error\Exception('You must specify the operation for Security::rijndael(), either encrypt or decrypt'); <add> throw new Exception('You must specify the operation for Security::rijndael(), either encrypt or decrypt'); <ide> } <ide> if (strlen($key) < 32) { <del> throw new Error\Exception('You must use a key larger than 32 bytes for Security::rijndael()'); <add> throw new Exception('You must use a key larger than 32 bytes for Security::rijndael()'); <ide> } <ide> $algorithm = MCRYPT_RIJNDAEL_256; <ide> $mode = MCRYPT_MODE_CBC; <ide> protected static function _crypt($password, $salt = false) { <ide> } <ide> <ide> if ($salt === true || strpos($salt, '$2y$') !== 0 || strlen($salt) < 29) { <del> throw new Error\Exception(sprintf( <add> throw new Exception(sprintf( <ide> 'Invalid salt: %s for blowfish Please visit http://www.php.net/crypt and read the appropriate section for building blowfish salts.', <ide> $salt <ide> )); <ide> public static function encrypt($plain, $key, $hmacSalt = null) { <ide> */ <ide> protected static function _checkKey($key, $method) { <ide> if (strlen($key) < 32) { <del> throw new Error\Exception(sprintf('Invalid key for %s, key must be at least 256 bits (32 bytes) long.', $method)); <add> throw new Exception(sprintf('Invalid key for %s, key must be at least 256 bits (32 bytes) long.', $method)); <ide> } <ide> } <ide> <ide> protected static function _checkKey($key, $method) { <ide> public static function decrypt($cipher, $key, $hmacSalt = null) { <ide> self::_checkKey($key, 'decrypt()'); <ide> if (empty($cipher)) { <del> throw new Error\Exception('The data to decrypt cannot be empty.'); <add> throw new Exception('The data to decrypt cannot be empty.'); <ide> } <ide> if ($hmacSalt === null) { <ide> $hmacSalt = Configure::read('Security.salt');
7
Python
Python
do more documentation formating
f6f798504bcedd091562d0d468ca37290aff9ce5
<ide><path>numpy/core/fromnumeric.py <ide> def _wrapit(obj, method, *args, **kwds): <ide> <ide> <ide> def take(a, indices, axis=None, out=None, mode='raise'): <del> """Return an array with values pulled from the given array at the given <del> indices. <add> """Return an array formed from the elements of a at the given indices. <ide> <ide> This function does the same thing as "fancy" indexing; however, it can <ide> be easier to use if you need to specify a given axis. <ide> <del> :Parameters: <del> - `a` : array <del> The source array <del> - `indices` : int array <del> The indices of the values to extract. <del> - `axis` : None or int, optional (default=None) <del> The axis over which to select values. None signifies that the <del> operation should be performed over the flattened array. <del> - `out` : array, optional <del> If provided, the result will be inserted into this array. It should <del> be of the appropriate shape and dtype. <del> - `mode` : one of 'raise', 'wrap', or 'clip', optional <del> (default='raise') <del> Specifies how out-of-bounds indices will behave. <del> - 'raise' : raise an error <del> - 'wrap' : wrap around <del> - 'clip' : clip to the range <add> *Parameters*: <ide> <del> :Returns: <del> - `subarray` : array <add> a : array <add> The source array <add> <add> indices : int array <add> The indices of the values to extract. <add> <add> axis : {None, int}, optional <add> The axis over which to select values. None signifies that the <add> operation should be performed over the flattened array. <add> <add> out : {None, array}, optional <add> If provided, the result will be inserted into this array. It should <add> be of the appropriate shape and dtype. <add> <add> mode : {'raise', 'wrap', 'clip'}, optional <add> Specifies how out-of-bounds indices will behave. <add> 'raise' -- raise an error <add> 'wrap' -- wrap around <add> 'clip' -- clip to the range <add> <add> *Returns*: <add> <add> subarray : array <add> The returned array has the same type as a. <ide> <del> :See also: <del> - numpy.ndarray.take() : equivalent method <add> *See Also*: <add> <add> `ndarray.take` : equivalent method <ide> <ide> """ <ide> try: <ide> def take(a, indices, axis=None, out=None, mode='raise'): <ide> <ide> # not deprecated --- copy if necessary, view otherwise <ide> def reshape(a, newshape, order='C'): <del> """Return an array that uses the data of the given array, but with a new <del> shape. <add> """Returns an array containing the data of a, but with a new shape. <add> <add> *Parameters*: <add> <add> a : array <add> Array to be reshaped. <add> <add> newshape : shape tuple or int <add> The new shape should be compatible with the original shape. If an <add> integer, then the result will be a 1D array of that length. <add> <add> order : {'C', 'FORTRAN'}, optional <add> Determines whether the array data should be viewed as in C <add> (row-major) order or FORTRAN (column-major) order. <add> <add> *Returns*: <ide> <del> :Parameters: <del> - `a` : array <del> - `newshape` : shape tuple or int <del> The new shape should be compatible with the original shape. If an <del> integer, then the result will be a 1D array of that length. <del> - `order` : 'C' or 'FORTRAN', optional (default='C') <del> Whether the array data should be viewed as in C (row-major) order or <del> FORTRAN (column-major) order. <add> reshaped_array : array <add> This will be a new view object if possible; otherwise, it will <add> return a copy. <ide> <del> :Returns: <del> - `reshaped_array` : array <del> This will be a new view object if possible; otherwise, it will <del> return a copy. <add> *See Also*: <ide> <del> :SeeAlso: <del> - numpy.ndarray.reshape() : Equivalent method. <add> `numpy.ndarray.reshape` : Equivalent method. <ide> <ide> """ <ide> try: <ide> def reshape(a, newshape, order='C'): <ide> def choose(a, choices, out=None, mode='raise'): <ide> """Use an index array to construct a new array from a set of choices. <ide> <del> Given an array of integers in {0, 1, ..., n-1} and a set of n choice <del> arrays, this function will create a new array that merges each of the <del> choice arrays. Where a value in `a` is i, then the new array will have <del> the value that choices[i] contains in the same place. <del> <del> :Parameters: <del> - `a` : int array <del> This array must contain integers in [0, n-1], where n is the number <del> of choices. <del> - `choices` : sequence of arrays <del> Each of the choice arrays should have the same shape as the index <del> array. <del> - `out` : array, optional <del> If provided, the result will be inserted into this array. It should <del> be of the appropriate shape and dtype <del> - `mode` : one of 'raise', 'wrap', or 'clip', optional (default='raise') <del> Specifies how out-of-bounds indices will behave. <del> - 'raise' : raise an error <del> - 'wrap' : wrap around <del> - 'clip' : clip to the range <del> <del> :Returns: <del> - `merged_array` : array <del> <del> :SeeAlso: <del> - numpy.ndarray.choose() : equivalent method <del> <del> Examples <del> --------- <del> <del> >>> choices = [[0, 1, 2, 3], [10, 11, 12, 13], <del> ... [20, 21, 22, 23], [30, 31, 32, 33]] <del> >>> choose([2, 3, 1, 0], choices) <del> array([20, 31, 12, 3]) <del> >>> choose([2, 4, 1, 0], choices, mode='clip') <del> array([20, 31, 12, 3]) <del> >>> choose([2, 4, 1, 0], choices, mode='wrap') <del> array([20, 1, 12, 3]) <add> Given an array of integers in {0, 1, ..., n-1} and a set of n choice arrays, <add> this function will create a new array that merges each of the choice arrays. <add> Where a value in `a` is i, then the new array will have the value that <add> choices[i] contains in the same place. <add> <add> *Parameters*: <add> <add> a : int array <add> This array must contain integers in [0, n-1], where n is the number <add> of choices. <add> <add> choices : sequence of arrays <add> Each of the choice arrays should have the same shape as the index <add> array. <add> <add> out : array, optional <add> If provided, the result will be inserted into this array. It should <add> be of the appropriate shape and dtype <add> <add> mode : {'raise', 'wrap', 'clip'}, optional <add> Specifies how out-of-bounds indices will behave. <add> 'raise' : raise an error <add> 'wrap' : wrap around <add> 'clip' : clip to the range <add> <add> *Returns*: <add> <add> merged_array : array <add> <add> *See Also*: <add> <add> `numpy.ndarray.choose` : equivalent method <add> <add> *Examples* <add> <add> >>> choices = [[0, 1, 2, 3], [10, 11, 12, 13], <add> ... [20, 21, 22, 23], [30, 31, 32, 33]] <add> >>> choose([2, 3, 1, 0], choices) <add> array([20, 31, 12, 3]) <add> >>> choose([2, 4, 1, 0], choices, mode='clip') <add> array([20, 31, 12, 3]) <add> >>> choose([2, 4, 1, 0], choices, mode='wrap') <add> array([20, 1, 12, 3]) <ide> <ide> """ <ide> try: <ide> def choose(a, choices, out=None, mode='raise'): <ide> def repeat(a, repeats, axis=None): <ide> """Repeat elements of an array. <ide> <del> :Parameters: <del> - `a` : array <del> - `repeats` : int or int array <del> The number of repetitions for each element. If a plain integer, then <del> it is applied to all elements. If an array, it needs to be of the <del> same length as the chosen axis. <del> - `axis` : None or int, optional (default=None) <del> The axis along which to repeat values. If None, then this function <del> will operated on the flattened array `a` and return a similarly flat <del> result. <add> *Parameters*: <ide> <del> :Returns: <del> - `repeated_array` : array <add> a : array <ide> <del> :SeeAlso: <del> - numpy.ndarray.repeat() : equivalent method <add> repeats : int or int array <add> The number of repetitions for each element. If a plain integer, then <add> it is applied to all elements. If an array, it needs to be of the <add> same length as the chosen axis. <ide> <del> Examples <del> -------- <add> axis : {None, int}, optional <add> The axis along which to repeat values. If None, then this function <add> will operated on the flattened array `a` and return a similarly flat <add> result. <ide> <del> >>> repeat([0, 1, 2], 2) <del> array([0, 0, 1, 1, 2, 2]) <del> >>> repeat([0, 1, 2], [2, 3, 4]) <del> array([0, 0, 1, 1, 1, 2, 2, 2, 2]) <add> *Returns*: <add> <add> repeated_array : array <add> <add> *See Also*: <add> <add> `numpy.ndarray.repeat` : equivalent method <add> <add> *Examples* <add> <add> >>> repeat([0, 1, 2], 2) <add> array([0, 0, 1, 1, 2, 2]) <add> >>> repeat([0, 1, 2], [2, 3, 4]) <add> array([0, 0, 1, 1, 1, 2, 2, 2, 2]) <ide> <ide> """ <ide> try: <ide> def repeat(a, repeats, axis=None): <ide> <ide> <ide> def put (a, ind, v, mode='raise'): <del> """Set a[n] = v[n] for all n in ind. If v is shorter than mask it <del> will be repeated as necessary. In particular v can be a scalar or <del> length 1 array. The routine put is the equivalent of the <add> """Set a[n] = v[n] for all n in ind. <add> <add> If v is shorter than mask it will be repeated as necessary. In particular v <add> can be a scalar or length 1 array. The routine put is the equivalent of the <ide> following (although the loop is in C for speed): <ide> <ide> ind = array(indices, copy=False) <ide> def put (a, ind, v, mode='raise'): <ide> def swapaxes(a, axis1, axis2): <ide> """Return array a with axis1 and axis2 interchanged. <ide> <add> Blah, Blah. <add> <ide> """ <ide> try: <ide> swapaxes = a.swapaxes <ide> def swapaxes(a, axis1, axis2): <ide> <ide> <ide> def transpose(a, axes=None): <del> """Return a view of the array with dimensions permuted according <del> to axes. If axes is None (default) returns array with dimensions <del> reversed. <add> """Return a view of the array with dimensions permuted. <add> <add> Permutes axis according to list axes. If axes is None (default) returns <add> array with dimensions reversed. <ide> <ide> """ <ide> try: <ide> def transpose(a, axes=None): <ide> def sort(a, axis=-1, kind='quicksort', order=None): <ide> """Return copy of 'a' sorted along the given axis. <ide> <del> :Description: <del> <ide> Perform an inplace sort along the given axis using the algorithm <ide> specified by the kind keyword. <ide> <del> :Parameters: <add> *Parameters*: <add> <ide> a : array <ide> Array to be sorted. <del> axis : integer <add> <add> axis : {None, int} optional <ide> Axis along which to sort. None indicates that the flattened <del> array should be used. Default is -1. <del> kind : string <del> Sorting algorithm to use. Possible values are 'quicksort', <del> 'mergesort', or 'heapsort'. Default is 'quicksort'. <del> order : list type or None <del> When a is an array with fields defined, this argument <del> specifies which fields to compare first, second, etc. Not <del> all fields need be specified. <del> <del> :Returns: <add> array should be used. <add> <add> kind : {'quicksort', 'mergesort', 'heapsort'}, optional <add> Sorting algorithm to use. <add> <add> order : {None, list type}, optional <add> When a is an array with fields defined, this argument specifies <add> which fields to compare first, second, etc. Not all fields need be <add> specified. <add> <add> *Returns*: <add> <ide> sorted_array : array of same type as a <ide> <del> :SeeAlso: <del> - argsort : Indirect sort. <del> - lexsort : Indirect stable sort on multiple keys. <del> - searchsorted : Find keys in sorted array. <add> *See Also*: <add> <add> `argsort` : Indirect sort. <ide> <del> Notes <del> ----- <add> `lexsort` : Indirect stable sort on multiple keys. <ide> <del> The various sorts are characterized by average speed, worst case <del> performance, need for work space, and whether they are stable. A <del> stable sort keeps items with the same key in the same relative <del> order. The three available algorithms have the following <del> properties: <add> `searchsorted` : Find keys in sorted array. <ide> <del> +-----------+-------+-------------+------------+-------+ <del> | kind | speed | worst case | work space | stable| <del> +===========+=======+=============+============+=======+ <del> | quicksort | 1 | O(n^2) | 0 | no | <del> +-----------+-------+-------------+------------+-------+ <del> | mergesort | 2 | O(n*log(n)) | ~n/2 | yes | <del> +-----------+-------+-------------+------------+-------+ <del> | heapsort | 3 | O(n*log(n)) | 0 | no | <del> +-----------+-------+-------------+------------+-------+ <add> *Notes* <ide> <del> All the sort algorithms make temporary copies of the data when <del> the sort is not along the last axis. Consequently, sorts along <del> the last axis are faster and use less space than sorts along <del> other axis. <add> The various sorts are characterized by average speed, worst case <add> performance, need for work space, and whether they are stable. A <add> stable sort keeps items with the same key in the same relative <add> order. The three available algorithms have the following <add> properties: <add> <add> +-----------+-------+-------------+------------+-------+ <add> | kind | speed | worst case | work space | stable| <add> +===========+=======+=============+============+=======+ <add> | quicksort | 1 | O(n^2) | 0 | no | <add> +-----------+-------+-------------+------------+-------+ <add> | mergesort | 2 | O(n*log(n)) | ~n/2 | yes | <add> +-----------+-------+-------------+------------+-------+ <add> | heapsort | 3 | O(n*log(n)) | 0 | no | <add> +-----------+-------+-------------+------------+-------+ <add> <add> All the sort algorithms make temporary copies of the data when <add> the sort is not along the last axis. Consequently, sorts along <add> the last axis are faster and use less space than sorts along <add> other axis. <ide> <ide> """ <ide> if axis is None: <ide> def sort(a, axis=-1, kind='quicksort', order=None): <ide> def argsort(a, axis=-1, kind='quicksort', order=None): <ide> """Returns array of indices that index 'a' in sorted order. <ide> <del> Perform an indirect sort along the given axis using the algorithm <del> specified by the kind keyword. It returns an array of indices of the <del> same shape as a that index data along the given axis in sorted order. <add> Perform an indirect sort along the given axis using the algorithm specified <add> by the kind keyword. It returns an array of indices of the same shape as a <add> that index data along the given axis in sorted order. <add> <add> *Parameters*: <ide> <del> :Parameters: <ide> a : array <del> Values that the returned indices should sort. <del> axis : integer <del> Axis to be indirectly sorted. None indicates that the <del> flattened array should be used. Default is -1. <del> kind : string <del> Sorting algorithm to use. Possible values are 'quicksort', <del> 'mergesort', or 'heapsort'. Default is 'quicksort'. <del> order : list type or None <del> When a is an array with fields defined, this argument <del> specifies which fields to compare first, second, etc. Not <del> all fields need be specified. <del> <del> :Returns: <add> Array to be sorted. <add> <add> axis : {None, int} optional <add> Axis along which to sort. None indicates that the flattened <add> array should be used. <add> <add> kind : {'quicksort', 'mergesort', 'heapsort'}, optional <add> Sorting algorithm to use. <add> <add> order : {None, list type}, optional <add> When a is an array with fields defined, this argument specifies <add> which fields to compare first, second, etc. Not all fields need be <add> specified. <add> <add> *Returns*: <add> <ide> indices : integer array <ide> Array of indices that sort 'a' along the specified axis. <ide> <del> :SeeAlso: <del> - lexsort : Indirect stable sort with multiple keys. <del> - sort : Inplace sort. <add> *See Also*: <add> <add> `lexsort` : Indirect stable sort with multiple keys. <add> <add> `sort` : Inplace sort. <ide> <del> Notes <del> ----- <add> *Notes* <ide> <del> The various sorts are characterized by average speed, worst case <del> performance, need for work space, and whether they are stable. A <del> stable sort keeps items with the same key in the same relative <del> order. The three available algorithms have the following <del> properties: <add> The various sorts are characterized by average speed, worst case <add> performance, need for work space, and whether they are stable. A <add> stable sort keeps items with the same key in the same relative <add> order. The three available algorithms have the following <add> properties: <ide> <del> +-----------+-------+-------------+------------+-------+ <del> | kind | speed | worst case | work space | stable| <del> +===========+=======+=============+============+=======+ <del> | quicksort | 1 | O(n^2) | 0 | no | <del> +-----------+-------+-------------+------------+-------+ <del> | mergesort | 2 | O(n*log(n)) | ~n/2 | yes | <del> +-----------+-------+-------------+------------+-------+ <del> | heapsort | 3 | O(n*log(n)) | 0 | no | <del> +-----------+-------+-------------+------------+-------+ <add> +-----------+-------+-------------+------------+-------+ <add> | kind | speed | worst case | work space | stable| <add> +===========+=======+=============+============+=======+ <add> | quicksort | 1 | O(n^2) | 0 | no | <add> +-----------+-------+-------------+------------+-------+ <add> | mergesort | 2 | O(n*log(n)) | ~n/2 | yes | <add> +-----------+-------+-------------+------------+-------+ <add> | heapsort | 3 | O(n*log(n)) | 0 | no | <add> +-----------+-------+-------------+------------+-------+ <ide> <del> All the sort algorithms make temporary copies of the data when <del> the sort is not along the last axis. Consequently, sorts along <del> the last axis are faster and use less space than sorts along <del> other axis. <add> All the sort algorithms make temporary copies of the data when <add> the sort is not along the last axis. Consequently, sorts along <add> the last axis are faster and use less space than sorts along <add> other axis. <ide> <ide> """ <ide> try: <ide> def argsort(a, axis=-1, kind='quicksort', order=None): <ide> <ide> <ide> def argmax(a, axis=None): <del> """Return the indices to the maximum value of the 1-D arrays along <del> the given axis. <add> """Returns array of indices of the maximum values of along the given axis. <add> <add> *Parameters*: <add> <add> a : array <add> Array to look in. <add> <add> axis : {None, integer} <add> If None, the index is into the flattened array, otherwise along <add> the specified axis <add> <add> *Returns*: <add> <add> Array of indices <add> <add> *Examples* <add> <add> >>> a = arange(6).reshape(2,3) <add> >>> argmax(a) <add> 5 <add> >>> argmax(a,0) <add> array([1, 1, 1]) <add> >>> argmax(a,1) <add> array([2, 2]) <ide> <ide> """ <ide> try: <ide> def argmax(a, axis=None): <ide> <ide> <ide> def argmin(a, axis=None): <del> """Return the indices to the minimum value of the 1-D arrays along <del> the given axis. <add> """Return array of indices to the minimum values along the given axis. <add> <add> *Parameters*: <add> <add> a : array <add> Array to look in. <add> <add> axis : {None, integer} <add> If None, the index is into the flattened array, otherwise along <add> the specified axis <add> <add> *Returns*: <add> <add> Array of indices <add> <add> *Examples* <add> <add> >>> a = arange(6).reshape(2,3) <add> >>> argmin(a) <add> 0 <add> >>> argmin(a,0) <add> array([0, 0, 0]) <add> >>> argmin(a,1) <add> array([0, 0]) <ide> <ide> """ <ide> try: <ide> def argmin(a, axis=None): <ide> <ide> <ide> def searchsorted(a, v, side='left'): <del> """Return indices where keys in v should be inserted to maintain <del> order. <del> <del> Find the indices into a sorted array such that if the <del> corresponding keys in v were inserted before the indices the <del> order of a would be preserved. If side='left', then the first <del> such index is returned. If side='right', then the last such index <del> is returned. If there is no such index because the key is out of <del> bounds, then the length of a is returned, i.e., the key would <del> need to be appended. The returned index array has the same shape <del> as v. <del> <del> :Parameters: <add> """Return indices where keys in v should be inserted to maintain order. <add> <add> Find the indices into a sorted array such that if the corresponding keys in <add> v were inserted before the indices the order of a would be preserved. If <add> side='left', then the first such index is returned. If side='right', then <add> the last such index is returned. If there is no such index because the key <add> is out of bounds, then the length of a is returned, i.e., the key would need <add> to be appended. The returned index array has the same shape as v. <add> <add> *Parameters*: <add> <ide> a : 1-d array <del> Array sorted in ascending order. <add> Array must be sorted in ascending order. <add> <ide> v : array or list type <ide> Array of keys to be searched for in a. <del> side : string <del> Possible values are : 'left', 'right'. Default is 'left'. <del> Return the first or last index where the key could be <del> inserted. <ide> <del> :Returns: <add> side : {'left', 'right'}, optional <add> If 'left', the index of the first location where the key could be <add> inserted is found, if 'right', the index of the last such element is <add> returned. If the is no such element, then either 0 or N is returned, <add> where N is the size of the array. <add> <add> *Returns*: <add> <ide> indices : integer array <ide> Array of insertion points with the same shape as v. <ide> <del> :SeeAlso: <del> - sort : Inplace sort. <del> - histogram : Produce histogram from 1-d data. <add> *See Also*: <add> <add> `sort` : Inplace sort. <ide> <del> Notes <del> ----- <add> `histogram` : Produce histogram from 1-d data. <ide> <del> The array a must be 1-d and is assumed to be sorted in ascending <del> order. Searchsorted uses binary search to find the required <del> insertion points. <add> *Notes* <ide> <del> Examples <del> -------- <add> The array a must be 1-d and is assumed to be sorted in ascending <add> order. Searchsorted uses binary search to find the required <add> insertion points. <ide> <del> >>> searchsorted([1,2,3,4,5],[6,4,0]) <del> array([5, 3, 0]) <add> *Examples* <add> <add> >>> searchsorted([1,2,3,4,5],[6,4,0]) <add> array([5, 3, 0]) <ide> <ide> """ <ide> try: <ide> def resize(a, new_shape): <ide> Note that a.resize(new_shape) will fill the array with 0's beyond <ide> current definition of a. <ide> <add> *Parameters*: <add> <add> a : array_like <add> Array to be reshaped. <add> <add> new_shape : tuple <add> Shape of the new array. <add> <add> *Returns*: <add> <add> new_array : array <add> The new array is formed from the data in the old array, repeated if <add> necessary to fill out the required number of elements, with the new <add> shape. <add> <ide> """ <ide> <ide> if isinstance(new_shape, (int, nt.integer)): <ide> def resize(a, new_shape): <ide> def squeeze(a): <ide> """Remove single-dimensional entries from the shape of a. <ide> <del> Examples <del> -------- <add> *Examples* <ide> <del> >>> x = array([[[1,1,1],[2,2,2],[3,3,3]]]) <del> >>> x <del> array([[[1, 1, 1], <del> [2, 2, 2], <del> [3, 3, 3]]]) <del> >>> x.shape <del> (1, 3, 3) <del> >>> squeeze(x).shape <del> (3, 3) <add> >>> x = array([[[1,1,1],[2,2,2],[3,3,3]]]) <add> >>> x <add> array([[[1, 1, 1], <add> [2, 2, 2], <add> [3, 3, 3]]]) <add> >>> x.shape <add> (1, 3, 3) <add> >>> squeeze(x).shape <add> (3, 3) <ide> <ide> """ <del> <ide> try: <ide> squeeze = a.squeeze <ide> except AttributeError: <ide> def squeeze(a): <ide> def diagonal(a, offset=0, axis1=0, axis2=1): <ide> """Return specified diagonals. <ide> <del> If a is 2-d, returns the diagonal of self with the given offset, <del> i.e., the collection of elements of the form a[i,i+offset]. If a <del> has more than two dimensions, then the axes specified by axis1 and <del> axis2 are used to determine the 2-d subarray whose diagonal is <del> returned. The shape of the resulting array can be determined by <del> removing axis1 and axis2 and appending an index to the right equal <del> to the size of the resulting diagonals. <del> <del> :Parameters: <del> offset : integer <del> Offset of the diagonal from the main diagonal. Can be both <del> positive and negative. Defaults to main diagonal. <del> axis1 : integer <del> Axis to be used as the first axis of the 2-d subarrays from <del> which the diagonals should be taken. Defaults to first axis. <del> axis2 : integer <del> Axis to be used as the second axis of the 2-d subarrays from <del> which the diagonals should be taken. Defaults to second axis. <del> <del> :Returns: <add> If a is 2-d, returns the diagonal of self with the given offset, i.e., the <add> collection of elements of the form a[i,i+offset]. If a has more than two <add> dimensions, then the axes specified by axis1 and axis2 are used to determine <add> the 2-d subarray whose diagonal is returned. The shape of the resulting <add> array can be determined by removing axis1 and axis2 and appending an index <add> to the right equal to the size of the resulting diagonals. <add> <add> *Parameters*: <add> <add> a : array_like <add> Array from whis the diagonals are taken. <add> <add> offset : {0, integer}, optional <add> Offset of the diagonal from the main diagonal. Can be both positive <add> and negative. Defaults to main diagonal. <add> <add> axis1 : {0, integer}, optional <add> Axis to be used as the first axis of the 2-d subarrays from which <add> the diagonals should be taken. Defaults to first axis. <add> <add> axis2 : {1, integer}, optional <add> Axis to be used as the second axis of the 2-d subarrays from which <add> the diagonals should be taken. Defaults to second axis. <add> <add> *Returns*: <add> <ide> array_of_diagonals : array of same type as a <ide> If a is 2-d, a 1-d array containing the diagonal is <ide> returned. If a has larger dimensions, then an array of <ide> diagonals is returned. <ide> <del> :SeeAlso: <del> - diag : Matlab workalike for 1-d and 2-d arrays. <del> - diagflat : Create diagonal arrays. <del> - trace : Sum along diagonals. <del> <del> Examples <del> -------- <del> <del> >>> a = arange(4).reshape(2,2) <del> >>> a <del> array([[0, 1], <del> [2, 3]]) <del> >>> a.diagonal() <del> array([0, 3]) <del> >>> a.diagonal(1) <del> array([1]) <del> <del> >>> a = arange(8).reshape(2,2,2) <del> >>> a <del> array([[[0, 1], <del> [2, 3]], <del> [[4, 5], <del> [6, 7]]]) <del> >>> a.diagonal(0,-2,-1) <del> array([[0, 3], <del> [4, 7]]) <add> *See Also*: <add> <add> `diag` : Matlab workalike for 1-d and 2-d arrays. <add> <add> `diagflat` : Create diagonal arrays. <add> <add> `trace` : Sum along diagonals. <add> <add> *Examples* <add> <add> >>> a = arange(4).reshape(2,2) <add> >>> a <add> array([[0, 1], <add> [2, 3]]) <add> >>> a.diagonal() <add> array([0, 3]) <add> >>> a.diagonal(1) <add> array([1]) <add> <add> >>> a = arange(8).reshape(2,2,2) <add> >>> a <add> array([[[0, 1], <add> [2, 3]], <add> [[4, 5], <add> [6, 7]]]) <add> >>> a.diagonal(0,-2,-1) <add> array([[0, 3], <add> [4, 7]]) <ide> <ide> """ <ide> return asarray(a).diagonal(offset, axis1, axis2) <ide> def diagonal(a, offset=0, axis1=0, axis2=1): <ide> def trace(a, offset=0, axis1=0, axis2=1, dtype=None, out=None): <ide> """Return the sum along diagonals of the array. <ide> <add> If a is 2-d, returns the sum along the diagonal of self with the given offset, i.e., the <add> collection of elements of the form a[i,i+offset]. If a has more than two <add> dimensions, then the axes specified by axis1 and axis2 are used to determine <add> the 2-d subarray whose trace is returned. The shape of the resulting <add> array can be determined by removing axis1 and axis2 and appending an index <add> to the right equal to the size of the resulting diagonals. Arrays of integer <add> type are summed <add> <add> *Parameters*: <add> <add> a : array_like <add> Array from whis the diagonals are taken. <add> <add> offset : {0, integer}, optional <add> Offset of the diagonal from the main diagonal. Can be both positive <add> and negative. Defaults to main diagonal. <add> <add> axis1 : {0, integer}, optional <add> Axis to be used as the first axis of the 2-d subarrays from which <add> the diagonals should be taken. Defaults to first axis. <add> <add> axis2 : {1, integer}, optional <add> Axis to be used as the second axis of the 2-d subarrays from which <add> the diagonals should be taken. Defaults to second axis. <add> <add> dtype : {None, dtype}, optional <add> Determines the type of the returned array and of the accumulator <add> where the elements are summed. If dtype has the value None and a is <add> of integer type of precision less than the default integer <add> precision, then the default integer precision is used. Otherwise, <add> the precision is the same as that of a. <add> <add> out : {None, array}, optional <add> Array into which the sum can be placed. It's type is preserved and <add> it must be of the right shape to hold the output. <add> <add> *Returns*: <add> <add> sum_along_diagonals : array <add> If a is 2-d, a 0-d array containing the diagonal is <add> returned. If a has larger dimensions, then an array of <add> diagonals is returned. <add> <add> *Examples* <add> <add> >>> trace(eye(3)) <add> 3.0 <add> >>> a = arange(8).reshape((2,2,2)) <add> >>> trace(a) <add> array([6, 8]) <add> <ide> """ <ide> return asarray(a).trace(offset, axis1, axis2, dtype, out) <ide> <del>def ravel(m,order='C'): <del> """Return a 1d array with all the elements of m. The new array is <del> a view of m if possible, otherwise it is a copy. <add>def ravel(a, order='C'): <add> """Return a 1d array containing the elements of a. <add> <add> Returns the elements of a as a 1d array. The elements in the new array <add> are taken in the order specified by the order keyword. The new array is <add> a view of a if possible, otherwise it is a copy. <add> <add> *Parameters*: <add> <add> a : array_like <add> <add> order : {'C','F'}, optional <add> If order is 'C' the elements are taken in row major order. If order <add> is 'F' they are taken in column major order. <add> <add> *Returns*: <add> <add> 1d array of the elements of a. <ide> <del> Examples <del> -------- <add> *See Also*: <ide> <del> >>> x = array([[1,2,3],[4,5,6]]) <del> >>> x <del> array([[1, 2, 3], <del> [4, 5, 6]]) <del> >>> ravel(x) <del> array([1, 2, 3, 4, 5, 6]) <add> `ndarray.flat` : 1d iterator over the array. <add> <add> `ndarray.flatten` : 1d array copy of the elements of a in C order. <add> <add> *Examples* <add> <add> >>> x = array([[1,2,3],[4,5,6]]) <add> >>> x <add> array([[1, 2, 3], <add> [4, 5, 6]]) <add> >>> ravel(x) <add> array([1, 2, 3, 4, 5, 6]) <ide> <ide> """ <del> a = asarray(m) <del> return a.ravel(order) <add> return asarray(a).ravel(order) <add> <ide> <ide> def nonzero(a): <ide> """Return the indices of the elements of a which are not zero. <ide> <add> *Parameters*: <add> <add> a : array_like <add> <add> *Returns*: <add> <add> Tuple of arrays of indices. <add> <add> *Examples* <add> <add> >>> eye(3)[nonzero(eye(3))] <add> array([ 1., 1., 1.]) <add> >>> nonzero(eye(3)) <add> (array([0, 1, 2]), array([0, 1, 2])) <add> >>> eye(3)[nonzero(eye(3))] <add> array([ 1., 1., 1.]) <add> <ide> """ <ide> try: <ide> nonzero = a.nonzero <ide> def nonzero(a): <ide> res = nonzero() <ide> return res <ide> <add> <ide> def shape(a): <del> """Return the shape of a. This function can also be called on <del> nested sequences, e.g. <add> """Return the shape of a. <add> <add> *Parameters*: <add> <add> a : array type <ide> <del> Examples <del> -------- <add> *Returns*: <ide> <del> >>> x = array([1,2,3]) <del> >>> shape((x,x,x)) <del> (3, 3) <add> tuple of integers : <add> The elements of the tuple are the length of the corresponding array <add> dimension. <add> <add> *Examples* <add> <add> >>> shape(eye(3)) <add> (3, 3) <add> >>> shape([[1,2]]) <add> (1, 2) <ide> <ide> """ <ide> try: <ide> def shape(a): <ide> result = asarray(a).shape <ide> return result <ide> <del>def compress(condition, m, axis=None, out=None): <del> """Return m where condition is true. <ide> <del> Equivalent to m[condition]. <add>def compress(condition, a, axis=None, out=None): <add> """Return a where condition is true. <add> <add> Equivalent to a[condition]. <ide> <ide> """ <ide> try: <del> compress = m.compress <add> compress = a.compress <ide> except AttributeError: <del> return _wrapit(m, 'compress', condition, axis, out) <add> return _wrapit(a, 'compress', condition, axis, out) <ide> return compress(condition, axis, out) <ide> <del>def clip(m, m_min, m_max): <del> """Limit the values of m to [m_min, m_max]. Equivalent to <ide> <del> m[m < m_min] = m_min <del> m[m > m_max] = m_max <add>def clip(a, a_min, a_max): <add> """Limit the values of a to [a_min, a_max]. Equivalent to <add> <add> a[a < a_min] = a_min <add> a[a > a_max] = a_max <ide> <ide> """ <ide> try: <del> clip = m.clip <add> clip = a.clip <ide> except AttributeError: <del> return _wrapit(m, 'clip', m_min, m_max) <del> return clip(m_min, m_max) <add> return _wrapit(a, 'clip', a_min, a_max) <add> return clip(a_min, a_max) <add> <add> <add>def sum(a, axis=None, dtype=None, out=None): <add> """Sum the array over the given axis. <ide> <del>def sum(x, axis=None, dtype=None, out=None): <del> """Sum the array over the given axis. The optional dtype argument <del> is the data type for intermediate calculations. <add> *Parameters*: <ide> <del> The default is to upcast (promote) smaller integer types to the <del> platform-dependent Int. For example, on 32-bit platforms: <add> a : array_type <ide> <del> x.dtype default sum() dtype <del> --------------------------------------------------- <del> bool, int8, int16, int32 int32 <add> axis : {None, integer} <add> Axis over which the sums are taken. If None is used, then the sum is <add> over all the array elements. <ide> <del> Examples <del> -------- <add> dtype : {None, dtype}, optional <add> Determines the type of the returned array and of the accumulator <add> where the elements are summed. If dtype has the value None and a is <add> of integer type of precision less than the default platform integer <add> precision, then the default integer precision is used. Otherwise, <add> the precision is the same as that of a. <ide> <del> >>> N.sum([0.5, 1.5]) <del> 2.0 <del> >>> N.sum([0.5, 1.5], dtype=N.int32) <del> 1 <del> >>> N.sum([[0, 1], [0, 5]]) <del> 6 <del> >>> N.sum([[0, 1], [0, 5]], axis=1) <del> array([1, 5]) <add> out : {None, array}, optional <add> Array into which the sum can be placed. It's type is preserved and <add> it must be of the right shape to hold the output. <add> <add> *Returns*: <add> <add> Sum along specified axis : {array, scalar}, type as explained above. <add> If the sum is along an axis, then an array is returned whose shape <add> is the same as a with the specified axis removed. For 1d arrays or <add> dtype=None, the result is a 0d array. <add> <add> *Examples* <add> <add> >>> N.sum([0.5, 1.5]) <add> 2.0 <add> >>> N.sum([0.5, 1.5], dtype=N.int32) <add> 1 <add> >>> N.sum([[0, 1], [0, 5]]) <add> 6 <add> >>> N.sum([[0, 1], [0, 5]], axis=1) <add> array([1, 5]) <ide> <ide> """ <del> if isinstance(x, _gentype): <del> res = _sum_(x) <add> if isinstance(a, _gentype): <add> res = _sum_(a) <ide> if out is not None: <ide> out[...] = res <ide> return out <ide> return res <ide> try: <del> sum = x.sum <add> sum = a.sum <ide> except AttributeError: <del> return _wrapit(x, 'sum', axis, dtype, out) <add> return _wrapit(a, 'sum', axis, dtype, out) <ide> return sum(axis, dtype, out) <ide> <del>def product (x, axis=None, dtype=None, out=None): <add> <add>def product (a, axis=None, dtype=None, out=None): <ide> """Product of the array elements over the given axis. <ide> <add> Blah, Blah. <add> <ide> """ <ide> try: <del> prod = x.prod <add> prod = a.prod <ide> except AttributeError: <del> return _wrapit(x, 'prod', axis, dtype, out) <add> return _wrapit(a, 'prod', axis, dtype, out) <ide> return prod(axis, dtype, out) <ide> <del>def sometrue (x, axis=None, out=None): <add> <add>def sometrue (a, axis=None, out=None): <ide> """Perform a logical_or over the given axis. <ide> <add> Blah, Blah. <add> <ide> """ <ide> try: <del> any = x.any <add> any = a.any <ide> except AttributeError: <del> return _wrapit(x, 'any', axis, out) <add> return _wrapit(a, 'any', axis, out) <ide> return any(axis, out) <ide> <del>def alltrue (x, axis=None, out=None): <add> <add>def alltrue (a, axis=None, out=None): <ide> """Perform a logical_and over the given axis. <ide> <add> Blah, Blah. <add> <ide> """ <ide> try: <del> all = x.all <add> all = a.all <ide> except AttributeError: <del> return _wrapit(x, 'all', axis, out) <add> return _wrapit(a, 'all', axis, out) <ide> return all(axis, out) <ide> <del>def any(x,axis=None, out=None): <add> <add>def any(a,axis=None, out=None): <ide> """Return true if any elements of x are true. <ide> <add> Blah, Blah. <add> <ide> """ <ide> try: <del> any = x.any <add> any = a.any <ide> except AttributeError: <del> return _wrapit(x, 'any', axis, out) <add> return _wrapit(a, 'any', axis, out) <ide> return any(axis, out) <ide> <del>def all(x,axis=None, out=None): <add> <add>def all(a,axis=None, out=None): <ide> """Return true if all elements of x are true: <ide> <add> Blah, Blah. <add> <ide> """ <ide> try: <del> all = x.all <add> all = a.all <ide> except AttributeError: <del> return _wrapit(x, 'all', axis, out) <add> return _wrapit(a, 'all', axis, out) <ide> return all(axis, out) <ide> <del>def cumsum (x, axis=None, dtype=None, out=None): <add> <add>def cumsum (a, axis=None, dtype=None, out=None): <ide> """Sum the array over the given axis. <ide> <add> Blah, Blah. <add> <ide> """ <ide> try: <del> cumsum = x.cumsum <add> cumsum = a.cumsum <ide> except AttributeError: <del> return _wrapit(x, 'cumsum', axis, dtype, out) <add> return _wrapit(a, 'cumsum', axis, dtype, out) <ide> return cumsum(axis, dtype, out) <ide> <del>def cumproduct (x, axis=None, dtype=None, out=None): <add> <add>def cumproduct (a, axis=None, dtype=None, out=None): <ide> """Return the cumulative product over the given axis. <ide> <add> Blah, Blah. <add> <ide> """ <ide> try: <del> cumprod = x.cumprod <add> cumprod = a.cumprod <ide> except AttributeError: <del> return _wrapit(x, 'cumprod', axis, dtype, out) <add> return _wrapit(a, 'cumprod', axis, dtype, out) <ide> return cumprod(axis, dtype, out) <ide> <add> <ide> def ptp(a, axis=None, out=None): <ide> """Return maximum - minimum along the the given dimension. <ide> <add> Blah, Blah. <add> <ide> """ <ide> try: <ide> ptp = a.ptp <ide> except AttributeError: <ide> return _wrapit(a, 'ptp', axis, out) <ide> return ptp(axis, out) <ide> <add> <ide> def amax(a, axis=None, out=None): <ide> """Return the maximum of 'a' along dimension axis. <ide> <add> Blah, Blah. <add> <ide> """ <ide> try: <ide> amax = a.max <ide> except AttributeError: <ide> return _wrapit(a, 'max', axis, out) <ide> return amax(axis, out) <ide> <add> <ide> def amin(a, axis=None, out=None): <ide> """Return the minimum of a along dimension axis. <add> <add> Blah, Blah. <add> <ide> """ <ide> try: <ide> amin = a.min <ide> except AttributeError: <ide> return _wrapit(a, 'min', axis, out) <ide> return amin(axis, out) <ide> <add> <ide> def alen(a): <ide> """Return the length of a Python object interpreted as an array <ide> of at least 1 dimension. <ide> <add> Blah, Blah. <add> <ide> """ <ide> try: <ide> return len(a) <ide> except TypeError: <ide> return len(array(a,ndmin=1)) <ide> <add> <ide> def prod(a, axis=None, dtype=None, out=None): <ide> """Return the product of the elements along the given axis. <ide> <add> Blah, Blah. <add> <ide> """ <ide> try: <ide> prod = a.prod <ide> except AttributeError: <ide> return _wrapit(a, 'prod', axis, dtype, out) <ide> return prod(axis, dtype, out) <ide> <add> <ide> def cumprod(a, axis=None, dtype=None, out=None): <ide> """Return the cumulative product of the elements along the given axis. <ide> <add> Blah, Blah. <add> <ide> """ <ide> try: <ide> cumprod = a.cumprod <ide> except AttributeError: <ide> return _wrapit(a, 'cumprod', axis, dtype, out) <ide> return cumprod(axis, dtype, out) <ide> <add> <ide> def ndim(a): <ide> """Return the number of dimensions of a. <ide> <add> Blah, Blah. <add> <ide> """ <ide> try: <ide> return a.ndim <ide> except AttributeError: <ide> return asarray(a).ndim <ide> <add> <ide> def rank(a): <ide> """Return the rank of sequence a (the number of dimensions, not <ide> the matrix rank). The rank of a scalar is zero. <ide> <add> Blah, Blah. <add> <ide> """ <ide> try: <ide> return a.ndim <ide> except AttributeError: <ide> return asarray(a).ndim <ide> <add> <ide> def size(a, axis=None): <ide> """Return the number of elements in sequence a, or along a given axis. <ide> <add> Blah, Blah. <add> <ide> """ <ide> <ide> if axis is None: <ide> def size(a, axis=None): <ide> except AttributeError: <ide> return asarray(a).shape[axis] <ide> <add> <ide> def round_(a, decimals=0, out=None): <ide> """Round a to the given number of decimals. <ide> <del> The real and imaginary parts of complex numbers are rounded <del> separately. Nothing is done if the input is an integer array with <del> decimals >= 0. <add> The real and imaginary parts of complex numbers are rounded separately. <add> Nothing is done if the input is an integer array with decimals >= 0. <ide> <del> :Parameters: <del> decimals : integer <del> Number of decimal places to round to (default 0). When <del> 'decimals' is negative it specifies the number of <del> positions to the left of the decimal point. <del> out : array <del> Existing array to use for output (by default, make a <del> copy of a). <add> *Parameters*: <add> <add> decimals : {0, int}, optional <add> Number of decimal places to round to. When decimals is negative it <add> specifies the number of positions to the left of the decimal point. <add> out : {None, array}, optional <add> Existing array to use for output (by default, make a copy of a). <add> <add> *Returns*: <ide> <del> :Returns: <ide> out : array <del> May be used to specify a different array to hold the <del> result rather than the default 'a'. If the type of the <del> array specified by 'out' differs from that of 'a', the <del> result is cast to the new type, otherwise the original <del> type is kept. Floats round to floats by default. <add> May be used to specify a different array to hold the result rather <add> than the default a. If the type of the array specified by 'out' <add> differs from that of a, the result is cast to the new type, <add> otherwise the original type is kept. Floats round to floats by <add> default. <ide> <del> Notes <del> ----- <add> *See Also*: <ide> <del> Numpy rounds to even. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 <del> round to 0.0, etc. Results may also be surprising due to the inexact <del> representation of decimal fractions in IEEE floating point and the <del> errors introduced in scaling the numbers when 'decimals' is something <del> other than 0. <add> `around` : alias of this function <ide> <del> The function around is an alias for round_. <add> *Notes* <add> <add> Numpy rounds to even. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 round <add> to 0.0, etc. Results may also be surprising due to the inexact <add> representation of decimal fractions in IEEE floating point and the <add> errors introduced in scaling the numbers when decimals is something <add> other than 0. <ide> <ide> """ <ide> try: <ide> def round_(a, decimals=0, out=None): <ide> return _wrapit(a, 'round', decimals, out) <ide> return round(decimals, out) <ide> <del>around = round_ <ide> <ide> def mean(a, axis=None, dtype=None, out=None): <ide> """Compute the mean along the specified axis. <ide> def mean(a, axis=None, dtype=None, out=None): <ide> over the flattened array by default, otherwise over the specified <ide> axis. <ide> <del> :Parameters: <add> *Parameters*: <add> <ide> axis : integer <del> Axis along which the means are computed. The default is <del> to compute the standard deviation of the flattened array. <add> Axis along which the means are computed. The default is to compute <add> the standard deviation of the flattened array. <ide> dtype : type <del> Type to use in computing the means. For arrays of integer <del> type the default is float32, for arrays of float types it is <del> the same as the array type. <add> Type to use in computing the means. For arrays of integer type the <add> default is float32, for arrays of float types it is the same as the <add> array type. <ide> out : ndarray <del> Alternative output array in which to place the result. It <del> must have the same shape as the expected output but the type <del> will be cast if necessary. <add> Alternative output array in which to place the result. It must have <add> the same shape as the expected output but the type will be cast if <add> necessary. <add> <add> *Returns*: <ide> <del> :Returns: <ide> mean : array (see dtype parameter above) <del> A new array holding the result is returned unless out is <del> specified, in which case a reference to out is returned. <add> A new array holding the result is returned unless out is specified, <add> in which case a reference to out is returned. <add> <add> *See Also*: <ide> <del> :SeeAlso: <del> - var : Variance <del> - std : Standard deviation <add> `var` : Variance <ide> <del> Notes <del> ----- <add> `std` : Standard deviation <ide> <del> The mean is the sum of the elements along the axis divided by the <del> number of elements. <add> *Notes* <add> <add> The mean is the sum of the elements along the axis divided by the number <add> of elements. <ide> <ide> """ <ide> try: <ide> def mean(a, axis=None, dtype=None, out=None): <ide> def std(a, axis=None, dtype=None, out=None): <ide> """Compute the standard deviation along the specified axis. <ide> <del> Returns the standard deviation of the array elements, a measure <del> of the spread of a distribution. The standard deviation is <del> computed for the flattened array by default, otherwise over the <del> specified axis. <add> Returns the standard deviation of the array elements, a measure of the <add> spread of a distribution. The standard deviation is computed for the <add> flattened array by default, otherwise over the specified axis. <add> <add> *Parameters*: <ide> <del> :Parameters: <ide> axis : integer <del> Axis along which the standard deviation is computed. The <del> default is to compute the standard deviation of the flattened <del> array. <add> Axis along which the standard deviation is computed. The default is <add> to compute the standard deviation of the flattened array. <ide> dtype : type <del> Type to use in computing the standard deviation. For arrays <del> of integer type the default is float32, for arrays of float <del> types it is the same as the array type. <add> Type to use in computing the standard deviation. For arrays of <add> integer type the default is float32, for arrays of float types it is <add> the same as the array type. <ide> out : ndarray <del> Alternative output array in which to place the result. It <del> must have the same shape as the expected output but the type <del> will be cast if necessary. <add> Alternative output array in which to place the result. It must have <add> the same shape as the expected output but the type will be cast if <add> necessary. <add> <add> *Returns*: <ide> <del> :Returns: <ide> standard_deviation : The return type varies, see above. <del> A new array holding the result is returned unless out is <del> specified, in which case a reference to out is returned. <add> A new array holding the result is returned unless out is specified, <add> in which case a reference to out is returned. <add> <add> *See Also*: <ide> <del> :SeeAlso: <del> - var : Variance <del> - mean : Average <add> `var` : Variance <ide> <del> Notes <del> ----- <add> `mean` : Average <ide> <del> The standard deviation is the square root of the average of the <del> squared deviations from the mean, i.e. var = sqrt(mean((x - <del> x.mean())**2)). The computed standard deviation is biased, i.e., <del> the mean is computed by dividing by the number of elements, N, <del> rather than by N-1. <add> *Notes*: <add> <add> The standard deviation is the square root of the average of the squared <add> deviations from the mean, i.e. var = sqrt(mean((x - x.mean())**2)). The <add> computed standard deviation is biased, i.e., the mean is computed by <add> dividing by the number of elements, N, rather than by N-1. <ide> <ide> """ <ide> try: <ide> def std(a, axis=None, dtype=None, out=None): <ide> def var(a, axis=None, dtype=None, out=None): <ide> """Compute the variance along the specified axis. <ide> <del> Returns the variance of the array elements, a measure of the <del> spread of a distribution. The variance is computed for the <del> flattened array by default, otherwise over the specified axis. <add> Returns the variance of the array elements, a measure of the spread of a <add> distribution. The variance is computed for the flattened array by default, <add> otherwise over the specified axis. <add> <add> *Parameters*: <ide> <del> :Parameters: <ide> axis : integer <del> Axis along which the variance is computed. The default is to <del> compute the variance of the flattened array. <add> Axis along which the variance is computed. The default is to compute <add> the variance of the flattened array. <ide> dtype : type <del> Type to use in computing the variance. For arrays of integer <del> type the default is float32, for arrays of float types it is <del> the same as the array type. <add> Type to use in computing the variance. For arrays of integer type <add> the default is float32, for arrays of float types it is the same as <add> the array type. <ide> out : ndarray <del> Alternative output array in which to place the result. It <del> must have the same shape as the expected output but the type <del> will be cast if necessary. <add> Alternative output array in which to place the result. It must have <add> the same shape as the expected output but the type will be cast if <add> necessary. <add> <add> *Returns*: <ide> <del> :Returns: <ide> variance : array (see dtype parameter above) <del> A new array holding the result is returned unless out is <del> specified, in which case a reference to out is returned. <add> A new array holding the result is returned unless out is specified, <add> in which case a reference to out is returned. <ide> <del> :SeeAlso: <del> - std : Standard deviation <del> - mean : Average <add> *See Also*: <ide> <del> Notes <del> ----- <add> `std` : Standard deviation <ide> <del> The variance is the average of the squared deviations from the <del> mean, i.e. var = mean((x - x.mean())**2). The computed variance <del> is biased, i.e., the mean is computed by dividing by the number <del> of elements, N, rather than by N-1. <add> `mean` : Average <add> <add> *Notes*: <add> <add> The variance is the average of the squared deviations from the mean, <add> i.e. var = mean((x - x.mean())**2). The computed variance is biased, <add> i.e., the mean is computed by dividing by the number of elements, N, <add> rather than by N-1. <ide> <ide> """ <ide> try: <ide> var = a.var <ide> except AttributeError: <ide> return _wrapit(a, 'var', axis, dtype, out) <ide> return var(axis, dtype, out) <add> <add># functions that are now aliases <add> <add>around = round_ <add>
1
PHP
PHP
make texthelper truncate more reasonable
d0683c5a72696e38336bf7145922c60a6f1d5e45
<ide><path>src/Utility/Text.php <ide> public static function truncate($text, $length = 100, array $options = []) <ide> } <ide> } <ide> $truncate = mb_substr($truncate, 0, $spacepos); <del> <add> <ide> // If truncate still empty, then we don't need to count ellipsis in the cut. <ide> if (mb_strlen($truncate) === 0) { <ide> $truncate = mb_substr($text, 0, $length); <ide> } <ide> } <del> <add> <ide> $truncate .= $ellipsis; <ide> <ide> if ($html) { <ide><path>tests/TestCase/Utility/TextTest.php <ide> public function testTruncate() <ide> $text9 = 'НОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; <ide> $text10 = 'http://example.com/something/foo:bar'; <ide> <add> $this->assertSame($this->Text->truncate('Hello', 3), '...'); <add> $this->assertSame($this->Text->truncate('Hello', 3, ['exact' => false]), 'Hel...'); <ide> $this->assertSame($this->Text->truncate($text1, 15), 'The quick br...'); <ide> $this->assertSame($this->Text->truncate($text1, 15, ['exact' => false]), 'The quick...'); <ide> $this->assertSame($this->Text->truncate($text1, 100), 'The quick brown fox jumps over the lazy dog'); <ide> $this->assertSame($this->Text->truncate($text2, 10), 'Heiz&ou...'); <del> $this->assertSame($this->Text->truncate($text2, 10, ['exact' => false]), '...'); <add> $this->assertSame($this->Text->truncate($text2, 10, ['exact' => false]), 'Heiz&ouml;...'); <ide> $this->assertSame($this->Text->truncate($text3, 20), '<b>&copy; 2005-20...'); <ide> $this->assertSame($this->Text->truncate($text4, 15), '<img src="my...'); <ide> $this->assertSame($this->Text->truncate($text5, 6, ['ellipsis' => '']), '0<b>1<'); <ide> $this->assertSame($this->Text->truncate($text1, 15, ['html' => true]), "The quick brow\xe2\x80\xa6"); <ide> $this->assertSame($this->Text->truncate($text1, 15, ['exact' => false, 'html' => true]), "The quick\xe2\x80\xa6"); <ide> $this->assertSame($this->Text->truncate($text2, 10, ['html' => true]), "Heiz&ouml;lr&uuml;c\xe2\x80\xa6"); <del> $this->assertSame($this->Text->truncate($text2, 10, ['exact' => false, 'html' => true]), "\xe2\x80\xa6"); <add> $this->assertSame($this->Text->truncate($text2, 10, ['exact' => false, 'html' => true]), "Heiz&ouml;\xe2\x80\xa6"); <ide> $this->assertSame($this->Text->truncate($text3, 20, ['html' => true]), "<b>&copy; 2005-2007, Cake S\xe2\x80\xa6</b>"); <ide> $this->assertSame($this->Text->truncate($text4, 15, ['html' => true]), "<img src=\"mypic.jpg\"> This image ta\xe2\x80\xa6"); <ide> $this->assertSame($this->Text->truncate($text4, 45, ['html' => true]), "<img src=\"mypic.jpg\"> This image tag is not XHTML conform!<br><hr/><b>But the\xe2\x80\xa6</b>");
2
Javascript
Javascript
add support for modeltype in the router
0ecc1d799950eb29b6d672f3c1702bdd8f2e5e53
<ide><path>packages/ember-states/lib/routable.js <ide> var get = Ember.get, getPath = Ember.getPath; <ide> // * .onURLChange(callback) - this happens when the user presses <ide> // the back or forward button <ide> <add>var paramForClass = function(classObject) { <add> var className = classObject.toString(), <add> parts = className.split("."), <add> last = parts[parts.length - 1]; <add> <add> return Ember.String.underscore(last) + "_id"; <add>}; <add> <ide> Ember.Routable = Ember.Mixin.create({ <ide> init: function() { <ide> this.on('setupControllers', this, this.stashContext); <ide> Ember.Routable = Ember.Mixin.create({ <ide> return Ember._RouteMatcher.create({ route: get(this, 'route') }); <ide> }).cacheable(), <ide> <del> deserialize: function(manager, context) { <del> return context; <add> modelClass: Ember.computed(function() { <add> var modelType = get(this, 'modelType'); <add> <add> if (typeof modelType === 'string') { <add> return Ember.getPath(window, modelType); <add> } else { <add> return modelType; <add> } <add> }).cacheable(), <add> <add> deserialize: function(manager, params) { <add> var modelClass, param; <add> <add> if (modelClass = get(this, 'modelClass')) { <add> return modelClass.find(params[paramForClass(modelClass)]); <add> } else { <add> return params; <add> } <ide> }, <ide> <ide> serialize: function(manager, context) { <add> var modelClass, param, id; <add> <add> if (modelClass = get(this, 'modelClass')) { <add> param = paramForClass(modelClass); <add> id = get(context, 'id'); <add> context = {}; <add> context[param] = id; <add> } <add> <ide> return context; <ide> }, <ide> <ide><path>packages/ember-states/tests/routable_test.js <ide> test("should invoke the serialize method on a state when it is entered programma <ide> equal(setURL, '/posts/2'); <ide> }); <ide> <add>var url, firstPost, firstUser; <add> <add>module("default serialize and deserialize", { <add> setup: function() { <add> window.TestApp = Ember.Namespace.create(); <add> window.TestApp.Post = Ember.Object.extend(); <add> window.TestApp.Post.find = function(id) { <add> if (id === "1") { return firstPost; } <add> }; <add> <add> window.TestApp.User = Ember.Object.extend(); <add> window.TestApp.User.find = function(id) { <add> if (id === "1") { return firstUser; } <add> }; <add> <add> firstPost = window.TestApp.Post.create({ id: 1 }); <add> firstUser = window.TestApp.User.create({ id: 1 }); <add> <add> router = Ember.Router.create({ <add> location: { <add> setURL: function(passedURL) { <add> url = passedURL; <add> } <add> }, <add> <add> initialState: 'root', <add> root: Ember.State.extend({ <add> post: Ember.State.extend({ <add> route: '/posts/:post_id', <add> modelType: 'TestApp.Post', <add> <add> setupControllers: function(router, post) { <add> equal(post, firstPost, "the post should have deserialized correctly"); <add> } <add> }), <add> <add> user: Ember.State.extend({ <add> route: '/users/:user_id', <add> modelType: window.TestApp.User, <add> <add> setupControllers: function(router, user) { <add> equal(user, firstUser, "the post should have deserialized correctly"); <add> } <add> }) <add> }) <add> }); <add> }, <add> <add> teardown: function() { <add> window.TestApp = undefined; <add> } <add>}); <add> <add>test("should use a specified String `modelType` in the default `serialize`", function() { <add> router.transitionTo('post', firstPost); <add> equal(url, "/posts/1"); <add>}); <add> <add>test("should use a specified String `modelType` in the default `deserialize`", function() { <add> expect(1); <add> <add> router.route("/posts/1"); <add>}); <add> <add>test("should use a specified class `modelType` in the default `serialize`", function() { <add> router.transitionTo('user', firstUser); <add> equal(url, "/users/1"); <add>}); <add> <add>test("should use a specified class `modelType` in the default `deserialize`", function() { <add> expect(1); <add> <add> router.route("/users/1"); <add>}); <add>
2
PHP
PHP
fix incorrect formation of query string
26495b36d13ba751e2de320cdc4f41d8464448ea
<ide><path>cake/libs/model/datasources/dbo/dbo_postgres.php <ide> function alterSchema($compare, $table = null) { <ide> $default = isset($col['default']) ? $col['default'] : null; <ide> $nullable = isset($col['null']) ? $col['null'] : null; <ide> unset($col['default'], $col['null']); <del> $colList[] = 'ALTER COLUMN '. $fieldName .' TYPE ' . str_replace($fieldName, '', $this->buildColumn($col)); <del> <add> $colList[] = 'ALTER COLUMN '. $fieldName .' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col)); <ide> if (isset($nullable)) { <ide> $nullable = ($nullable) ? 'DROP NOT NULL' : 'SET NOT NULL'; <ide> $colList[] = 'ALTER COLUMN '. $fieldName .' ' . $nullable;
1
Go
Go
remove use of deprecated system.getosversion()
81f9edc7b0efce763ad89a7b62f0546e5a12aff6
<ide><path>pkg/parsers/operatingsystem/operatingsystem_windows.go <ide> package operatingsystem // import "github.com/docker/docker/pkg/parsers/operatin <ide> import ( <ide> "fmt" <ide> <del> "github.com/docker/docker/pkg/system" <add> "github.com/Microsoft/hcsshim/osversion" <ide> "golang.org/x/sys/windows/registry" <ide> ) <ide> <ide> func withCurrentVersionRegistryKey(f func(registry.Key) (string, error)) (string <ide> <ide> // GetOperatingSystemVersion gets the version of the current operating system, as a string. <ide> func GetOperatingSystemVersion() (string, error) { <del> version := system.GetOSVersion() <add> version := osversion.Get() <ide> return fmt.Sprintf("%d.%d.%d", version.MajorVersion, version.MinorVersion, version.Build), nil <ide> } <ide>
1
PHP
PHP
use $fillable and $guarded accessor methods
bbfc14b60b50d2b9f327479cbbb0918dd4c6fc94
<ide><path>src/Illuminate/Database/Eloquent/Model.php <ide> public function forceFill(array $attributes) <ide> */ <ide> protected function fillableFromArray(array $attributes) <ide> { <del> if (count($this->fillable) > 0 && ! static::$unguarded) { <del> return array_intersect_key($attributes, array_flip($this->fillable)); <add> if (count($this->getFillable()) > 0 && ! static::$unguarded) { <add> return array_intersect_key($attributes, array_flip($this->getFillable())); <ide> } <ide> <ide> return $attributes; <ide> public function isFillable($key) <ide> // If the key is in the "fillable" array, we can of course assume that it's <ide> // a fillable attribute. Otherwise, we will check the guarded array when <ide> // we need to determine if the attribute is black-listed on the model. <del> if (in_array($key, $this->fillable)) { <add> if (in_array($key, $this->getFillable())) { <ide> return true; <ide> } <ide> <ide> if ($this->isGuarded($key)) { <ide> return false; <ide> } <ide> <del> return empty($this->fillable) && ! Str::startsWith($key, '_'); <add> return empty($this->getFillable()) && ! Str::startsWith($key, '_'); <ide> } <ide> <ide> /** <ide> public function isFillable($key) <ide> */ <ide> public function isGuarded($key) <ide> { <del> return in_array($key, $this->guarded) || $this->guarded == ['*']; <add> return in_array($key, $this->getGuarded()) || $this->getGuarded() == ['*']; <ide> } <ide> <ide> /** <ide> public function isGuarded($key) <ide> */ <ide> public function totallyGuarded() <ide> { <del> return count($this->fillable) == 0 && $this->guarded == ['*']; <add> return count($this->getFillable()) == 0 && $this->getGuarded() == ['*']; <ide> } <ide> <ide> /**
1
Javascript
Javascript
update api.js normalizr url
2ec2b1a2393404178826b0d4a42cdc016d1b4acf
<ide><path>examples/real-world/middleware/api.js <ide> function callApi(endpoint, schema) { <ide> // consumption by reducers, because we can easily build a normalized tree <ide> // and keep it updated as we fetch more data. <ide> <del>// Read more about Normalizr: https://github.com/gaearon/normalizr <add>// Read more about Normalizr: https://github.com/paularmstrong/normalizr <ide> <ide> // GitHub's API may return results with uppercase letters while the query <ide> // doesn't contain any. For example, "someuser" could result in "SomeUser"
1
Go
Go
update code for new test cases
9d11db0f8c2be614f18eec856f11edbff5da17fe
<ide><path>networkdriver/ipallocator/allocator.go <ide> var ( <ide> ErrNetworkAlreadyAllocated = errors.New("requested network overlaps with existing network") <ide> ErrNetworkAlreadyRegisterd = errors.New("requested network is already registered") <ide> ErrNetworkOverlapsWithNameservers = errors.New("requested network overlaps with nameserver") <del> ErrNoAvailableIps = errors.New("no available ips on network") <add> ErrNoAvailableIPs = errors.New("no available ip addresses on network") <ide> ErrIPAlreadyAllocated = errors.New("ip already allocated") <ide> <ide> lock = sync.Mutex{} <ide> func getNextIp(network *net.IPNet) (*net.IP, error) { <ide> ownIP = ipToInt(&network.IP) <ide> available = availableIPS[n] <ide> allocated = allocatedIPs[n] <del> <del> first, _ = networkRange(network) <del> base = ipToInt(&first) <del> <del> pos = int32(available.Pop()) <add> first, _ = networkRange(network) <add> base = ipToInt(&first) <add> size = int(networkSize(network.Mask)) <add> max = int32(size - 2) // size -1 for the broadcast address, -1 for the gateway address <add> pos = int32(available.Pop()) <ide> ) <ide> <ide> // We pop and push the position not the ip <ide> func getNextIp(network *net.IPNet) (*net.IP, error) { <ide> return ip, nil <ide> } <ide> <del> var ( <del> size = int(networkSize(network.Mask)) <del> max = int32(size - 2) // size -1 for the broadcast address, -1 for the gateway address <del> ) <del> <del> if pos = int32(allocated.PullBack()); pos == 0 { <del> pos = 1 <del> } <del> <add> pos = int32(allocated.PullBack()) <ide> for i := int32(0); i < max; i++ { <del> next := int32(base + pos) <ide> pos = pos%max + 1 <add> next := int32(base + pos) <ide> <ide> if next == ownIP { <ide> continue <ide> } <ide> <del> ip := intToIP(next) <del> allocated.Push(int(pos)) <del> <del> return ip, nil <add> if !allocated.Exists(int(pos)) { <add> ip := intToIP(next) <add> allocated.Push(int(pos)) <add> return ip, nil <add> } <ide> } <del> return nil, ErrNoAvailableIps <add> return nil, ErrNoAvailableIPs <ide> } <ide> <ide> func registerIP(network *net.IPNet, ip *net.IP) error { <ide><path>networkdriver/ipallocator/allocator_test.go <ide> func TestIPAllocator(t *testing.T) { <ide> // 2(u) - 3(u) - 4(u) - 5(u) - 6(u) <ide> // ↑ <ide> <del> assertIPEquals(t, &expectedIPs[3], newIPs[0]) <del> assertIPEquals(t, &expectedIPs[4], newIPs[1]) <del> assertIPEquals(t, &expectedIPs[2], newIPs[2]) <add> assertIPEquals(t, &expectedIPs[2], newIPs[0]) <add> assertIPEquals(t, &expectedIPs[3], newIPs[1]) <add> assertIPEquals(t, &expectedIPs[4], newIPs[2]) <ide> <ide> _, err = RequestIP(network, nil) <ide> if err == nil {
2
Javascript
Javascript
prevent rangeerror in safari
54a14c7c68ec5b23fbd8cbdb7ac3bc39d2903475
<ide><path>d3.layout.js <ide> function d3_layout_forceAccumulate(quad) { <ide> cy = 0; <ide> quad.count = 0; <ide> if (!quad.leaf) { <del> quad.nodes.forEach(function(c) { <add> var nodes = quad.nodes, <add> n = nodes.length, <add> i = -1, <add> c; <add> while (++i < n) { <add> c = nodes[i]; <add> if (c == null) continue; <ide> d3_layout_forceAccumulate(c); <ide> quad.count += c.count; <ide> cx += c.count * c.cx; <ide> cy += c.count * c.cy; <del> }); <add> } <ide> } <ide> if (quad.point) { <ide> // jitter internal nodes that are coincident <ide><path>d3.layout.min.js <del>(function(){function bh(a,b,c){return a._tree.ancestor.parent==b.parent?a._tree.ancestor:c}function bg(a,b,c){a=a._tree,b=b._tree;var d=c/(b.number-a.number);a.change+=d,b.change-=d,b.shift+=c,b.prelim+=c,b.mod+=c}function bf(a){var b=0,c=0,d=a.children,e=d.length,f;while(--e>=0)f=d[e]._tree,f.prelim+=b,f.mod+=b,b+=f.shift+(c+=f.change)}function be(a,b){function c(a,d){var e=a.children;if(e){var f,g=null,h=-1,i=e.length;while(++h<i)f=e[h],c(f,g),g=f}b(a,d)}c(a,null)}function bd(a,b){return a.depth-b.depth}function bc(a,b){return b.x-a.x}function bb(a,b){return a.x-b.x}function ba(a,b){var c=a.children;if(c){var d,e=c.length,f=-1;while(++f<e)b(d=ba(c[f],b),a)>0&&(a=d)}return a}function _(a){return a.children?a.children[a.children.length-1]:a._tree.thread}function $(a){return a.children?a.children[0]:a._tree.thread}function Z(a,b){return a.parent==b.parent?1:2}function Y(a){var b=a.children;return b?Y(b[b.length-1]):a}function X(a){var b=a.children;return b?X(b[0]):a}function W(a){return a.reduce(function(a,b){return a+b.x},0)/a.length}function V(a){return 1+d3.max(a,function(a){return a.y})}function U(a,b,c){var d=b.r+c.r,e=a.r+c.r,f=b.x-a.x,g=b.y-a.y,h=Math.sqrt(f*f+g*g),i=(e*e+h*h-d*d)/(2*e*h),j=Math.acos(i),k=i*e,l=Math.sin(j)*e;f/=h,g/=h,c.x=a.x+k*f+l*g,c.y=a.y+k*g-l*f}function T(a,b,c,d){var e=a.children;a.x=b+=d*a.x,a.y=c+=d*a.y,a.r*=d;if(e){var f=-1,g=e.length;while(++f<g)T(e[f],b,c,d)}}function S(a){var b=a.children;b?(b.forEach(S),a.r=P(b)):a.r=Math.sqrt(a.value)}function R(a){delete a._pack_next,delete a._pack_prev}function Q(a){a._pack_next=a._pack_prev=a}function P(a){function l(a){b=Math.min(a.x-a.r,b),c=Math.max(a.x+a.r,c),d=Math.min(a.y-a.r,d),e=Math.max(a.y+a.r,e)}var b=Infinity,c=-Infinity,d=Infinity,e=-Infinity,f=a.length,g,h,i,j,k;a.forEach(Q),g=a[0],g.x=-g.r,g.y=0,l(g);if(f>1){h=a[1],h.x=h.r,h.y=0,l(h);if(f>2){i=a[2],U(g,h,i),l(i),M(g,i),g._pack_prev=i,M(i,h),h=g._pack_next;for(var m=3;m<f;m++){U(g,h,i=a[m]);var n=0,o=1,p=1;for(j=h._pack_next;j!==h;j=j._pack_next,o++)if(O(j,i)){n=1;break}if(n==1)for(k=g._pack_prev;k!==j._pack_prev;k=k._pack_prev,p++)if(O(k,i)){p<o&&(n=-1,j=k);break}n==0?(M(g,i),h=i,l(i)):n>0?(N(g,j),h=j,m--):(N(j,h),g=j,m--)}}}var q=(b+c)/2,r=(d+e)/2,s=0;for(var m=0;m<f;m++){var t=a[m];t.x-=q,t.y-=r,s=Math.max(s,t.r+Math.sqrt(t.x*t.x+t.y*t.y))}a.forEach(R);return s}function O(a,b){var c=b.x-a.x,d=b.y-a.y,e=a.r+b.r;return e*e-c*c-d*d>.001}function N(a,b){a._pack_next=b,b._pack_prev=a}function M(a,b){var c=a._pack_next;a._pack_next=b,b._pack_prev=a,b._pack_next=c,c._pack_prev=b}function L(a,b){return a.value-b.value}function J(a){return d3.merge(a.map(function(a){return(a.children||[]).map(function(b){return{source:a,target:b}})}))}function I(a,b){return b.value-a.value}function H(a){return a.value}function G(a){return a.children}function F(a,b){a.sort=d3.rebind(a,b.sort),a.children=d3.rebind(a,b.children),a.links=J,a.value=d3.rebind(a,b.value),a.nodes=function(b){K=!0;return(a.nodes=a)(b)};return a}function E(a){return[d3.min(a),d3.max(a)]}function D(a,b){var c=-1,d=+a[0],e=(a[1]-d)/b,f=[];while(++c<=b)f[c]=e*c+d;return f}function C(a,b){return D(a,Math.ceil(Math.log(b.length)/Math.LN2+1))}function B(a,b){return a+b[1]}function A(a){return a.reduce(B,0)}function z(a){var b=1,c=0,d=a[0][1],e,f=a.length;for(;b<f;++b)(e=a[b][1])>d&&(c=b,d=e);return c}function w(a,b,c){a.y0=b,a.y=c}function v(a){return a.y}function u(a){return a.x}function t(a){return 1}function s(a){return 20}function r(a){var b=0,c=0;a.count=0,a.leaf||a.nodes.forEach(function(d){r(d),a.count+=d.count,b+=d.count*d.cx,c+=d.count*d.cy}),a.point&&(a.leaf||(a.point.x+=Math.random()-.5,a.point.y+=Math.random()-.5),a.count++,b+=a.point.x,c+=a.point.y),a.cx=b/a.count,a.cy=c/a.count}function q(){d3.event.stopPropagation(),d3.event.preventDefault()}function p(){i&&(q(),i=!1)}function o(){!f||(g&&(i=!0,q()),d3.event.type==="mouseup"&&n(),f.fixed=!1,e=h=f=j=null)}function n(){if(!!f){var a=j.parentNode;if(!a){f.fixed=!1,h=f=j=null;return}var b=m(a);g=!0,f.px=b[0]-h[0],f.py=b[1]-h[1],q(),e.resume()}}function m(a){return d3.event.touches?d3.svg.touches(a)[0]:d3.svg.mouse(a)}function l(a){a!==f&&(a.fixed=!1)}function k(a){a.fixed=!0}function c(a,c){if(a===c)return a;var d=b(a),e=b(c),f=d.pop(),g=e.pop(),h=null;while(f===g)h=f,f=d.pop(),g=e.pop();return h}function b(a){var b=[],c=a.parent;while(c!=null)b.push(a),a=c,c=c.parent;b.push(a);return b}function a(a){var b=a.source,d=a.target,e=c(b,d),f=[b];while(b!==e)b=b.parent,f.push(b);var g=f.length;while(d!==e)f.splice(g,0,d),d=d.parent;return f}d3.layout={},d3.layout.bundle=function(){return function(b){var c=[],d=-1,e=b.length;while(++d<e)c.push(a(b[d]));return c}},d3.layout.chord=function(){function k(){b.sort(function(a,b){return i(a.target.value,b.target.value)})}function j(){var a={},j=[],l=d3.range(e),m=[],n,o,p,q,r;b=[],c=[],n=0,q=-1;while(++q<e){o=0,r=-1;while(++r<e)o+=d[q][r];j.push(o),m.push(d3.range(e)),n+=o}g&&l.sort(function(a,b){return g(j[a],j[b])}),h&&m.forEach(function(a,b){a.sort(function(a,c){return h(d[b][a],d[b][c])})}),n=(2*Math.PI-f*e)/n,o=0,q=-1;while(++q<e){p=o,r=-1;while(++r<e){var s=l[q],t=m[q][r],u=d[s][t];a[s+"-"+t]={index:s,subindex:t,startAngle:o,endAngle:o+=u*n,value:u}}c.push({index:s,startAngle:p,endAngle:o,value:(o-p)/n}),o+=f}q=-1;while(++q<e){r=q-1;while(++r<e){var v=a[q+"-"+r],w=a[r+"-"+q];(v.value||w.value)&&b.push(v.value<w.value?{source:w,target:v}:{source:v,target:w})}}i&&k()}var a={},b,c,d,e,f=0,g,h,i;a.matrix=function(f){if(!arguments.length)return d;e=(d=f)&&d.length,b=c=null;return a},a.padding=function(d){if(!arguments.length)return f;f=d,b=c=null;return a},a.sortGroups=function(d){if(!arguments.length)return g;g=d,b=c=null;return a},a.sortSubgroups=function(c){if(!arguments.length)return h;h=c,b=null;return a},a.sortChords=function(c){if(!arguments.length)return i;i=c,b&&k();return a},a.chords=function(){b||j();return b},a.groups=function(){c||j();return c};return a},d3.layout.force=function(){function G(b,c){var d=m(this.parentNode);(f=b).fixed=!0,g=!1,j=this,e=a,h=[d[0]-b.x,d[1]-b.y],q()}function F(){var a=A.length,e=B.length,f=d3.geom.quadtree(A),g,h,j,k,l,m,n;for(g=0;g<e;++g){h=B[g],j=h.source,k=h.target,m=k.x-j.x,n=k.y-j.y;if(l=m*m+n*n)l=d*D[g]*((l=Math.sqrt(l))-C[g])/l,m*=l,n*=l,k.x-=m,k.y-=n,j.x+=m,j.y+=n}var o=d*x;m=c[0]/2,n=c[1]/2,g=-1;while(++g<a)h=A[g],h.x+=(m-h.x)*o,h.y+=(n-h.y)*o;r(f);var p=d*w;g=-1;while(++g<a)f.visit(E(A[g],p));g=-1;while(++g<a)h=A[g],h.fixed?(h.x=h.px,h.y=h.py):(h.x-=(h.px-(h.px=h.x))*i,h.y-=(h.py-(h.py=h.y))*i);b.tick.dispatch({type:"tick",alpha:d});return(d*=.99)<.005}function E(a,b){return function(c,d,e,f,g){if(c.point!==a){var h=c.cx-a.x,i=c.cy-a.y,j=1/Math.sqrt(h*h+i*i);if((f-d)*j<y){var k=b*c.count*j*j;a.x+=h*k,a.y+=i*k;return!0}if(c.point&&isFinite(j)){var k=b*j*j;a.x+=h*k,a.y+=i*k}}}}var a={},b=d3.dispatch("tick"),c=[1,1],d,i=.9,u=s,v=t,w=-30,x=.1,y=.8,z,A=[],B=[],C,D;a.on=function(c,d){b[c].add(d);return a},a.nodes=function(b){if(!arguments.length)return A;A=b;return a},a.links=function(b){if(!arguments.length)return B;B=b;return a},a.size=function(b){if(!arguments.length)return c;c=b;return a},a.linkDistance=function(b){if(!arguments.length)return u;u=d3.functor(b);return a},a.distance=a.linkDistance,a.linkStrength=function(b){if(!arguments.length)return v;v=d3.functor(b);return a},a.friction=function(b){if(!arguments.length)return i;i=b;return a},a.charge=function(b){if(!arguments.length)return w;w=b;return a},a.gravity=function(b){if(!arguments.length)return x;x=b;return a},a.theta=function(b){if(!arguments.length)return y;y=b;return a},a.start=function(){function l(){if(!i){i=[];for(d=0;d<e;++d)i[d]=[];for(d=0;d<f;++d){var a=B[d];i[a.source.index].push(a.target),i[a.target.index].push(a.source)}}return i[b]}function k(a,c){var d=l(b),e=-1,f=d.length,g;while(++e<f)if(!isNaN(g=d[e][a]))return g;return Math.random()*c}var b,d,e=A.length,f=B.length,g=c[0],h=c[1],i,j;for(b=0;b<e;++b)(j=A[b]).index=b;C=[],D=[];for(b=0;b<f;++b)j=B[b],typeof j.source=="number"&&(j.source=A[j.source]),typeof j.target=="number"&&(j.target=A[j.target]),C[b]=u.call(this,j,b),D[b]=v.call(this,j,b);for(b=0;b<e;++b)j=A[b],isNaN(j.x)&&(j.x=k("x",g)),isNaN(j.y)&&(j.y=k("y",h)),isNaN(j.px)&&(j.px=j.x),isNaN(j.py)&&(j.py=j.y);return a.resume()},a.resume=function(){d=.1,d3.timer(F);return a},a.stop=function(){d=0;return a},a.drag=function(){this.on("mouseover.force",k).on("mouseout.force",l).on("mousedown.force",G).on("touchstart.force",G),d3.select(window).on("mousemove.force",n).on("touchmove.force",n).on("mouseup.force",o,!0).on("touchend.force",o,!0).on("click.force",p,!0);return a};return a};var e,f,g,h,i,j;d3.layout.partition=function(){function e(e,f){var g=a.call(this,e,f);c(g[0],0,b[0],b[1]/d(g[0]));return g}function d(a){var b=a.children,c=0;if(b){var e=-1,f=b.length;while(++e<f)c=Math.max(c,d(b[e]))}return 1+c}function c(a,b,d,e){var f=a.children;a.x=b,a.y=a.depth*e,a.dx=d,a.dy=e;if(f){var g=-1,h=f.length,i,j;d/=a.value;while(++g<h)c(i=f[g],b,j=i.value*d,e),b+=j}}var a=d3.layout.hierarchy(),b=[1,1];e.size=function(a){if(!arguments.length)return b;b=a;return e};return F(e,a)},d3.layout.pie=function(){function f(f,g){var h=+(typeof c=="function"?c.apply(this,arguments):c),i=(typeof e=="function"?e.apply(this,arguments):e)-c,j=d3.range(f.length);b!=null&&j.sort(function(a,c){return b(f[a],f[c])});var k=f.map(a);i/=k.reduce(function(a,b){return a+b},0);var l=j.map(function(a){return{value:d=k[a],startAngle:h,endAngle:h+=d*i}});return f.map(function(a,b){return l[j[b]]})}var a=Number,b=null,c=0,e=2*Math.PI;f.value=function(b){if(!arguments.length)return a;a=b;return f},f.sort=function(a){if(!arguments.length)return b;b=a;return f},f.startAngle=function(a){if(!arguments.length)return c;c=a;return f},f.endAngle=function(a){if(!arguments.length)return e;e=a;return f};return f},d3.layout.stack=function(){function g(h,i){var j=h.map(function(b,c){return a.call(g,b,c)}),k=j.map(function(a,b){return a.map(function(a,b){return[e.call(g,a,b),f.call(g,a,b)]})}),l=b.call(g,k,i);j=d3.permute(j,l),k=d3.permute(k,l);var m=c.call(g,k,i),n=j.length,o=j[0].length,p,q,r;for(q=0;q<o;++q){d.call(g,j[0][q],r=m[q],k[0][q][1]);for(p=1;p<n;++p)d.call(g,j[p][q],r+=k[p-1][q][1],k[p][q][1])}return h}var a=Object,b=x["default"],c=y.zero,d=w,e=u,f=v;g.values=function(b){if(!arguments.length)return a;a=b;return g},g.order=function(a){if(!arguments.length)return b;b=typeof a=="function"?a:x[a];return g},g.offset=function(a){if(!arguments.length)return c;c=typeof a=="function"?a:y[a];return g},g.x=function(a){if(!arguments.length)return e;e=a;return g},g.y=function(a){if(!arguments.length)return f;f=a;return g},g.out=function(a){if(!arguments.length)return d;d=a;return g};return g};var x={"inside-out":function(a){var b=a.length,c,d,e=a.map(z),f=a.map(A),g=d3.range(b).sort(function(a,b){return e[a]-e[b]}),h=0,i=0,j=[],k=[];for(c=0;c<b;++c)d=g[c],h<i?(h+=f[d],j.push(d)):(i+=f[d],k.push(d));return k.reverse().concat(j)},reverse:function(a){return d3.range(a.length).reverse()},"default":function(a){return d3.range(a.length)}},y={silhouette:function(a){var b=a.length,c=a[0].length,d=[],e=0,f,g,h,i=[];for(g=0;g<c;++g){for(f=0,h=0;f<b;f++)h+=a[f][g][1];h>e&&(e=h),d.push(h)}for(g=0;g<c;++g)i[g]=(e-d[g])/2;return i},wiggle:function(a){var b=a.length,c=a[0],d=c.length,e=0,f,g,h,i,j,k,l,m,n,o=[];o[0]=m=n=0;for(g=1;g<d;++g){for(f=0,i=0;f<b;++f)i+=a[f][g][1];for(f=0,j=0,l=c[g][0]-c[g-1][0];f<b;++f){for(h=0,k=(a[f][g][1]-a[f][g-1][1])/(2*l);h<f;++h)k+=(a[h][g][1]-a[h][g-1][1])/l;j+=k*a[f][g][1]}o[g]=m-=i?j/i*l:0,m<n&&(n=m)}for(g=0;g<d;++g)o[g]-=n;return o},expand:function(a){var b=a.length,c=a[0].length,d=1/b,e,f,g,h=[];for(f=0;f<c;++f){for(e=0,g=0;e<b;e++)g+=a[e][f][1];if(g)for(e=0;e<b;e++)a[e][f][1]/=g;else for(e=0;e<b;e++)a[e][f][1]=d}for(f=0;f<c;++f)h[f]=0;return h},zero:function(a){var b=-1,c=a[0].length,d=[];while(++b<c)d[b]=0;return d}};d3.layout.histogram=function(){function e(e,f){var g=[],h=e.map(b,this),i=c.call(this,h,f),j=d.call(this,i,h,f),k,f=-1,l=h.length,m=j.length-1,n=a?1/l:1,o;while(++f<m)k=g[f]=[],k.dx=j[f+1]-(k.x=j[f]),k.y=0;f=-1;while(++f<l)o=h[f],o>=i[0]&&o<=i[1]&&(k=g[d3.bisect(j,o,1,m)-1],k.y+=n,k.push(e[f]));return g}var a=!0,b=Number,c=E,d=C;e.value=function(a){if(!arguments.length)return b;b=a;return e},e.range=function(a){if(!arguments.length)return c;c=d3.functor(a);return e},e.bins=function(a){if(!arguments.length)return d;d=typeof a=="number"?function(b){return D(b,a)}:d3.functor(a);return e},e.frequency=function(b){if(!arguments.length)return a;a=!!b;return e};return e},d3.layout.hierarchy=function(){function g(a){var b=[];e(a,0,b);return b}function f(a,b){var d=a.children,e=0;if(d){var h=-1,i=d.length,j=b+1;while(++h<i)e+=f(d[h],j)}else c&&(e=c.call(g,K?a:a.data,b));c&&(a.value=e);return e}function e(f,h,i){var j=b.call(g,f,h),k=K?f:{data:f};k.depth=h,i.push(k);if(j){var l=-1,m=j.length,n=k.children=[],o=0,p=h+1;while(++l<m)d=e(j[l],p,i),d.parent=k,n.push(d),o+=d.value;a&&n.sort(a),c&&(k.value=o)}else c&&(k.value=c.call(g,f,h));return k}var a=I,b=G,c=H;g.sort=function(b){if(!arguments.length)return a;a=b;return g},g.children=function(a){if(!arguments.length)return b;b=a;return g},g.value=function(a){if(!arguments.length)return c;c=a;return g},g.revalue=function(a){f(a,0);return a};return g};var K=!1;d3.layout.pack=function(){function c(c,d){var e=a.call(this,c,d),f=e[0];f.x=0,f.y=0,S(f);var g=b[0],h=b[1],i=1/Math.max(2*f.r/g,2*f.r/h);T(f,g/2,h/2,i);return e}var a=d3.layout.hierarchy().sort(L),b=[1,1];c.size=function(a){if(!arguments.length)return b;b=a;return c};return F(c,a)},d3.layout.cluster=function(){function d(d,e){var f=a.call(this,d,e),g=f[0],h,i=0,j,k;be(g,function(a){a.children?(a.x=W(a.children),a.y=V(a.children)):(a.x=h?i+=b(a,h):0,a.y=0,h=a)});var l=X(g),m=Y(g),n=l.x-b(l,m)/2,o=m.x+b(m,l)/2;be(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=(1-a.y/g.y)*c[1]});return f}var a=d3.layout.hierarchy().sort(null).value(null),b=Z,c=[1,1];d.separation=function(a){if(!arguments.length)return b;b=a;return d},d.size=function(a){if(!arguments.length)return c;c=a;return d};return F(d,a)},d3.layout.tree=function(){function d(d,e){function j(a,c,d){if(c){var e=a,f=a,g=c,h=a.parent.children[0],i=e._tree.mod,j=f._tree.mod,k=g._tree.mod,l=h._tree.mod,m;while(g=_(g),e=$(e),g&&e)h=$(h),f=_(f),f._tree.ancestor=a,m=g._tree.prelim+k-e._tree.prelim-i+b(g,e),m>0&&(bg(bh(g,a,d),a,m),i+=m,j+=m),k+=g._tree.mod,i+=e._tree.mod,l+=h._tree.mod,j+=f._tree.mod;g&&!_(f)&&(f._tree.thread=g,f._tree.mod+=k-j),e&&!$(h)&&(h._tree.thread=e,h._tree.mod+=i-l,d=a)}return d}function i(a,b){a.x=a._tree.prelim+b;var c=a.children;if(c){var d=-1,e=c.length;b+=a._tree.mod;while(++d<e)i(c[d],b)}}function h(a,c){var d=a.children,e=a._tree;if(d){var f=d.length,g=d[0],i,k=g,l,m=-1;while(++m<f)l=d[m],h(l,i),k=j(l,i,k),i=l;bf(a);var n=.5*(g._tree.prelim+l._tree.prelim);c?(e.prelim=c._tree.prelim+b(a,c),e.mod=e.prelim-n):e.prelim=n}else c&&(e.prelim=c._tree.prelim+b(a,c))}var f=a.call(this,d,e),g=f[0];be(g,function(a,b){a._tree={ancestor:a,prelim:0,mod:0,change:0,shift:0,number:b?b._tree.number+1:0}}),h(g),i(g,-g._tree.prelim);var k=ba(g,bc),l=ba(g,bb),m=ba(g,bd),n=k.x-b(k,l)/2,o=l.x+b(l,k)/2,p=m.depth||1;be(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=a.depth/p*c[1],delete a._tree});return f}var a=d3.layout.hierarchy().sort(null).value(null),b=Z,c=[1,1];d.separation=function(a){if(!arguments.length)return b;b=a;return d},d.size=function(a){if(!arguments.length)return c;c=a;return d};return F(d,a)},d3.layout.treemap=function(){function l(b){var f=e||a(b),j=f[0];j.x=0,j.y=0,j.dx=c[0],j.dy=c[1],e&&a.revalue(j),g(j,c[0]*c[1]/j.value),(e?i:h)(j),d&&(e=f);return f}function k(a,c,d,e){var f=-1,g=a.length,h=d.x,i=d.y,j=c?b(a.area/c):0,k;if(c==d.dx){if(e||j>d.dy)j=d.dy;while(++f<g)k=a[f],k.x=h,k.y=i,k.dy=j,h+=k.dx=b(k.area/j);k.z=!0,k.dx+=d.x+d.dx-h,d.y+=j,d.dy-=j}else{if(e||j>d.dx)j=d.dx;while(++f<g)k=a[f],k.x=h,k.y=i,k.dx=j,i+=k.dy=b(k.area/j);k.z=!1,k.dy+=d.y+d.dy-i,d.x+=j,d.dx-=j}}function j(a,b){var c=a.area,d,e=0,g=Infinity,h=-1,i=a.length;while(++h<i)d=a[h].area,d<g&&(g=d),d>e&&(e=d);c*=c,b*=b;return Math.max(b*e*f/c,c/(b*g*f))}function i(a){if(!!a.children){var b={x:a.x,y:a.y,dx:a.dx,dy:a.dy},c=a.children.slice(),d,e=[];e.area=0;while(d=c.pop())e.push(d),e.area+=d.area,d.z!=null&&(k(e,d.z?b.dx:b.dy,b,!c.length),e.length=e.area=0);a.children.forEach(i)}}function h(a){if(!!a.children){var b={x:a.x,y:a.y,dx:a.dx,dy:a.dy},c=[],d=a.children.slice(),e,f=Infinity,g,i=Math.min(b.dx,b.dy),l;c.area=0;while((l=d.length)>0)c.push(e=d[l-1]),c.area+=e.area,(g=j(c,i))<=f?(d.pop(),f=g):(c.area-=c.pop().area,k(c,i,b,!1),i=Math.min(b.dx,b.dy),c.length=c.area=0,f=Infinity);c.length&&(k(c,i,b,!0),c.length=c.area=0),a.children.forEach(h)}}function g(a,b){var c=a.children;a.area=a.value*b;if(c){var d=-1,e=c.length;while(++d<e)g(c[d],b)}}var a=d3.layout.hierarchy(),b=Math.round,c=[1,1],d=!1,e,f=.5*(1+Math.sqrt(5));l.size=function(a){if(!arguments.length)return c;c=a;return l},l.round=function(a){if(!arguments.length)return b!=Number;b=a?Math.round:Number;return l},l.sticky=function(a){if(!arguments.length)return d;d=a,e=null;return l},l.ratio=function(a){if(!arguments.length)return f;f=a;return l};return F(l,a)}})() <ide>\ No newline at end of file <add>(function(){function bh(a,b,c){return a._tree.ancestor.parent==b.parent?a._tree.ancestor:c}function bg(a,b,c){a=a._tree,b=b._tree;var d=c/(b.number-a.number);a.change+=d,b.change-=d,b.shift+=c,b.prelim+=c,b.mod+=c}function bf(a){var b=0,c=0,d=a.children,e=d.length,f;while(--e>=0)f=d[e]._tree,f.prelim+=b,f.mod+=b,b+=f.shift+(c+=f.change)}function be(a,b){function c(a,d){var e=a.children;if(e){var f,g=null,h=-1,i=e.length;while(++h<i)f=e[h],c(f,g),g=f}b(a,d)}c(a,null)}function bd(a,b){return a.depth-b.depth}function bc(a,b){return b.x-a.x}function bb(a,b){return a.x-b.x}function ba(a,b){var c=a.children;if(c){var d,e=c.length,f=-1;while(++f<e)b(d=ba(c[f],b),a)>0&&(a=d)}return a}function _(a){return a.children?a.children[a.children.length-1]:a._tree.thread}function $(a){return a.children?a.children[0]:a._tree.thread}function Z(a,b){return a.parent==b.parent?1:2}function Y(a){var b=a.children;return b?Y(b[b.length-1]):a}function X(a){var b=a.children;return b?X(b[0]):a}function W(a){return a.reduce(function(a,b){return a+b.x},0)/a.length}function V(a){return 1+d3.max(a,function(a){return a.y})}function U(a,b,c){var d=b.r+c.r,e=a.r+c.r,f=b.x-a.x,g=b.y-a.y,h=Math.sqrt(f*f+g*g),i=(e*e+h*h-d*d)/(2*e*h),j=Math.acos(i),k=i*e,l=Math.sin(j)*e;f/=h,g/=h,c.x=a.x+k*f+l*g,c.y=a.y+k*g-l*f}function T(a,b,c,d){var e=a.children;a.x=b+=d*a.x,a.y=c+=d*a.y,a.r*=d;if(e){var f=-1,g=e.length;while(++f<g)T(e[f],b,c,d)}}function S(a){var b=a.children;b?(b.forEach(S),a.r=P(b)):a.r=Math.sqrt(a.value)}function R(a){delete a._pack_next,delete a._pack_prev}function Q(a){a._pack_next=a._pack_prev=a}function P(a){function l(a){b=Math.min(a.x-a.r,b),c=Math.max(a.x+a.r,c),d=Math.min(a.y-a.r,d),e=Math.max(a.y+a.r,e)}var b=Infinity,c=-Infinity,d=Infinity,e=-Infinity,f=a.length,g,h,i,j,k;a.forEach(Q),g=a[0],g.x=-g.r,g.y=0,l(g);if(f>1){h=a[1],h.x=h.r,h.y=0,l(h);if(f>2){i=a[2],U(g,h,i),l(i),M(g,i),g._pack_prev=i,M(i,h),h=g._pack_next;for(var m=3;m<f;m++){U(g,h,i=a[m]);var n=0,o=1,p=1;for(j=h._pack_next;j!==h;j=j._pack_next,o++)if(O(j,i)){n=1;break}if(n==1)for(k=g._pack_prev;k!==j._pack_prev;k=k._pack_prev,p++)if(O(k,i)){p<o&&(n=-1,j=k);break}n==0?(M(g,i),h=i,l(i)):n>0?(N(g,j),h=j,m--):(N(j,h),g=j,m--)}}}var q=(b+c)/2,r=(d+e)/2,s=0;for(var m=0;m<f;m++){var t=a[m];t.x-=q,t.y-=r,s=Math.max(s,t.r+Math.sqrt(t.x*t.x+t.y*t.y))}a.forEach(R);return s}function O(a,b){var c=b.x-a.x,d=b.y-a.y,e=a.r+b.r;return e*e-c*c-d*d>.001}function N(a,b){a._pack_next=b,b._pack_prev=a}function M(a,b){var c=a._pack_next;a._pack_next=b,b._pack_prev=a,b._pack_next=c,c._pack_prev=b}function L(a,b){return a.value-b.value}function J(a){return d3.merge(a.map(function(a){return(a.children||[]).map(function(b){return{source:a,target:b}})}))}function I(a,b){return b.value-a.value}function H(a){return a.value}function G(a){return a.children}function F(a,b){a.sort=d3.rebind(a,b.sort),a.children=d3.rebind(a,b.children),a.links=J,a.value=d3.rebind(a,b.value),a.nodes=function(b){K=!0;return(a.nodes=a)(b)};return a}function E(a){return[d3.min(a),d3.max(a)]}function D(a,b){var c=-1,d=+a[0],e=(a[1]-d)/b,f=[];while(++c<=b)f[c]=e*c+d;return f}function C(a,b){return D(a,Math.ceil(Math.log(b.length)/Math.LN2+1))}function B(a,b){return a+b[1]}function A(a){return a.reduce(B,0)}function z(a){var b=1,c=0,d=a[0][1],e,f=a.length;for(;b<f;++b)(e=a[b][1])>d&&(c=b,d=e);return c}function w(a,b,c){a.y0=b,a.y=c}function v(a){return a.y}function u(a){return a.x}function t(a){return 1}function s(a){return 20}function r(a){var b=0,c=0;a.count=0;if(!a.leaf){var d=a.nodes,e=d.length,f=-1,g;while(++f<e){g=d[f];if(g==null)continue;r(g),a.count+=g.count,b+=g.count*g.cx,c+=g.count*g.cy}}a.point&&(a.leaf||(a.point.x+=Math.random()-.5,a.point.y+=Math.random()-.5),a.count++,b+=a.point.x,c+=a.point.y),a.cx=b/a.count,a.cy=c/a.count}function q(){d3.event.stopPropagation(),d3.event.preventDefault()}function p(){i&&(q(),i=!1)}function o(){!f||(g&&(i=!0,q()),d3.event.type==="mouseup"&&n(),f.fixed=!1,e=h=f=j=null)}function n(){if(!!f){var a=j.parentNode;if(!a){f.fixed=!1,h=f=j=null;return}var b=m(a);g=!0,f.px=b[0]-h[0],f.py=b[1]-h[1],q(),e.resume()}}function m(a){return d3.event.touches?d3.svg.touches(a)[0]:d3.svg.mouse(a)}function l(a){a!==f&&(a.fixed=!1)}function k(a){a.fixed=!0}function c(a,c){if(a===c)return a;var d=b(a),e=b(c),f=d.pop(),g=e.pop(),h=null;while(f===g)h=f,f=d.pop(),g=e.pop();return h}function b(a){var b=[],c=a.parent;while(c!=null)b.push(a),a=c,c=c.parent;b.push(a);return b}function a(a){var b=a.source,d=a.target,e=c(b,d),f=[b];while(b!==e)b=b.parent,f.push(b);var g=f.length;while(d!==e)f.splice(g,0,d),d=d.parent;return f}d3.layout={},d3.layout.bundle=function(){return function(b){var c=[],d=-1,e=b.length;while(++d<e)c.push(a(b[d]));return c}},d3.layout.chord=function(){function k(){b.sort(function(a,b){return i(a.target.value,b.target.value)})}function j(){var a={},j=[],l=d3.range(e),m=[],n,o,p,q,r;b=[],c=[],n=0,q=-1;while(++q<e){o=0,r=-1;while(++r<e)o+=d[q][r];j.push(o),m.push(d3.range(e)),n+=o}g&&l.sort(function(a,b){return g(j[a],j[b])}),h&&m.forEach(function(a,b){a.sort(function(a,c){return h(d[b][a],d[b][c])})}),n=(2*Math.PI-f*e)/n,o=0,q=-1;while(++q<e){p=o,r=-1;while(++r<e){var s=l[q],t=m[q][r],u=d[s][t];a[s+"-"+t]={index:s,subindex:t,startAngle:o,endAngle:o+=u*n,value:u}}c.push({index:s,startAngle:p,endAngle:o,value:(o-p)/n}),o+=f}q=-1;while(++q<e){r=q-1;while(++r<e){var v=a[q+"-"+r],w=a[r+"-"+q];(v.value||w.value)&&b.push(v.value<w.value?{source:w,target:v}:{source:v,target:w})}}i&&k()}var a={},b,c,d,e,f=0,g,h,i;a.matrix=function(f){if(!arguments.length)return d;e=(d=f)&&d.length,b=c=null;return a},a.padding=function(d){if(!arguments.length)return f;f=d,b=c=null;return a},a.sortGroups=function(d){if(!arguments.length)return g;g=d,b=c=null;return a},a.sortSubgroups=function(c){if(!arguments.length)return h;h=c,b=null;return a},a.sortChords=function(c){if(!arguments.length)return i;i=c,b&&k();return a},a.chords=function(){b||j();return b},a.groups=function(){c||j();return c};return a},d3.layout.force=function(){function G(b,c){var d=m(this.parentNode);(f=b).fixed=!0,g=!1,j=this,e=a,h=[d[0]-b.x,d[1]-b.y],q()}function F(){var a=A.length,e=B.length,f=d3.geom.quadtree(A),g,h,j,k,l,m,n;for(g=0;g<e;++g){h=B[g],j=h.source,k=h.target,m=k.x-j.x,n=k.y-j.y;if(l=m*m+n*n)l=d*D[g]*((l=Math.sqrt(l))-C[g])/l,m*=l,n*=l,k.x-=m,k.y-=n,j.x+=m,j.y+=n}var o=d*x;m=c[0]/2,n=c[1]/2,g=-1;while(++g<a)h=A[g],h.x+=(m-h.x)*o,h.y+=(n-h.y)*o;r(f);var p=d*w;g=-1;while(++g<a)f.visit(E(A[g],p));g=-1;while(++g<a)h=A[g],h.fixed?(h.x=h.px,h.y=h.py):(h.x-=(h.px-(h.px=h.x))*i,h.y-=(h.py-(h.py=h.y))*i);b.tick.dispatch({type:"tick",alpha:d});return(d*=.99)<.005}function E(a,b){return function(c,d,e,f,g){if(c.point!==a){var h=c.cx-a.x,i=c.cy-a.y,j=1/Math.sqrt(h*h+i*i);if((f-d)*j<y){var k=b*c.count*j*j;a.x+=h*k,a.y+=i*k;return!0}if(c.point&&isFinite(j)){var k=b*j*j;a.x+=h*k,a.y+=i*k}}}}var a={},b=d3.dispatch("tick"),c=[1,1],d,i=.9,u=s,v=t,w=-30,x=.1,y=.8,z,A=[],B=[],C,D;a.on=function(c,d){b[c].add(d);return a},a.nodes=function(b){if(!arguments.length)return A;A=b;return a},a.links=function(b){if(!arguments.length)return B;B=b;return a},a.size=function(b){if(!arguments.length)return c;c=b;return a},a.linkDistance=function(b){if(!arguments.length)return u;u=d3.functor(b);return a},a.distance=a.linkDistance,a.linkStrength=function(b){if(!arguments.length)return v;v=d3.functor(b);return a},a.friction=function(b){if(!arguments.length)return i;i=b;return a},a.charge=function(b){if(!arguments.length)return w;w=b;return a},a.gravity=function(b){if(!arguments.length)return x;x=b;return a},a.theta=function(b){if(!arguments.length)return y;y=b;return a},a.start=function(){function l(){if(!i){i=[];for(d=0;d<e;++d)i[d]=[];for(d=0;d<f;++d){var a=B[d];i[a.source.index].push(a.target),i[a.target.index].push(a.source)}}return i[b]}function k(a,c){var d=l(b),e=-1,f=d.length,g;while(++e<f)if(!isNaN(g=d[e][a]))return g;return Math.random()*c}var b,d,e=A.length,f=B.length,g=c[0],h=c[1],i,j;for(b=0;b<e;++b)(j=A[b]).index=b;C=[],D=[];for(b=0;b<f;++b)j=B[b],typeof j.source=="number"&&(j.source=A[j.source]),typeof j.target=="number"&&(j.target=A[j.target]),C[b]=u.call(this,j,b),D[b]=v.call(this,j,b);for(b=0;b<e;++b)j=A[b],isNaN(j.x)&&(j.x=k("x",g)),isNaN(j.y)&&(j.y=k("y",h)),isNaN(j.px)&&(j.px=j.x),isNaN(j.py)&&(j.py=j.y);return a.resume()},a.resume=function(){d=.1,d3.timer(F);return a},a.stop=function(){d=0;return a},a.drag=function(){this.on("mouseover.force",k).on("mouseout.force",l).on("mousedown.force",G).on("touchstart.force",G),d3.select(window).on("mousemove.force",n).on("touchmove.force",n).on("mouseup.force",o,!0).on("touchend.force",o,!0).on("click.force",p,!0);return a};return a};var e,f,g,h,i,j;d3.layout.partition=function(){function e(e,f){var g=a.call(this,e,f);c(g[0],0,b[0],b[1]/d(g[0]));return g}function d(a){var b=a.children,c=0;if(b){var e=-1,f=b.length;while(++e<f)c=Math.max(c,d(b[e]))}return 1+c}function c(a,b,d,e){var f=a.children;a.x=b,a.y=a.depth*e,a.dx=d,a.dy=e;if(f){var g=-1,h=f.length,i,j;d/=a.value;while(++g<h)c(i=f[g],b,j=i.value*d,e),b+=j}}var a=d3.layout.hierarchy(),b=[1,1];e.size=function(a){if(!arguments.length)return b;b=a;return e};return F(e,a)},d3.layout.pie=function(){function f(f,g){var h=+(typeof c=="function"?c.apply(this,arguments):c),i=(typeof e=="function"?e.apply(this,arguments):e)-c,j=d3.range(f.length);b!=null&&j.sort(function(a,c){return b(f[a],f[c])});var k=f.map(a);i/=k.reduce(function(a,b){return a+b},0);var l=j.map(function(a){return{value:d=k[a],startAngle:h,endAngle:h+=d*i}});return f.map(function(a,b){return l[j[b]]})}var a=Number,b=null,c=0,e=2*Math.PI;f.value=function(b){if(!arguments.length)return a;a=b;return f},f.sort=function(a){if(!arguments.length)return b;b=a;return f},f.startAngle=function(a){if(!arguments.length)return c;c=a;return f},f.endAngle=function(a){if(!arguments.length)return e;e=a;return f};return f},d3.layout.stack=function(){function g(h,i){var j=h.map(function(b,c){return a.call(g,b,c)}),k=j.map(function(a,b){return a.map(function(a,b){return[e.call(g,a,b),f.call(g,a,b)]})}),l=b.call(g,k,i);j=d3.permute(j,l),k=d3.permute(k,l);var m=c.call(g,k,i),n=j.length,o=j[0].length,p,q,r;for(q=0;q<o;++q){d.call(g,j[0][q],r=m[q],k[0][q][1]);for(p=1;p<n;++p)d.call(g,j[p][q],r+=k[p-1][q][1],k[p][q][1])}return h}var a=Object,b=x["default"],c=y.zero,d=w,e=u,f=v;g.values=function(b){if(!arguments.length)return a;a=b;return g},g.order=function(a){if(!arguments.length)return b;b=typeof a=="function"?a:x[a];return g},g.offset=function(a){if(!arguments.length)return c;c=typeof a=="function"?a:y[a];return g},g.x=function(a){if(!arguments.length)return e;e=a;return g},g.y=function(a){if(!arguments.length)return f;f=a;return g},g.out=function(a){if(!arguments.length)return d;d=a;return g};return g};var x={"inside-out":function(a){var b=a.length,c,d,e=a.map(z),f=a.map(A),g=d3.range(b).sort(function(a,b){return e[a]-e[b]}),h=0,i=0,j=[],k=[];for(c=0;c<b;++c)d=g[c],h<i?(h+=f[d],j.push(d)):(i+=f[d],k.push(d));return k.reverse().concat(j)},reverse:function(a){return d3.range(a.length).reverse()},"default":function(a){return d3.range(a.length)}},y={silhouette:function(a){var b=a.length,c=a[0].length,d=[],e=0,f,g,h,i=[];for(g=0;g<c;++g){for(f=0,h=0;f<b;f++)h+=a[f][g][1];h>e&&(e=h),d.push(h)}for(g=0;g<c;++g)i[g]=(e-d[g])/2;return i},wiggle:function(a){var b=a.length,c=a[0],d=c.length,e=0,f,g,h,i,j,k,l,m,n,o=[];o[0]=m=n=0;for(g=1;g<d;++g){for(f=0,i=0;f<b;++f)i+=a[f][g][1];for(f=0,j=0,l=c[g][0]-c[g-1][0];f<b;++f){for(h=0,k=(a[f][g][1]-a[f][g-1][1])/(2*l);h<f;++h)k+=(a[h][g][1]-a[h][g-1][1])/l;j+=k*a[f][g][1]}o[g]=m-=i?j/i*l:0,m<n&&(n=m)}for(g=0;g<d;++g)o[g]-=n;return o},expand:function(a){var b=a.length,c=a[0].length,d=1/b,e,f,g,h=[];for(f=0;f<c;++f){for(e=0,g=0;e<b;e++)g+=a[e][f][1];if(g)for(e=0;e<b;e++)a[e][f][1]/=g;else for(e=0;e<b;e++)a[e][f][1]=d}for(f=0;f<c;++f)h[f]=0;return h},zero:function(a){var b=-1,c=a[0].length,d=[];while(++b<c)d[b]=0;return d}};d3.layout.histogram=function(){function e(e,f){var g=[],h=e.map(b,this),i=c.call(this,h,f),j=d.call(this,i,h,f),k,f=-1,l=h.length,m=j.length-1,n=a?1/l:1,o;while(++f<m)k=g[f]=[],k.dx=j[f+1]-(k.x=j[f]),k.y=0;f=-1;while(++f<l)o=h[f],o>=i[0]&&o<=i[1]&&(k=g[d3.bisect(j,o,1,m)-1],k.y+=n,k.push(e[f]));return g}var a=!0,b=Number,c=E,d=C;e.value=function(a){if(!arguments.length)return b;b=a;return e},e.range=function(a){if(!arguments.length)return c;c=d3.functor(a);return e},e.bins=function(a){if(!arguments.length)return d;d=typeof a=="number"?function(b){return D(b,a)}:d3.functor(a);return e},e.frequency=function(b){if(!arguments.length)return a;a=!!b;return e};return e},d3.layout.hierarchy=function(){function g(a){var b=[];e(a,0,b);return b}function f(a,b){var d=a.children,e=0;if(d){var h=-1,i=d.length,j=b+1;while(++h<i)e+=f(d[h],j)}else c&&(e=c.call(g,K?a:a.data,b));c&&(a.value=e);return e}function e(f,h,i){var j=b.call(g,f,h),k=K?f:{data:f};k.depth=h,i.push(k);if(j){var l=-1,m=j.length,n=k.children=[],o=0,p=h+1;while(++l<m)d=e(j[l],p,i),d.parent=k,n.push(d),o+=d.value;a&&n.sort(a),c&&(k.value=o)}else c&&(k.value=c.call(g,f,h));return k}var a=I,b=G,c=H;g.sort=function(b){if(!arguments.length)return a;a=b;return g},g.children=function(a){if(!arguments.length)return b;b=a;return g},g.value=function(a){if(!arguments.length)return c;c=a;return g},g.revalue=function(a){f(a,0);return a};return g};var K=!1;d3.layout.pack=function(){function c(c,d){var e=a.call(this,c,d),f=e[0];f.x=0,f.y=0,S(f);var g=b[0],h=b[1],i=1/Math.max(2*f.r/g,2*f.r/h);T(f,g/2,h/2,i);return e}var a=d3.layout.hierarchy().sort(L),b=[1,1];c.size=function(a){if(!arguments.length)return b;b=a;return c};return F(c,a)},d3.layout.cluster=function(){function d(d,e){var f=a.call(this,d,e),g=f[0],h,i=0,j,k;be(g,function(a){a.children?(a.x=W(a.children),a.y=V(a.children)):(a.x=h?i+=b(a,h):0,a.y=0,h=a)});var l=X(g),m=Y(g),n=l.x-b(l,m)/2,o=m.x+b(m,l)/2;be(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=(1-a.y/g.y)*c[1]});return f}var a=d3.layout.hierarchy().sort(null).value(null),b=Z,c=[1,1];d.separation=function(a){if(!arguments.length)return b;b=a;return d},d.size=function(a){if(!arguments.length)return c;c=a;return d};return F(d,a)},d3.layout.tree=function(){function d(d,e){function j(a,c,d){if(c){var e=a,f=a,g=c,h=a.parent.children[0],i=e._tree.mod,j=f._tree.mod,k=g._tree.mod,l=h._tree.mod,m;while(g=_(g),e=$(e),g&&e)h=$(h),f=_(f),f._tree.ancestor=a,m=g._tree.prelim+k-e._tree.prelim-i+b(g,e),m>0&&(bg(bh(g,a,d),a,m),i+=m,j+=m),k+=g._tree.mod,i+=e._tree.mod,l+=h._tree.mod,j+=f._tree.mod;g&&!_(f)&&(f._tree.thread=g,f._tree.mod+=k-j),e&&!$(h)&&(h._tree.thread=e,h._tree.mod+=i-l,d=a)}return d}function i(a,b){a.x=a._tree.prelim+b;var c=a.children;if(c){var d=-1,e=c.length;b+=a._tree.mod;while(++d<e)i(c[d],b)}}function h(a,c){var d=a.children,e=a._tree;if(d){var f=d.length,g=d[0],i,k=g,l,m=-1;while(++m<f)l=d[m],h(l,i),k=j(l,i,k),i=l;bf(a);var n=.5*(g._tree.prelim+l._tree.prelim);c?(e.prelim=c._tree.prelim+b(a,c),e.mod=e.prelim-n):e.prelim=n}else c&&(e.prelim=c._tree.prelim+b(a,c))}var f=a.call(this,d,e),g=f[0];be(g,function(a,b){a._tree={ancestor:a,prelim:0,mod:0,change:0,shift:0,number:b?b._tree.number+1:0}}),h(g),i(g,-g._tree.prelim);var k=ba(g,bc),l=ba(g,bb),m=ba(g,bd),n=k.x-b(k,l)/2,o=l.x+b(l,k)/2,p=m.depth||1;be(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=a.depth/p*c[1],delete a._tree});return f}var a=d3.layout.hierarchy().sort(null).value(null),b=Z,c=[1,1];d.separation=function(a){if(!arguments.length)return b;b=a;return d},d.size=function(a){if(!arguments.length)return c;c=a;return d};return F(d,a)},d3.layout.treemap=function(){function l(b){var f=e||a(b),j=f[0];j.x=0,j.y=0,j.dx=c[0],j.dy=c[1],e&&a.revalue(j),g(j,c[0]*c[1]/j.value),(e?i:h)(j),d&&(e=f);return f}function k(a,c,d,e){var f=-1,g=a.length,h=d.x,i=d.y,j=c?b(a.area/c):0,k;if(c==d.dx){if(e||j>d.dy)j=d.dy;while(++f<g)k=a[f],k.x=h,k.y=i,k.dy=j,h+=k.dx=b(k.area/j);k.z=!0,k.dx+=d.x+d.dx-h,d.y+=j,d.dy-=j}else{if(e||j>d.dx)j=d.dx;while(++f<g)k=a[f],k.x=h,k.y=i,k.dx=j,i+=k.dy=b(k.area/j);k.z=!1,k.dy+=d.y+d.dy-i,d.x+=j,d.dx-=j}}function j(a,b){var c=a.area,d,e=0,g=Infinity,h=-1,i=a.length;while(++h<i)d=a[h].area,d<g&&(g=d),d>e&&(e=d);c*=c,b*=b;return Math.max(b*e*f/c,c/(b*g*f))}function i(a){if(!!a.children){var b={x:a.x,y:a.y,dx:a.dx,dy:a.dy},c=a.children.slice(),d,e=[];e.area=0;while(d=c.pop())e.push(d),e.area+=d.area,d.z!=null&&(k(e,d.z?b.dx:b.dy,b,!c.length),e.length=e.area=0);a.children.forEach(i)}}function h(a){if(!!a.children){var b={x:a.x,y:a.y,dx:a.dx,dy:a.dy},c=[],d=a.children.slice(),e,f=Infinity,g,i=Math.min(b.dx,b.dy),l;c.area=0;while((l=d.length)>0)c.push(e=d[l-1]),c.area+=e.area,(g=j(c,i))<=f?(d.pop(),f=g):(c.area-=c.pop().area,k(c,i,b,!1),i=Math.min(b.dx,b.dy),c.length=c.area=0,f=Infinity);c.length&&(k(c,i,b,!0),c.length=c.area=0),a.children.forEach(h)}}function g(a,b){var c=a.children;a.area=a.value*b;if(c){var d=-1,e=c.length;while(++d<e)g(c[d],b)}}var a=d3.layout.hierarchy(),b=Math.round,c=[1,1],d=!1,e,f=.5*(1+Math.sqrt(5));l.size=function(a){if(!arguments.length)return c;c=a;return l},l.round=function(a){if(!arguments.length)return b!=Number;b=a?Math.round:Number;return l},l.sticky=function(a){if(!arguments.length)return d;d=a,e=null;return l},l.ratio=function(a){if(!arguments.length)return f;f=a;return l};return F(l,a)}})() <ide>\ No newline at end of file <ide><path>src/layout/force.js <ide> function d3_layout_forceAccumulate(quad) { <ide> cy = 0; <ide> quad.count = 0; <ide> if (!quad.leaf) { <del> quad.nodes.forEach(function(c) { <add> var nodes = quad.nodes, <add> n = nodes.length, <add> i = -1, <add> c; <add> while (++i < n) { <add> c = nodes[i]; <add> if (c == null) continue; <ide> d3_layout_forceAccumulate(c); <ide> quad.count += c.count; <ide> cx += c.count * c.cx; <ide> cy += c.count * c.cy; <del> }); <add> } <ide> } <ide> if (quad.point) { <ide> // jitter internal nodes that are coincident
3
Python
Python
fix names + typos and load_file args
327fa2e76ebd82cc7306c536d01b6b804314012b
<ide><path>airflow/hooks/webhdfs_hook.py <ide> from airflow.configuration import conf <ide> import logging <ide> <del>from hdfs import InsecureClient, Hdfserror <add>from hdfs import InsecureClient, HdfsError <ide> from airflow.utils import AirflowException <ide> <ide> <ide> class WebHDFSHook(BaseHook): <ide> """ <ide> Interact with HDFS. This class is a wrapper around the hdfscli library. <ide> """ <del> def __init__(self, hdfs_conn_id='hdfs_default'): <del> self.hdfs_conn_id = hdfs_conn_id <add> def __init__(self, webhdfs_conn_id='webhdfs_default'): <add> self.webhdfs_conn_id = webhdfs_conn_id <ide> <ide> def get_conn(self): <ide> """ <ide> Returns a hdfscli InsecureClient object. <ide> """ <del> nn_connections = self.get_connections(self.hdfs_conn_id) <add> nn_connections = self.get_connections(self.webhdfs_conn_id) <ide> for nn in nn_connections: <ide> try: <del> logging.debug('Trying namenode {nn.host}'.format(nn)) <del> client = InsecureClient('http://{nn.host}:{nn.port}'.format(nn)) <add> logging.debug('Trying namenode {}'.format(nn.host)) <add> client = InsecureClient('http://{nn.host}:{nn.port}'.format(nn=nn)) <ide> client.content('/') <del> logging.debug('Using namenode {nn.host} for hook'.format(nn)) <add> logging.debug('Using namenode {} for hook'.format(nn.host)) <ide> return client <del> except Hdfserror as e: <add> except HdfsError as e: <ide> logging.debug("Read operation on namenode {nn.host} failed with" <del> " error: {e.messaage}".format(**locals())) <add> " error: {e.message}".format(**locals())) <ide> nn_hosts = [c.host for c in nn_connections] <ide> no_nn_error = "Read operations failed on the namenodes below:\n{}".format("\n".join(nn_hosts)) <ide> raise WebHDFSHookException(no_nn_error) <ide> def check_for_path(self, hdfs_path): <ide> return bool(c.status(hdfs_path, strict=False)) <ide> <ide> def load_file(self, source, destination, overwrite=True, parallelism=1, <del> tmp_dir=None, chunk_size=2 ** 16, progress=None, **kwargs): <add> **kwargs): <ide> """ <ide> Uploads a file to HDFS <ide> <ide> def load_file(self, source, destination, overwrite=True, parallelism=1, <ide> local_path=source, <ide> overwrite=overwrite, <ide> n_threads=parallelism, <del> tmp_dir=tmp_dir, <del> chunk_size=chunk_size, <del> progress=progress, <ide> **kwargs) <ide> logging.debug("Uploaded file {} to {}".format(source, destination)) <ide><path>airflow/operators/sensors.py <ide> class WebHdfsSensor(BaseSensorOperator): <ide> def __init__( <ide> self, <ide> filepath, <del> hdfs_conn_id='hdfs_default', <add> webhdfs_conn_id='webhdfs_default', <ide> *args, **kwargs): <ide> super(WebHdfsSensor, self).__init__(*args, **kwargs) <ide> self.filepath = filepath <del> self.hdfs_conn_id = hdfs_conn_id <add> self.hdfs_conn_id = webhdfs_conn_id <ide> <ide> def poke(self, context): <del> c = hooks.WebHDFSHook(self.hdfs_conn_id).get_conn() <add> c = hooks.WebHDFSHook(self.webhdfs_conn_id).get_conn() <ide> logging.info( <ide> 'Poking for file {self.filepath} '.format(**locals())) <ide> return c.check_for_path(hdfs_path=self.filepath)
2
Java
Java
fix compilation of spel elvis/ternary expressions
d41d28f8cef5355e0cc36e51049577fb113f3b6f
<ide><path>spring-expression/src/main/java/org/springframework/expression/spel/ast/Elvis.java <ide> /* <del> * Copyright 2002-2014 the original author or authors. <add> * Copyright 2002-2016 the original author or authors. <ide> * <ide> * Licensed under the Apache License, Version 2.0 (the "License"); <ide> * you may not use this file except in compliance with the License. <ide> public Elvis(int pos, SpelNodeImpl... args) { <ide> @Override <ide> public TypedValue getValueInternal(ExpressionState state) throws EvaluationException { <ide> TypedValue value = this.children[0].getValueInternal(state); <add> // If this check is changed, the generateCode method will need changing too <ide> if (!StringUtils.isEmpty(value.getValue())) { <ide> return value; <ide> } <ide> public void generateCode(MethodVisitor mv, CodeFlow cf) { <ide> // exit type descriptor can be null if both components are literal expressions <ide> computeExitTypeDescriptor(); <ide> this.children[0].generateCode(mv, cf); <add> CodeFlow.insertBoxIfNecessary(mv, cf.lastDescriptor().charAt(0)); <ide> Label elseTarget = new Label(); <ide> Label endOfIf = new Label(); <ide> mv.visitInsn(DUP); <ide> mv.visitJumpInsn(IFNULL, elseTarget); <del> mv.visitJumpInsn(GOTO, endOfIf); <add> // Also check if empty string, as per the code in the interpreted version <add> mv.visitInsn(DUP); <add> mv.visitLdcInsn(""); <add> mv.visitInsn(SWAP); <add> mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z",false); <add> mv.visitJumpInsn(IFEQ, endOfIf); // If not empty, drop through to elseTarget <ide> mv.visitLabel(elseTarget); <ide> mv.visitInsn(POP); <ide> this.children[1].generateCode(mv, cf); <ide> private void computeExitTypeDescriptor() { <ide> if (conditionDescriptor.equals(ifNullValueDescriptor)) { <ide> this.exitTypeDescriptor = conditionDescriptor; <ide> } <del> else if (conditionDescriptor.equals("Ljava/lang/Object") && !CodeFlow.isPrimitive(ifNullValueDescriptor)) { <del> this.exitTypeDescriptor = ifNullValueDescriptor; <del> } <del> else if (ifNullValueDescriptor.equals("Ljava/lang/Object") && !CodeFlow.isPrimitive(conditionDescriptor)) { <del> this.exitTypeDescriptor = conditionDescriptor; <del> } <ide> else { <ide> // Use the easiest to compute common super type <ide> this.exitTypeDescriptor = "Ljava/lang/Object"; <ide><path>spring-expression/src/main/java/org/springframework/expression/spel/ast/Ternary.java <ide> /* <del> * Copyright 2002-2014 the original author or authors. <add> * Copyright 2002-2016 the original author or authors. <ide> * <ide> * Licensed under the Apache License, Version 2.0 (the "License"); <ide> * you may not use this file except in compliance with the License. <ide> private void computeExitTypeDescriptor() { <ide> if (leftDescriptor.equals(rightDescriptor)) { <ide> this.exitTypeDescriptor = leftDescriptor; <ide> } <del> else if (leftDescriptor.equals("Ljava/lang/Object") && !CodeFlow.isPrimitive(rightDescriptor)) { <del> this.exitTypeDescriptor = rightDescriptor; <del> } <del> else if (rightDescriptor.equals("Ljava/lang/Object") && !CodeFlow.isPrimitive(leftDescriptor)) { <del> this.exitTypeDescriptor = leftDescriptor; <del> } <ide> else { <ide> // Use the easiest to compute common super type <ide> this.exitTypeDescriptor = "Ljava/lang/Object"; <ide><path>spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java <ide> package org.springframework.expression.spel; <ide> <ide> import java.io.IOException; <add>import java.lang.reflect.Field; <ide> import java.lang.reflect.Method; <ide> import java.util.ArrayList; <add>import java.util.Collections; <ide> import java.util.HashMap; <ide> import java.util.List; <ide> import java.util.Map; <ide> public void indexerMapAccessor_12045() throws Exception { <ide> assertEquals(3, expression.getValue(root)); <ide> assertEquals(3, expression.getValue(root)); <ide> } <add> <add> @Test <add> public void elvisOperator_SPR15192() { <add> SpelParserConfiguration configuration = new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, null); <add> Expression exp; <add> <add> exp = new SpelExpressionParser(configuration).parseExpression("bar()"); <add> assertEquals("BAR", exp.getValue(new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("BAR", exp.getValue(new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> exp = new SpelExpressionParser(configuration).parseExpression("bar('baz')"); <add> assertEquals("BAZ", exp.getValue(new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("BAZ", exp.getValue(new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> StandardEvaluationContext context = new StandardEvaluationContext(); <add> context.setVariable("map", Collections.singletonMap("foo", "qux")); <add> <add> exp = new SpelExpressionParser(configuration).parseExpression("bar(#map['foo'])"); <add> assertEquals("QUX", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("QUX", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> exp = new SpelExpressionParser(configuration).parseExpression("bar(#map['foo'] ?: 'qux')"); <add> assertEquals("QUX", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("QUX", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> // When the condition is a primitive <add> exp = new SpelExpressionParser(configuration).parseExpression("3?:'foo'"); <add> assertEquals("3", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("3", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> // When the condition is a double slot primitive <add> exp = new SpelExpressionParser(configuration).parseExpression("3L?:'foo'"); <add> assertEquals("3", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("3", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> // When the condition is an empty string <add> exp = new SpelExpressionParser(configuration).parseExpression("''?:4L"); <add> assertEquals("4", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("4", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> // null condition <add> exp = new SpelExpressionParser(configuration).parseExpression("null?:4L"); <add> assertEquals("4", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("4", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> // variable access returning primitive <add> exp = new SpelExpressionParser(configuration).parseExpression("#x?:'foo'"); <add> context.setVariable("x",50); <add> assertEquals("50", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("50", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> exp = new SpelExpressionParser(configuration).parseExpression("#x?:'foo'"); <add> context.setVariable("x",null); <add> assertEquals("foo", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("foo", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> // variable access returning array <add> exp = new SpelExpressionParser(configuration).parseExpression("#x?:'foo'"); <add> context.setVariable("x",new int[]{1,2,3}); <add> assertEquals("1,2,3", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("1,2,3", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> } <add> <add> @Test <add> public void ternaryOperator_SPR15192() { <add> SpelParserConfiguration configuration = new SpelParserConfiguration(SpelCompilerMode.IMMEDIATE, null); <add> Expression exp; <add> StandardEvaluationContext context = new StandardEvaluationContext(); <add> context.setVariable("map", Collections.singletonMap("foo", "qux")); <add> <add> exp = new SpelExpressionParser(configuration).parseExpression("bar(#map['foo'] != null ? #map['foo'] : 'qux')"); <add> assertEquals("QUX", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("QUX", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> exp = new SpelExpressionParser(configuration).parseExpression("3==3?3:'foo'"); <add> assertEquals("3", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("3", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> exp = new SpelExpressionParser(configuration).parseExpression("3!=3?3:'foo'"); <add> assertEquals("foo", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("foo", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> // When the condition is a double slot primitive <add> exp = new SpelExpressionParser(configuration).parseExpression("3==3?3L:'foo'"); <add> assertEquals("3", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("3", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> exp = new SpelExpressionParser(configuration).parseExpression("3!=3?3L:'foo'"); <add> assertEquals("foo", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("foo", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> // When the condition is an empty string <add> exp = new SpelExpressionParser(configuration).parseExpression("''==''?'abc':4L"); <add> assertEquals("abc", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("abc", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> // null condition <add> exp = new SpelExpressionParser(configuration).parseExpression("3==3?null:4L"); <add> assertEquals(null, exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals(null, exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> // variable access returning primitive <add> exp = new SpelExpressionParser(configuration).parseExpression("#x==#x?50:'foo'"); <add> context.setVariable("x",50); <add> assertEquals("50", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("50", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> exp = new SpelExpressionParser(configuration).parseExpression("#x!=#x?50:'foo'"); <add> context.setVariable("x",null); <add> assertEquals("foo", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("foo", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> <add> // variable access returning array <add> exp = new SpelExpressionParser(configuration).parseExpression("#x==#x?'1,2,3':'foo'"); <add> context.setVariable("x",new int[]{1,2,3}); <add> assertEquals("1,2,3", exp.getValue(context, new Foo(), String.class)); <add> assertCanCompile(exp); <add> assertEquals("1,2,3", exp.getValue(context, new Foo(), String.class)); <add> assertIsCompiled(exp); <add> } <add> <add> private void assertIsCompiled(Expression ex) { <add> try { <add> Field f = SpelExpression.class.getDeclaredField("compiledAst"); <add> f.setAccessible(true); <add> Object object = f.get(ex); <add> assertNotNull(object); <add> } catch (Exception e) { <add> fail(e.toString()); <add> } <add> } <add> <add> public static class Foo { <add> <add> public String bar() { <add> return "BAR"; <add> } <add> <add> public String bar(String arg) { <add> return arg.toUpperCase(); <add> } <add> <add> } <add> <ide> <ide> <ide> // helper methods
3
Javascript
Javascript
support an element mounting before its owner
965fb8be6b9e59d6552231039f3d8c1ff20d2793
<ide><path>packages/react-devtools-shared/src/__tests__/store-test.js <ide> describe('Store', () => { <ide> expect(store).toMatchSnapshot('2: add host nodes'); <ide> }); <ide> <add> // This test is not the same cause as what's reported on GitHub, <add> // but the resulting behavior (owner mounting after descendant) is the same. <add> // Thec ase below is admittedly contrived and relies on side effects. <add> // I'mnot yet sure of how to reduce the GitHub reported production case to a test though. <add> // See https://github.com/facebook/react/issues/21445 <add> it('should handle when a component mounts before its owner', () => { <add> const promise = new Promise(resolve => {}); <add> <add> let Dynamic = null; <add> const Owner = () => { <add> Dynamic = <Child />; <add> throw promise; <add> }; <add> const Parent = () => { <add> return Dynamic; <add> }; <add> const Child = () => null; <add> <add> const container = document.createElement('div'); <add> <add> act(() => <add> ReactDOM.render( <add> <> <add> <React.Suspense fallback="Loading..."> <add> <Owner /> <add> </React.Suspense> <add> <Parent /> <add> </>, <add> container, <add> ), <add> ); <add> expect(store).toMatchInlineSnapshot(` <add> [root] <add> <Suspense> <add> ▾ <Parent> <add> <Child> <add> `); <add> }); <add> <ide> describe('collapseNodesByDefault:false', () => { <ide> beforeEach(() => { <ide> store.collapseNodesByDefault = false; <ide><path>packages/react-devtools-shared/src/backend/renderer.js <ide> export function attach( <ide> const elementType = getElementTypeForFiber(fiber); <ide> const {_debugOwner} = fiber; <ide> <del> const ownerID = _debugOwner != null ? getFiberIDThrows(_debugOwner) : 0; <add> // Ideally we should call getFiberIDThrows() for _debugOwner, <add> // since owners are almost always higher in the tree (and so have already been processed), <add> // but in some (rare) instances reported in open source, a descendant mounts before an owner. <add> // Since this is a DEV only field it's probably okay to also just lazily generate and ID here if needed. <add> // See https://github.com/facebook/react/issues/21445 <add> const ownerID = <add> _debugOwner != null ? getOrGenerateFiberID(_debugOwner) : 0; <ide> const parentID = parentFiber ? getFiberIDThrows(parentFiber) : 0; <ide> <ide> const displayNameStringID = getStringID(displayName);
2
PHP
PHP
remove useless variable
80093b2ddff081165d3d97a59a88746f0b30f931
<ide><path>src/Illuminate/Routing/Router.php <ide> protected function createRoute($methods, $uri, $action) <ide> } <ide> <ide> $route = $this->newRoute( <del> $methods, $uri = $this->prefix($uri), $action <add> $methods, $this->prefix($uri), $action <ide> ); <ide> <ide> // If we have groups that need to be merged, we will merge them now after this
1
Text
Text
add prs welcome badge
6b307a55fb1508640913d9e03ea8ee6da374b38f
<ide><path>README.md <del># [React](https://facebook.github.io/react/) [![Build Status](https://img.shields.io/travis/facebook/react/master.svg?style=flat)](https://travis-ci.org/facebook/react) [![Coverage Status](https://img.shields.io/coveralls/facebook/react/master.svg?style=flat)](https://coveralls.io/github/facebook/react?branch=master) [![npm version](https://img.shields.io/npm/v/react.svg?style=flat)](https://www.npmjs.com/package/react) <add># [React](https://facebook.github.io/react/) [![Build Status](https://img.shields.io/travis/facebook/react/master.svg?style=flat)](https://travis-ci.org/facebook/react) [![Coverage Status](https://img.shields.io/coveralls/facebook/react/master.svg?style=flat)](https://coveralls.io/github/facebook/react?branch=master) [![npm version](https://img.shields.io/npm/v/react.svg?style=flat)](https://www.npmjs.com/package/react) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md#pull-requests) <ide> <ide> React is a JavaScript library for building user interfaces. <ide>
1
Javascript
Javascript
add test case
2656628db5bd4891b490297b549533a7545e161d
<ide><path>test/configCases/asset-modules/assetModuleFilename/index.js <ide> import png from "../_images/file.png"; <ide> import svg from "../_images/file.svg"; <add>import svg2 from "../_images/file.svg?custom2"; <add>import svg3 from "../_images/file.svg?custom3"; <ide> <ide> it("should change filenames", () => { <ide> expect(png).toEqual("images/[ext]/success-png.png"); <ide> expect(svg).toEqual("images/success-svg.svg"); <add> expect(svg2).toEqual("custom-images/success.svg"); <add> expect(svg3).toEqual("images/custom/success.svg"); <ide> }); <ide><path>test/configCases/asset-modules/assetModuleFilename/webpack.config.js <ide> module.exports = { <ide> rules: [ <ide> { <ide> test: /\.(png|svg)$/, <del> type: "asset/resource" <add> type: "asset/resource", <add> rules: [ <add> { <add> resourceQuery: "?custom2", <add> generator: { <add> // TODO webpack 6: remove generator.filename <add> filename: "custom-images/success[ext]" <add> } <add> }, <add> { <add> resourceQuery: "?custom3", <add> parser: { <add> filename: "images/custom/success[ext]" <add> } <add> } <add> ] <ide> } <ide> ] <ide> }
2
PHP
PHP
add a test for src and href attributes
3b1a11e2d2d0a3d432db0171205e7d0d2b1553c1
<ide><path>lib/Cake/Test/Case/View/Helper/TextHelperTest.php <ide> public function testAutoLinkUrls() { <ide> $expected = 'Text with a url <a href="http://www.not--work.com">http://www.not--work.com</a> and more'; <ide> $result = $this->Text->autoLinkUrls($text); <ide> $this->assertEqual($expected, $result); <add> <add> $text = 'Text with a partial <a href="http://www.cakephp.org">link</a> link'; <add> $expected = 'Text with a partial <a href="http://www.cakephp.org">link</a> link'; <add> $result = $this->Text->autoLinkUrls($text, array('escape' => false)); <add> $this->assertEqual($expected, $result); <add> <add> $text = 'Text with a partial <iframe src="http://www.cakephp.org" /> link'; <add> $expected = 'Text with a partial <iframe src="http://www.cakephp.org" /> link'; <add> $result = $this->Text->autoLinkUrls($text, array('escape' => false)); <add> $this->assertEqual($expected, $result); <ide> } <ide> <ide> /**
1
Ruby
Ruby
simplify the code in schema cache
2004e4efa9c2ac90421e12de74b16a592a25e1be
<ide><path>activerecord/lib/active_record/connection_adapters/schema_cache.rb <ide> def initialize(conn) <ide> @columns_hash = {} <ide> @primary_keys = {} <ide> @tables = {} <del> prepare_default_proc <ide> end <ide> <ide> def primary_keys(table_name) <del> @primary_keys[table_name] <add> @primary_keys[table_name] ||= table_exists?(table_name) ? connection.primary_key(table_name) : nil <ide> end <ide> <ide> # A cached lookup for table existence. <ide> def table_exists?(name) <ide> # Add internal cache for table with +table_name+. <ide> def add(table_name) <ide> if table_exists?(table_name) <del> @primary_keys[table_name] <del> @columns[table_name] <del> @columns_hash[table_name] <add> primary_keys(table_name) <add> columns(table_name) <add> columns_hash(table_name) <ide> end <ide> end <ide> <ide> def tables(name) <ide> end <ide> <ide> # Get the columns for a table <del> def columns(table) <del> @columns[table] <add> def columns(table_name) <add> @columns[table_name] ||= connection.columns(table_name) <ide> end <ide> <ide> # Get the columns for a table as a hash, key is the column name <ide> # value is the column object. <del> def columns_hash(table) <del> @columns_hash[table] <add> def columns_hash(table_name) <add> @columns_hash[table_name] ||= Hash[columns(table_name).map { |col| <add> [col.name, col] <add> }] <ide> end <ide> <ide> # Clears out internal caches <ide> def clear_table_cache!(table_name) <ide> def marshal_dump <ide> # if we get current version during initialization, it happens stack over flow. <ide> @version = ActiveRecord::Migrator.current_version <del> [@version] + [@columns, @columns_hash, @primary_keys, @tables].map { |val| <del> Hash[val] <del> } <add> [@version, @columns, @columns_hash, @primary_keys, @tables] <ide> end <ide> <ide> def marshal_load(array) <ide> @version, @columns, @columns_hash, @primary_keys, @tables = array <del> prepare_default_proc <del> end <del> <del> private <del> <del> def prepare_default_proc <del> @columns.default_proc = Proc.new do |h, table_name| <del> h[table_name] = connection.columns(table_name) <del> end <del> <del> @columns_hash.default_proc = Proc.new do |h, table_name| <del> h[table_name] = Hash[columns(table_name).map { |col| <del> [col.name, col] <del> }] <del> end <del> <del> @primary_keys.default_proc = Proc.new do |h, table_name| <del> h[table_name] = table_exists?(table_name) ? connection.primary_key(table_name) : nil <del> end <ide> end <ide> end <ide> end
1
Ruby
Ruby
add extra documentation for password_field
137e5d91db0820e023dcb6b660e13279d650a856
<ide><path>actionpack/lib/action_view/helpers/form_helper.rb <ide> def text_field(object_name, method, options = {}) <ide> # Returns an input tag of the "password" type tailored for accessing a specified attribute (identified by +method+) on an object <ide> # assigned to the template (identified by +object+). Additional options on the input tag can be passed as a <ide> # hash with +options+. These options will be tagged onto the HTML as an HTML element attribute as in the example <del> # shown. <add> # shown. This field will be blank by default; pass in a value via +options+ if this is not desired. <ide> # <ide> # ==== Examples <ide> # password_field(:login, :pass, :size => 20)
1
Python
Python
make requested changes
58b4027ef73866f3e16c91f9ab707b33c9a3fba9
<ide><path>numpy/core/arrayprint.py <ide> def _extendLine_pretty(s, line, word, line_width, next_line_prefix, legacy): <ide> if len(words) == 1 or legacy == '1.13': <ide> return _extendLine(s, line, word, line_width, next_line_prefix, legacy) <ide> <del> line_length = len(line) <ide> max_word_length = max(len(word) for word in words) <del> if line_length + max_word_length > line_width and \ <del> len(line) > len(next_line_prefix): <add> if (len(line) + max_word_length > line_width and <add> len(line) > len(next_line_prefix)): <ide> s += line.rstrip() + '\n' <ide> line = next_line_prefix + words[0] <ide> indent = next_line_prefix <ide> else: <add> indent = len(line)*' ' <ide> line += words[0] <del> indent = line_length*' ' <ide> <ide> for word in words[1::]: <ide> s += line.rstrip() + '\n' <ide> line = indent + word <ide> <del> suffix_length = max_word_length-len(words[-1]) <add> suffix_length = max_word_length - len(words[-1]) <ide> line += suffix_length*' ' <ide> <ide> return s, line
1
Python
Python
add back celery intersphinx mapping
1f7836e07e643b3e9e0eca57ae077072358c63c1
<ide><path>docs/conf.py <ide> def _get_params(root_schema: dict, prefix: str = "", default_section: str = "") <ide> pkg_name: (f"{THIRD_PARTY_INDEXES[pkg_name]}/", (f'{INVENTORY_CACHE_DIR}/{pkg_name}/objects.inv',)) <ide> for pkg_name in [ <ide> 'boto3', <del> # 'celery', # Temporarily remove celery as it disappeared from Internet <add> 'celery', <ide> 'docker', <ide> 'hdfs', <ide> 'jinja2', <ide><path>docs/exts/docs_build/third_party_inventories.py <ide> <ide> THIRD_PARTY_INDEXES = { <ide> 'boto3': 'https://boto3.amazonaws.com/v1/documentation/api/latest', <del> 'celery': 'https://docs.celeryproject.org/en/stable', <add> 'celery': 'https://docs.celeryq.dev/en/stable/', <ide> 'docker': 'https://docker-py.readthedocs.io/en/stable', <ide> 'hdfs': 'https://hdfscli.readthedocs.io/en/latest', <ide> 'jinja2': 'https://jinja.palletsprojects.com/en/2.11.x',
2
PHP
PHP
$job phpdoc
68a9ff343125412dadddb7bf35f88ab42b90f1a9
<ide><path>src/Illuminate/Queue/InteractsWithQueue.php <ide> trait InteractsWithQueue <ide> /** <ide> * The underlying queue job instance. <ide> * <del> * @var \Illuminate\Contracts\Queue\Job <add> * @var \Illuminate\Contracts\Queue\Job|null <ide> */ <ide> public $job; <ide>
1
PHP
PHP
remove support for asset filters
b8814ff39b3b9af796faef38e1f2a18c84df250c
<ide><path>lib/Cake/Routing/Filter/AssetDispatcher.php <ide> public function beforeDispatch($event) { <ide> return; <ide> } <ide> <del> if ($result = $this->_filterAsset($event)) { <del> $event->stopPropagation(); <del> return $result; <del> } <del> <ide> $assetFile = $this->_getAssetFile($url); <ide> if ($assetFile === null || !file_exists($assetFile)) { <ide> return null; <ide> public function beforeDispatch($event) { <ide> return $response; <ide> } <ide> <del>/** <del> * Checks if the client is requesting a filtered asset and runs the corresponding <del> * filter if any is configured <del> * <del> * @param Cake\Event\Event $event containing the request and response object <del> * @return Cake\Network\Response if the client is requesting a recognized asset, null otherwise <del> */ <del> protected function _filterAsset($event) { <del> $url = $event->data['request']->url; <del> $response = $event->data['response']; <del> $filters = Configure::read('Asset.filter'); <del> $isCss = ( <del> strpos($url, 'ccss/') === 0 || <del> preg_match('#^(theme/([^/]+)/ccss/)|(([^/]+)(?<!css)/ccss)/#i', $url) <del> ); <del> $isJs = ( <del> strpos($url, 'cjs/') === 0 || <del> preg_match('#^/((theme/[^/]+)/cjs/)|(([^/]+)(?<!js)/cjs)/#i', $url) <del> ); <del> <del> if (($isCss && empty($filters['css'])) || ($isJs && empty($filters['js']))) { <del> $response->statusCode(404); <del> return $response; <del> } <del> <del> if ($isCss) { <del> include WWW_ROOT . DS . $filters['css']; <del> return $response; <del> } <del> <del> if ($isJs) { <del> include WWW_ROOT . DS . $filters['js']; <del> return $response; <del> } <del> } <del> <ide> /** <ide> * Builds asset file path based off url <ide> * <ide><path>lib/Cake/Test/TestCase/Routing/DispatcherTest.php <ide> public function testAsset($url, $file) { <ide> $this->assertEquals($expected, $headers['Content-Length']); <ide> } <ide> <del>/** <del> * test that missing asset processors trigger a 404 with no response body. <del> * <del> * @return void <del> */ <del> public function testMissingAssetProcessor404() { <del> $response = $this->getMock('Cake\Network\Response', array('send')); <del> $Dispatcher = new TestDispatcher(); <del> Configure::write('Asset.filter', array( <del> 'js' => '', <del> 'css' => null <del> )); <del> Configure::write('Dispatcher.filters', array('AssetDispatcher')); <del> <del> $request = new Request('ccss/cake.generic.css'); <del> $Dispatcher->dispatch($request, $response); <del> $this->assertEquals('404', $response->statusCode()); <del> } <del> <ide> /** <ide> * Data provider for cached actions. <ide> * <ide><path>lib/Cake/Test/TestCase/Routing/Filter/AssetDispatcherTest.php <ide> public function tearDown() { <ide> Configure::write('Dispatcher.filters', array()); <ide> } <ide> <del>/** <del> * test that asset filters work for theme and plugin assets <del> * <del> * @return void <del> */ <del> public function testAssetFilterForThemeAndPlugins() { <del> $filter = new AssetDispatcher(); <del> $response = $this->getMock('Cake\Network\Response', array('_sendHeader')); <del> Configure::write('Asset.filter', array( <del> 'js' => '', <del> 'css' => '' <del> )); <del> App::build(array( <del> 'Plugin' => array(CAKE . 'Test/TestApp/Plugin/'), <del> 'View' => array(CAKE . 'Test/TestApp/View/') <del> ), APP::RESET); <del> <del> $request = new Request('theme/test_theme/ccss/cake.generic.css'); <del> $event = new Event('DispatcherTest', $this, compact('request', 'response')); <del> $this->assertSame($response, $filter->beforeDispatch($event)); <del> $this->assertTrue($event->isStopped()); <del> <del> $request = new Request('theme/test_theme/cjs/debug_kit.js'); <del> $event = new Event('DispatcherTest', $this, compact('request', 'response')); <del> $this->assertSame($response, $filter->beforeDispatch($event)); <del> $this->assertTrue($event->isStopped()); <del> <del> $request = new Request('test_plugin/ccss/cake.generic.css'); <del> $event = new Event('DispatcherTest', $this, compact('request', 'response')); <del> $this->assertSame($response, $filter->beforeDispatch($event)); <del> $this->assertTrue($event->isStopped()); <del> <del> $request = new Request('test_plugin/cjs/debug_kit.js'); <del> $event = new Event('DispatcherTest', $this, compact('request', 'response')); <del> $this->assertSame($response, $filter->beforeDispatch($event)); <del> $this->assertTrue($event->isStopped()); <del> <del> $request = new Request('css/ccss/debug_kit.css'); <del> $event = new Event('DispatcherTest', $this, compact('request', 'response')); <del> $this->assertNull($filter->beforeDispatch($event)); <del> $this->assertFalse($event->isStopped()); <del> <del> $request = new Request('js/cjs/debug_kit.js'); <del> $event = new Event('DispatcherTest', $this, compact('request', 'response')); <del> $this->assertNull($filter->beforeDispatch($event)); <del> $this->assertFalse($event->isStopped()); <del> } <del> <ide> /** <ide> * Tests that $response->checkNotModified() is called and bypasses <ide> * file dispatching <ide> public function testAssetFilterForThemeAndPlugins() { <ide> */ <ide> public function testNotModified() { <ide> $filter = new AssetDispatcher(); <del> Configure::write('Asset.filter', array( <del> 'js' => '', <del> 'css' => '' <del> )); <ide> App::build(array( <ide> 'Plugin' => array(CAKE . 'Test/TestApp/Plugin/'), <ide> 'View' => array(CAKE . 'Test/TestApp/View/') <ide><path>lib/Cake/Test/TestCase/View/Helper/HtmlHelperTest.php <ide> public function testStyle() { <ide> * @return void <ide> */ <ide> public function testCssLink() { <del> Configure::write('Asset.filter.css', false); <del> <ide> $result = $this->Html->css('screen'); <ide> $expected = array( <ide> 'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*css\/screen\.css/') <ide> public function testCssLink() { <ide> $expected['link']['href'] = 'preg:/http:\/\/.*\/screen\.css\?1234/'; <ide> $this->assertTags($result, $expected); <ide> <del> Configure::write('Asset.filter.css', 'css.php'); <del> $result = $this->Html->css('cake.generic'); <del> $expected['link']['href'] = 'preg:/.*ccss\/cake\.generic\.css/'; <del> $this->assertTags($result, $expected); <del> <ide> $result = $this->Html->css('//example.com/css/cake.generic.css'); <ide> $expected['link']['href'] = 'preg:/.*example\.com\/css\/cake\.generic\.css/'; <ide> $this->assertTags($result, $expected); <ide> <del> Configure::write('Asset.filter.css', false); <del> <ide> $result = explode("\n", trim($this->Html->css(array('cake.generic', 'vendor.generic')))); <ide> $expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css/'; <ide> $this->assertTags($result[0], $expected); <ide> public function testCssLink() { <ide> * @return void <ide> */ <ide> public function testPluginCssLink() { <del> Configure::write('Asset.filter.css', false); <ide> Plugin::load('TestPlugin'); <ide> <ide> $result = $this->Html->css('TestPlugin.test_plugin_asset'); <ide> public function testPluginCssLink() { <ide> $expected['link']['href'] = 'preg:/.*test_plugin\/css\/test_plugin_asset\.css\?1234/'; <ide> $this->assertTags($result, $expected); <ide> <del> Configure::write('Asset.filter.css', 'css.php'); <del> $result = $this->Html->css('TestPlugin.test_plugin_asset'); <del> $expected['link']['href'] = 'preg:/.*test_plugin\/ccss\/test_plugin_asset\.css/'; <del> $this->assertTags($result, $expected); <del> <del> Configure::write('Asset.filter.css', false); <del> <ide> $result = explode("\n", trim($this->Html->css(array('TestPlugin.test_plugin_asset', 'TestPlugin.vendor.generic')))); <ide> $expected['link']['href'] = 'preg:/.*test_plugin\/css\/test_plugin_asset\.css/'; <ide> $this->assertTags($result[0], $expected); <ide> public function testScriptWithBlocks() { <ide> $this->assertNull($result); <ide> } <ide> <del>/** <del> * Test that Asset.filter.js works. <del> * <del> * @return void <del> */ <del> public function testScriptAssetFilter() { <del> Configure::write('Asset.filter.js', 'js.php'); <del> <del> $result = $this->Html->script('jquery-1.3'); <del> $expected = array( <del> 'script' => array('type' => 'text/javascript', 'src' => 'cjs/jquery-1.3.js') <del> ); <del> $this->assertTags($result, $expected); <del> <del> $result = $this->Html->script('//example.com/js/jquery-1.3.js'); <del> $expected = array( <del> 'script' => array('type' => 'text/javascript', 'src' => '//example.com/js/jquery-1.3.js') <del> ); <del> $this->assertTags($result, $expected); <del> } <del> <ide> /** <ide> * test a script file in the webroot/theme dir. <ide> * <ide><path>lib/Cake/View/Helper/HtmlHelper.php <ide> public function css($path, $rel = null, $options = array()) { <ide> $url = $path; <ide> } else { <ide> $url = $this->assetUrl($path, $options + array('pathPrefix' => CSS_URL, 'ext' => '.css')); <del> <del> if (Configure::read('Asset.filter.css')) { <del> $pos = strpos($url, CSS_URL); <del> if ($pos !== false) { <del> $url = substr($url, 0, $pos) . 'ccss/' . substr($url, $pos + strlen(CSS_URL)); <del> } <del> } <ide> } <ide> <ide> if ($rel == 'import') { <ide> public function script($url, $options = array()) { <ide> <ide> if (strpos($url, '//') === false) { <ide> $url = $this->assetUrl($url, $options + array('pathPrefix' => JS_URL, 'ext' => '.js')); <del> <del> if (Configure::read('Asset.filter.js')) { <del> $url = str_replace(JS_URL, 'cjs/', $url); <del> } <ide> } <ide> $attributes = $this->_parseAttributes($options, array('block', 'once'), ' '); <ide> $out = sprintf($this->_tags['javascriptlink'], $url, $attributes);
5
Ruby
Ruby
improve readability of guard clause
682914bf40733303105680b165c8a324b1ba90bd
<ide><path>Library/Homebrew/cask/cask.rb <ide> def outdated_versions(greedy = false) <ide> end <ide> <ide> def outdated_info(greedy, verbose, json) <del> return token unless verbose || json <add> return token if !verbose && !json <ide> <ide> installed_versions = outdated_versions(greedy).join(", ") <ide>
1
Text
Text
remove duplicate insert of ssh alias
f15e496be27399170e64fa94c8d1e2feb177c085
<ide><path>upgrade.md <ide> - Add new `expire_on_close` option to `session` configuration file. <ide> - Remove call to `redirectIfTrailingSlash` in `bootstrap/start.php` file. <ide> - Edit `app/config/app.php`; in `aliases` change `'Controller' => 'Illuminate\Routing\Controllers\Controller',` <del> to use `Illuminate\Routing\Controller` and add `'SSH' => 'Illuminate\Support\Facades\SSH',` <add> to use `Illuminate\Routing\Controller` <ide> - Edit `app/controllers/BaseController.php` change `use Illuminate\Routing\Controllers\Controller;` to `use Illuminate\Routing\Controller; <ide> ` <ide> - Edit `app/config/app.php`; in `providers` add `'Illuminate\Remote\RemoteServiceProvider',`
1
Java
Java
remove yoganode.create() from the abstract class
97607ff175db4af29276337832acd7a15bc237d9
<ide><path>ReactAndroid/src/main/java/com/facebook/yoga/YogaNode.java <ide> import javax.annotation.Nullable; <ide> <ide> public abstract class YogaNode { <del> public static YogaNode create() { <del> return new YogaNodeJNIFinalizer(); <del> } <del> <del> public static YogaNode create(YogaConfig config) { <del> return new YogaNodeJNIFinalizer(config); <del> } <del> <ide> public abstract void reset(); <ide> <ide> public abstract int getChildCount();
1
Javascript
Javascript
track free vars over iifes
fe2681cb3158a7d92d56171bd41d39d0acaa74fa
<ide><path>lib/Parser.js <ide> Parser.prototype.walkExpression = function walkExpression(expression) { <ide> this.walkExpressions(expression.arguments); <ide> break; <ide> case "CallExpression": <del> var callee = this.evaluateExpression(expression.callee); <del> if(callee.isIdentifier()) { <del> var result = this.applyPluginsBailResult("call " + callee.identifier, expression); <del> if(result === true) <del> break; <del> } <add> if(expression.callee.type === "FunctionExpression" && expression.arguments) { <add> // (function(...) { }(...)) <add> var args = expression.arguments.map(function(arg) { <add> var result = this.evaluateExpression(arg); <add> if(!result.isIdentifier()) result = undefined; <add> if(!result) { <add> this.walkExpression(arg); <add> return; <add> } <add> return result.identifier; <add> }, this); <add> this.inScope(expression.callee.params.filter(function(identifier, idx) { <add> return identifier.name !== args[idx]; <add> }), function() { <add> if(expression.callee.body.type === "BlockStatement") <add> this.walkStatement(expression.callee.body); <add> else <add> this.walkExpression(expression.callee.body); <add> }.bind(this)); <ide> <del> if(expression.callee) <del> this.walkExpression(expression.callee); <del> if(expression.arguments) <del> this.walkExpressions(expression.arguments); <add> } else { <add> <add> var callee = this.evaluateExpression(expression.callee); <add> if(callee.isIdentifier()) { <add> var result = this.applyPluginsBailResult("call " + callee.identifier, expression); <add> if(result === true) <add> break; <add> } <add> <add> if(expression.callee) <add> this.walkExpression(expression.callee); <add> if(expression.arguments) <add> this.walkExpressions(expression.arguments); <add> } <ide> break; <ide> case "MemberExpression": <ide> var expr = expression; <ide><path>test/cases/parsing/extract-amd/index.js <ide> it("should parse a bound function expression 4", function(done) { <ide> done(); <ide> }.bind(null, 123)); <ide> }); <add> <add>it("should not fail issue #138 second", function() { <add> (function(define, global) { 'use strict'; <add> define(function (require) { <add> (typeof require).should.be.eql("function"); <add> require("./a").should.be.eql("a"); <add> return "#138 2."; <add> }); <add> })(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }, this); <add> module.exports.should.be.eql("#138 2."); <add>}); <ide>\ No newline at end of file
2
Javascript
Javascript
emit unhandled warning immediately
3ce9305a705a0ea521a82afb0e4a2bef079d9548
<ide><path>lib/internal/process/promises.js <ide> function emitPromiseRejectionWarnings() { <ide> } <ide> } <ide> <del> let hadListeners = false; <add> let maybeScheduledTicks = false; <ide> let len = pendingUnhandledRejections.length; <ide> while (len--) { <ide> const promise = pendingUnhandledRejections.shift(); <ide> function emitPromiseRejectionWarnings() { <ide> const { reason, uid } = promiseInfo; <ide> if (!process.emit('unhandledRejection', reason, promise)) { <ide> emitWarning(uid, reason); <del> } else { <del> hadListeners = true; <ide> } <add> maybeScheduledTicks = true; <ide> } <ide> } <del> return hadListeners || pendingUnhandledRejections.length !== 0; <add> return maybeScheduledTicks || pendingUnhandledRejections.length !== 0; <ide> } <ide><path>test/parallel/test-promises-unhandled-rejections.js <ide> asyncTest('Rejected promise inside unhandledRejection allows nextTick loop' + <ide> process.nextTick(() => promise.catch(() => done())); <ide> }); <ide> }); <add> <add>asyncTest( <add> 'Unhandled promise rejection emits a warning immediately', <add> function(done) { <add> clean(); <add> Promise.reject(0); <add> const { emitWarning } = process; <add> process.emitWarning = common.mustCall((...args) => { <add> if (timer) { <add> clearTimeout(timer); <add> timer = null; <add> done(); <add> } <add> emitWarning(...args); <add> }, 2); <add> <add> let timer = setTimeout(common.mustNotCall(), 10000); <add> }, <add>);
2
Javascript
Javascript
remove redundancy in the ie special submit handler
8a6bbc70d07e78d0ff84f174d0d17c11a743e2c9
<ide><path>src/event.js <ide> var rnamespaces = /\.(.*)$/, <ide> (!m[4] || elem.getAttribute( m[4] ) == m[5]) && <ide> (!m[6] || !elem[ m[6] ]) <ide> ); <del> } <add> }; <ide> <ide> function useNativeMethod( event ) { <ide> if ( !event.isDefaultPrevented() && this[ event.type ] ) { <ide> if ( !jQuery.support.submitBubbles ) { <ide> <ide> jQuery.event.special.submit = { <ide> setup: function() { <add> // Only need this for delegated form submit events <ide> if ( jQuery.nodeName( this, "form" ) ) { <ide> return false; <ide> } <ide> <del> jQuery.event.add(this, "click._submit", function( e ) { <del> var elem = e.target, <del> type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; <del> <del> trigger( "submit", this, arguments ); <del> if ( (type === "submit" || type === "image") && elem.form ) { <del> simulate( "submit", this, e ); <del> } <del> }); <del> <del> jQuery.event.add(this, "keypress._submit", function( e ) { <add> jQuery.event.add(this, "click._submit keypress._submit", function( e ) { <ide> var elem = e.target, <ide> type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : ""; <ide> <del> if ( (type === "text" || type === "password") && elem.form && e.keyCode === 13 ) { <add> // Do the elem.form check after type to avoid VML-related crash in IE (#TODO) <add> if ( (e.type === "click" && (type === "submit" || type === "image") && elem.form) || <add> (e.type === "keypress" && e.keyCode === 13 && (type === "text" || type === "password") && elem.form) ) { <ide> simulate( "submit", this, e ); <ide> } <ide> });
1
Javascript
Javascript
optimize outgoing requests
08133f45c73cbae241881979dd41d0d63b4f84a0
<ide><path>lib/_http_outgoing.js <ide> exports.OutgoingMessage = OutgoingMessage; <ide> OutgoingMessage.prototype.setTimeout = function(msecs, callback) { <ide> if (callback) <ide> this.on('timeout', callback); <add> <ide> if (!this.socket) { <ide> this.once('socket', function(socket) { <ide> socket.setTimeout(msecs); <ide> OutgoingMessage.prototype._writeRaw = function(data, encoding, callback) { <ide> return true; <ide> } <ide> <del> if (this.connection && <del> this.connection._httpMessage === this && <del> this.connection.writable && <del> !this.connection.destroyed) { <add> var connection = this.connection; <add> if (connection && <add> connection._httpMessage === this && <add> connection.writable && <add> !connection.destroyed) { <ide> // There might be pending data in the this.output buffer. <del> while (this.output.length) { <del> if (!this.connection.writable) { <del> this._buffer(data, encoding, callback); <del> return false; <add> var outputLength = this.output.length; <add> if (outputLength > 0) { <add> var output = this.output; <add> var outputEncodings = this.outputEncodings; <add> var outputCallbacks = this.outputCallbacks; <add> for (var i = 0; i < outputLength; i++) { <add> connection.write(output[i], outputEncodings[i], <add> outputCallbacks[i]); <ide> } <del> var c = this.output.shift(); <del> var e = this.outputEncodings.shift(); <del> var cb = this.outputCallbacks.shift(); <del> this.connection.write(c, e, cb); <add> <add> this.output = []; <add> this.outputEncodings = []; <add> this.outputCallbacks = []; <ide> } <ide> <ide> // Directly write to socket. <del> return this.connection.write(data, encoding, callback); <del> } else if (this.connection && this.connection.destroyed) { <add> return connection.write(data, encoding, callback); <add> } else if (connection && connection.destroyed) { <ide> // The socket was destroyed. If we're still trying to write to it, <ide> // then we haven't gotten the 'close' event yet. <ide> return false; <ide> } else { <ide> // buffer, as long as we're not destroyed. <del> this._buffer(data, encoding, callback); <del> return false; <add> return this._buffer(data, encoding, callback); <ide> } <ide> }; <ide> <ide> OutgoingMessage.prototype._storeHeader = function(firstLine, headers) { <ide> messageHeader: firstLine <ide> }; <ide> <del> var field, value; <del> <ide> if (headers) { <ide> var keys = Object.keys(headers); <ide> var isArray = Array.isArray(headers); <ide> OutgoingMessage.prototype._renderHeaders = function() { <ide> throw new Error('Can\'t render headers after they are sent to the client.'); <ide> } <ide> <del> if (!this._headers) return {}; <add> var headersMap = this._headers; <add> if (!headersMap) return {}; <ide> <ide> var headers = {}; <del> var keys = Object.keys(this._headers); <add> var keys = Object.keys(headersMap); <add> var headerNames = this._headerNames; <ide> <ide> for (var i = 0, l = keys.length; i < l; i++) { <ide> var key = keys[i]; <del> headers[this._headerNames[key]] = this._headers[key]; <add> headers[headerNames[key]] = headersMap[key]; <ide> } <ide> return headers; <ide> }; <ide> OutgoingMessage.prototype._finish = function() { <ide> // This function, outgoingFlush(), is called by both the Server and Client <ide> // to attempt to flush any pending messages out to the socket. <ide> OutgoingMessage.prototype._flush = function() { <del> if (this.socket && this.socket.writable) { <del> var ret; <del> while (this.output.length) { <del> var data = this.output.shift(); <del> var encoding = this.outputEncodings.shift(); <del> var cb = this.outputCallbacks.shift(); <del> ret = this.socket.write(data, encoding, cb); <add> var socket = this.socket; <add> var outputLength, ret; <add> <add> if (socket && socket.writable) { <add> // There might be remaining data in this.output; write it out <add> outputLength = this.output.length; <add> if (outputLength > 0) { <add> var output = this.output; <add> var outputEncodings = this.outputEncodings; <add> var outputCallbacks = this.outputCallbacks; <add> for (var i = 0; i < outputLength; i++) { <add> ret = socket.write(output[i], outputEncodings[i], <add> outputCallbacks[i]); <add> } <add> <add> this.output = []; <add> this.outputEncodings = []; <add> this.outputCallbacks = []; <ide> } <ide> <ide> if (this.finished) {
1
Ruby
Ruby
precompile the image we're referencing, too
4f31b7767e4a3cf7125235455a652f263c431278
<ide><path>railties/test/application/assets_test.rb <ide> class ::PostsController < ActionController::Base; end <ide> test "asset urls should be protocol-relative if no request is in scope" do <ide> app_file "app/assets/images/rails.png", "notreallyapng" <ide> app_file "app/assets/javascripts/image_loader.js.erb", "var src='<%= image_path('rails.png') %>';" <del> add_to_config "config.assets.precompile = %w{image_loader.js}" <add> add_to_config "config.assets.precompile = %w{rails.png image_loader.js}" <ide> add_to_config "config.asset_host = 'example.com'" <ide> precompile! <ide> <ide> class ::PostsController < ActionController::Base; end <ide> app_file "app/assets/images/rails.png", "notreallyapng" <ide> <ide> app_file "app/assets/javascripts/app.js.erb", "var src='<%= image_path('rails.png') %>';" <del> add_to_config "config.assets.precompile = %w{app.js}" <add> add_to_config "config.assets.precompile = %w{rails.png app.js}" <ide> precompile! <ide> <ide> assert_match "src='/sub/uri/assets/rails.png'", File.read(Dir["#{app_path}/public/assets/app-*.js"].first)
1
Javascript
Javascript
use smaller n value in some http tests
8a968e4ee7b298496c0e781deccbd95e3717d386
<ide><path>benchmark/http/check_invalid_header_char.js <ide> const bench = common.createBenchmark(main, { <ide> 'foo\nbar', <ide> '\x7F' <ide> ], <del> n: [5e8], <add> n: [1e6], <ide> }); <ide> <ide> function main(conf) { <ide><path>benchmark/http/check_is_http_token.js <ide> const bench = common.createBenchmark(main, { <ide> ':alternate-protocol', // fast bailout <ide> 'alternate-protocol:' // slow bailout <ide> ], <del> n: [5e8], <add> n: [1e6], <ide> }); <ide> <ide> function main(conf) {
2
Python
Python
fix seq2seqtrainingarguments docs
6f1727d83adf8c6fdff659cb40565b306de44ade
<ide><path>src/transformers/training_args_seq2seq.py <ide> @add_start_docstrings(TrainingArguments.__doc__) <ide> class Seq2SeqTrainingArguments(TrainingArguments): <ide> """ <del> sortish_sampler (`bool`, *optional*, defaults to `False`): <del> Whether to use a *sortish sampler* or not. Only possible if the underlying datasets are *Seq2SeqDataset* for <del> now but will become generally available in the near future. <del> <del> It sorts the inputs according to lengths in order to minimize the padding size, with a bit of randomness for <del> the training set. <del> predict_with_generate (`bool`, *optional*, defaults to `False`): <del> Whether to use generate to calculate generative metrics (ROUGE, BLEU). <del> generation_max_length (`int`, *optional*): <del> The `max_length` to use on each evaluation loop when `predict_with_generate=True`. Will default to the <del> `max_length` value of the model configuration. <del> generation_num_beams (`int`, *optional*): <del> The `num_beams` to use on each evaluation loop when `predict_with_generate=True`. Will default to the <del> `num_beams` value of the model configuration. <add> Args: <add> sortish_sampler (`bool`, *optional*, defaults to `False`): <add> Whether to use a *sortish sampler* or not. Only possible if the underlying datasets are *Seq2SeqDataset* <add> for now but will become generally available in the near future. <add> <add> It sorts the inputs according to lengths in order to minimize the padding size, with a bit of randomness <add> for the training set. <add> predict_with_generate (`bool`, *optional*, defaults to `False`): <add> Whether to use generate to calculate generative metrics (ROUGE, BLEU). <add> generation_max_length (`int`, *optional*): <add> The `max_length` to use on each evaluation loop when `predict_with_generate=True`. Will default to the <add> `max_length` value of the model configuration. <add> generation_num_beams (`int`, *optional*): <add> The `num_beams` to use on each evaluation loop when `predict_with_generate=True`. Will default to the <add> `num_beams` value of the model configuration. <ide> """ <ide> <ide> sortish_sampler: bool = field(default=False, metadata={"help": "Whether to use SortishSampler or not."})
1
Javascript
Javascript
use new lesson-builder
58bee4c3b27a60c6e91836be76854c6fcc92e14a
<ide><path>Gruntfile.js <ide> module.exports = function(grunt) { <ide> thumbnailBackground: 'threejsfundamentals-background.jpg', <ide> text: [ <ide> { <del> font: 'bold 100px sans-serif', <add> font: 'bold 100px lesson-font', <ide> verticalSpacing: 100, <ide> offset: [100, 120], <ide> textAlign: 'left', <ide> module.exports = function(grunt) { <ide> textWrapWidth: 1000, <ide> }, <ide> { <del> font: 'bold 60px sans-serif', <add> font: 'bold 60px lesson-font', <ide> text: 'threejsfundamentals.org', <ide> verticalSpacing: 100, <ide> offset: [-100, -90],
1
Javascript
Javascript
fix element.toggle logic
e3655ef733f7f69a4b1175cd6843f8bfe4c32f5d
<ide><path>actionpack/lib/action_view/helpers/javascripts/prototype.js <ide> Object.extend(Element, { <ide> toggle: function() { <ide> for (var i = 0; i < arguments.length; i++) { <ide> var element = $(arguments[i]); <del> Element[Element.visible(element) ? 'show' : 'hide'](element); <add> Element[Element.visible(element) ? 'hide' : 'show'](element); <ide> } <ide> }, <ide> <ide><path>railties/html/javascripts/prototype.js <ide> Object.extend(Element, { <ide> toggle: function() { <ide> for (var i = 0; i < arguments.length; i++) { <ide> var element = $(arguments[i]); <del> Element[Element.visible(element) ? 'show' : 'hide'](element); <add> Element[Element.visible(element) ? 'hide' : 'show'](element); <ide> } <ide> }, <ide>
2
PHP
PHP
allow running initial auth checks earlier
dce5db021450376465eeddf64666e5473e1c6ce6
<ide><path>src/Controller/Component/AuthComponent.php <ide> class AuthComponent extends Component <ide> * - `storage` - Storage class to use for persisting user record. When using <ide> * stateless authenticator you should set this to 'Memory'. Defaults to 'Session'. <ide> * <add> * - 'earlyAuth' - If set to true initial auth checks are done in beforeFilter() <add> * callback instead of startup(), i.e. before controller's beforeFilter(). <add> * Defaults to false for backwards compatibility. <add> * <ide> * @var array <ide> */ <ide> protected $_defaultConfig = [ <ide> class AuthComponent extends Component <ide> 'logoutRedirect' => null, <ide> 'authError' => null, <ide> 'unauthorizedRedirect' => true, <del> 'storage' => 'Session' <add> 'storage' => 'Session', <add> 'earlyAuth' => false <ide> ]; <ide> <ide> /** <ide> public function initialize(array $config) <ide> } <ide> <ide> /** <del> * Main execution method. Handles redirecting of invalid users, and processing <del> * of login form data. <add> * Callback for Controller.initialize event. <add> * <add> * @param \Cake\Event\Event $event The Controller.initialize event instance. <add> * @return void|\Cake\Network\Response <add> */ <add> public function beforeFilter(Event $event) <add> { <add> if ($this->_config['earlyAuth']) { <add> return $this->_authCheck($event); <add> } <add> } <add> <add> /** <add> * Callback for Controller.startup event. <ide> * <del> * @param \Cake\Event\Event $event The startup event. <add> * @param \Cake\Event\Event $event The Controller.startup event instance. <ide> * @return void|\Cake\Network\Response <ide> */ <ide> public function startup(Event $event) <add> { <add> if (!$this->_config['earlyAuth']) { <add> return $this->_authCheck($event); <add> } <add> } <add> <add> /** <add> * Main execution method. Handles initial authentication check and redirecting <add> * of invalid users. <add> * <add> * @param \Cake\Event\Event $event Event instance. <add> * @return void|\Cake\Network\Response <add> */ <add> public function _authCheck(Event $event) <ide> { <ide> $controller = $event->subject(); <ide> <ide><path>tests/TestCase/Controller/Component/AuthComponentTest.php <ide> public function testSessionKeyBC() <ide> $this->Auth->sessionKey = false; <ide> $this->assertInstanceOf('Cake\Auth\Storage\MemoryStorage', $this->Auth->storage()); <ide> } <add> <add> /** <add> * Test that setting config 'earlyAuth' to true make AuthComponent do the initial <add> * checks in beforeFilter() instead of startup(). <add> * <add> * @return void <add> */ <add> public function testEarlyAuthConfig() <add> { <add> $this->Controller->components()->set('Auth', $this->Auth); <add> $this->Auth->earlyAuthTest = true; <add> <add> $this->Controller->startupProcess(); <add> $this->assertEquals('Controller.startup', $this->Auth->authCheckCalledFrom); <add> <add> $this->Auth->authCheckCalledFrom = null; <add> $this->Auth->config('earlyAuth', true); <add> $this->Controller->startupProcess(); <add> $this->assertEquals('Controller.initialize', $this->Auth->authCheckCalledFrom); <add> } <ide> } <ide><path>tests/test_app/TestApp/Controller/Component/TestAuthComponent.php <ide> namespace TestApp\Controller\Component; <ide> <ide> use Cake\Controller\Component\AuthComponent; <add>use Cake\Event\Event; <ide> <ide> /** <ide> * TestAuthComponent class <ide> * <ide> */ <ide> class TestAuthComponent extends AuthComponent <ide> { <add> public function _authCheck(Event $event) <add> { <add> if (isset($this->earlyAuthTest)) { <add> $this->authCheckCalledFrom = $event->name; <add> return; <add> } <add> <add> return parent::_authCheck($event); <add> } <ide> <ide> /** <ide> * Helper method to add/set an authenticate object instance
3
Text
Text
add table of contents info
9194fea915a30eabf1e7cd1531903d19baa56734
<ide><path>docs/docs/refactor/00-table-of-contents.md <add># Goals of the documentation <add>- Flow of docs should mimic progression of questions a new user would ask <add>- High information density -- assume the reader is adept at JS <add> <add># Outline <add> <ide> Motivation / Why React? <ide> - Declarative (simple) <ide> - Components (separation of concerns)
1
Javascript
Javascript
replace many if's with if-else statement
6e86a70da2f54bd68cc5a8038a5d6940d6a4fce9
<ide><path>lib/assert.js <ide> function innerFail(actual, expected, message, operator, stackStartFunction) { <ide> } <ide> <ide> function fail(actual, expected, message, operator, stackStartFunction) { <del> if (arguments.length === 0) { <add> const argsLen = arguments.length; <add> <add> if (argsLen === 0) { <ide> message = 'Failed'; <del> } <del> if (arguments.length === 1) { <add> } else if (argsLen === 1) { <ide> message = actual; <ide> actual = undefined; <del> } <del> if (arguments.length === 2) { <add> } else if (argsLen === 2) { <ide> operator = '!='; <ide> } <add> <ide> innerFail(actual, expected, message, operator, stackStartFunction || fail); <ide> } <add> <ide> assert.fail = fail; <ide> <ide> // The AssertionError is defined in internal/error.
1
Javascript
Javascript
add a way to disable external links
98e989116c839f2c3b9d2b16752c8ad6431214c3
<ide><path>src/display/annotation_layer.js <ide> class LinkAnnotationElement extends AnnotationElement { <ide> target: (data.newWindow ? <ide> LinkTarget.BLANK : linkService.externalLinkTarget), <ide> rel: linkService.externalLinkRel, <add> enabled: linkService.externalLinkEnabled, <ide> }); <ide> <ide> if (!data.url) { <ide><path>src/display/display_utils.js <ide> const LinkTargetStringMap = [ <ide> * The default value is `LinkTarget.NONE`. <ide> * @property {string} rel - (optional) The link relationship. <ide> * The default value is `DEFAULT_LINK_REL`. <add> * @property {boolean} enabled - (optional) Whether the link should be enabled. <add> * The default value is true. <ide> */ <ide> <ide> /** <ide> * Adds various attributes (href, title, target, rel) to hyperlinks. <ide> * @param {HTMLLinkElement} link - The link element. <ide> * @param {ExternalLinkParameters} params <ide> */ <del>function addLinkAttributes(link, { url, target, rel, } = {}) { <del> link.href = link.title = (url ? removeNullCharacters(url) : ''); <add>function addLinkAttributes(link, { url, target, rel, enabled = true, } = {}) { <add> const urlNullRemoved = (url ? removeNullCharacters(url) : ''); <add> if (enabled) { <add> link.href = link.title = urlNullRemoved; <add> } else { <add> link.href = ''; <add> link.title = `Disabled: ${urlNullRemoved}`; <add> link.onclick = () => { <add> return false; <add> }; <add> } <ide> <ide> if (url) { <ide> const LinkTargetValues = Object.values(LinkTarget); <ide><path>web/app.js <ide> let PDFViewerApplication = { <ide> this.pdfLoadingTask = loadingTask; <ide> <ide> loadingTask.onPassword = (updateCallback, reason) => { <add> this.pdfLinkService.externalLinkEnabled = false; <ide> this.passwordPrompt.setUpdateCallback(updateCallback, reason); <ide> this.passwordPrompt.open(); <ide> }; <ide><path>web/interfaces.js <ide> class IPDFLinkService { <ide> */ <ide> set rotation(value) {} <ide> <add> /** <add> * @returns {boolean} <add> */ <add> get externalLinkEnabled() {} <add> <add> /** <add> * @param {boolean} value <add> */ <add> set externalLinkEnabled(value) {} <add> <ide> /** <ide> * @param dest - The PDF destination object. <ide> */ <ide><path>web/pdf_link_service.js <ide> class PDFLinkService { <ide> * @param {PDFLinkServiceOptions} options <ide> */ <ide> constructor({ eventBus, externalLinkTarget = null, <del> externalLinkRel = null, } = {}) { <add> externalLinkRel = null, externalLinkEnabled = true, } = {}) { <ide> this.eventBus = eventBus || getGlobalEventBus(); <ide> this.externalLinkTarget = externalLinkTarget; <ide> this.externalLinkRel = externalLinkRel; <add> this.externalLinkEnabled = externalLinkEnabled; <ide> <ide> this.baseUrl = null; <ide> this.pdfDocument = null; <ide> class SimpleLinkService { <ide> constructor() { <ide> this.externalLinkTarget = null; <ide> this.externalLinkRel = null; <add> this.externalLinkEnabled = true; <ide> } <ide> <ide> /** <ide><path>web/pdf_outline_viewer.js <ide> class PDFOutlineViewer { <ide> url, <ide> target: (newWindow ? LinkTarget.BLANK : linkService.externalLinkTarget), <ide> rel: linkService.externalLinkRel, <add> enabled: linkService.externalLinkEnabled, <ide> }); <ide> return; <ide> }
6
Python
Python
handle pytz.ambiguoustimeerror. closes
7e3c7928eb599d34ab2ba7b320dc1db81fcbe106
<ide><path>celery/utils/timeutils.py <ide> <ide> try: <ide> import pytz <del>except ImportError: # pragma: no cover <del> pytz = None # noqa <add> from pytz import AmbiguousTimeError <add>except ImportError: # pragma: no cover <add> pytz = None # noqa <add> <add> class AmbiguousTimeError(Exception): # noqa <add> pass <ide> <ide> <ide> C_REMDEBUG = os.environ.get('C_REMDEBUG', False) <ide> def is_naive(dt): <ide> def make_aware(dt, tz): <ide> """Sets the timezone for a datetime object.""" <ide> try: <del> localize = tz.localize <add> _localize = tz.localize <ide> except AttributeError: <ide> return dt.replace(tzinfo=tz) <ide> else: <ide> # works on pytz timezones <del> return localize(dt, is_dst=None) <add> try: <add> return _localize(dt, is_dst=None) <add> except AmbiguousTimeError: <add> return min(_localize(dt, is_dst=True), <add> _localize(dt, is_dst=False)) <ide> <ide> <ide> def localize(dt, tz): <ide> """Convert aware datetime to another timezone.""" <ide> dt = dt.astimezone(tz) <ide> try: <del> normalize = tz.normalize <del> except AttributeError: <add> _normalize = tz.normalize <add> except AttributeError: # non-pytz tz <ide> return dt <ide> else: <del> return normalize(dt) # pytz <add> try: <add> return _normalize(dt, is_dst=None) <add> except AmbiguousTimeError: <add> return min(_normalize(dt, is_dst=True), <add> _normalize(dt, is_dst=False)) <ide> <ide> <ide> def to_utc(dt):
1
Javascript
Javascript
use the right repo
6ecac3b152b9ff6e6fd69af1efd4c5c5dafaf5be
<ide><path>build/release.js <ide> var releaseVersion, <ide> <ide> scpURL = "jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/", <ide> cdnURL = "http://code.origin.jquery.com/", <del> repoURL = "git://github.com/dmethvin/jquery.git", <del> //repoURL = "git://github.com/jquery/jquery.git", <add> repoURL = "git@github.com:jquery/jquery.git", <ide> <ide> // Windows needs the .cmd version but will find the non-.cmd <ide> // On Windows, ensure the HOME environment variable is set
1
Python
Python
fix mathlib test
3b1e1e3e6f3589d562d70b3cefff51f1666f6427
<ide><path>numpy/core/setup.py <ide> def get_dotblas_sources(ext, build_dir): <ide> <ide> def testcode_mathlib(): <ide> return """\ <del>/* check whether libm is broken */ <del>#include <math.h> <del>int main(int argc, char *argv[]) <add>/* <add> * check whether libm is explicitly needed for access to basic math functions <add> */ <add>char exp(void); <add>int main(void) <ide> { <del> return exp(-1.) > 1.0; <add> exp(); <add> return 0; <ide> } <ide> """ <ide>
1
PHP
PHP
return empty string if no items in html list
9a90d303c7ab1ede66c8c84fbfb90f31e9840547
<ide><path>laravel/html.php <ide> private static function listing($type, $list, $attributes = array()) <ide> { <ide> $html = ''; <ide> <add> if (count($list) == 0) return $html; <add> <ide> foreach ($list as $key => $value) <ide> { <ide> // If the value is an array, we will recurse the function so that we can
1
Python
Python
add a docstring to nan_to_num. closes #406
2e832de49f69d26eb7c8d133e45f9b9d99f7a3a6
<ide><path>numpy/lib/type_check.py <ide> def _getmaxmin(t): <ide> return f.max, f.min <ide> <ide> def nan_to_num(x): <del> # mapping: <del> # NaN -> 0 <del> # Inf -> limits.double_max <del> # -Inf -> limits.double_min <add> """ <add> Replaces NaN's with 0 and infinities with large numbers <add> <add> The following mappings are applied: <add> NaN -> 0 <add> Inf -> limits.double_max <add> -Inf -> limits.double_min <add> """ <ide> try: <ide> t = x.dtype.type <ide> except AttributeError:
1
Python
Python
improve the docstring of the new norm function
6eb57a767713a7a2b74e1cd3365c34638ec55eac
<ide><path>numpy/linalg/linalg.py <ide> def norm(x, ord=None, axis=None): <ide> <ide> Parameters <ide> ---------- <del> x : {(M,), (M, N)} array_like <del> Input array. <add> x : array_like <add> Input array. If `axis` is None, `x` must be 1-D or 2-D. <ide> ord : {non-zero int, inf, -inf, 'fro'}, optional <ide> Order of the norm (see table under ``Notes``). inf means numpy's <ide> `inf` object. <ide> axis : int or None, optional <ide> If `axis` is not None, it specifies the axis of `x` along which to <del> compute the vector norms. <add> compute the vector norms. If `axis` is None, then either a vector <add> norm (when `x` is 1-D) or a matrix norm (when `x` is 2-D) is returned. <ide> <ide> Returns <ide> -------
1
Text
Text
fix typo in buildsrc/readme.md
fac1b94623f13a79182a57cf772760cd69cc2414
<ide><path>buildSrc/README.md <ide> They are declared in the `build.gradle` file in this folder. <ide> <ide> ### Compiler conventions <ide> <del>The `org.springframework.build.compile` plubin applies the Java compiler conventions to the build. <add>The `org.springframework.build.compile` plugin applies the Java compiler conventions to the build. <ide> By default, the build compiles sources with Java `1.8` source and target compatibility. <ide> You can test a different source compatibility version on the CLI with a project property like: <ide>
1