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
|
|---|---|---|---|---|---|
Javascript
|
Javascript
|
serialize the grammar registry
|
d52c4bc33b8ed13c1cb008ad7ec28e83760dda87
|
<ide><path>spec/atom-environment-spec.js
<ide> describe('AtomEnvironment', () => {
<ide> })
<ide>
<ide> it('serializes the text editor registry', async () => {
<add> await atom.packages.activatePackage('language-text')
<ide> const editor = await atom.workspace.open('sample.js')
<del> atom.textEditors.setGrammarOverride(editor, 'text.plain')
<add> expect(atom.grammars.assignLanguageMode(editor, 'plain text')).toBe(true)
<ide>
<ide> const atom2 = new AtomEnvironment({
<ide> applicationDelegate: atom.applicationDelegate,
<ide> describe('AtomEnvironment', () => {
<ide> atom2.initialize({document, window})
<ide>
<ide> await atom2.deserialize(atom.serialize())
<del> expect(atom2.textEditors.getGrammarOverride(editor)).toBe('text.plain')
<add> await atom2.packages.activatePackage('language-text')
<add> const editor2 = atom2.workspace.getActiveTextEditor()
<add> expect(editor2.getBuffer().getLanguageMode().getLanguageName()).toBe('Plain Text')
<ide> atom2.destroy()
<ide> })
<ide>
<ide><path>spec/grammar-registry-spec.js
<ide> describe('GrammarRegistry', () => {
<ide> expect(grammarRegistry.assignLanguageMode(buffer, 'css')).toBe(true)
<ide> expect(buffer.getLanguageMode().getLanguageName()).toBe('CSS')
<ide>
<del> expect(grammarRegistry.autoAssignLanguageMode(buffer)).toBe(true)
<add> grammarRegistry.autoAssignLanguageMode(buffer)
<ide> expect(buffer.getLanguageMode().getLanguageName()).toBe('JavaScript')
<ide> })
<ide> })
<ide> describe('GrammarRegistry', () => {
<ide> expect(atom.grammars.selectGrammar('foo.js').name).not.toBe(grammar.name)
<ide> })
<ide> })
<add>
<add> describe('serialization', () => {
<add> it('persists editors\' grammar overrides', async () => {
<add> const buffer1 = new TextBuffer()
<add> const buffer2 = new TextBuffer()
<add>
<add> grammarRegistry.loadGrammarSync(require.resolve('language-c/grammars/c.cson'))
<add> grammarRegistry.loadGrammarSync(require.resolve('language-html/grammars/html.cson'))
<add> grammarRegistry.loadGrammarSync(require.resolve('language-javascript/grammars/javascript.cson'))
<add>
<add> grammarRegistry.maintainLanguageMode(buffer1)
<add> grammarRegistry.maintainLanguageMode(buffer2)
<add> grammarRegistry.assignLanguageMode(buffer1, 'c')
<add> grammarRegistry.assignLanguageMode(buffer2, 'javascript')
<add>
<add> const buffer1Copy = await TextBuffer.deserialize(buffer1.serialize())
<add> const buffer2Copy = await TextBuffer.deserialize(buffer2.serialize())
<add>
<add> const grammarRegistryCopy = new GrammarRegistry({config: atom.config})
<add> grammarRegistryCopy.deserialize(JSON.parse(JSON.stringify(grammarRegistry.serialize())))
<add>
<add> grammarRegistryCopy.loadGrammarSync(require.resolve('language-c/grammars/c.cson'))
<add> grammarRegistryCopy.loadGrammarSync(require.resolve('language-html/grammars/html.cson'))
<add>
<add> expect(buffer1Copy.getLanguageMode().getLanguageName()).toBe('None')
<add> expect(buffer2Copy.getLanguageMode().getLanguageName()).toBe('None')
<add>
<add> grammarRegistryCopy.maintainLanguageMode(buffer1Copy)
<add> grammarRegistryCopy.maintainLanguageMode(buffer2Copy)
<add> expect(buffer1Copy.getLanguageMode().getLanguageName()).toBe('C')
<add> expect(buffer2Copy.getLanguageMode().getLanguageName()).toBe('None')
<add>
<add> grammarRegistryCopy.loadGrammarSync(require.resolve('language-javascript/grammars/javascript.cson'))
<add> expect(buffer1Copy.getLanguageMode().getLanguageName()).toBe('C')
<add> expect(buffer2Copy.getLanguageMode().getLanguageName()).toBe('JavaScript')
<add> })
<add> })
<ide> })
<ide>
<ide> function retainedBufferCount (grammarRegistry) {
<ide><path>spec/text-editor-registry-spec.js
<ide> describe('TextEditorRegistry', function () {
<ide> })
<ide> })
<ide> })
<del>
<del> describe('serialization', function () {
<del> it('persists editors\' grammar overrides', async function () {
<del> const editor2 = new TextEditor()
<del>
<del> await atom.packages.activatePackage('language-c')
<del> await atom.packages.activatePackage('language-html')
<del> await atom.packages.activatePackage('language-javascript')
<del>
<del> registry.maintainGrammar(editor)
<del> registry.maintainGrammar(editor2)
<del> atom.grammars.assignLanguageMode(editor, 'c')
<del> atom.grammars.assignLanguageMode(editor2, 'javascript')
<del>
<del> await atom.packages.deactivatePackage('language-javascript')
<del>
<del> const editorCopy = TextEditor.deserialize(editor.serialize(), atom)
<del> const editor2Copy = TextEditor.deserialize(editor2.serialize(), atom)
<del>
<del> const registryCopy = new TextEditorRegistry({
<del> assert: atom.assert,
<del> config: atom.config,
<del> grammarRegistry: atom.grammars,
<del> packageManager: {deferredActivationHooks: null}
<del> })
<del> registryCopy.deserialize(JSON.parse(JSON.stringify(registry.serialize())))
<del>
<del> expect(editorCopy.getGrammar().name).toBe('Null Grammar')
<del> expect(editor2Copy.getGrammar().name).toBe('Null Grammar')
<del>
<del> registryCopy.maintainGrammar(editorCopy)
<del> registryCopy.maintainGrammar(editor2Copy)
<del> expect(editorCopy.getGrammar().name).toBe('C')
<del> expect(editor2Copy.getGrammar().name).toBe('Null Grammar')
<del>
<del> await atom.packages.activatePackage('language-javascript')
<del> expect(editorCopy.getGrammar().name).toBe('C')
<del> expect(editor2Copy.getGrammar().name).toBe('JavaScript')
<del> })
<del> })
<ide> })
<ide>
<ide> function getSubscriptionCount (editor) {
<ide><path>src/atom-environment.js
<ide> class AtomEnvironment {
<ide> project: this.project.serialize(options),
<ide> workspace: this.workspace.serialize(),
<ide> packageStates: this.packages.serialize(),
<del> grammars: {grammarOverridesByPath: this.grammars.grammarOverridesByPath},
<add> grammars: this.grammars.serialize(),
<ide> fullScreen: this.isFullScreen(),
<ide> windowDimensions: this.windowDimensions,
<del> textEditors: this.textEditors.serialize()
<ide> }
<ide> }
<ide>
<ide> class AtomEnvironment {
<ide>
<ide> this.deserializeTimings.project = Date.now() - startTime
<ide>
<del> if (state.textEditors) this.textEditors.deserialize(state.textEditors)
<add> if (state.grammars) this.grammars.deserialize(state.grammars)
<ide>
<ide> startTime = Date.now()
<ide> if (state.workspace) this.workspace.deserialize(state.workspace, this.deserializers)
<ide><path>src/grammar-registry.js
<ide> class GrammarRegistry extends FirstMate.GrammarRegistry {
<ide> this.onDidUpdateGrammar(grammarAddedOrUpdated)
<ide> }
<ide>
<add> serialize () {
<add> const languageNameOverridesByBufferId = {}
<add> this.languageNameOverridesByBufferId.forEach((languageName, bufferId) => {
<add> languageNameOverridesByBufferId[bufferId] = languageName
<add> })
<add> return {languageNameOverridesByBufferId}
<add> }
<add>
<add> deserialize (params) {
<add> for (const bufferId in params.languageNameOverridesByBufferId || {}) {
<add> this.languageNameOverridesByBufferId.set(
<add> bufferId,
<add> params.languageNameOverridesByBufferId[bufferId]
<add> )
<add> }
<add> }
<add>
<ide> createToken (value, scopes) {
<ide> return new Token({value, scopes})
<ide> }
<ide>
<ide> maintainLanguageMode (buffer) {
<add> this.grammarScoresByBuffer.set(buffer, null)
<add>
<ide> const languageNameOverride = this.languageNameOverridesByBufferId.get(buffer.id)
<ide> if (languageNameOverride) {
<ide> this.assignLanguageMode(buffer, languageNameOverride)
<ide> class GrammarRegistry extends FirstMate.GrammarRegistry {
<ide> buffer.getPath(),
<ide> buffer.getTextInRange(GRAMMAR_SELECTION_RANGE)
<ide> )
<del> const currentScore = this.grammarScoresByBuffer.get(buffer)
<del> if (currentScore == null || result.score > currentScore) {
<del> this.languageNameOverridesByBufferId.delete(buffer.id)
<del> this.grammarScoresByBuffer.set(buffer, result.score)
<del> if (result.grammar.name !== buffer.getLanguageMode().getLanguageName()) {
<del> buffer.setLanguageMode(this.languageModeForGrammarAndBuffer(result.grammar, buffer))
<del> }
<del> return true
<del> } else {
<del> return false
<add> this.languageNameOverridesByBufferId.delete(buffer.id)
<add> this.grammarScoresByBuffer.set(buffer, result.score)
<add> if (result.grammar.name !== buffer.getLanguageMode().getLanguageName()) {
<add> buffer.setLanguageMode(this.languageModeForGrammarAndBuffer(result.grammar, buffer))
<ide> }
<ide> }
<ide>
<ide> class GrammarRegistry extends FirstMate.GrammarRegistry {
<ide>
<ide> grammarAddedOrUpdated (grammar) {
<ide> this.grammarScoresByBuffer.forEach((score, buffer) => {
<add> if (global.debug) debugger
<add>
<ide> const languageMode = buffer.getLanguageMode()
<ide> if (grammar.injectionSelector) {
<ide> if (languageMode.hasTokenForSelector(grammar.injectionSelector)) {
<ide> class GrammarRegistry extends FirstMate.GrammarRegistry {
<ide> return
<ide> }
<ide>
<del> if (grammar.name === buffer.getLanguageMode().getLanguageName()) {
<add> const overrideName = this.languageNameOverridesByBufferId.get(buffer.id)
<add>
<add> if (grammar.name &&
<add> (grammar.name === buffer.getLanguageMode().getLanguageName() ||
<add> grammar.name.toLowerCase() === overrideName)) {
<ide> buffer.setLanguageMode(this.languageModeForGrammarAndBuffer(grammar, buffer))
<del> } else if (!this.languageNameOverridesByBufferId.has(buffer.id)) {
<add> } else if (!overrideName) {
<ide> const score = this.getGrammarScore(
<ide> grammar,
<ide> buffer.getPath(),
| 5
|
Javascript
|
Javascript
|
fix param name and tidy up examples
|
e101c127af0b499d03b93c07460f28cfbffa2cc2
|
<ide><path>src/ng/directive/input.js
<ide> var ngValueDirective = function() {
<ide> * @name ngModelOptions
<ide> *
<ide> * @description
<del> * Allows tuning how model updates are done. Using `ngModelOptions` you can specify a custom list of events
<del> * that will trigger a model update and/or a debouncing delay so that the actual update only takes place
<del> * when a timer expires; this timer will be reset after another change takes place.
<add> * Allows tuning how model updates are done. Using `ngModelOptions` you can specify a custom list of
<add> * events that will trigger a model update and/or a debouncing delay so that the actual update only
<add> * takes place when a timer expires; this timer will be reset after another change takes place.
<ide> *
<del> * @param {Object=} Object that contains options to apply to the current model. Valid keys are:
<del> * - updateOn: string specifying which event should be the input bound to. You can set several events
<del> * using an space delimited list. There is a special event called `default` that
<del> * matches the default events belonging of the control.
<del> * - debounce: integer value which contains the debounce model update value in milliseconds. A value of 0
<del> * triggers an immediate update. If an object is supplied instead, you can specify a custom value
<del> * for each event. I.e.
<del> * `ngModelOptions="{ updateOn: 'default blur', debounce: {'default': 500, 'blur': 0} }"`
<add> * @param {Object} ngModelOptions options to apply to the current model. Valid keys are:
<add> * - `updateOn`: string specifying which event should be the input bound to. You can set several
<add> * events using an space delimited list. There is a special event called `default` that
<add> * matches the default events belonging of the control.
<add> * - `debounce`: integer value which contains the debounce model update value in milliseconds. A
<add> * value of 0 triggers an immediate update. If an object is supplied instead, you can specify a
<add> * custom value for each event. For example:
<add> * `ngModelOptions="{ updateOn: 'default blur', debounce: {'default': 500, 'blur': 0} }"`
<ide> *
<ide> * @example
<ide>
<del> The following example shows how to override immediate updates. Changes on the inputs within the form will update the model
<del> only when the control loses focus (blur event).
<add> The following example shows how to override immediate updates. Changes on the inputs within the
<add> form will update the model only when the control loses focus (blur event).
<ide>
<del> <example name="ngModelOptions-directive-1">
<add> <example name="ngModelOptions-directive-blur">
<ide> <file name="index.html">
<del> <script>
<del> function Ctrl($scope) {
<del> $scope.user = { name: 'say', data: '' };
<del> }
<del> </script>
<ide> <div ng-controller="Ctrl">
<del> <form>
<del> Name:
<del> <input type="text" ng-model="user.name" ng-model-options="{ updateOn: 'blur' }" name="uName" /><br />
<del> Other data:
<del> <input type="text" ng-model="user.data" name="uData" /><br />
<del> </form>
<add> Name:
<add> <input type="text"
<add> ng-model="user.name"
<add> ng-model-options="{ updateOn: 'blur' }" /><br />
<add>
<add> Other data:
<add> <input type="text" ng-model="user.data" /><br />
<add>
<ide> <pre>user.name = <span ng-bind="user.name"></span></pre>
<ide> </div>
<ide> </file>
<add> <file name="app.js">
<add> function Ctrl($scope) {
<add> $scope.user = { name: 'say', data: '' };
<add> }
<add> </file>
<ide> <file name="protractor.js" type="protractor">
<ide> var model = element(by.binding('user.name'));
<ide> var input = element(by.model('user.name'));
<ide> var ngValueDirective = function() {
<ide>
<ide> This one shows how to debounce model changes. Model will be updated only 500 milliseconds after last change.
<ide>
<del> <example name="ngModelOptions-directive-2">
<add> <example name="ngModelOptions-directive-debounce">
<ide> <file name="index.html">
<del> <script>
<del> function Ctrl($scope) {
<del> $scope.user = { name: 'say' };
<del> }
<del> </script>
<del> <div ng-controller="Ctrl">
<del> <form>
<del> Name:
<del> <input type="text" ng-model="user.name" name="uName" ng-model-options="{ debounce: 500 }" /><br />
<del> </form>
<add> <div ng-controller="Ctrl">
<add> Name:
<add> <input type="text"
<add> ng-model="user.name"
<add> ng-model-options="{ debounce: 500 }" /><br />
<ide> <pre>user.name = <span ng-bind="user.name"></span></pre>
<ide> </div>
<ide> </file>
<add> <file name="app.js">
<add> function Ctrl($scope) {
<add> $scope.user = { name: 'say' };
<add> }
<add> </file>
<ide> </example>
<ide> */
<ide> var ngModelOptionsDirective = function() {
| 1
|
Go
|
Go
|
use archive.copywithtar in vfs.create
|
b6db23cffe942b8d94c80d1e9b3f1f6fca87d139
|
<ide><path>daemon/graphdriver/vfs/driver.go
<ide> import (
<ide> "path"
<ide>
<ide> "github.com/docker/docker/daemon/graphdriver"
<add> "github.com/docker/docker/pkg/archive"
<ide> "github.com/docker/libcontainer/label"
<ide> )
<ide>
<ide> func isGNUcoreutils() bool {
<ide> return false
<ide> }
<ide>
<del>func copyDir(src, dst string) error {
<del> argv := make([]string, 0, 4)
<del>
<del> if isGNUcoreutils() {
<del> argv = append(argv, "-aT", "--reflink=auto", src, dst)
<del> } else {
<del> argv = append(argv, "-a", src+"/.", dst+"/.")
<del> }
<del>
<del> if output, err := exec.Command("cp", argv...).CombinedOutput(); err != nil {
<del> return fmt.Errorf("Error VFS copying directory: %s (%s)", err, output)
<del> }
<del> return nil
<del>}
<del>
<ide> func (d *Driver) Create(id, parent string) error {
<ide> dir := d.dir(id)
<ide> if err := os.MkdirAll(path.Dir(dir), 0700); err != nil {
<ide> func (d *Driver) Create(id, parent string) error {
<ide> if err != nil {
<ide> return fmt.Errorf("%s: %s", parent, err)
<ide> }
<del> if err := copyDir(parentDir, dir); err != nil {
<add> if err := archive.CopyWithTar(parentDir, dir); err != nil {
<ide> return err
<ide> }
<ide> return nil
| 1
|
Javascript
|
Javascript
|
fix merge issue
|
1027871ead1a1131df4d22dac693e6ba06062f9d
|
<ide><path>test/HotModuleReplacementPlugin.test.js
<ide> describe("HotModuleReplacementPlugin", () => {
<ide> },
<ide> plugins: [new webpack.HotModuleReplacementPlugin()],
<ide> optimization: {
<del> namedChunks: true
<add> chunkIds: "named"
<ide> }
<ide> });
<ide> fs.writeFileSync(entryFile, "1", "utf-8");
| 1
|
Ruby
|
Ruby
|
add config to method calls in fixtures
|
6223e2067608aa7fa2ecd2c50e2db74f26ad5914
|
<ide><path>activerecord/lib/active_record/fixtures.rb
<ide> class FixtureSet
<ide>
<ide> @@all_cached_fixtures = Hash.new { |h,k| h[k] = {} }
<ide>
<del> def self.default_fixture_model_name(fixture_set_name) # :nodoc:
<del> ActiveRecord::Base.pluralize_table_names ?
<add> def self.default_fixture_model_name(fixture_set_name, config = ActiveRecord::Base) # :nodoc:
<add> config.pluralize_table_names ?
<ide> fixture_set_name.singularize.camelize :
<ide> fixture_set_name.camelize
<ide> end
<ide>
<del> def self.default_fixture_table_name(fixture_set_name) # :nodoc:
<del> "#{ ActiveRecord::Base.table_name_prefix }"\
<add> def self.default_fixture_table_name(fixture_set_name, config = ActiveRecord::Base) # :nodoc:
<add> "#{ config.table_name_prefix }"\
<ide> "#{ fixture_set_name.tr('/', '_') }"\
<del> "#{ ActiveRecord::Base.table_name_suffix }".to_sym
<add> "#{ config.table_name_suffix }".to_sym
<ide> end
<ide>
<ide> def self.reset_cache
<ide> def self.instantiate_all_loaded_fixtures(object, load_instances = true)
<ide> cattr_accessor :all_loaded_fixtures
<ide> self.all_loaded_fixtures = {}
<ide>
<del> def self.create_fixtures(fixtures_directory, fixture_set_names, class_names = {})
<add> def self.create_fixtures(fixtures_directory, fixture_set_names, class_names = {}, config = ActiveRecord::Base)
<ide> fixture_set_names = Array(fixture_set_names).map(&:to_s)
<ide> class_names = class_names.stringify_keys
<ide>
<ide> def self.create_fixtures(fixtures_directory, fixture_set_names, class_names = {}
<ide> fixtures_map[fs_name] = new( # ActiveRecord::FixtureSet.new
<ide> connection,
<ide> fs_name,
<del> class_names[fs_name] || (default_fixture_model_name(fs_name).safe_constantize),
<add> class_names[fs_name] || (default_fixture_model_name(fs_name, config).safe_constantize),
<ide> ::File.join(fixtures_directory, fs_name))
<ide> end
<ide>
<ide> def self.identify(label)
<ide> Zlib.crc32(label.to_s) % MAX_ID
<ide> end
<ide>
<del> attr_reader :table_name, :name, :fixtures, :model_class
<add> attr_reader :table_name, :name, :fixtures, :model_class, :config
<ide>
<del> def initialize(connection, name, class_name, path)
<add> def initialize(connection, name, class_name, path, config = ActiveRecord::Base)
<ide> @fixtures = {} # Ordered hash
<ide> @name = name
<ide> @path = path
<add> @config = config
<ide>
<ide> if class_name.is_a?(String)
<ide> ActiveSupport::Deprecation.warn("The ability to pass in strings as a class name will be removed in Rails 4.2, consider using the class itself instead.")
<ide> def initialize(connection, name, class_name, path)
<ide>
<ide> @table_name = ( model_class.respond_to?(:table_name) ?
<ide> model_class.table_name :
<del> self.class.default_fixture_table_name(name) )
<add> self.class.default_fixture_table_name(name, config) )
<ide>
<ide> read_fixture_files
<ide> end
<ide> def size
<ide> # Return a hash of rows to be inserted. The key is the table, the value is
<ide> # a list of rows to insert to that table.
<ide> def table_rows
<del> now = ActiveRecord::Base.default_timezone == :utc ? Time.now.utc : Time.now
<add> now = config.default_timezone == :utc ? Time.now.utc : Time.now
<ide> now = now.to_s(:db)
<ide>
<ide> # allow a standard key to be used for doing defaults in YAML
<ide> def after_teardown
<ide> class_attribute :use_transactional_fixtures
<ide> class_attribute :use_instantiated_fixtures # true, false, or :no_instances
<ide> class_attribute :pre_loaded_fixtures
<add> class_attribute :config
<ide>
<ide> self.fixture_table_names = []
<ide> self.use_transactional_fixtures = true
<ide> self.use_instantiated_fixtures = false
<ide> self.pre_loaded_fixtures = false
<add> self.config = ActiveRecord::Base
<ide>
<ide> self.fixture_class_names = Hash.new do |h, fixture_set_name|
<del> h[fixture_set_name] = ActiveRecord::FixtureSet.default_fixture_model_name(fixture_set_name)
<add> h[fixture_set_name] = ActiveRecord::FixtureSet.default_fixture_model_name(fixture_set_name, self.config)
<ide> end
<ide> end
<ide>
<ide> def fixtures(*fixture_set_names)
<ide> end
<ide>
<ide> self.fixture_table_names |= fixture_set_names
<del> require_fixture_classes(fixture_set_names)
<add> require_fixture_classes(fixture_set_names, self.config)
<ide> setup_fixture_accessors(fixture_set_names)
<ide> end
<ide>
<ide> def try_to_load_dependency(file_name)
<ide> end
<ide> end
<ide>
<del> def require_fixture_classes(fixture_set_names = nil)
<add> def require_fixture_classes(fixture_set_names = nil, config = ActiveRecord::Base)
<ide> if fixture_set_names
<ide> fixture_set_names = fixture_set_names.map { |n| n.to_s }
<ide> else
<ide> fixture_set_names = fixture_table_names
<ide> end
<ide>
<ide> fixture_set_names.each do |file_name|
<del> file_name = file_name.singularize if ActiveRecord::Base.pluralize_table_names
<add> file_name = file_name.singularize if config.pluralize_table_names
<ide> try_to_load_dependency(file_name)
<ide> end
<ide> end
<ide> def run_in_transaction?
<ide> !self.class.uses_transaction?(method_name)
<ide> end
<ide>
<del> def setup_fixtures
<add> def setup_fixtures(config = ActiveRecord::Base)
<ide> if pre_loaded_fixtures && !use_transactional_fixtures
<ide> raise RuntimeError, 'pre_loaded_fixtures requires use_transactional_fixtures'
<ide> end
<ide> def setup_fixtures
<ide> if @@already_loaded_fixtures[self.class]
<ide> @loaded_fixtures = @@already_loaded_fixtures[self.class]
<ide> else
<del> @loaded_fixtures = load_fixtures
<add> @loaded_fixtures = load_fixtures(config)
<ide> @@already_loaded_fixtures[self.class] = @loaded_fixtures
<ide> end
<ide> @fixture_connections = enlist_fixture_connections
<ide> def setup_fixtures
<ide> else
<ide> ActiveRecord::FixtureSet.reset_cache
<ide> @@already_loaded_fixtures[self.class] = nil
<del> @loaded_fixtures = load_fixtures
<add> @loaded_fixtures = load_fixtures(config)
<ide> end
<ide>
<ide> # Instantiate fixtures for every test if requested.
<del> instantiate_fixtures if use_instantiated_fixtures
<add> instantiate_fixtures(config) if use_instantiated_fixtures
<ide> end
<ide>
<ide> def teardown_fixtures
<ide> def enlist_fixture_connections
<ide> end
<ide>
<ide> private
<del> def load_fixtures
<del> fixtures = ActiveRecord::FixtureSet.create_fixtures(fixture_path, fixture_table_names, fixture_class_names)
<add> def load_fixtures(config)
<add> fixtures = ActiveRecord::FixtureSet.create_fixtures(fixture_path, fixture_table_names, fixture_class_names, config)
<ide> Hash[fixtures.map { |f| [f.name, f] }]
<ide> end
<ide>
<ide> # for pre_loaded_fixtures, only require the classes once. huge speed improvement
<ide> @@required_fixture_classes = false
<ide>
<del> def instantiate_fixtures
<add> def instantiate_fixtures(config)
<ide> if pre_loaded_fixtures
<ide> raise RuntimeError, 'Load fixtures before instantiating them.' if ActiveRecord::FixtureSet.all_loaded_fixtures.empty?
<ide> unless @@required_fixture_classes
<del> self.class.require_fixture_classes ActiveRecord::FixtureSet.all_loaded_fixtures.keys
<add> self.class.require_fixture_classes ActiveRecord::FixtureSet.all_loaded_fixtures.keys, config
<ide> @@required_fixture_classes = true
<ide> end
<ide> ActiveRecord::FixtureSet.instantiate_all_loaded_fixtures(self, load_instances?)
<ide><path>activerecord/test/cases/fixtures_test.rb
<ide> def test_no_rollback_in_teardown_unless_transaction_active
<ide> end
<ide>
<ide> private
<del> def load_fixtures
<add> def load_fixtures(config)
<ide> raise 'argh'
<ide> end
<ide> end
| 2
|
Text
|
Text
|
remove dead taps
|
e4f607e4c8a4368a506edfcbbecfe6d24abc7f34
|
<ide><path>share/doc/homebrew/Custom-GCC-and-cross-compilers.md
<ide> Rather than merging in brews for either of these cases at this time, we're listi
<ide>
<ide> * Homebrew provides a `gcc` formula for use with Xcode 4.2+ or when needing C++11 support on earlier versions.
<ide> * [Homebrew-versions](https://github.com/homebrew/homebrew-versions) provides an up to date GCC duplicates e.g. `brew install homebrew/versions/gcc48`
<del>* [MSP430 development](https://github.com/Homebrew/homebrew/issues/issue/2336)
<del>* [OS161 development](https://github.com/maxpow4h/homebrew-os161) Your university probably uses a different version, replacing the URLs with your university's URLs will probably work.
<del>* [ARM-EABI](https://github.com/paxswill/homebrew-paxswill) provides an arm-none-eabi toolchain formula.
<ide> * [RISC-V](https://github.com/riscv/homebrew-riscv) provides the RISC-V toolchain including binutils and gcc.
| 1
|
Python
|
Python
|
remove print statement in test_endian_recarray
|
da5ee659fcc7891794dd18dc48b057eb72f08025
|
<ide><path>numpy/core/tests/test_regression.py
<ide> def test_endian_recarray(self,level=rlevel):
<ide> d = buf[0]['data'][0]
<ide> buf[0]['head'] = h
<ide> buf[0]['data'][0] = d
<del> print buf[0]['head']
<ide> assert_(buf[0]['head'] == 1)
<ide>
<del>
<ide> def test_mem_dot(self,level=rlevel):
<ide> """Ticket #106"""
<ide> x = np.random.randn(0,1)
| 1
|
Text
|
Text
|
fix style of n-api.md
|
12e62ea785258e8718f2cf48122b71993049308e
|
<ide><path>doc/api/n-api.md
<ide> added:
<ide>
<ide> > Stability: 1 - Experimental
<ide>
<del>````c
<add>```c
<ide> NAPI_EXTERN napi_status node_api_throw_syntax_error(napi_env env,
<ide> const char* code,
<ide> const char* msg);
<ide> napiVersion: 1
<ide> NAPI_EXTERN napi_status napi_is_error(napi_env env,
<ide> napi_value value,
<ide> bool* result);
<del>````
<add>```
<ide>
<ide> * `[in] env`: The environment that the API is invoked under.
<ide> * `[in] value`: The `napi_value` to be checked.
| 1
|
PHP
|
PHP
|
modify tests to also test the new behaviour
|
cbe8c41080e605622b68ec9ed6908e46e48a9171
|
<ide><path>tests/Database/DatabaseEloquentBelongsToManyTest.php
<ide> public function testSyncMethodSyncsIntermediateTableWithGivenArray($list)
<ide> $relation->getRelated()->shouldReceive('touches')->andReturn(false);
<ide> $relation->getParent()->shouldReceive('touches')->andReturn(false);
<ide>
<del> $relation->sync($list);
<add> $this->assertEquals(array('attached' => array(4), 'detached' => array(1), 'updated' => array()), $relation->sync($list));
<ide> }
<ide>
<ide>
<ide> public function syncMethodListProvider()
<ide>
<ide> public function testSyncMethodSyncsIntermediateTableWithGivenArrayAndAttributes()
<ide> {
<del> $relation = $this->getMock('Illuminate\Database\Eloquent\Relations\BelongsToMany', array('attach', 'detach', 'touchIfTouching'), $this->getRelationArguments());
<add> $relation = $this->getMock('Illuminate\Database\Eloquent\Relations\BelongsToMany', array('attach', 'detach', 'touchIfTouching', 'updateExistingPivot'), $this->getRelationArguments());
<ide> $query = m::mock('stdClass');
<ide> $query->shouldReceive('from')->once()->with('user_role')->andReturn($query);
<ide> $query->shouldReceive('where')->once()->with('user_id', 1)->andReturn($query);
<ide> $relation->getQuery()->shouldReceive('getQuery')->andReturn($mockQueryBuilder = m::mock('StdClass'));
<ide> $mockQueryBuilder->shouldReceive('newQuery')->once()->andReturn($query);
<ide> $query->shouldReceive('lists')->once()->with('role_id')->andReturn(array(1, 2, 3));
<ide> $relation->expects($this->once())->method('attach')->with($this->equalTo(4), $this->equalTo(array('foo' => 'bar')), $this->equalTo(false));
<add> $relation->expects($this->once())->method('updateExistingPivot')->with($this->equalTo(3), $this->equalTo(array('baz' => 'qux')), $this->equalTo(false));
<ide> $relation->expects($this->once())->method('detach')->with($this->equalTo(array(1)));
<ide> $relation->expects($this->once())->method('touchIfTouching');
<ide>
<del> $relation->sync(array(2, 3, 4 => array('foo' => 'bar')));
<add> $this->assertEquals(array('attached' => array(4), 'detached' => array(1), 'updated' => array(3)), $relation->sync(array(2, 3 => array('baz' => 'qux'), 4 => array('foo' => 'bar'))));
<ide> }
<ide>
<ide>
<ide> public function __construct()
<ide>
<ide> class EloquentBelongsToManyPivotStub {
<ide> public $user_id;
<del>}
<ide>\ No newline at end of file
<add>}
| 1
|
Javascript
|
Javascript
|
add strict equalities in src/core/colorspace.js
|
0012b8803c3f9871d74b6d8d286def608d067fb5
|
<ide><path>src/core/colorspace.js
<ide> var ColorSpace = (function ColorSpaceClosure() {
<ide> var count = originalWidth * originalHeight;
<ide> var rgbBuf = null;
<ide> var numComponentColors = 1 << bpc;
<del> var needsResizing = originalHeight != height || originalWidth != width;
<add> var needsResizing = originalHeight !== height || originalWidth !== width;
<ide> var i, ii;
<ide>
<ide> if (this.isPassthrough(bpc)) {
<ide> var ColorSpace = (function ColorSpaceClosure() {
<ide> var stream = xref.fetchIfRef(cs[1]);
<ide> var dict = stream.dict;
<ide> numComps = dict.get('N');
<del> if (numComps == 1) {
<add> if (numComps === 1) {
<ide> return 'DeviceGrayCS';
<del> } else if (numComps == 3) {
<add> } else if (numComps === 3) {
<ide> return 'DeviceRgbCS';
<del> } else if (numComps == 4) {
<add> } else if (numComps === 4) {
<ide> return 'DeviceCmykCS';
<ide> }
<ide> break;
<ide> var ColorSpace = (function ColorSpaceClosure() {
<ide> return true;
<ide> }
<ide> for (var i = 0, ii = decode.length; i < ii; i += 2) {
<del> if (decode[i] !== 0 || decode[i + 1] != 1) {
<add> if (decode[i] !== 0 || decode[i + 1] !== 1) {
<ide> return false;
<ide> }
<ide> }
<ide> var DeviceRgbCS = (function DeviceRgbCSClosure() {
<ide> return (inputLength * (3 + alpha01) / 3) | 0;
<ide> },
<ide> isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
<del> return bits == 8;
<add> return bits === 8;
<ide> },
<ide> fillRgb: ColorSpace.prototype.fillRgb,
<ide> isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
| 1
|
Text
|
Text
|
improve examples in buffer docs
|
9f7efd58a1e102737694f4e3f6946dac0eb283bf
|
<ide><path>doc/api/buffer.md
<ide> endian). `value` *should* be a valid 64-bit double. Behavior is undefined when
<ide> ```js
<ide> const buf = Buffer.allocUnsafe(8);
<ide>
<del>buf.writeDoubleBE(0xdeadbeefcafebabe, 0);
<add>buf.writeDoubleBE(123.456, 0);
<ide>
<ide> console.log(buf);
<del>// Prints: <Buffer 43 eb d5 b7 dd f9 5f d7>
<add>// Prints: <Buffer 40 5e dd 2f 1a 9f be 77>
<ide>
<del>buf.writeDoubleLE(0xdeadbeefcafebabe, 0);
<add>buf.writeDoubleLE(123.456, 0);
<ide>
<ide> console.log(buf);
<del>// Prints: <Buffer d7 5f f9 dd b7 d5 eb 43>
<add>// Prints: <Buffer 77 be 9f 1a 2f dd 5e 40>
<ide> ```
<ide>
<ide> ### buf.writeFloatBE(value, offset)
| 1
|
PHP
|
PHP
|
update version in "since" tag
|
5153f579c3c55867c0e67375122bd991dd3d46aa
|
<ide><path>src/Shell/Task/AssetsTask.php
<ide> public function copy($name = null)
<ide> * @param string|null $name Name of plugin for which to remove assets.
<ide> * If null all plugins will be processed.
<ide> * @return void
<del> * @since 3.5.11
<add> * @since 3.5.12
<ide> */
<ide> public function remove($name = null)
<ide> {
| 1
|
Javascript
|
Javascript
|
add beforeremoveinstance method to reactnoop
|
434770c3b4b94315c789234c27ed9dc2ec8a78ad
|
<ide><path>packages/react-noop-renderer/src/createReactNoop.js
<ide> function createReactNoop(reconciler: Function, useMutation: boolean) {
<ide> getInstanceFromNode() {
<ide> throw new Error('Not yet implemented.');
<ide> },
<add>
<add> beforeRemoveInstance(instance: any): void {
<add> // NO-OP
<add> },
<ide> };
<ide>
<ide> const hostConfig = useMutation
| 1
|
Python
|
Python
|
update examples with updated lxd driver api
|
5ea66a7c5389032f541486e317e023a8b9987016
|
<ide><path>example_lxd.py
<ide> from libcloud.container.types import Provider
<ide> from libcloud.container.providers import get_driver
<ide> from pylxd import Client
<del>import requests
<del>
<ide>
<ide> def pylxdFunc():
<ide>
<ide> def pylxdFunc():
<ide> print("Image name: ", image.filename)
<ide>
<ide>
<del>def main():
<add>def work_with_containers():
<ide>
<del> # LXD API specification can be found at:
<add> # LXD API specification can be found at:
<ide> # https://github.com/lxc/lxd/blob/master/doc/rest-api.md#10containersnamemetadata
<ide>
<ide> # LXD host change accordingly
<ide> def main():
<ide> # get the list of the containers
<ide> containers = conn.list_containers()
<ide>
<del>
<ide> # create a new container
<ide> name = 'third-lxd-container'
<ide>
<ide> def main():
<ide> for container in containers:
<ide> print("Container: %s is: %s" % (container.name, container.state))
<ide>
<add>def work_with_images():
<add> # LXD host change accordingly
<add> host_lxd = 'https://192.168.2.4'
<add>
<add> # port that LXD server is listening at
<add> # change this according to your configuration
<add> port_id = 8443
<add>
<add> # get the libcloud LXD driver
<add> lxd_driver = get_driver(Provider.LXD)
<add>
<add> # acquire the connection.
<add> # certificates should have been added to the LXD server
<add> # here we assume they are on the same directory change
<add> # accordingly
<add> conn = lxd_driver(key='', secret='', secure=False,
<add> host=host_lxd, port=port_id, key_file='lxd.key', cert_file='lxd.crt')
<add>
<ide> # get the images this LXD server is publishing
<ide> images = conn.list_images()
<ide>
<ide> print("Number of images: ", len(images))
<ide>
<ide> for image in images:
<ide> print("Image: ", image.name)
<del> print("\tPath ",image.path)
<add> print("\tPath ", image.path)
<ide> print("\tVersion ", image.version)
<ide>
<del> #container_id = containers[0].name
<del> #container_url = '%s:%s/1.0/containers/%s/state' % ('https://192.168.2.4', port_id, container_id)
<del> #cert=('lxd.crt', 'lxd.key' )
<del> #data = {"action":'start', "timeout":30, "statefule":True}
<del> #r = requests.put(container_url, json=data, verify=False, cert=cert)
<del> #print("put of 1.0/containers/%s/state returned: "%(container_id) + r.text)
<del>
<del> #data['action'] = 'stop'
<del> #r = requests.put(container_url, json=data, verify=False, cert=cert)
<del> #print("put of 1.0/containers/%s/state returned: " % (container_id) + r.text)
<del>
<del>
<del> # start a container
<del> #container = conn.start_container(container=containers[0])
<del> #print(container)
<del>
<del> # stop the container
<add>def work_with_storage_pools():
<add> pass
<ide>
<ide>
<ide> if __name__ == '__main__':
<del> #pylxdFunc()
<del> main()
<ide>\ No newline at end of file
<add>
<add> work_with_containers()
<add> work_with_images()
<add> work_with_storage_pools()
<ide>\ No newline at end of file
| 1
|
Python
|
Python
|
fix vit test
|
1ddf3c2b74214b770f511b15216144aac0e337eb
|
<ide><path>tests/test_pipelines_image_classification.py
<ide> def run_pipeline_test(self, image_classifier, examples):
<ide>
<ide> @require_torch
<ide> def test_small_model_pt(self):
<del> small_model = "lysandre/tiny-vit-random"
<add> small_model = "hf-internal-testing/tiny-random-vit"
<ide> image_classifier = pipeline("image-classification", model=small_model)
<ide>
<ide> outputs = image_classifier("http://images.cocodataset.org/val2017/000000039769.jpg")
<ide> self.assertEqual(
<ide> nested_simplify(outputs, decimals=4),
<del> [
<del> {"score": 0.0015, "label": "chambered nautilus, pearly nautilus, nautilus"},
<del> {"score": 0.0015, "label": "pajama, pyjama, pj's, jammies"},
<del> {"score": 0.0014, "label": "trench coat"},
<del> {"score": 0.0014, "label": "handkerchief, hankie, hanky, hankey"},
<del> {"score": 0.0014, "label": "baboon"},
<del> ],
<add> [{"label": "LABEL_1", "score": 0.574}, {"label": "LABEL_0", "score": 0.426}],
<ide> )
<ide>
<ide> outputs = image_classifier(
<ide> def test_small_model_pt(self):
<ide> self.assertEqual(
<ide> nested_simplify(outputs, decimals=4),
<ide> [
<del> [
<del> {"score": 0.0015, "label": "chambered nautilus, pearly nautilus, nautilus"},
<del> {"score": 0.0015, "label": "pajama, pyjama, pj's, jammies"},
<del> ],
<del> [
<del> {"score": 0.0015, "label": "chambered nautilus, pearly nautilus, nautilus"},
<del> {"score": 0.0015, "label": "pajama, pyjama, pj's, jammies"},
<del> ],
<add> [{"label": "LABEL_1", "score": 0.574}, {"label": "LABEL_0", "score": 0.426}],
<add> [{"label": "LABEL_1", "score": 0.574}, {"label": "LABEL_0", "score": 0.426}],
<ide> ],
<ide> )
<ide>
<ide> @require_tf
<ide> def test_small_model_tf(self):
<del> small_model = "lysandre/tiny-vit-random"
<add> small_model = "hf-internal-testing/tiny-random-vit"
<ide> image_classifier = pipeline("image-classification", model=small_model)
<ide>
<ide> outputs = image_classifier("http://images.cocodataset.org/val2017/000000039769.jpg")
<ide> self.assertEqual(
<ide> nested_simplify(outputs, decimals=4),
<del> [
<del> {"score": 0.0015, "label": "chambered nautilus, pearly nautilus, nautilus"},
<del> {"score": 0.0015, "label": "pajama, pyjama, pj's, jammies"},
<del> {"score": 0.0014, "label": "trench coat"},
<del> {"score": 0.0014, "label": "handkerchief, hankie, hanky, hankey"},
<del> {"score": 0.0014, "label": "baboon"},
<del> ],
<add> [{"label": "LABEL_1", "score": 0.574}, {"label": "LABEL_0", "score": 0.426}],
<ide> )
<ide>
<ide> outputs = image_classifier(
<ide> def test_small_model_tf(self):
<ide> self.assertEqual(
<ide> nested_simplify(outputs, decimals=4),
<ide> [
<del> [
<del> {"score": 0.0015, "label": "chambered nautilus, pearly nautilus, nautilus"},
<del> {"score": 0.0015, "label": "pajama, pyjama, pj's, jammies"},
<del> ],
<del> [
<del> {"score": 0.0015, "label": "chambered nautilus, pearly nautilus, nautilus"},
<del> {"score": 0.0015, "label": "pajama, pyjama, pj's, jammies"},
<del> ],
<add> [{"label": "LABEL_1", "score": 0.574}, {"label": "LABEL_0", "score": 0.426}],
<add> [{"label": "LABEL_1", "score": 0.574}, {"label": "LABEL_0", "score": 0.426}],
<ide> ],
<ide> )
<ide>
<ide> def test_custom_tokenizer(self):
<ide> tokenizer = PreTrainedTokenizer()
<ide>
<ide> # Assert that the pipeline can be initialized with a feature extractor that is not in any mapping
<del> image_classifier = pipeline("image-classification", model="lysandre/tiny-vit-random", tokenizer=tokenizer)
<add> image_classifier = pipeline(
<add> "image-classification", model="hf-internal-testing/tiny-random-vit", tokenizer=tokenizer
<add> )
<ide>
<ide> self.assertIs(image_classifier.tokenizer, tokenizer)
<ide>
| 1
|
PHP
|
PHP
|
fix the related test
|
49da430987e873f5aa6e9054c7ca94f0edd7b820
|
<ide><path>tests/TestCase/Console/Command/Task/TestTaskTest.php
<ide> public static function caseFileNameProvider() {
<ide> */
<ide> public function testTestCaseFileName($type, $class, $expected) {
<ide> $result = $this->Task->testCaseFileName($type, $class);
<del> $expected = ROOT . DS . 'Test/' . $expected;
<add> $expected = ROOT . DS . 'tests/' . $expected;
<ide> $this->assertPathEquals($expected, $result);
<ide> }
<ide>
| 1
|
Javascript
|
Javascript
|
fix russian locale for calendar next week
|
4aa10549f4dcdba2ec9428acf6418bf1a6bcc5c0
|
<ide><path>src/locale/ru.js
<ide> export default moment.defineLocale('ru', {
<ide> sameDay: '[Сегодня в] LT',
<ide> nextDay: '[Завтра в] LT',
<ide> lastDay: '[Вчера в] LT',
<del> nextWeek: function () {
<del> return this.day() === 2 ? '[Во] dddd [в] LT' : '[В] dddd [в] LT';
<add> nextWeek: function (now) {
<add> if (now.week() !== this.week()) {
<add> switch (this.day()) {
<add> case 0:
<add> return '[В следующее] dddd [в] LT';
<add> case 1:
<add> case 2:
<add> case 4:
<add> return '[В следующий] dddd [в] LT';
<add> case 3:
<add> case 5:
<add> case 6:
<add> return '[В следующую] dddd [в] LT';
<add> }
<add> } else {
<add> if (this.day() === 2) {
<add> return '[Во] dddd [в] LT';
<add> } else {
<add> return '[В] dddd [в] LT';
<add> }
<add> }
<ide> },
<ide> lastWeek: function (now) {
<ide> if (now.week() !== this.week()) {
<ide><path>src/test/locale/ru.js
<ide> test('calendar day', function (assert) {
<ide> });
<ide>
<ide> test('calendar next week', function (assert) {
<del> var i, m;
<del> function makeFormat(d) {
<del> return d.day() === 2 ? '[Во] dddd [в] LT' : '[В] dddd [в] LT';
<add> var i, m, now;
<add>
<add> function makeFormatNext(d) {
<add> switch (d.day()) {
<add> case 0:
<add> return '[В следующее] dddd [в] LT';
<add> case 1:
<add> case 2:
<add> case 4:
<add> return '[В следующий] dddd [в] LT';
<add> case 3:
<add> case 5:
<add> case 6:
<add> return '[В следующую] dddd [в] LT';
<add> }
<add> }
<add>
<add> function makeFormatThis(d) {
<add> if (d.day() === 2) {
<add> return '[Во] dddd [в] LT';
<add> }
<add> else {
<add> return '[В] dddd [в] LT';
<add> }
<ide> }
<ide>
<add> now = moment().startOf('week');
<ide> for (i = 2; i < 7; i++) {
<del> m = moment().add({d: i});
<del> assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days current time');
<add> m = moment(now).add({d: i});
<add> assert.equal(m.calendar(now), m.format(makeFormatThis(m)), 'Today + ' + i + ' days current time');
<ide> m.hours(0).minutes(0).seconds(0).milliseconds(0);
<del> assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days beginning of day');
<add> assert.equal(m.calendar(now), m.format(makeFormatThis(m)), 'Today + ' + i + ' days beginning of day');
<ide> m.hours(23).minutes(59).seconds(59).milliseconds(999);
<del> assert.equal(m.calendar(), m.format(makeFormat(m)), 'Today + ' + i + ' days end of day');
<add> assert.equal(m.calendar(now), m.format(makeFormatThis(m)), 'Today + ' + i + ' days end of day');
<add> }
<add>
<add> now = moment().endOf('week');
<add> for (i = 2; i < 7; i++) {
<add> m = moment(now).add({d: i});
<add> assert.equal(m.calendar(now), m.format(makeFormatNext(m)), 'Today + ' + i + ' days current time');
<add> m.hours(0).minutes(0).seconds(0).milliseconds(0);
<add> assert.equal(m.calendar(now), m.format(makeFormatNext(m)), 'Today + ' + i + ' days beginning of day');
<add> m.hours(23).minutes(59).seconds(59).milliseconds(999);
<add> assert.equal(m.calendar(now), m.format(makeFormatNext(m)), 'Today + ' + i + ' days end of day');
<ide> }
<ide> });
<ide>
<ide> test('calendar last week', function (assert) {
<ide> }
<ide>
<ide> function makeFormatThis(d) {
<del> switch (d.day()) {
<del> case 2:
<add> if (d.day() === 2) {
<ide> return '[Во] dddd [в] LT';
<del> case 0:
<del> case 1:
<del> case 3:
<del> case 4:
<del> case 5:
<del> case 6:
<add> }
<add> else {
<ide> return '[В] dddd [в] LT';
<ide> }
<ide> }
| 2
|
Java
|
Java
|
fix javadoc typo
|
c7babab2ddfe843a100bd67b63f2353df15ac1a8
|
<ide><path>spring-aop/src/main/java/org/springframework/aop/aspectj/RuntimeTestWalker.java
<ide> * migrate to {@code ShadowMatch.getVariablesInvolvedInRuntimeTest()}
<ide> * or some similar operation.
<ide> *
<del> * <p>See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=151593"/>.
<add> * <p>See <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=151593"/>Bug 151593</a>
<ide> *
<ide> * @author Adrian Colyer
<ide> * @author Ramnivas Laddad
<ide> * @since 2.0
<ide> */
<del>class RuntimeTestWalker {
<add>class RuntimeTestWlalker {
<ide>
<ide> private static final Field residualTestField;
<ide>
| 1
|
Ruby
|
Ruby
|
pass args to render's super method
|
98ec4ebfe730438024b95bca904fe324740396ad
|
<ide><path>actionview/lib/action_view/rendering.rb
<ide> def view_renderer
<ide> # Render template to response_body
<ide> # :api: public
<ide> def render(*args, &block)
<del> super
<add> super(*args, &block)
<add>
<ide> options = _normalize_render(*args, &block)
<ide> self.response_body = render_to_body(options)
<ide> end
| 1
|
Javascript
|
Javascript
|
prevent a v8 deopt when profiling
|
7a48c900b7d8c97580d62adfa3625a7b7567c998
|
<ide><path>packages/react-reconciler/src/ReactFiber.js
<ide> function FiberNode(
<ide> this.alternate = null;
<ide>
<ide> if (enableProfilerTimer) {
<add> // Note: The following is done to avoid a v8 deopt.
<add> //
<add> // It is important to initialize the fields below with doubles.
<add> // Otherwise Fibers will deopt and end up having separate shapes when
<add> // doubles are later assigned to fields that initially contained smis.
<add> // This is a bug in v8 having something to do with Object.preventExtension().
<add> //
<add> // Learn more about this deopt here:
<add> // https://github.com/facebook/react/issues/14365
<add> // https://bugs.chromium.org/p/v8/issues/detail?id=8538
<add> this.actualDuration = Number.NaN;
<add> this.actualStartTime = Number.NaN;
<add> this.selfBaseDuration = Number.NaN;
<add> this.treeBaseDuration = Number.NaN;
<add>
<add> // It's okay to replace the initial doubles with smis after initialization.
<add> // This simplifies other profiler code and doesn't trigger the deopt.
<ide> this.actualDuration = 0;
<ide> this.actualStartTime = -1;
<ide> this.selfBaseDuration = 0;
| 1
|
Javascript
|
Javascript
|
fix typo when rejecting promise in getpage
|
652dde48da59141a3d8ad7b0c124ae6b4efd19ac
|
<ide><path>src/display/api.js
<ide> var WorkerTransport = (function WorkerTransportClosure() {
<ide> getPage: function WorkerTransport_getPage(pageNumber, capability) {
<ide> if (pageNumber <= 0 || pageNumber > this.numPages ||
<ide> (pageNumber|0) !== pageNumber) {
<del> return new Promise.reject(new Error('Invalid page request'));
<add> return Promise.reject(new Error('Invalid page request'));
<ide> }
<ide>
<ide> var pageIndex = pageNumber - 1;
| 1
|
Ruby
|
Ruby
|
fix rubocop errors
|
260fc858dfc538aaa3de3d82e3c5aaaf5301ae3d
|
<ide><path>Library/Homebrew/extend/os/linux/cleanup.rb
<ide> def use_system_ruby?
<ide> check_ruby_version = HOMEBREW_LIBRARY_PATH/"utils/ruby_check_version_script.rb"
<ide> rubies.uniq.any? do |ruby|
<ide> quiet_system ruby, "--enable-frozen-string-literal", "--disable=gems,did_you_mean,rubyopt",
<del> check_ruby_version, HOMEBREW_REQUIRED_RUBY_VERSION
<add> check_ruby_version, HOMEBREW_REQUIRED_RUBY_VERSION
<ide> end
<ide> end
<ide> end
| 1
|
PHP
|
PHP
|
extract change column
|
32fa8266a8431305d6e57ccdb205ed1704be62cd
|
<ide><path>src/Illuminate/Database/Schema/Grammars/ChangeColumn.php
<add><?php
<add>
<add>namespace Illuminate\Database\Schema\Grammars;
<add>
<add>use RuntimeException;
<add>use Doctrine\DBAL\Types\Type;
<add>use Illuminate\Support\Fluent;
<add>use Doctrine\DBAL\Schema\Table;
<add>use Doctrine\DBAL\Schema\Column;
<add>use Illuminate\Database\Connection;
<add>use Doctrine\DBAL\Schema\Comparator;
<add>use Illuminate\Database\Schema\Blueprint;
<add>use Doctrine\DBAL\Schema\AbstractSchemaManager as SchemaManager;
<add>
<add>class ChangeColumn
<add>{
<add> /**
<add> * Compile a change column command into a series of SQL statements.
<add> *
<add> * @param \Illuminate\Database\Schema\Grammars\Grammar $grammar
<add> * @param \Illuminate\Database\Schema\Blueprint $blueprint
<add> * @param \Illuminate\Support\Fluent $command
<add> * @param \Illuminate\Database\Connection $connection
<add> * @return array
<add> *
<add> * @throws \RuntimeException
<add> */
<add> public static function compile($grammar, Blueprint $blueprint, Fluent $command, Connection $connection)
<add> {
<add> if (! $connection->isDoctrineAvailable()) {
<add> throw new RuntimeException(sprintf(
<add> 'Changing columns for table "%s" requires Doctrine DBAL; install "doctrine/dbal".',
<add> $blueprint->getTable()
<add> ));
<add> }
<add>
<add> $tableDiff = static::getChangedDiff(
<add> $grammar, $blueprint, $schema = $connection->getDoctrineSchemaManager()
<add> );
<add>
<add> if ($tableDiff !== false) {
<add> return (array) $schema->getDatabasePlatform()->getAlterTableSQL($tableDiff);
<add> }
<add>
<add> return [];
<add> }
<add>
<add> /**
<add> * Get the Doctrine table difference for the given changes.
<add> *
<add> * @param \Illuminate\Database\Schema\Grammars\Grammar $grammar
<add> * @param \Illuminate\Database\Schema\Blueprint $blueprint
<add> * @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema
<add> * @return \Doctrine\DBAL\Schema\TableDiff|bool
<add> */
<add> protected static function getChangedDiff($grammar, Blueprint $blueprint, SchemaManager $schema)
<add> {
<add> $current = $schema->listTableDetails($grammar->getTablePrefix().$blueprint->getTable());
<add>
<add> return (new Comparator)->diffTable(
<add> $current, static::getTableWithColumnChanges($blueprint, $current)
<add> );
<add> }
<add>
<add> /**
<add> * Get a copy of the given Doctrine table after making the column changes.
<add> *
<add> * @param \Illuminate\Database\Schema\Blueprint $blueprint
<add> * @param \Doctrine\DBAL\Schema\Table $table
<add> * @return \Doctrine\DBAL\Schema\TableDiff
<add> */
<add> protected static function getTableWithColumnChanges(Blueprint $blueprint, Table $table)
<add> {
<add> $table = clone $table;
<add>
<add> foreach ($blueprint->getChangedColumns() as $fluent) {
<add> $column = static::getDoctrineColumn($table, $fluent);
<add>
<add> // Here we will spin through each fluent column definition and map it to the proper
<add> // Doctrine column definitions - which is necessary because Laravel and Doctrine
<add> // use some different terminology for various column attributes on the tables.
<add> foreach ($fluent->getAttributes() as $key => $value) {
<add> if (! is_null($option = static::mapFluentOptionToDoctrine($key))) {
<add> if (method_exists($column, $method = 'set'.ucfirst($option))) {
<add> $column->{$method}(static::mapFluentValueToDoctrine($option, $value));
<add> }
<add> }
<add> }
<add> }
<add>
<add> return $table;
<add> }
<add>
<add> /**
<add> * Get the Doctrine column instance for a column change.
<add> *
<add> * @param \Doctrine\DBAL\Schema\Table $table
<add> * @param \Illuminate\Support\Fluent $fluent
<add> * @return \Doctrine\DBAL\Schema\Column
<add> */
<add> protected static function getDoctrineColumn(Table $table, Fluent $fluent)
<add> {
<add> return $table->changeColumn(
<add> $fluent['name'], static::getDoctrineColumnChangeOptions($fluent)
<add> )->getColumn($fluent['name']);
<add> }
<add>
<add> /**
<add> * Get the Doctrine column change options.
<add> *
<add> * @param \Illuminate\Support\Fluent $fluent
<add> * @return array
<add> */
<add> protected static function getDoctrineColumnChangeOptions(Fluent $fluent)
<add> {
<add> $options = ['type' => static::getDoctrineColumnType($fluent['type'])];
<add>
<add> if (in_array($fluent['type'], ['text', 'mediumText', 'longText'])) {
<add> $options['length'] = static::calculateDoctrineTextLength($fluent['type']);
<add> }
<add>
<add> return $options;
<add> }
<add>
<add> /**
<add> * Get the doctrine column type.
<add> *
<add> * @param string $type
<add> * @return \Doctrine\DBAL\Types\Type
<add> */
<add> protected static function getDoctrineColumnType($type)
<add> {
<add> $type = strtolower($type);
<add>
<add> switch ($type) {
<add> case 'biginteger':
<add> $type = 'bigint';
<add> break;
<add> case 'smallinteger':
<add> $type = 'smallint';
<add> break;
<add> case 'mediumtext':
<add> case 'longtext':
<add> $type = 'text';
<add> break;
<add> case 'binary':
<add> $type = 'blob';
<add> break;
<add> }
<add>
<add> return Type::getType($type);
<add> }
<add>
<add> /**
<add> * Calculate the proper column length to force the Doctrine text type.
<add> *
<add> * @param string $type
<add> * @return int
<add> */
<add> protected static function calculateDoctrineTextLength($type)
<add> {
<add> switch ($type) {
<add> case 'mediumText':
<add> return 65535 + 1;
<add> case 'longText':
<add> return 16777215 + 1;
<add> default:
<add> return 255 + 1;
<add> }
<add> }
<add>
<add> /**
<add> * Get the matching Doctrine option for a given Fluent attribute name.
<add> *
<add> * @param string $attribute
<add> * @return string|null
<add> */
<add> protected static function mapFluentOptionToDoctrine($attribute)
<add> {
<add> switch ($attribute) {
<add> case 'type':
<add> case 'name':
<add> return;
<add> case 'nullable':
<add> return 'notnull';
<add> case 'total':
<add> return 'precision';
<add> case 'places':
<add> return 'scale';
<add> default:
<add> return $attribute;
<add> }
<add> }
<add>
<add> /**
<add> * Get the matching Doctrine value for a given Fluent attribute.
<add> *
<add> * @param string $option
<add> * @param mixed $value
<add> * @return mixed
<add> */
<add> protected static function mapFluentValueToDoctrine($option, $value)
<add> {
<add> return $option == 'notnull' ? ! $value : $value;
<add> }
<add>}
<ide><path>src/Illuminate/Database/Schema/Grammars/Grammar.php
<ide>
<ide> namespace Illuminate\Database\Schema\Grammars;
<ide>
<del>use RuntimeException;
<ide> use Doctrine\DBAL\Types\Type;
<ide> use Illuminate\Support\Fluent;
<ide> use Doctrine\DBAL\Schema\Table;
<ide> use Doctrine\DBAL\Schema\Column;
<ide> use Doctrine\DBAL\Schema\TableDiff;
<ide> use Illuminate\Database\Connection;
<del>use Doctrine\DBAL\Schema\Comparator;
<ide> use Illuminate\Database\Query\Expression;
<ide> use Illuminate\Database\Schema\Blueprint;
<ide> use Illuminate\Database\Grammar as BaseGrammar;
<ide> public function compileRenameColumn(Blueprint $blueprint, Fluent $command, Conne
<ide> return RenameColumn::compile($this, $blueprint, $command, $connection);
<ide> }
<ide>
<add> /**
<add> * Compile a change column command into a series of SQL statements.
<add> *
<add> * @param \Illuminate\Database\Schema\Blueprint $blueprint
<add> * @param \Illuminate\Support\Fluent $command
<add> * @param \Illuminate\Database\Connection $connection
<add> * @return array
<add> *
<add> * @throws \RuntimeException
<add> */
<add> public function compileChange(Blueprint $blueprint, Fluent $command, Connection $connection)
<add> {
<add> return ChangeColumn::compile($this, $blueprint, $command, $connection);
<add> }
<add>
<ide> /**
<ide> * Compile a foreign key command.
<ide> *
<ide> public function wrapTable($table)
<ide> }
<ide>
<ide> /**
<del> * {@inheritdoc}
<add> * Wrap a value in keyword identifiers.
<add> *
<add> * @param \Illuminate\Database\Query\Expression|string $value
<add> * @param bool $prefixAlias
<add> * @return string
<ide> */
<ide> public function wrap($value, $prefixAlias = false)
<ide> {
<ide> public function getDoctrineTableDiff(Blueprint $blueprint, SchemaManager $schema
<ide> });
<ide> }
<ide>
<del> /**
<del> * Compile a change column command into a series of SQL statements.
<del> *
<del> * @param \Illuminate\Database\Schema\Blueprint $blueprint
<del> * @param \Illuminate\Support\Fluent $command
<del> * @param \Illuminate\Database\Connection $connection
<del> * @return array
<del> *
<del> * @throws \RuntimeException
<del> */
<del> public function compileChange(Blueprint $blueprint, Fluent $command, Connection $connection)
<del> {
<del> if (! $connection->isDoctrineAvailable()) {
<del> throw new RuntimeException(sprintf(
<del> 'Changing columns for table "%s" requires Doctrine DBAL; install "doctrine/dbal".',
<del> $blueprint->getTable()
<del> ));
<del> }
<del>
<del> $schema = $connection->getDoctrineSchemaManager();
<del>
<del> $tableDiff = $this->getChangedDiff($blueprint, $schema);
<del>
<del> if ($tableDiff !== false) {
<del> return (array) $schema->getDatabasePlatform()->getAlterTableSQL($tableDiff);
<del> }
<del>
<del> return [];
<del> }
<del>
<del> /**
<del> * Get the Doctrine table difference for the given changes.
<del> *
<del> * @param \Illuminate\Database\Schema\Blueprint $blueprint
<del> * @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema
<del> * @return \Doctrine\DBAL\Schema\TableDiff|bool
<del> */
<del> protected function getChangedDiff(Blueprint $blueprint, SchemaManager $schema)
<del> {
<del> $table = $schema->listTableDetails($this->getTablePrefix().$blueprint->getTable());
<del>
<del> return (new Comparator)->diffTable($table, $this->getTableWithColumnChanges($blueprint, $table));
<del> }
<del>
<del> /**
<del> * Get a copy of the given Doctrine table after making the column changes.
<del> *
<del> * @param \Illuminate\Database\Schema\Blueprint $blueprint
<del> * @param \Doctrine\DBAL\Schema\Table $table
<del> * @return \Doctrine\DBAL\Schema\TableDiff
<del> */
<del> protected function getTableWithColumnChanges(Blueprint $blueprint, Table $table)
<del> {
<del> $table = clone $table;
<del>
<del> foreach ($blueprint->getChangedColumns() as $fluent) {
<del> $column = $this->getDoctrineColumnForChange($table, $fluent);
<del>
<del> // Here we will spin through each fluent column definition and map it to the proper
<del> // Doctrine column definitions - which is necessary because Laravel and Doctrine
<del> // use some different terminology for various column attributes on the tables.
<del> foreach ($fluent->getAttributes() as $key => $value) {
<del> if (! is_null($option = $this->mapFluentOptionToDoctrine($key))) {
<del> if (method_exists($column, $method = 'set'.ucfirst($option))) {
<del> $column->{$method}($this->mapFluentValueToDoctrine($option, $value));
<del> }
<del> }
<del> }
<del> }
<del>
<del> return $table;
<del> }
<del>
<del> /**
<del> * Get the Doctrine column instance for a column change.
<del> *
<del> * @param \Doctrine\DBAL\Schema\Table $table
<del> * @param \Illuminate\Support\Fluent $fluent
<del> * @return \Doctrine\DBAL\Schema\Column
<del> */
<del> protected function getDoctrineColumnForChange(Table $table, Fluent $fluent)
<del> {
<del> return $table->changeColumn(
<del> $fluent['name'], $this->getDoctrineColumnChangeOptions($fluent)
<del> )->getColumn($fluent['name']);
<del> }
<del>
<del> /**
<del> * Get the Doctrine column change options.
<del> *
<del> * @param \Illuminate\Support\Fluent $fluent
<del> * @return array
<del> */
<del> protected function getDoctrineColumnChangeOptions(Fluent $fluent)
<del> {
<del> $options = ['type' => $this->getDoctrineColumnType($fluent['type'])];
<del>
<del> if (in_array($fluent['type'], ['text', 'mediumText', 'longText'])) {
<del> $options['length'] = $this->calculateDoctrineTextLength($fluent['type']);
<del> }
<del>
<del> return $options;
<del> }
<del>
<del> /**
<del> * Get the doctrine column type.
<del> *
<del> * @param string $type
<del> * @return \Doctrine\DBAL\Types\Type
<del> */
<del> protected function getDoctrineColumnType($type)
<del> {
<del> $type = strtolower($type);
<del>
<del> switch ($type) {
<del> case 'biginteger':
<del> $type = 'bigint';
<del> break;
<del> case 'smallinteger':
<del> $type = 'smallint';
<del> break;
<del> case 'mediumtext':
<del> case 'longtext':
<del> $type = 'text';
<del> break;
<del> case 'binary':
<del> $type = 'blob';
<del> break;
<del> }
<del>
<del> return Type::getType($type);
<del> }
<del>
<del> /**
<del> * Calculate the proper column length to force the Doctrine text type.
<del> *
<del> * @param string $type
<del> * @return int
<del> */
<del> protected function calculateDoctrineTextLength($type)
<del> {
<del> switch ($type) {
<del> case 'mediumText':
<del> return 65535 + 1;
<del> case 'longText':
<del> return 16777215 + 1;
<del> default:
<del> return 255 + 1;
<del> }
<del> }
<del>
<del> /**
<del> * Get the matching Doctrine option for a given Fluent attribute name.
<del> *
<del> * @param string $attribute
<del> * @return string|null
<del> */
<del> protected function mapFluentOptionToDoctrine($attribute)
<del> {
<del> switch ($attribute) {
<del> case 'type':
<del> case 'name':
<del> return;
<del> case 'nullable':
<del> return 'notnull';
<del> case 'total':
<del> return 'precision';
<del> case 'places':
<del> return 'scale';
<del> default:
<del> return $attribute;
<del> }
<del> }
<del>
<del> /**
<del> * Get the matching Doctrine value for a given Fluent attribute.
<del> *
<del> * @param string $option
<del> * @param mixed $value
<del> * @return mixed
<del> */
<del> protected function mapFluentValueToDoctrine($option, $value)
<del> {
<del> return $option == 'notnull' ? ! $value : $value;
<del> }
<del>
<ide> /**
<ide> * Check if this Grammar supports schema changes wrapped in a transaction.
<ide> *
<ide><path>src/Illuminate/Database/Schema/Grammars/RenameColumn.php
<ide> public static function compile($grammar, Blueprint $blueprint, Fluent $command,
<ide> /**
<ide> * Get a new column instance with the new column name.
<ide> *
<add> * @param \Illuminate\Database\Schema\Grammars\Grammar $grammar
<ide> * @param \Illuminate\Database\Schema\Blueprint $blueprint
<ide> * @param \Illuminate\Support\Fluent $command
<ide> * @param \Doctrine\DBAL\Schema\Column $column
| 3
|
Python
|
Python
|
pass kwargs correctly
|
686040e8fcebde33977eb0891520036dbf10d7b2
|
<ide><path>airflow/configuration.py
<ide> def test_mode():
<ide>
<ide>
<ide> def get(section, key, **kwargs):
<del> return conf.get(section, key, kwargs)
<add> return conf.get(section, key, **kwargs)
<ide>
<ide>
<ide> def getboolean(section, key):
| 1
|
Ruby
|
Ruby
|
fix 1.9 issue
|
1e95f019bb0b2f1f37c5897562da691eb72c0f1c
|
<ide><path>actionpack/lib/action_controller/railties/url_helpers.rb
<ide> module UrlHelpers
<ide> def self.with(router)
<ide> Module.new do
<ide> define_method(:inherited) do |klass|
<del> super
<add> super(klass)
<ide> klass.send(:include, router.named_url_helpers)
<ide> end
<ide> end
| 1
|
Python
|
Python
|
remove testsuite package from setup.py
|
b93ab41ed12c3dd0c37fb7a85f1aa93966b46d77
|
<ide><path>setup.py
<ide> def run(self):
<ide> description='A microframework based on Werkzeug, Jinja2 '
<ide> 'and good intentions',
<ide> long_description=__doc__,
<del> packages=['flask', 'flask.ext', 'flask.testsuite'],
<add> packages=['flask', 'flask.ext'],
<ide> include_package_data=True,
<ide> zip_safe=False,
<ide> platforms='any',
| 1
|
Javascript
|
Javascript
|
improve vector2 closure performance
|
5f2187fbef3960f2111d498adf5e6a8c50404946
|
<ide><path>src/math/Vector2.js
<ide> Object.assign( Vector2.prototype, {
<ide>
<ide> clampScalar: function () {
<ide>
<del> var min, max;
<add> var min = new Vector2();
<add> var max = new Vector2();
<ide>
<ide> return function clampScalar( minVal, maxVal ) {
<ide>
<del> if ( min === undefined ) {
<del>
<del> min = new Vector2();
<del> max = new Vector2();
<del>
<del> }
<del>
<ide> min.set( minVal, minVal );
<ide> max.set( maxVal, maxVal );
<ide>
| 1
|
Javascript
|
Javascript
|
improve fspromises writefile performance
|
e1ce7f1194ce81188e080fca0ec6fb80db842c5d
|
<ide><path>lib/internal/fs/promises.js
<ide> const kIoMaxLength = 2 ** 31 - 1;
<ide>
<ide> const kReadFileBufferLength = 512 * 1024;
<ide> const kReadFileUnknownBufferLength = 64 * 1024;
<del>const kWriteFileMaxChunkSize = 2 ** 14;
<add>const kWriteFileMaxChunkSize = 512 * 1024;
<ide>
<ide> const {
<ide> ArrayPrototypePush,
<ide><path>test/parallel/test-fs-promises-file-handle-writeFile.js
<ide> async function validateWriteFile() {
<ide> async function doWriteAndCancel() {
<ide> const filePathForHandle = path.resolve(tmpDir, 'dogs-running.txt');
<ide> const fileHandle = await open(filePathForHandle, 'w+');
<del> const buffer = Buffer.from('dogs running'.repeat(10000), 'utf8');
<add> const buffer = Buffer.from('dogs running'.repeat(512 * 1024), 'utf8');
<ide> const controller = new AbortController();
<ide> const { signal } = controller;
<ide> process.nextTick(() => controller.abort());
| 2
|
Javascript
|
Javascript
|
add random attribute to user props
|
e035a4a1322620c67efd2da7497545a6eae86b4e
|
<ide><path>loopbackMigration.js
<ide> var users = dbObservable
<ide> user[provider + 'id'] = user[provider];
<ide> user[provider] = null;
<ide> });
<add> user.rand = Math.random();
<ide>
<ide> return user;
<ide> })
| 1
|
Javascript
|
Javascript
|
adapt interface of node-haste duplicates
|
a51e9a0704ecbd1bcfafe9cf87b21270708ba933
|
<ide><path>packager/src/ModuleGraph/node-haste/Module.js
<ide> module.exports = class Module {
<ide> constructor(
<ide> path: string,
<ide> moduleCache: ModuleCache,
<del> info: Promise<TransformedFile>,
<add> info: TransformedFile,
<ide> ) {
<del> this.hasteID = info.then(({hasteID}) => hasteID);
<add> this.hasteID = Promise.resolve(info.hasteID);
<ide> this.moduleCache = moduleCache;
<ide> this.name = this.hasteID.then(name => name || getName(path));
<ide> this.path = path;
<ide><path>packager/src/ModuleGraph/node-haste/ModuleCache.js
<ide> const Package = require('./Package');
<ide>
<ide> import type {PackageData, TransformedFile} from '../types.flow';
<ide>
<del>type GetFn<T> = (path: string) => Promise<T>;
<ide> type GetClosestPackageFn = (filePath: string) => ?string;
<ide>
<ide> module.exports = class ModuleCache {
<ide> _getClosestPackage: GetClosestPackageFn;
<del> getPackageData: GetFn<PackageData>;
<del> getTransformedFile: GetFn<TransformedFile>;
<add> getTransformedFile: string => TransformedFile;
<ide> modules: Map<string, Module>;
<ide> packages: Map<string, Package>;
<ide>
<del> constructor(getClosestPackage: GetClosestPackageFn, getTransformedFile: GetFn<TransformedFile>) {
<add> constructor(
<add> getClosestPackage: GetClosestPackageFn,
<add> getTransformedFile: string => TransformedFile,
<add> ) {
<ide> this._getClosestPackage = getClosestPackage;
<ide> this.getTransformedFile = getTransformedFile;
<del> this.getPackageData = path => getTransformedFile(path).then(
<del> f => f.package || Promise.reject(new Error(`"${path}" does not exist`))
<del> );
<ide> this.modules = new Map();
<ide> this.packages = new Map();
<ide> }
<ide> module.exports = class ModuleCache {
<ide> return p;
<ide> }
<ide>
<add> getPackageData(path: string): PackageData {
<add> const pkg = this.getTransformedFile(path).package;
<add> if (!pkg) {
<add> throw new Error(`"${path}" does not exist`);
<add> }
<add> return pkg;
<add> }
<add>
<ide> getPackageOf(filePath: string) {
<ide> const candidate = this._getClosestPackage(filePath);
<ide> return candidate != null ? this.getPackage(candidate) : null;
<ide><path>packager/src/ModuleGraph/node-haste/Package.js
<ide> const path = require('path');
<ide> import type {PackageData} from '../types.flow';
<ide>
<ide> module.exports = class Package {
<del> data: Promise<PackageData>;
<add> data: PackageData;
<ide> path: string;
<ide> root: string;
<ide> type: 'Package';
<ide>
<del> constructor(packagePath: string, data: Promise<PackageData>) {
<add> constructor(packagePath: string, data: PackageData) {
<ide> this.data = data;
<ide> this.path = packagePath;
<ide> this.root = path.dirname(packagePath);
<ide> module.exports = class Package {
<ide>
<ide> getMain() {
<ide> // Copied from node-haste/Package.js
<del> return this.data.then(data => {
<del> const replacements = getReplacements(data);
<del> if (typeof replacements === 'string') {
<del> return path.join(this.root, replacements);
<del> }
<del>
<del> let main = getMain(data);
<del>
<del> if (replacements && typeof replacements === 'object') {
<del> main = replacements[main] ||
<del> replacements[main + '.js'] ||
<del> replacements[main + '.json'] ||
<del> replacements[main.replace(/(\.js|\.json)$/, '')] ||
<del> main;
<del> }
<del>
<del> return path.join(this.root, main);
<del> });
<add> const replacements = getReplacements(this.data);
<add> if (typeof replacements === 'string') {
<add> return path.join(this.root, replacements);
<add> }
<add>
<add> let main = getMain(this.data);
<add>
<add> if (replacements && typeof replacements === 'object') {
<add> main = replacements[main] ||
<add> replacements[main + '.js'] ||
<add> replacements[main + '.json'] ||
<add> replacements[main.replace(/(\.js|\.json)$/, '')] ||
<add> main;
<add> }
<add>
<add> return path.join(this.root, main);
<ide> }
<ide>
<ide> getName() {
<del> return this.data.then(p => nullthrows(p.name));
<add> return Promise.resolve(nullthrows(this.data.name));
<ide> }
<ide>
<ide> isHaste() {
<del> return this.data.then(p => !!p.name);
<add> return Promise.resolve(!!this.data.name);
<ide> }
<ide>
<ide> redirectRequire(name: string) {
<ide> // Copied from node-haste/Package.js
<del> return this.data.then(data => {
<del> const replacements = getReplacements(data);
<del>
<del> if (!replacements || typeof replacements !== 'object') {
<del> return name;
<del> }
<del>
<del> if (!path.isAbsolute(name)) {
<del> const replacement = replacements[name];
<del> // support exclude with "someDependency": false
<del> return replacement === false
<del> ? false
<del> : replacement || name;
<del> }
<del>
<del> let relPath = './' + path.relative(this.root, name);
<del> if (path.sep !== '/') {
<del> relPath = relPath.replace(new RegExp('\\' + path.sep, 'g'), '/');
<del> }
<del>
<del> let redirect = replacements[relPath];
<add> const replacements = getReplacements(this.data);
<ide>
<del> // false is a valid value
<add> if (!replacements || typeof replacements !== 'object') {
<add> return name;
<add> }
<add>
<add> if (!path.isAbsolute(name)) {
<add> const replacement = replacements[name];
<add> // support exclude with "someDependency": false
<add> return replacement === false
<add> ? false
<add> : replacement || name;
<add> }
<add>
<add> let relPath = './' + path.relative(this.root, name);
<add> if (path.sep !== '/') {
<add> relPath = relPath.replace(new RegExp('\\' + path.sep, 'g'), '/');
<add> }
<add>
<add> let redirect = replacements[relPath];
<add>
<add> // false is a valid value
<add> if (redirect == null) {
<add> redirect = replacements[relPath + '.js'];
<ide> if (redirect == null) {
<del> redirect = replacements[relPath + '.js'];
<del> if (redirect == null) {
<del> redirect = replacements[relPath + '.json'];
<del> }
<add> redirect = replacements[relPath + '.json'];
<ide> }
<add> }
<ide>
<del> // support exclude with "./someFile": false
<del> if (redirect === false) {
<del> return false;
<del> }
<add> // support exclude with "./someFile": false
<add> if (redirect === false) {
<add> return false;
<add> }
<ide>
<del> if (redirect) {
<del> return path.join(
<del> this.root,
<del> redirect
<del> );
<del> }
<add> if (redirect) {
<add> return path.join(
<add> this.root,
<add> redirect
<add> );
<add> }
<ide>
<del> return name;
<del> });
<add> return name;
<ide> }
<ide> };
<ide>
<ide><path>packager/src/ModuleGraph/node-haste/node-haste.flow.js
<ide> export type Package = {
<ide> path: Path,
<ide> root: Path,
<ide> type: 'Package',
<del> getMain(): Promise<Path>,
<add> getMain(): Path,
<ide> getName(): Promise<ModuleID>,
<ide> isHaste(): Promise<boolean>,
<del> redirectRequire(id: ModuleID): Promise<Path | false>,
<add> redirectRequire(id: ModuleID): Path | false,
<ide> };
<ide>
<del>// when changing this to `type`, the code does not typecheck any more
<del>export interface ModuleCache {
<add>export type ModuleCache = {
<ide> getAssetModule(path: Path): Module,
<ide> getModule(path: Path): Module,
<ide> getPackage(path: Path): Package,
<ide><path>packager/src/ModuleGraph/node-haste/node-haste.js
<ide> exports.createResolveFn = function(options: ResolveOptions): ResolveFn {
<ide> transformedFiles,
<ide> } = options;
<ide> const files = Object.keys(transformedFiles);
<del> const getTransformedFile =
<del> path => Promise.resolve(
<del> transformedFiles[path] || Promise.reject(new Error(`"${path} does not exist`))
<del> );
<add> function getTransformedFile(path) {
<add> const result = transformedFiles[path];
<add> if (!result) {
<add> throw new Error(`"${path} does not exist`);
<add> }
<add> return result;
<add> }
<ide>
<ide> const helpers = new DependencyGraphHelpers({
<ide> assetExts,
| 5
|
Go
|
Go
|
apply load balancer properly
|
f9442ee314600a13fb99f6b90313395fc3625c53
|
<ide><path>libnetwork/osl/namespace_linux.go
<ide> func (n *networkNamespace) ApplyOSTweaks(types []SandboxType) {
<ide> for _, t := range types {
<ide> switch t {
<ide> case SandboxTypeLoadBalancer:
<del> kernel.ApplyOSTweaks(loadBalancerConfig)
<add> n.InvokeFunc(func() { kernel.ApplyOSTweaks(loadBalancerConfig) })
<ide> }
<ide> }
<ide> }
| 1
|
Ruby
|
Ruby
|
avoid multiple hash lookups
|
06dc88445463513b58ed47ae8b21f853efda6898
|
<ide><path>activerecord/lib/active_record/relation/spawn_methods.rb
<ide> def apply_finder_options(options)
<ide>
<ide> options.assert_valid_keys(VALID_FIND_OPTIONS)
<ide>
<del> [:joins, :select, :group, :having, :limit, :offset, :from, :lock, :readonly].each do |finder|
<del> relation = relation.send(finder, options[finder]) if options.has_key?(finder)
<add> [:joins, :select, :group, :having, :limit, :offset, :from, :lock].each do |finder|
<add> if value = options[finder]
<add> relation = relation.send(finder, value)
<add> end
<ide> end
<ide>
<add> relation = relation.readonly(options[:readonly]) if options.key? :readonly
<add>
<ide> # Give precedence to newly-applied orders and groups to play nicely with with_scope
<ide> [:group, :order].each do |finder|
<ide> relation.send("#{finder}_values=", Array.wrap(options[finder]) + relation.send("#{finder}_values")) if options.has_key?(finder)
| 1
|
PHP
|
PHP
|
fix glob problem in migration resolver
|
04f21380ca2304a2aa95f8dfcd76675b83d58437
|
<ide><path>laravel/cli/tasks/migrate/resolver.php
<ide> protected function migrations($bundle)
<ide> {
<ide> $files = glob(Bundle::path($bundle).'migrations/*_*'.EXT);
<ide>
<add> // When open_basedir is enabled, glob will return false on an
<add> // empty directory, so we will return an empty array in this
<add> // case so the application doesn't bomb out.
<add> if ($files === false)
<add> {
<add> return array();
<add> }
<add>
<ide> // Once we have the array of files in the migration directory,
<ide> // we'll take the basename of the file and remove the PHP file
<ide> // extension, which isn't needed.
| 1
|
Text
|
Text
|
update image url (#484)
|
af12df9fe8e18834e1c5cd28b4fad04a44c7d57e
|
<ide><path>README.md
<ide> where {\displaystyle \oplus } \oplus denotes the exclusive disjunction (XOR) op
<ide>
<ide> [caesar]: https://upload.wikimedia.org/wikipedia/commons/4/4a/Caesar_cipher_left_shift_of_3.svg
<ide>
<del>[ROT13-image]: https://en.wikipedia.org/wiki/File:ROT13_table_with_example.svg
<add>[ROT13-image]: https://upload.wikimedia.org/wikipedia/commons/3/33/ROT13_table_with_example.svg
<ide>
<del>[QuickSelect-image]: https://en.wikipedia.org/wiki/File:Selecting_quickselect_frames.gif
<add>[QuickSelect-image]: https://upload.wikimedia.org/wikipedia/commons/0/04/Selecting_quickselect_frames.gif
| 1
|
Ruby
|
Ruby
|
exclude empty rack
|
0d74967ceb15fe954ca722c11de91326d072fa05
|
<ide><path>Library/Homebrew/formula.rb
<ide> def self.each
<ide> # @private
<ide> def self.racks
<ide> @racks ||= if HOMEBREW_CELLAR.directory?
<del> HOMEBREW_CELLAR.subdirs.reject(&:symlink?)
<add> HOMEBREW_CELLAR.subdirs.reject do |rack|
<add> rack.symlink? || rack.subdirs.empty?
<add> end
<ide> else
<ide> []
<ide> end
| 1
|
PHP
|
PHP
|
allow rlike in conditions
|
d0f75a03af584710db4094e5561a7f085ff3faa2
|
<ide><path>lib/Cake/Model/Datasource/DboSource.php
<ide> class DboSource extends DataSource {
<ide> *
<ide> * @var array
<ide> */
<del> protected $_sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', 'regexp', 'similar to');
<add> protected $_sqlOps = array('like', 'ilike', 'rlike', 'or', 'not', 'in', 'between', 'regexp', 'similar to');
<ide>
<ide> /**
<ide> * Indicates the level of nested transactions
<ide><path>lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
<ide> public function testArrayConditionsParsing() {
<ide> $expected = " WHERE ((`User`.`user` = 'mariano') OR (`User`.`user` = 'nate'))";
<ide> $this->assertEquals($expected, $result);
<ide>
<add> $result = $this->Dbo->conditions(array('User.user RLIKE' => 'mariano|nate'));
<add> $expected = " WHERE `User`.`user` RLIKE 'mariano|nate'";
<add> $this->assertEquals($expected, $result);
<add>
<ide> $result = $this->Dbo->conditions(array('or' => array(
<ide> 'score BETWEEN ? AND ?' => array('4', '5'), 'rating >' => '20'
<ide> )));
| 2
|
Java
|
Java
|
avoid unnecessary computation of cleaned url
|
96a4e1150e608a66998988f5d4903297ef11e977
|
<ide><path>spring-core/src/main/java/org/springframework/core/io/UrlResource.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> public class UrlResource extends AbstractFileResolvingResource {
<ide> /**
<ide> * Cleaned URL (with normalized path), used for comparisons.
<ide> */
<del> private final URL cleanedUrl;
<add> @Nullable
<add> private volatile URL cleanedUrl;
<ide>
<ide>
<ide> /**
<ide> public UrlResource(URI uri) throws MalformedURLException {
<ide> Assert.notNull(uri, "URI must not be null");
<ide> this.uri = uri;
<ide> this.url = uri.toURL();
<del> this.cleanedUrl = getCleanedUrl(this.url, uri.toString());
<ide> }
<ide>
<ide> /**
<ide> public UrlResource(URI uri) throws MalformedURLException {
<ide> */
<ide> public UrlResource(URL url) {
<ide> Assert.notNull(url, "URL must not be null");
<del> this.url = url;
<del> this.cleanedUrl = getCleanedUrl(this.url, url.toString());
<ide> this.uri = null;
<add> this.url = url;
<ide> }
<ide>
<ide> /**
<ide> public UrlResource(String protocol, String location, @Nullable String fragment)
<ide> try {
<ide> this.uri = new URI(protocol, location, fragment);
<ide> this.url = this.uri.toURL();
<del> this.cleanedUrl = getCleanedUrl(this.url, this.uri.toString());
<ide> }
<ide> catch (URISyntaxException ex) {
<ide> MalformedURLException exToThrow = new MalformedURLException(ex.getMessage());
<ide> public UrlResource(String protocol, String location, @Nullable String fragment)
<ide> * @return the cleaned URL (possibly the original URL as-is)
<ide> * @see org.springframework.util.StringUtils#cleanPath
<ide> */
<del> private URL getCleanedUrl(URL originalUrl, String originalPath) {
<add> private static URL getCleanedUrl(URL originalUrl, String originalPath) {
<ide> String cleanedPath = StringUtils.cleanPath(originalPath);
<ide> if (!cleanedPath.equals(originalPath)) {
<ide> try {
<ide> private URL getCleanedUrl(URL originalUrl, String originalPath) {
<ide> return originalUrl;
<ide> }
<ide>
<add> /**
<add> * Lazily determine a cleaned URL for the given original URL.
<add> * @see #getCleanedUrl(URL, String)
<add> */
<add> private URL getCleanedUrl() {
<add> URL cleanedUrl = this.cleanedUrl;
<add> if (cleanedUrl != null) {
<add> return cleanedUrl;
<add> }
<add> cleanedUrl = getCleanedUrl(this.url, (this.uri != null ? this.uri : this.url).toString());
<add> this.cleanedUrl = cleanedUrl;
<add> return cleanedUrl;
<add> }
<add>
<add>
<ide> /**
<ide> * This implementation opens an InputStream for the given URL.
<ide> * <p>It sets the {@code useCaches} flag to {@code false},
<ide> protected URL createRelativeURL(String relativePath) throws MalformedURLExceptio
<ide> */
<ide> @Override
<ide> public String getFilename() {
<del> return StringUtils.getFilename(this.cleanedUrl.getPath());
<add> return StringUtils.getFilename(getCleanedUrl().getPath());
<ide> }
<ide>
<ide> /**
<ide> public String getDescription() {
<ide> @Override
<ide> public boolean equals(@Nullable Object other) {
<ide> return (this == other || (other instanceof UrlResource &&
<del> this.cleanedUrl.equals(((UrlResource) other).cleanedUrl)));
<add> getCleanedUrl().equals(((UrlResource) other).getCleanedUrl())));
<ide> }
<ide>
<ide> /**
<ide> * This implementation returns the hash code of the underlying URL reference.
<ide> */
<ide> @Override
<ide> public int hashCode() {
<del> return this.cleanedUrl.hashCode();
<add> return getCleanedUrl().hashCode();
<ide> }
<ide>
<ide> }
| 1
|
Text
|
Text
|
fix some formatting
|
c86d50ed25d5cfdf0a3d083f76fdc76580bf117f
|
<ide><path>docs/basics/UsageWithReact.md
<ide> render(
<ide>
<ide> ## Next Steps
<ide>
<del>Read the [complete source code for this tutorial](ExampleTodoList.md) to better internalize the knowledge you have gained.
<add>Read the [complete source code for this tutorial](ExampleTodoList.md) to better internalize the knowledge you have gained.
<ide> Then, head straight to the [advanced tutorial](../advanced/README.md) to learn how to handle network requests and routing!
<ide>
<ide> You should also take some time to **[read through the React-Redux docs](https://react-redux.js.org)** to get
| 1
|
Javascript
|
Javascript
|
reduce flake on multifilecertproject
|
42ec3e2ecb00f75249255b60e1dc96eb00776fd4
|
<ide><path>cypress/integration/learn/challenges/multifileCertProject.js
<ide> describe('multifileCertProjects', function () {
<ide> cy.preserveSession();
<ide> });
<ide>
<del> it('should show a save code button', function () {
<del> cy.get(selectors.saveCodeBtn);
<del> });
<del>
<del> it('should save to database (savedChallenges) when clicking save code button', function () {
<add> it('should save and reload user code', function () {
<add> // save to database (savedChallenges) when clicking save code button
<ide> cy.get(selectors.editor).click().focused().clear().type(save1text);
<ide> cy.get(selectors.saveCodeBtn).click();
<ide> cy.contains('Your code was saved to the database.');
<del> });
<del>
<del> it('should not allow you to save twice in a row too fast', function () {
<del> cy.get(selectors.saveCodeBtn).click().click();
<del> cy.contains('Your code was not saved.');
<del> });
<del>
<del> it('should load saved code on a hard refresh', function () {
<add> // load saved code on a hard refresh
<ide> cy.reload();
<ide> cy.contains(save1text);
<ide> });
<ide>
<del> it('should save to database (savedChallenges) when using ctrl+s hotkey', function () {
<add> it('should save to using ctrl+s hotkey and persist through navigation', function () {
<add> // since rapid clicks will cause the save requests to be ignored, we have to
<add> // purge the db:
<add> cy.exec('npm run seed');
<add> // and the redux store:
<add> cy.reload();
<ide> cy.get(selectors.editor)
<ide> .click()
<ide> .focused()
<ide> .clear()
<ide> .type(`${save2text}{ctrl+s}`);
<ide> cy.contains('Your code was saved to the database.');
<del> });
<del>
<del> it('should load saved code when navigating site (no hard refresh)', function () {
<add> // load saved code when navigating site (no hard refresh)'
<ide> cy.contains('Responsive Web Design Projects').click();
<add> cy.contains('In this Responsive Web Design Certification');
<ide> cy.contains('Build a Tribute Page').click();
<ide> cy.contains(save2text);
<add> // trigger the warning about saving too quickly
<add> cy.get(selectors.saveCodeBtn).click().click();
<add> cy.contains('Your code was not saved.');
<ide> });
<ide> });
| 1
|
Python
|
Python
|
add about.py, adapt setup.py
|
211913d689943b38a42dd7bd47bd8c5608fe439d
|
<ide><path>setup.py
<ide> #!/usr/bin/env python
<del>from __future__ import division, print_function
<add>from __future__ import print_function
<ide> import os
<ide> import shutil
<ide> import subprocess
<ide> from distutils.core import Extension, setup
<ide>
<ide>
<del>MAJOR = 0
<del>MINOR = 100
<del>MICRO = 0
<del>ISRELEASE = False
<del>VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
<del>DEFAULT_MODEL = 'en_default==1.0.4'
<del>
<del>
<ide> PACKAGES = [
<ide> 'spacy',
<ide> 'spacy.tokens',
<ide> def build_extensions(self):
<ide> build_ext.build_extensions(self)
<ide>
<ide>
<del># Return the git revision as a string
<del>def git_version():
<del> def _minimal_ext_cmd(cmd):
<del> # construct minimal environment
<del> env = {}
<del> for k in ['SYSTEMROOT', 'PATH']:
<del> v = os.environ.get(k)
<del> if v is not None:
<del> env[k] = v
<del> # LANGUAGE is used on win32
<del> env['LANGUAGE'] = 'C'
<del> env['LANG'] = 'C'
<del> env['LC_ALL'] = 'C'
<del> out = subprocess.Popen(cmd, stdout = subprocess.PIPE, env=env).communicate()[0]
<del> return out
<del>
<del> try:
<del> out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
<del> GIT_REVISION = out.strip().decode('ascii')
<del> except OSError:
<del> GIT_REVISION = 'Unknown'
<del>
<del> return GIT_REVISION
<del>
<del>
<del>def get_version_info():
<del> # Adding the git rev number needs to be done inside write_version_py(),
<del> # otherwise the import of spacy.about messes up the build under Python 3.
<del> FULLVERSION = VERSION
<del> if os.path.exists('.git'):
<del> GIT_REVISION = git_version()
<del> elif os.path.exists(os.path.join('spacy', 'about.py')):
<del> # must be a source distribution, use existing version file
<del> try:
<del> from spacy.about import git_revision as GIT_REVISION
<del> except ImportError:
<del> raise ImportError('Unable to import git_revision. Try removing '
<del> 'spacy/about.py and the build directory '
<del> 'before building.')
<del> else:
<del> GIT_REVISION = 'Unknown'
<del>
<del> if not ISRELEASE:
<del> FULLVERSION += '.dev0+' + GIT_REVISION[:7]
<del>
<del> return FULLVERSION, GIT_REVISION
<del>
<del>
<del>def write_version(path):
<del> cnt = """# THIS FILE IS GENERATED FROM SPACY SETUP.PY
<del>short_version = '%(version)s'
<del>version = '%(version)s'
<del>full_version = '%(full_version)s'
<del>git_revision = '%(git_revision)s'
<del>release = %(isrelease)s
<del>default_model = '%(default_model)s'
<del>if not release:
<del> version = full_version
<del>"""
<del> FULLVERSION, GIT_REVISION = get_version_info()
<del>
<del> with open(path, 'w') as f:
<del> f.write(cnt % {'version': VERSION,
<del> 'full_version' : FULLVERSION,
<del> 'git_revision' : GIT_REVISION,
<del> 'isrelease': str(ISRELEASE),
<del> 'default_model': DEFAULT_MODEL})
<del>
<del>
<ide> def generate_cython(root, source):
<ide> print('Cythonizing sources')
<ide> p = subprocess.call([sys.executable,
<ide> def setup_package():
<ide> return clean(root)
<ide>
<ide> with chdir(root):
<del> write_version(os.path.join(root, 'spacy', 'about.py'))
<add> about = {}
<add> with open(os.path.join(root, "spacy", "about.py")) as f:
<add> exec(f.read(), about)
<ide>
<ide> include_dirs = [
<ide> get_python_inc(plat_specific=True),
<ide> def setup_package():
<ide> prepare_includes(root)
<ide>
<ide> setup(
<del> name='spacy',
<add> name=about['__name__'],
<ide> zip_safe=False,
<ide> packages=PACKAGES,
<ide> package_data={'': ['*.pyx', '*.pxd']},
<del> description='Industrial-strength NLP',
<del> author='Matthew Honnibal',
<del> author_email='matt@spacy.io',
<del> version=VERSION,
<del> url='https://spacy.io',
<del> license='MIT',
<add> description=about['__summary__'],
<add> author=about['__author__'],
<add> author_email=about['__email__'],
<add> version=about['__version__'],
<add> url=about['__uri__'],
<add> license=about['__license__'],
<ide> ext_modules=ext_modules,
<ide> install_requires=['numpy', 'murmurhash>=0.26,<0.27', 'cymem>=1.30,<1.31', 'preshed>=0.46.1,<0.47',
<ide> 'thinc>=4.2.0,<4.3.0', 'text_unidecode', 'plac', 'six',
<ide><path>spacy/about.py
<add># inspired from:
<add>
<add># https://python-packaging-user-guide.readthedocs.org/en/latest/single_source_version/
<add># https://github.com/pypa/warehouse/blob/master/warehouse/__about__.py
<add>
<add>__name__ = 'spacy'
<add>__version__ = '0.100.0'
<add>__summary__ = 'Industrial-strength NLP'
<add>__uri__ = 'https://spacy.io'
<add>__author__ = 'Matthew Honnibal'
<add>__email__ = 'matt@spacy.io'
<add>__license__ = 'MIT'
<add>__release__ = False
<add>__default_model__ = 'en_default==1.0.4'
<ide><path>spacy/en/download.py
<ide> def main(data_size='all', force=False):
<ide> path = os.path.dirname(os.path.abspath(__file__))
<ide>
<ide> if force:
<del> sputnik.purge('spacy', about.short_version)
<add> sputnik.purge(about.__name__, about.__version__)
<ide>
<del> package = sputnik.install('spacy', about.short_version, about.default_model)
<add> package = sputnik.install(about.__name__, about.__version__, about.__default_model__)
<ide>
<ide> try:
<del> sputnik.package('spacy', about.short_version, about.default_model)
<add> sputnik.package(about.__name__, about.__version__, about.__default_model__)
<ide> except PackageNotFoundException, CompatiblePackageNotFoundException:
<ide> print("Model failed to install. Please run 'python -m "
<ide> "spacy.en.download --force'.", file=sys.stderr)
<ide><path>spacy/language.py
<ide> from .syntax.ner import BiluoPushDown
<ide> from .syntax.arc_eager import ArcEager
<ide>
<del>from . import about
<ide> from . import util
<ide> from .attrs import TAG, DEP, ENT_IOB, ENT_TYPE, HEAD
<ide>
<ide> def __init__(self,
<ide> via = data_dir
<ide>
<ide> if via is None:
<del> package = util.get_package_by_name(about.default_model)
<add> package = util.get_package_by_name()
<ide> else:
<ide> package = util.get_package(via)
<ide>
<ide><path>spacy/util.py
<ide> def get_package(via=None):
<ide> return DirPackage(via)
<ide>
<ide>
<del>def get_package_by_name(name, via=None):
<add>def get_package_by_name(name=None, via=None):
<ide> try:
<del> return sputnik.package('spacy', about.short_version, name, data_path=via)
<add> return sputnik.package(about.__name__, about.__version__,
<add> name or about.__default_model__, data_path=via)
<ide> except PackageNotFoundException as e:
<ide> raise RuntimeError("Model not installed. Please run 'python -m "
<ide> "spacy.en.download' to install latest compatible "
| 5
|
Text
|
Text
|
add angular logo
|
d61fd5f661ccc7ed13043529f9e94aa82e2feb9e
|
<ide><path>guide/spanish/angularjs/index.md
<ide> title: AngularJS
<ide> localeTitle: AngularJS
<ide> ---
<ide> ## AngularJS
<add>
<ide>
<ide> AngularJS (versiones 1.x) es un marco de JavaScript de front-end de código abierto. AngularJS extiende HTML para desarrollar front-ends ricos y poderosos. Reduce el uso repetitivo del código HTML. Esta repetición se puede evitar utilizando las directivas proporcionadas por AngularJS que ahorra mucho tiempo y esfuerzo.
<ide>
| 1
|
Python
|
Python
|
fix default tokenizer
|
ab44630db2b45577d9c7a3478e47ad1f2e2b1e4f
|
<ide><path>src/transformers/pipelines.py
<ide> def __call__(
<ide> "impl": SummarizationPipeline,
<ide> "tf": TFAutoModelWithLMHead if is_tf_available() else None,
<ide> "pt": AutoModelWithLMHead if is_torch_available() else None,
<del> "default": {
<del> "model": {"pt": "bart-large-cnn", "tf": "t5-small"},
<del> "config": None,
<del> "tokenizer": {"pt": ("bart-large-cnn", {"use_fast": False}), "tf": "t5-small"},
<del> },
<add> "default": {"model": {"pt": "bart-large-cnn", "tf": "t5-small"}, "config": None, "tokenizer": None},
<ide> },
<ide> "translation_en_to_fr": {
<ide> "impl": TranslationPipeline,
| 1
|
Javascript
|
Javascript
|
fix the typo error
|
048b977d8e5cede2259df69fc7c0bbfedd84100d
|
<ide><path>lib/internal/repl/recoverable.js
<ide> const { tokTypes: tt, Parser: AcornParser } = acorn;
<ide> function isRecoverableError(e, code) {
<ide> let recoverable = false;
<ide>
<del> // Determine if the point of the any error raised is at the end of the input.
<add> // Determine if the point of any error raised is at the end of the input.
<ide> // There are two cases to consider:
<ide> //
<ide> // 1. Any error raised after we have encountered the 'eof' token.
| 1
|
Text
|
Text
|
add more highlighting to docs
|
e1ee94ca17835bd6ca933a5634042e7d049d8fc0
|
<ide><path>docs/docs/jsx-in-depth.md
<ide> redirect_from:
<ide> Fundamentally, JSX just provides syntactic sugar for the `React.createElement(component, props, ...children)` function. The JSX code:
<ide>
<ide> ```js
<del><MyButton color="blue" shadowSize={2}>Click Me</MyButton>
<add><MyButton color="blue" shadowSize={2}>
<add> Click Me
<add></MyButton>
<ide> ```
<ide>
<ide> compiles into:
<ide>
<ide> ```js
<del>React.createElement(MyButton, {color: "blue", shadowSize: 2}, 'Click Me')
<add>React.createElement(
<add> MyButton,
<add> {color: 'blue', shadowSize: 2},
<add> 'Click Me'
<add>)
<ide> ```
<ide>
<ide> You can also use the self-closing form of the tag if there are no children. So:
<ide> You can also use the self-closing form of the tag if there are no children. So:
<ide> compiles into:
<ide>
<ide> ```js
<del>React.createElement('div', {className: 'sidebar'}, null)
<add>React.createElement(
<add> 'div',
<add> {className: 'sidebar'},
<add> null
<add>)
<ide> ```
<ide>
<ide> If you want to test out how some specific JSX is converted into JavaScript, you can try out [the online Babel compiler](https://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2015%2Creact%2Cstage-0&code=function%20hello()%20%7B%0A%20%20return%20%3Cdiv%3EHello%20world!%3C%2Fdiv%3E%3B%0A%7D).
<ide> The first part of a JSX tag determines the type of the React element.
<ide>
<ide> Capitalized types indicate that the JSX tag is referring to a React component. These tags get compiled into a direct reference to the named variable, so if you use the JSX `<Foo />` expression, `Foo` must be in scope.
<ide>
<add>### React Must Be in Scope
<add>
<ide> Since JSX compiles into calls to `React.createElement`, the `React` library must also always be in scope from your JSX code.
<ide>
<del>For example, both of the imports are necessary in this code, even though 'React' and 'CustomButton' are not directly referenced from JavaScript:
<add>For example, both of the imports are necessary in this code, even though `React` and `CustomButton` are not directly referenced from JavaScript:
<ide>
<del>```js
<add>```js{1,2,5}
<ide> import React from 'react';
<ide> import CustomButton from './CustomButton';
<ide>
<ide> function WarningButton() {
<add> // return React.createElement(CustomButton, {color: 'red'}, null);
<ide> return <CustomButton color="red" />;
<ide> }
<ide> ```
<ide>
<del>If you don't use a JavaScript bundler and added React as a script tag, it is already in scope as a React global.
<add>If you don't use a JavaScript bundler and added React as a script tag, it is already in scope as a `React` global.
<add>
<add>### Using Dot Notation for JSX Type
<ide>
<ide> You can also refer to a React component using dot-notation from within JSX. This is convenient if you have a single module that exports many React components. For example, if `MyComponents.DatePicker` is a component, you can use it directly from JSX with:
<ide>
<del>```js
<add>```js{10}
<ide> import React from 'react';
<ide>
<ide> const MyComponents = {
<del> DatePicker: function(props) {
<del> return <div>imagine a {props.color} datepicker here</div>;
<add> DatePicker: function DatePicker(props) {
<add> return <div>Imagine a {props.color} datepicker here.</div>;
<ide> }
<ide> }
<ide>
<ide> function BlueDatePicker() {
<ide> }
<ide> ```
<ide>
<add>### User-Defined Components Must Be Capitalized
<add>
<ide> When an element type starts with a lowercase letter, it refers to a built-in component like `<div>` or `<span>` and results in a string `'div'` or `'span'` passed to `React.createElement`. Types that start with a capital letter like `<Foo />` compile to `React.createElement(Foo)` and correspond to a component defined or imported in your JavaScript file.
<ide>
<ide> We recommend naming components with a capital letter. If you do have a component that starts with a lowercase letter, assign it to a capitalized variable before using it in JSX.
<ide>
<ide> For example, this code will not run as expected:
<ide>
<del>```js
<add>```js{3,4,10,11}
<ide> import React from 'react';
<ide>
<add>// Wrong! This is a component and should have been capitalized:
<ide> function hello(props) {
<del> // This use of <div> is legitimate because div is a valid HTML tag
<add> // Correct! This use of <div> is legitimate because div is a valid HTML tag:
<ide> return <div>Hello {props.toWhat}</div>;
<ide> }
<ide>
<ide> function HelloWorld() {
<del> // This code attempts to create an HTML <hello> tag and fails
<add> // Wrong! React thinks <hello /> is an HTML tag because it's not capitalized:
<ide> return <hello toWhat="World" />;
<ide> }
<ide> ```
<ide>
<add>To fix this, we will rename `hello` to `Hello` and use `<Hello />` when referring to it:
<add>
<add>```js{3,4,10,11}
<add>import React from 'react';
<add>
<add>// Correct! This is a component and should be capitalized:
<add>function Hello(props) {
<add> // Correct! This use of <div> is legitimate because div is a valid HTML tag:
<add> return <div>Hello {props.toWhat}</div>;
<add>}
<add>
<add>function HelloWorld() {
<add> // Correct! React knows <Hello /> is a component because it's capitalized.
<add> return <Hello toWhat="World" />;
<add>}
<add>```
<add>
<add>### Choosing the Type at Runtime
<add>
<ide> You cannot use a general expression as the React element type. If you do want to use a general expression to indicate the type of the element, just assign it to a capitalized variable first. This often comes up when you want to render a different component based on a prop:
<ide>
<del>```js
<add>```js{10,11}
<ide> import React from 'react';
<ide> import { PhotoStory, VideoStory } from './stories';
<ide>
<ide> const components = {
<del> photo: <PhotoStory />,
<del> video: <VideoStory />,
<add> photo: PhotoStory,
<add> video: VideoStory
<ide> };
<ide>
<del>function Story1(props) {
<del> // Not valid JSX
<del> return <components[props.story] />;
<add>function Story(props) {
<add> // Wrong! JSX type can't be an expression.
<add> return <components[props.storyType] story={props.story} />;
<ide> }
<add>```
<ide>
<del>function render2(props) {
<del> const MyComponent = components[props.story];
<add>To fix this, we will assign the type to a capitalized variable first:
<ide>
<del> // Valid JSX
<del> return <MyComponent />;
<add>```js{9-11}
<add>import React from 'react';
<add>import { PhotoStory, VideoStory } from './stories';
<add>
<add>const components = {
<add> photo: PhotoStory,
<add> video: VideoStory
<add>};
<add>
<add>function Story(props) {
<add> // Correct! JSX type can be a capitalized variable.
<add> const SpecificStory = components[props.storyType];
<add> return <SpecificStory story={props.story} />;
<ide> }
<ide> ```
<ide>
<ide> For `MyComponent`, The value of `props.foo` will be `10` because the expression
<ide>
<ide> `if` statements and `for` loops are not expressions in JavaScript, so they can't be used in JSX directly. Instead, you can put these in the surrounding code. For example:
<ide>
<del>```js
<add>```js{3-7}
<ide> function NumberDescriber(props) {
<ide> let description;
<ide> if (props.number % 2 == 0) {
<ide> You can pass a string literal as a prop. These two JSX expressions are equivalen
<ide> ```js
<ide> <MyComponent message="hello world" />
<ide>
<del><MyComponent message={"hello world"} />
<add><MyComponent message={'hello world'} />
<ide> ```
<ide>
<ide> When you pass a string literal, its value is HTML-unescaped. So these two JSX expressions are equivalent:
<ide>
<ide> ```js
<ide> <MyComponent message="<3" />
<ide>
<del><MyComponent message={"<3"} />
<add><MyComponent message={'<3'} />
<ide> ```
<ide>
<ide> This behavior is usually not relevant. It's only mentioned here for completeness.
<ide> If you pass no value for a prop, it defaults to `true`. These two JSX expression
<ide> <MyTextBox autocomplete={true} />
<ide> ```
<ide>
<del>In general, we don't recommend using this because it can be confused with the ES6 object shorthand `{foo}` which is short for {foo: foo} rather than `{foo: true}`. This behavior is just there so that it matches the behavior of HTML.
<add>In general, we don't recommend using this because it can be confused with the [ES6 object shorthand](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Object_initializer#New_notations_in_ECMAScript_2015) `{foo}` which is short for `{foo: foo}` rather than `{foo: true}`. This behavior is just there so that it matches the behavior of HTML.
<ide>
<ide> ### Spread Attributes
<ide>
<del>If you already have `props` as an object, and you want to pass it in JSX, you can use `...` as a "spread" operator to pass the whole props object. These two render functions are equivalent:
<add>If you already have `props` as an object, and you want to pass it in JSX, you can use `...` as a "spread" operator to pass the whole props object. These two components are equivalent:
<ide>
<del>```js
<del>function render1() {
<del> const props = {left: 'ben', right: 'hector'};
<del> return <MyComponent {...props} />;
<add>```js{7}
<add>function App1() {
<add> return <Greeting firstName="Ben" lastName="Hector" />;
<ide> }
<ide>
<del>function render2() {
<del> return <MyComponent left="ben" right="hector" />;
<add>function App2() {
<add> const props = {firstName: 'Ben', lastName: 'Hector'};
<add> return <Greeting {...props} />;
<ide> }
<ide> ```
<ide>
<ide> You can pass any JavaScript expression as children, by enclosing it within `{}`.
<ide>
<ide> This is often useful for rendering a list of JSX expressions of arbitrary length. For example, this renders an HTML list:
<ide>
<del>```js
<add>```js{2,9}
<ide> function Item(props) {
<ide> return <li>{props.message}</li>;
<ide> }
<ide>
<del>function renderTodoList() {
<add>function TodoList() {
<ide> const todos = ['finish doc', 'submit pr', 'nag dan to review'];
<ide> return (
<ide> <ul>
<ide> function renderTodoList() {
<ide>
<ide> JavaScript expressions can be mixed with other types of children. This is often useful in lieu of string templates:
<ide>
<del>```js
<add>```js{2}
<ide> function Hello(props) {
<ide> return <div>Hello {props.addressee}!</div>;
<ide> }
<ide> ```
<ide>
<add>### Functions as Children
<add>
<ide> Normally, JavaScript expressions inserted in JSX will evaluate to a string, a React element, or a list of those things. However, `props.children` works just like any other prop in that it can pass any sort of data, not just the sorts that React knows how to render. For example, if you have a custom component, you could have it take a callback as `props.children`:
<ide>
<del>```js
<add>```js{4,13}
<ide> function ListOfTenThings() {
<ide> return (
<ide> <Repeat numTimes={10}>
<ide> function ListOfTenThings() {
<ide> // Calls the children callback numTimes to produce a repeated component
<ide> function Repeat(props) {
<ide> let items = [];
<del> for (let i = 0; i < numTimes; i++) {
<add> for (let i = 0; i < props.numTimes; i++) {
<ide> items.push(props.children(i));
<ide> }
<del> return <div>{items}</div>
<add> return <div>{items}</div>;
<ide> }
<ide> ```
<ide>
<ide> Children passed to a custom component can be anything, as long as that component transforms them into something React can understand before rendering. This usage is not common, but it works if you want to stretch what JSX is capable of.
<ide>
<del>`false`, `null`, 'undefined', and 'true' are valid children. They simply don't render. These JSX expressions will all render to the same thing:
<add>### Booleans, Null, and Undefined Are Ignored
<add>
<add>`false`, `null`, `undefined`, and `true` are valid children. They simply don't render. These JSX expressions will all render to the same thing:
<ide>
<ide> ```js
<ide> <div />
<ide> Children passed to a custom component can be anything, as long as that component
<ide> <div>{true}</div>
<ide> ```
<ide>
<del>This can be useful to conditionally render React elements. This JSX only renders a `<Header />` if `showHeader` is true:
<add>This can be useful to conditionally render React elements. This JSX only renders a `<Header />` if `showHeader` is `true`:
<ide>
<del>```js
<del><div>{showHeader && <Header />}<Content /></div>
<add>```js{2}
<add><div>
<add> {showHeader && <Header />}
<add> <Content />
<add></div>
<add>```
<add>
<add>One caveat is that some ["falsy" values](https://developer.mozilla.org/en-US/docs/Glossary/Falsy), such as the `0` number, are still rendered by React. For example, this code will not behave as you might expect because `0` will be printed when `props.messages` is an empty array:
<add>
<add>```js{2}
<add><div>
<add> {props.messages.length &&
<add> <MessageList messages={props.messages} />
<add> }
<add></div>
<add>```
<add>
<add>To fix this, make sure that the expression before `&&` is always boolean:
<add>
<add>```js{2}
<add><div>
<add> {props.messages.length > 0 &&
<add> <MessageList messages={props.messages} />
<add> }
<add></div>
<add>```
<add>
<add>Conversely, if you want a value like `false`, `true`, `null`, or `undefined` to appear in the output, you have to [convert it to a string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#String_conversion) first:
<add>
<add>```js{2}
<add><div>
<add> My JavaScript variable is {String(myVariable)}.
<add></div>
<ide> ```
<ide><path>docs/docs/refs-and-the-dom.md
<ide> In the typical React dataflow, [props](/react/docs/components-and-props.html) ar
<ide>
<ide> React supports a special attribute that you can attach to any component. The `ref` attribute takes a callback function, and the callback will be executed immediately after the component is mounted or unmounted.
<ide>
<del>When the `ref` attribute is used on a HTML element, the `ref` callback receives the underlying DOM element as its argument. For example, this code uses the `ref` callback to store a reference to a DOM node:
<add>When the `ref` attribute is used on an HTML element, the `ref` callback receives the underlying DOM element as its argument. For example, this code uses the `ref` callback to store a reference to a DOM node:
<ide>
<del>```javascript
<add>```javascript{8,9,19}
<ide> class CustomTextInput extends React.Component {
<ide> constructor(props) {
<ide> super(props);
<ide> class CustomTextInput extends React.Component {
<ide>
<ide> render() {
<ide> // Use the `ref` callback to store a reference to the text input DOM
<del> // element in this.textInput
<add> // element in this.textInput.
<ide> return (
<ide> <div>
<del> <input type="text" ref={(input) => this.textInput = input} />
<add> <input
<add> type="text"
<add> ref={(input) => this.textInput = input} />
<ide> <input
<ide> type="button"
<ide> value="Focus the text input"
<ide> Using the `ref` callback just to set a property on the class is a common pattern
<ide>
<ide> When the `ref` attribute is used on a custom component, the `ref` callback receives the mounted instance of the component as its argument. For example, if we wanted to wrap the `CustomTextInput` above to simulate it being clicked immediately after mounting:
<ide>
<del>```javascript
<add>```javascript{3,9}
<ide> class AutoFocusTextInput extends React.Component {
<ide> componentDidMount() {
<ide> this.textInput.focus();
<ide> }
<ide>
<ide> render() {
<del> return <CustomTextInput ref={(input) => this.textInput = input} />;
<add> return (
<add> <CustomTextInput
<add> ref={(input) => this.textInput = input} />
<add> );
<ide> }
<ide> }
<ide> ```
<ide>
<ide> You may not use the `ref` attribute on functional components because they don't have instances. You can, however, use the `ref` attribute inside the `render` function of a functional component:
<ide>
<del>```javascript
<add>```javascript{2,3,6,13}
<ide> function CustomTextInput(props) {
<ide> // textInput must be declared here so the ref callback can refer to it
<del> let textInput;
<add> let textInput = null;
<ide>
<ide> function handleClick() {
<ide> textInput.focus();
<ide> }
<ide>
<ide> return (
<ide> <div>
<del> <input type="text" ref={(input) => textInput = input} />
<add> <input
<add> type="text"
<add> ref={(input) => textInput = input} />
<ide> <input
<ide> type="button"
<ide> value="Focus the text input"
<ide> function CustomTextInput(props) {
<ide>
<ide> ### Don't Overuse Refs
<ide>
<del>Your first inclination may be to use refs to "make things happen" in your app. If this is the case, take a moment and think more critically about where state should be owned in the component hierarchy. Often, it becomes clear that the proper place to "own" that state is at a higher level in the hierarchy - see the [Lifting State Up](/react/docs/lifting-state-up.html) guide for examples of this.
<add>Your first inclination may be to use refs to "make things happen" in your app. If this is the case, take a moment and think more critically about where state should be owned in the component hierarchy. Often, it becomes clear that the proper place to "own" that state is at a higher level in the hierarchy. See the [Lifting State Up](/react/docs/lifting-state-up.html) guide for examples of this.
| 2
|
Mixed
|
Ruby
|
set retry_jitter to 0.0 for upgraded applications
|
0ebc720a049743519311818035d5175b288ba41d
|
<ide><path>activejob/lib/active_job/exceptions.rb
<ide> module Exceptions
<ide> extend ActiveSupport::Concern
<ide>
<ide> included do
<del> class_attribute :retry_jitter, instance_accessor: false, instance_predicate: false, default: 0.15
<add> class_attribute :retry_jitter, instance_accessor: false, instance_predicate: false, default: 0.0
<ide> end
<ide>
<ide> module ClassMethods
<ide><path>guides/source/configuring.md
<ide> There are a few configuration options available in Active Support:
<ide>
<ide> * `config.active_job.log_arguments` controls if the arguments of a job are logged. Defaults to `true`.
<ide>
<del>* `config.active_job.retry_jitter` controls the amount of "jitter" (random variation) applied to the delay time calculated when retrying failed jobs. Defaults to `0.15`.
<add>* `config.active_job.retry_jitter` controls the amount of "jitter" (random variation) applied to the delay time calculated when retrying failed jobs. Defaults to `0.0`.
<ide>
<ide> ### Configuring Action Cable
<ide>
<ide> text/javascript image/svg+xml application/postscript application/x-shockwave-fla
<ide>
<ide> - `config.active_record.has_many_inversing`: `true`
<ide> - `config.active_storage.track_variants`: `true`
<add>- `config.active_job.retry_jitter`: `0.15`
<ide>
<ide> #### For '6.0', new defaults from previous versions below and:
<ide>
<ide><path>railties/test/application/configuration_test.rb
<ide> class ::DummySerializer < ActiveJob::Serializers::ObjectSerializer; end
<ide> end
<ide> end
<ide>
<del> test "ActiveJob::Base.retry_jitter is 0.15 by default" do
<add> test "ActiveJob::Base.retry_jitter is 0.15 by default for new apps" do
<ide> app "development"
<ide>
<ide> assert_equal 0.15, ActiveJob::Base.retry_jitter
<ide> end
<ide>
<add> test "ActiveJob::Base.retry_jitter is 0.0 by default for upgraded apps" do
<add> remove_from_config '.*config\.load_defaults.*\n'
<add> app "development"
<add>
<add> assert_equal 0.0, ActiveJob::Base.retry_jitter
<add> end
<add>
<ide> test "ActiveJob::Base.retry_jitter can be set by config" do
<ide> app "development"
<ide>
| 3
|
Text
|
Text
|
fix spelling of penryn (#580)
|
1455aa3da6335b1eeb284e61171cff524c620fa3
|
<ide><path>share/doc/homebrew/Bottles.md
<ide> Bottles will not be used if the user requests it (see above), if the formula req
<ide> ## Bottle Creation
<ide> Bottles are currently created using the [Brew Test Bot](Brew-Test-Bot.md). We will be slowly adding them to all formulae.
<ide>
<del>By default, bottles will be built for the oldest CPU supported by the OS/architecture you're building for. (That's Core 2 for 64-bit OSs, Core for 32-bit.) This ensures that bottles are compatible with all computers you might distribute them to. If you *really* want your bottles to be optimized for something else, you can pass the `--bottle-arch=` option to build for another architecture - for example, `brew install foo --bottle-arch=penyrn`. Just remember that if you build for a newer architecture some of your users might get binaries they can't run and that would be sad!
<add>By default, bottles will be built for the oldest CPU supported by the OS/architecture you're building for. (That's Core 2 for 64-bit OSs, Core for 32-bit.) This ensures that bottles are compatible with all computers you might distribute them to. If you *really* want your bottles to be optimized for something else, you can pass the `--bottle-arch=` option to build for another architecture - for example, `brew install foo --bottle-arch=penryn`. Just remember that if you build for a newer architecture some of your users might get binaries they can't run and that would be sad!
<ide>
<ide> ## Bottle Format
<ide> Bottles are simple gzipped tarballs of compiled binaries. Any metadata is stored in a formula's bottle DSL and in the bottle filename (i.e. MacOS version, revision).
| 1
|
Javascript
|
Javascript
|
improve test for crypto pbkdf2
|
aeec6210170daed02fed0e9608e39bfe479b696a
|
<ide><path>test/parallel/test-crypto-pbkdf2.js
<ide> var crypto = require('crypto');
<ide> //
<ide> function testPBKDF2(password, salt, iterations, keylen, expected) {
<ide> var actual = crypto.pbkdf2Sync(password, salt, iterations, keylen, 'sha256');
<del> assert.equal(actual.toString('latin1'), expected);
<add> assert.strictEqual(actual.toString('latin1'), expected);
<ide>
<ide> crypto.pbkdf2(password, salt, iterations, keylen, 'sha256', (err, actual) => {
<del> assert.equal(actual.toString('latin1'), expected);
<add> assert.strictEqual(actual.toString('latin1'), expected);
<ide> });
<ide> }
<ide>
<ide> testPBKDF2('pass\0word', 'sa\0lt', 4096, 16,
<ide> var expected =
<ide> '64c486c55d30d4c5a079b8823b7d7cb37ff0556f537da8410233bcec330ed956';
<ide> var key = crypto.pbkdf2Sync('password', 'salt', 32, 32, 'sha256');
<del>assert.equal(key.toString('hex'), expected);
<add>assert.strictEqual(key.toString('hex'), expected);
<ide>
<ide> crypto.pbkdf2('password', 'salt', 32, 32, 'sha256', common.mustCall(ondone));
<ide> function ondone(err, key) {
<ide> if (err) throw err;
<del> assert.equal(key.toString('hex'), expected);
<add> assert.strictEqual(key.toString('hex'), expected);
<ide> }
<ide>
<ide> // Error path should not leak memory (check with valgrind).
<ide> assert.throws(function() {
<ide> crypto.pbkdf2('password', 'salt', 1, 20, null);
<del>});
<add>}, /^Error: No callback provided to pbkdf2$/);
<ide>
<ide> // Should not work with Infinity key length
<ide> assert.throws(function() {
<ide> crypto.pbkdf2('password', 'salt', 1, Infinity, 'sha256', common.fail);
<del>}, /Bad key length/);
<add>}, /^TypeError: Bad key length$/);
<ide>
<ide> // Should not work with negative Infinity key length
<ide> assert.throws(function() {
<ide> crypto.pbkdf2('password', 'salt', 1, -Infinity, 'sha256', common.fail);
<del>}, /Bad key length/);
<add>}, /^TypeError: Bad key length$/);
<ide>
<ide> // Should not work with NaN key length
<ide> assert.throws(function() {
<ide> crypto.pbkdf2('password', 'salt', 1, NaN, 'sha256', common.fail);
<del>}, /Bad key length/);
<add>}, /^TypeError: Bad key length$/);
<ide>
<ide> // Should not work with negative key length
<ide> assert.throws(function() {
<ide> crypto.pbkdf2('password', 'salt', 1, -1, 'sha256', common.fail);
<del>}, /Bad key length/);
<add>}, /^TypeError: Bad key length$/);
<ide>
<ide> // Should not work with key length that does not fit into 32 signed bits
<ide> assert.throws(function() {
<ide> crypto.pbkdf2('password', 'salt', 1, 4073741824, 'sha256', common.fail);
<del>}, /Bad key length/);
<add>}, /^TypeError: Bad key length$/);
<ide>
<ide> // Should not get FATAL ERROR with empty password and salt
<ide> // https://github.com/nodejs/node/issues/8571
| 1
|
Text
|
Text
|
modify the links for docker container commands
|
e5e1729698404bd1789b1d4d404fd899cb1ddf08
|
<ide><path>docs/reference/commandline/dockerd.md
<ide> membership.
<ide> If you need to access the Docker daemon remotely, you need to enable the `tcp`
<ide> Socket. Beware that the default setup provides un-encrypted and
<ide> un-authenticated direct access to the Docker daemon - and should be secured
<del>either using the [built in HTTPS encrypted socket](../../security/https.md), or by
<add>either using the [built in HTTPS encrypted socket](https://docs.docker.com/engine/security/https/), or by
<ide> putting a secure web proxy in front of it. You can listen on port `2375` on all
<ide> network interfaces with `-H tcp://0.0.0.0:2375`, or on a particular network
<ide> interface using its IP address: `-H tcp://192.168.59.103:2375`. It is
<ide> The list of currently supported options that can be reconfigured is this:
<ide> - `cluster-store-opts`: it uses the new options to reload the discovery store.
<ide> - `cluster-advertise`: it modifies the address advertised after reloading.
<ide> - `labels`: it replaces the daemon labels with a new set of labels.
<del>- `live-restore`: Enables [keeping containers alive during daemon downtime](../../admin/live-restore.md).
<add>- `live-restore`: Enables [keeping containers alive during daemon downtime](https://docs.docker.com/engine/admin/live-restore/).
<ide> - `max-concurrent-downloads`: it updates the max concurrent downloads for each pull.
<ide> - `max-concurrent-uploads`: it updates the max concurrent uploads for each push.
<ide> - `default-runtime`: it updates the runtime to be used if not is
<ide><path>docs/reference/commandline/export.md
<ide> the container, `docker export` will export the contents of the *underlying*
<ide> directory, not the contents of the volume.
<ide>
<ide> Refer to [Backup, restore, or migrate data
<del>volumes](../../tutorials/dockervolumes.md#backup-restore-or-migrate-data-volumes) in
<add>volumes](https://docs.docker.com/engine/tutorials/dockervolumes/#backup-restore-or-migrate-data-volumes) in
<ide> the user guide for examples on exporting data in a volume.
<ide>
<ide> ## Examples
<ide><path>docs/reference/commandline/logs.md
<ide> The `docker logs` command batch-retrieves logs present at the time of execution.
<ide> > the `json-file` or `journald` logging driver.
<ide>
<ide> For more information about selecting and configuring login-drivers, refer to
<del>[Configure logging drivers](../../admin/logging/overview.md).
<add>[Configure logging drivers](https://docs.docker.com/engine/admin/logging/overview/).
<ide>
<ide> The `docker logs --follow` command will continue streaming the new output from
<ide> the container's `STDOUT` and `STDERR`.
<ide><path>docs/reference/commandline/pull.md
<ide> If you are behind an HTTP proxy server, for example in corporate settings,
<ide> before open a connect to registry, you may need to configure the Docker
<ide> daemon's proxy settings, using the `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY`
<ide> environment variables. To set these environment variables on a host using
<del>`systemd`, refer to the [control and configure Docker with systemd](../../admin/systemd.md#http-proxy)
<add>`systemd`, refer to the [control and configure Docker with systemd](https://docs.docker.com/engine/admin/systemd/#http-proxy)
<ide> for variables configuration.
<ide>
<ide> ## Examples
<ide> same image, their layers are stored only once and do not consume extra disk
<ide> space.
<ide>
<ide> For more information about images, layers, and the content-addressable store,
<del>refer to [understand images, containers, and storage drivers](../../userguide/storagedriver/imagesandcontainers.md).
<add>refer to [understand images, containers, and storage drivers](https://docs.docker.com/engine/userguide/storagedriver/imagesandcontainers/).
<ide>
<ide>
<ide> ## Pull an image by digest (immutable identifier)
<ide><path>docs/reference/commandline/run.md
<ide> of all containers.
<ide> The `docker run` command can be used in combination with `docker commit` to
<ide> [*change the command that a container runs*](commit.md). There is additional detailed information about `docker run` in the [Docker run reference](../run.md).
<ide>
<del>For information on connecting a container to a network, see the ["*Docker network overview*"](../../userguide/networking/index.md).
<add>For information on connecting a container to a network, see the ["*Docker network overview*"](https://docs.docker.com/engine/userguide/networking/).
<ide>
<ide> ## Examples
<ide>
<ide> binary (refer to [get the linux binary](
<ide> you give the container the full access to create and manipulate the host's
<ide> Docker daemon.
<ide>
<del>For in-depth information about volumes, refer to [manage data in containers](../../tutorials/dockervolumes.md)
<add>For in-depth information about volumes, refer to [manage data in containers](https://docs.docker.com/engine/tutorials/dockervolumes/)
<ide>
<ide> ### Publish or expose port (-p, --expose)
<ide>
<ide> $ docker run -p 127.0.0.1:80:8080 ubuntu bash
<ide>
<ide> This binds port `8080` of the container to port `80` on `127.0.0.1` of the host
<ide> machine. The [Docker User
<del>Guide](../../userguide/networking/default_network/dockerlinks.md)
<add>Guide](https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/)
<ide> explains in detail how to manipulate ports in Docker.
<ide>
<ide> $ docker run --expose 80 ubuntu bash
<ide> format:
<ide> You can load multiple label-files by supplying multiple `--label-file` flags.
<ide>
<ide> For additional information on working with labels, see [*Labels - custom
<del>metadata in Docker*](../../userguide/labels-custom-metadata.md) in the Docker User
<add>metadata in Docker*](https://docs.docker.com/engine/userguide/labels-custom-metadata/) in the Docker User
<ide> Guide.
<ide>
<ide> ### Connect a container to a network (--network)
<ide><path>docs/reference/commandline/search.md
<ide> Options:
<ide>
<ide> Search [Docker Hub](https://hub.docker.com) for images
<ide>
<del>See [*Find Public Images on Docker Hub*](../../tutorials/dockerrepos.md#searching-for-images) for
<add>See [*Find Public Images on Docker Hub*](https://docs.docker.com/engine/tutorials/dockerrepos/#searching-for-images) for
<ide> more details on finding shared images from the command line.
<ide>
<ide> > **Note:**
| 6
|
PHP
|
PHP
|
update paginatorhelper + tests
|
a9dceb4dadddb2963b80706ff8ec3236a0a1b431
|
<ide><path>lib/Cake/Test/TestCase/View/Helper/PaginatorHelperTest.php
<ide> * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
<ide> */
<ide> namespace Cake\Test\TestCase\View\Helper;
<add>
<ide> use Cake\Core\Configure;
<ide> use Cake\Network\Request;
<ide> use Cake\Routing\Router;
<ide> use Cake\View\Helper\PaginatorHelper;
<ide> use Cake\View\View;
<ide>
<add>
<ide> if (!defined('FULL_BASE_URL')) {
<ide> define('FULL_BASE_URL', 'http://cakephp.org');
<ide> }
<ide> public function setUp() {
<ide> 'page' => 1,
<ide> 'conditions' => array()
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> )
<ide> ));
<ide> $this->Paginator->Html = new HtmlHelper($this->View);
<ide>
<ide> Configure::write('Routing.prefixes', array());
<ide> Router::reload();
<add> Router::connect('/:controller/:action/*');
<add> Router::connect('/:plugin/:controller/:action/*');
<ide> }
<ide>
<ide> /**
<ide> public function testDisabledLink() {
<ide> * @return void
<ide> */
<ide> public function testSortLinks() {
<del> Router::reload();
<del> Router::parse('/');
<ide> Router::setRequestInfo(array(
<ide> array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'url' => array('url' => 'accounts/')),
<del> array('base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/')
<add> array('base' => '', 'here' => '/accounts/', 'webroot' => '/')
<ide> ));
<add>
<ide> $this->Paginator->options(array('url' => array('param')));
<ide> $this->Paginator->request['paging'] = array(
<ide> 'Article' => array(
<ide> public function testSortLinks() {
<ide> 'order' => array('date' => 'asc'),
<ide> 'conditions' => array()
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide>
<ide> $result = $this->Paginator->sort('title');
<ide> $expected = array(
<del> 'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:asc'),
<add> 'a' => array('href' => '/accounts/index/param?page=1&sort=title&direction=asc'),
<ide> 'Title',
<ide> '/a'
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $result = $this->Paginator->sort('date');
<ide> $expected = array(
<del> 'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:date/direction:desc', 'class' => 'asc'),
<add> 'a' => array('href' => '/accounts/index/param?page=1&sort=date&direction=desc', 'class' => 'asc'),
<ide> 'Date',
<ide> '/a'
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $result = $this->Paginator->sort('title', 'TestTitle');
<ide> $expected = array(
<del> 'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:asc'),
<add> 'a' => array('href' => '/accounts/index/param?page=1&sort=title&direction=asc'),
<ide> 'TestTitle',
<ide> '/a'
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $result = $this->Paginator->sort('title', array('asc' => 'ascending', 'desc' => 'descending'));
<ide> $expected = array(
<del> 'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:asc'),
<add> 'a' => array('href' => '/accounts/index/param?page=1&sort=title&direction=asc'),
<ide> 'ascending',
<ide> '/a'
<ide> );
<ide> public function testSortLinks() {
<ide> $this->Paginator->request->params['paging']['Article']['options']['sort'] = 'title';
<ide> $result = $this->Paginator->sort('title', array('asc' => 'ascending', 'desc' => 'descending'));
<ide> $expected = array(
<del> 'a' => array('href' => '/officespace/accounts/index/param/page:1/sort:title/direction:desc', 'class' => 'asc'),
<add> 'a' => array('href' => '/accounts/index/param?page=1&sort=title&direction=desc', 'class' => 'asc'),
<ide> 'descending',
<ide> '/a'
<ide> );
<ide> public function testSortLinks() {
<ide> $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
<ide> $this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
<ide> $result = $this->Paginator->sort('title');
<del> $this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result);
<add> $expected = array(
<add> 'a' => array('href' => '/accounts/index/param?page=1&sort=title&direction=asc', 'class' => 'desc'),
<add> 'Title',
<add> '/a'
<add> );
<add> $this->assertTags($result, $expected);
<ide>
<ide> $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
<ide> $this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
<ide> $result = $this->Paginator->sort('title');
<del> $this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result);
<add> $expected = array(
<add> 'a' => array('href' => '/accounts/index/param?page=1&sort=title&direction=desc', 'class' => 'asc'),
<add> 'Title',
<add> '/a'
<add> );
<add> $this->assertTags($result, $expected);
<ide>
<ide> $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
<ide> $this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
<ide> $result = $this->Paginator->sort('title', 'Title', array('direction' => 'desc'));
<del> $this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result);
<add> $expected = array(
<add> 'a' => array('href' => '/accounts/index/param?page=1&sort=title&direction=asc', 'class' => 'desc'),
<add> 'Title',
<add> '/a'
<add> );
<add> $this->assertTags($result, $expected);
<ide>
<ide> $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
<ide> $this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
<ide> $result = $this->Paginator->sort('title', 'Title', array('direction' => 'asc'));
<del> $this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:asc" class="desc">Title<\/a>$/', $result);
<add> $expected = array(
<add> 'a' => array('href' => '/accounts/index/param?page=1&sort=title&direction=asc', 'class' => 'desc'),
<add> 'Title',
<add> '/a'
<add> );
<add> $this->assertTags($result, $expected);
<ide>
<ide> $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
<ide> $this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
<ide> $result = $this->Paginator->sort('title', 'Title', array('direction' => 'asc'));
<del> $this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result);
<add> $expected = array(
<add> 'a' => array('href' => '/accounts/index/param?page=1&sort=title&direction=desc', 'class' => 'asc'),
<add> 'Title',
<add> '/a'
<add> );
<add> $this->assertTags($result, $expected);
<ide>
<ide> $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
<ide> $this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
<ide> $result = $this->Paginator->sort('title', 'Title', array('direction' => 'desc'));
<del> $this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="asc">Title<\/a>$/', $result);
<add> $expected = array(
<add> 'a' => array('href' => '/accounts/index/param?page=1&sort=title&direction=desc', 'class' => 'asc'),
<add> 'Title',
<add> '/a'
<add> );
<add> $this->assertTags($result, $expected);
<ide>
<ide> $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
<ide> $this->Paginator->request->params['paging']['Article']['options']['sort'] = null;
<ide> $result = $this->Paginator->sort('title', 'Title', array('direction' => 'desc', 'class' => 'foo'));
<del> $this->assertRegExp('/\/accounts\/index\/param\/page:1\/sort:title\/direction:desc" class="foo asc">Title<\/a>$/', $result);
<add> $expected = array(
<add> 'a' => array('href' => '/accounts/index/param?page=1&sort=title&direction=desc', 'class' => 'foo asc'),
<add> 'Title',
<add> '/a'
<add> );
<add> $this->assertTags($result, $expected);
<ide> }
<ide>
<ide> /**
<ide> public function testSortLinkWithVirtualField() {
<ide>
<ide> $result = $this->Paginator->sort('Article.full_name');
<ide> $expected = array(
<del> 'a' => array('href' => '/accounts/index/page:1/sort:Article.full_name/direction:desc', 'class' => 'asc'),
<add> 'a' => array('href' => '/accounts/index?page=1&sort=Article.full_name&direction=desc', 'class' => 'asc'),
<ide> 'Article.full Name',
<ide> '/a'
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $result = $this->Paginator->sort('full_name');
<ide> $expected = array(
<del> 'a' => array('href' => '/accounts/index/page:1/sort:full_name/direction:desc', 'class' => 'asc'),
<add> 'a' => array('href' => '/accounts/index?page=1&sort=full_name&direction=desc', 'class' => 'asc'),
<ide> 'Full Name',
<ide> '/a'
<ide> );
<ide> public function testSortLinkWithVirtualField() {
<ide> $this->Paginator->request->params['paging']['Article']['options']['order'] = array('full_name' => 'desc');
<ide> $result = $this->Paginator->sort('Article.full_name');
<ide> $expected = array(
<del> 'a' => array('href' => '/accounts/index/page:1/sort:Article.full_name/direction:asc', 'class' => 'desc'),
<add> 'a' => array('href' => '/accounts/index?page=1&sort=Article.full_name&direction=asc', 'class' => 'desc'),
<ide> 'Article.full Name',
<ide> '/a'
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $result = $this->Paginator->sort('full_name');
<ide> $expected = array(
<del> 'a' => array('href' => '/accounts/index/page:1/sort:full_name/direction:asc', 'class' => 'desc'),
<add> 'a' => array('href' => '/accounts/index?page=1&sort=full_name&direction=asc', 'class' => 'desc'),
<ide> 'Full Name',
<ide> '/a'
<ide> );
<ide> public function testSortLinkWithVirtualField() {
<ide> * @return void
<ide> */
<ide> public function testSortLinksUsingDirectionOption() {
<del> Router::reload();
<del> Router::parse('/');
<ide> Router::setRequestInfo(array(
<del> array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(),
<add> array('plugin' => null, 'controller' => 'accounts', 'action' => 'index',
<ide> 'url' => array('url' => 'accounts/', 'mod_rewrite' => 'true')),
<ide> array('base' => '/', 'here' => '/accounts/', 'webroot' => '/',)
<ide> ));
<ide> $this->Paginator->options(array('url' => array('param')));
<ide>
<ide> $result = $this->Paginator->sort('title', 'TestTitle', array('direction' => 'desc'));
<ide> $expected = array(
<del> 'a' => array('href' => '/accounts/index/param/page:1/sort:title/direction:desc'),
<add> 'a' => array('href' => '/accounts/index/param?page=1&sort=title&direction=desc'),
<ide> 'TestTitle',
<ide> '/a'
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $result = $this->Paginator->sort('title', array('asc' => 'ascending', 'desc' => 'descending'), array('direction' => 'desc'));
<ide> $expected = array(
<del> 'a' => array('href' => '/accounts/index/param/page:1/sort:title/direction:desc'),
<add> 'a' => array('href' => '/accounts/index/param?page=1&sort=title&direction=desc'),
<ide> 'descending',
<ide> '/a'
<ide> );
<ide> public function testSortLinksUsingDirectionOption() {
<ide> * @return void
<ide> */
<ide> public function testSortLinksUsingDotNotation() {
<del> Router::reload();
<del> Router::parse('/');
<ide> Router::setRequestInfo(array(
<del> array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'form' => array(), 'url' => array('url' => 'accounts/', 'mod_rewrite' => 'true'), 'bare' => 0),
<del> array('base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/')
<add> array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array()),
<add> array('base' => '', 'here' => '/accounts/', 'webroot' => '/')
<ide> ));
<ide>
<ide> $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'desc');
<ide> $result = $this->Paginator->sort('Article.title', 'Title');
<ide> $expected = array(
<del> 'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:asc', 'class' => 'desc'),
<add> 'a' => array('href' => '/accounts/index?page=1&sort=Article.title&direction=asc', 'class' => 'desc'),
<ide> 'Title',
<ide> '/a'
<ide> );
<ide> public function testSortLinksUsingDotNotation() {
<ide> $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
<ide> $result = $this->Paginator->sort('Article.title', 'Title');
<ide> $expected = array(
<del> 'a' => array('href' => '/officespace/accounts/index/page:1/sort:Article.title/direction:desc', 'class' => 'asc'),
<add> 'a' => array('href' => '/accounts/index?page=1&sort=Article.title&direction=desc', 'class' => 'asc'),
<ide> 'Title',
<ide> '/a'
<ide> );
<ide> public function testSortLinksUsingDotNotation() {
<ide> $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Account.title' => 'asc');
<ide> $result = $this->Paginator->sort('title');
<ide> $expected = array(
<del> 'a' => array('href' => '/officespace/accounts/index/page:1/sort:title/direction:asc'),
<add> 'a' => array('href' => '/accounts/index?page=1&sort=title&direction=asc'),
<ide> 'Title',
<ide> '/a'
<ide> );
<ide> public function testSortDirFallbackToParams() {
<ide> */
<ide> public function testSortAdminLinks() {
<ide> Configure::write('Routing.prefixes', array('admin'));
<del>
<ide> Router::reload();
<add> Router::connect('/admin/:controller/:action/*', array('admin' => true, 'prefix' => 'admin'));
<ide> Router::setRequestInfo(array(
<del> array('pass' => array(), 'named' => array(), 'controller' => 'users', 'plugin' => null, 'action' => 'admin_index', 'prefix' => 'admin', 'admin' => true, 'url' => array('ext' => 'html', 'url' => 'admin/users')),
<add> array('controller' => 'users', 'plugin' => null, 'action' => 'admin_index', 'prefix' => 'admin', 'admin' => true),
<ide> array('base' => '', 'here' => '/admin/users', 'webroot' => '/')
<ide> ));
<del> Router::parse('/admin/users');
<ide> $this->Paginator->request->params['paging']['Article']['page'] = 1;
<ide> $result = $this->Paginator->next('Next');
<ide> $expected = array(
<ide> 'span' => array('class' => 'next'),
<del> 'a' => array('href' => '/admin/users/index/page:2', 'rel' => 'next'),
<add> 'a' => array('href' => '/admin/users/index?page=2', 'rel' => 'next'),
<ide> 'Next',
<ide> '/a',
<ide> '/span'
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<del> Router::reload();
<del> Router::setRequestInfo(array(
<del> array('plugin' => null, 'controller' => 'test', 'action' => 'admin_index', 'pass' => array(), 'prefix' => 'admin', 'admin' => true, 'url' => array('url' => 'admin/test')),
<del> array('base' => '', 'here' => '/admin/test', 'webroot' => '/')
<del> ));
<del> Router::parse('/');
<ide> $this->Paginator->options(array('url' => array('param')));
<ide> $result = $this->Paginator->sort('title');
<ide> $expected = array(
<del> 'a' => array('href' => '/admin/test/index/param/page:1/sort:title/direction:asc'),
<add> 'a' => array('href' => '/admin/users/index/param?page=1&sort=title&direction=asc'),
<ide> 'Title',
<ide> '/a'
<ide> );
<ide> public function testSortAdminLinks() {
<ide> $this->Paginator->options(array('url' => array('param')));
<ide> $result = $this->Paginator->sort('Article.title', 'Title');
<ide> $expected = array(
<del> 'a' => array('href' => '/admin/test/index/param/page:1/sort:Article.title/direction:asc'),
<add> 'a' => array('href' => '/admin/users/index/param?page=1&sort=Article.title&direction=asc'),
<ide> 'Title',
<ide> '/a'
<ide> );
<ide> public function testSortAdminLinks() {
<ide> public function testUrlGeneration() {
<ide> $result = $this->Paginator->sort('controller');
<ide> $expected = array(
<del> 'a' => array('href' => '/index/page:1/sort:controller/direction:asc'),
<add> 'a' => array('href' => '/index?page=1&sort=controller&direction=asc'),
<ide> 'Controller',
<ide> '/a'
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $result = $this->Paginator->url();
<del> $this->assertEquals('/index/page:1', $result);
<add> $this->assertEquals('/index?page=1', $result);
<ide>
<ide> $this->Paginator->request->params['paging']['Article']['options']['page'] = 2;
<ide> $result = $this->Paginator->url();
<del> $this->assertEquals('/index/page:2', $result);
<add> $this->assertEquals('/index?page=2', $result);
<ide>
<ide> $options = array('order' => array('Article' => 'desc'));
<ide> $result = $this->Paginator->url($options);
<del> $this->assertEquals('/index/page:2/sort:Article/direction:desc', $result);
<add> $this->assertEquals('/index?page=2&sort=Article&direction=desc', $result);
<ide>
<ide> $this->Paginator->request->params['paging']['Article']['options']['page'] = 3;
<ide> $options = array('order' => array('Article.name' => 'desc'));
<ide> $result = $this->Paginator->url($options);
<del> $this->assertEquals('/index/page:3/sort:Article.name/direction:desc', $result);
<add> $this->assertEquals('/index?page=3&sort=Article.name&direction=desc', $result);
<ide> }
<ide>
<ide> /**
<ide> public function testUrlGeneration() {
<ide> * @return void
<ide> */
<ide> public function testUrlGenerationWithPrefixes() {
<del> $_back = Configure::read('Routing');
<del>
<ide> Configure::write('Routing.prefixes', array('members'));
<ide> Router::reload();
<del>
<del> Router::parse('/');
<add> Router::connect('/members/:controller/:action/*', array('prefix' => 'members', 'members' => true));
<add> Router::connect('/:controller/:action/*');
<ide>
<ide> Router::setRequestInfo(array(
<del> array('controller' => 'posts', 'action' => 'index', 'form' => array(), 'url' => array(), 'plugin' => null),
<add> array('controller' => 'posts', 'action' => 'index', 'plugin' => null),
<ide> array('base' => '', 'here' => 'posts/index', 'webroot' => '/')
<ide> ));
<ide>
<ide> public function testUrlGenerationWithPrefixes() {
<ide> $options = array('members' => true);
<ide>
<ide> $result = $this->Paginator->url($options);
<del> $expected = '/members/posts/index/page:2';
<add> $expected = '/members/posts/index?page=2';
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $result = $this->Paginator->sort('name', null, array('url' => $options));
<ide> $expected = array(
<del> 'a' => array('href' => '/members/posts/index/page:2/sort:name/direction:asc'),
<add> 'a' => array('href' => '/members/posts/index?page=2&sort=name&direction=asc'),
<ide> 'Name',
<ide> '/a'
<ide> );
<ide> public function testUrlGenerationWithPrefixes() {
<ide> $result = $this->Paginator->next('next', array('url' => $options));
<ide> $expected = array(
<ide> 'span' => array('class' => 'next'),
<del> 'a' => array('href' => '/members/posts/index/page:3', 'rel' => 'next'),
<add> 'a' => array('href' => '/members/posts/index?page=3', 'rel' => 'next'),
<ide> 'next',
<ide> '/a',
<ide> '/span'
<ide> public function testUrlGenerationWithPrefixes() {
<ide> $result = $this->Paginator->prev('prev', array('url' => $options));
<ide> $expected = array(
<ide> 'span' => array('class' => 'prev'),
<del> 'a' => array('href' => '/members/posts/index/page:1', 'rel' => 'prev'),
<add> 'a' => array('href' => '/members/posts/index?page=1', 'rel' => 'prev'),
<ide> 'prev',
<ide> '/a',
<ide> '/span'
<ide> public function testUrlGenerationWithPrefixes() {
<ide>
<ide> $options = array('members' => true, 'controller' => 'posts', 'order' => array('name' => 'desc'));
<ide> $result = $this->Paginator->url($options);
<del> $expected = '/members/posts/index/page:2/sort:name/direction:desc';
<add> $expected = '/members/posts/index?page=2&sort=name&direction=desc';
<ide> $this->assertEquals($expected, $result);
<ide>
<ide> $options = array('controller' => 'posts', 'order' => array('Article.name' => 'desc'));
<ide> $result = $this->Paginator->url($options);
<del> $expected = '/posts/index/page:2/sort:Article.name/direction:desc';
<add> $expected = '/posts/index?page=2&sort=Article.name&direction=desc';
<ide> $this->assertEquals($expected, $result);
<del>
<del> Configure::write('Routing', $_back);
<ide> }
<ide>
<ide> /**
<ide> public function testOptions() {
<ide> * @return void
<ide> */
<ide> public function testPassedArgsMergingWithUrlOptions() {
<del> Router::reload();
<del> Router::parse('/');
<ide> Router::setRequestInfo(array(
<del> array('plugin' => null, 'controller' => 'articles', 'action' => 'index', 'pass' => array('2'), 'named' => array('foo' => 'bar'), 'url' => array('url' => 'articles/index/2/foo:bar')),
<add> array('plugin' => null, 'controller' => 'articles', 'action' => 'index', 'pass' => array('2')),
<ide> array('base' => '/', 'here' => '/articles/', 'webroot' => '/')
<ide> ));
<ide> $this->Paginator->request->params['paging'] = array(
<ide> public function testPassedArgsMergingWithUrlOptions() {
<ide> 'order' => array(),
<ide> 'conditions' => array()
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide>
<ide> public function testPassedArgsMergingWithUrlOptions() {
<ide>
<ide> $result = $this->Paginator->sort('title');
<ide> $expected = array(
<del> 'a' => array('href' => '/articles/index/2/page:1/foo:bar/sort:title/direction:asc?x=y'),
<add> 'a' => array('href' => '/articles/index/2?page=1&foo=bar&sort=title&direction=asc&x=y'),
<ide> 'Title',
<ide> '/a'
<ide> );
<ide> public function testPassedArgsMergingWithUrlOptions() {
<ide> $expected = array(
<ide> array('span' => array('class' => 'current')), '1', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/articles/index/2/page:2/foo:bar?x=y')), '2', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/articles/index/2?page=2&foo=bar&x=y')), '2', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/articles/index/2/page:3/foo:bar?x=y')), '3', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/articles/index/2?page=3&foo=bar&x=y')), '3', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/articles/index/2/page:4/foo:bar?x=y')), '4', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/articles/index/2?page=4&foo=bar&x=y')), '4', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/articles/index/2/page:5/foo:bar?x=y')), '5', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/articles/index/2?page=5&foo=bar&x=y')), '5', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/articles/index/2/page:6/foo:bar?x=y')), '6', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/articles/index/2?page=6&foo=bar&x=y')), '6', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/articles/index/2/page:7/foo:bar?x=y')), '7', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/articles/index/2?page=7&foo=bar&x=y')), '7', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $result = $this->Paginator->next('Next');
<ide> $expected = array(
<ide> 'span' => array('class' => 'next'),
<del> 'a' => array('href' => '/articles/index/2/page:2/foo:bar?x=y', 'rel' => 'next'),
<del> 'Next',
<del> '/a',
<del> '/span'
<del> );
<del> $this->assertTags($result, $expected);
<del> }
<del>
<del>/**
<del> * testPassedArgsMergingWithUrlOptionsParamTypeQuerystring method
<del> *
<del> * @return void
<del> */
<del> public function testPassedArgsMergingWithUrlOptionsParamTypeQuerystring() {
<del> Router::reload();
<del> Router::parse('/');
<del> Router::setRequestInfo(array(
<del> array('plugin' => null, 'controller' => 'articles', 'action' => 'index', 'pass' => array('2'), 'named' => array('foo' => 'bar'), 'url' => array('url' => 'articles/index/2/foo:bar')),
<del> array('base' => '/', 'here' => '/articles/', 'webroot' => '/')
<del> ));
<del> $this->Paginator->request->params['paging'] = array(
<del> 'Article' => array(
<del> 'page' => 1, 'current' => 3, 'count' => 13,
<del> 'prevPage' => false, 'nextPage' => true, 'pageCount' => 8,
<del> 'options' => array(
<del> 'page' => 1,
<del> 'order' => array(),
<del> 'conditions' => array()
<del> ),
<del> 'paramType' => 'querystring'
<del> )
<del> );
<del>
<del> $this->Paginator->request->params['pass'] = array(2);
<del> $this->Paginator->request->params['named'] = array('foo' => 'bar');
<del> $this->Paginator->request->query = array('x' => 'y');
<del> $this->Paginator->beforeRender('posts/index');
<del>
<del> $result = $this->Paginator->sort('title');
<del> $expected = array(
<del> 'a' => array('href' => '/articles/index/2/foo:bar?x=y&page=1&sort=title&direction=asc'),
<del> 'Title',
<del> '/a'
<del> );
<del> $this->assertTags($result, $expected);
<del>
<del> $result = $this->Paginator->numbers();
<del> $expected = array(
<del> array('span' => array('class' => 'current')), '1', '/span',
<del> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar?x=y&page=2')), '2', '/a', '/span',
<del> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar?x=y&page=3')), '3', '/a', '/span',
<del> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar?x=y&page=4')), '4', '/a', '/span',
<del> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar?x=y&page=5')), '5', '/a', '/span',
<del> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar?x=y&page=6')), '6', '/a', '/span',
<del> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/articles/index/2/foo:bar?x=y&page=7')), '7', '/a', '/span',
<del> );
<del> $this->assertTags($result, $expected);
<del>
<del> $result = $this->Paginator->next('Next');
<del> $expected = array(
<del> 'span' => array('class' => 'next'),
<del> 'a' => array('href' => '/articles/index/2/foo:bar?x=y&page=2', 'rel' => 'next'),
<add> 'a' => array('href' => '/articles/index/2?page=2&foo=bar&x=y', 'rel' => 'next'),
<ide> 'Next',
<ide> '/a',
<ide> '/span'
<ide> public function testPagingLinks() {
<ide> 'options' => array(
<ide> 'page' => 1,
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide> $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
<ide> public function testPagingLinks() {
<ide> $result = $this->Paginator->prev('<< Previous', null, null, array('class' => 'disabled'));
<ide> $expected = array(
<ide> 'span' => array('class' => 'prev'),
<del> 'a' => array('href' => '/index/page:1', 'rel' => 'prev'),
<add> 'a' => array('href' => '/index?page=1', 'rel' => 'prev'),
<ide> '<< Previous',
<ide> '/a',
<ide> '/span'
<ide> public function testPagingLinks() {
<ide> $result = $this->Paginator->next('Next');
<ide> $expected = array(
<ide> 'span' => array('class' => 'next'),
<del> 'a' => array('href' => '/index/page:3', 'rel' => 'next'),
<add> 'a' => array('href' => '/index?page=3', 'rel' => 'next'),
<ide> 'Next',
<ide> '/a',
<ide> '/span'
<ide> public function testPagingLinks() {
<ide> $result = $this->Paginator->next('Next', array('tag' => 'li'));
<ide> $expected = array(
<ide> 'li' => array('class' => 'next'),
<del> 'a' => array('href' => '/index/page:3', 'rel' => 'next'),
<add> 'a' => array('href' => '/index?page=3', 'rel' => 'next'),
<ide> 'Next',
<ide> '/a',
<ide> '/li'
<ide> public function testPagingLinks() {
<ide> $result = $this->Paginator->prev('<< Previous', array('escape' => true));
<ide> $expected = array(
<ide> 'span' => array('class' => 'prev'),
<del> 'a' => array('href' => '/index/page:1', 'rel' => 'prev'),
<add> 'a' => array('href' => '/index?page=1', 'rel' => 'prev'),
<ide> '<< Previous',
<ide> '/a',
<ide> '/span'
<ide> public function testPagingLinks() {
<ide> $result = $this->Paginator->prev('<< Previous', array('escape' => false));
<ide> $expected = array(
<ide> 'span' => array('class' => 'prev'),
<del> 'a' => array('href' => '/index/page:1', 'rel' => 'prev'),
<add> 'a' => array('href' => '/index?page=1', 'rel' => 'prev'),
<ide> 'preg:/<< Previous/',
<ide> '/a',
<ide> '/span'
<ide> public function testPagingLinks() {
<ide> 'options' => array(
<ide> 'page' => 1,
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide>
<ide> public function testPagingLinks() {
<ide> 'limit' => 3,
<ide> 'order' => array('Client.name' => 'DESC'),
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide>
<ide> public function testPagingLinks() {
<ide> $expected = array(
<ide> 'span' => array('class' => 'prev'),
<ide> 'a' => array(
<del> 'href' => '/index/page:1/limit:3/sort:Client.name/direction:DESC',
<add> 'href' => '/index?page=1&limit=3&sort=Client.name&direction=DESC',
<ide> 'rel' => 'prev'
<ide> ),
<ide> '<< Previous',
<ide> public function testPagingLinks() {
<ide> $expected = array(
<ide> 'span' => array('class' => 'next'),
<ide> 'a' => array(
<del> 'href' => '/index/page:3/limit:3/sort:Client.name/direction:DESC',
<add> 'href' => '/index?page=3&limit=3&sort=Client.name&direction=DESC',
<ide> 'rel' => 'next'
<ide> ),
<ide> 'Next',
<ide> public function testPagingLinks() {
<ide> 'order' => array(),
<ide> 'conditions' => array()
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide> $result = $this->Paginator->prev('Prev');
<ide> $expected = array(
<ide> 'span' => array('class' => 'prev'),
<del> 'a' => array('href' => '/index/page:1/limit:10', 'rel' => 'prev'),
<add> 'a' => array('href' => '/index?page=1&limit=10', 'rel' => 'prev'),
<ide> 'Prev',
<ide> '/a',
<ide> '/span'
<ide> public function testPagingLinks() {
<ide> 'options' => array(
<ide> 'page' => 2, 'limit' => 10, 'order' => array(), 'conditions' => array()
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide> $this->Paginator->options(array('url' => array(12, 'page' => 3)));
<ide> $result = $this->Paginator->prev('Prev', array('url' => array('foo' => 'bar')));
<ide> $expected = array(
<ide> 'span' => array('class' => 'prev'),
<del> 'a' => array('href' => '/index/12/page:1/limit:10/foo:bar', 'rel' => 'prev'),
<add> 'a' => array('href' => '/index/12?page=1&limit=10&foo=bar', 'rel' => 'prev'),
<ide> 'Prev',
<ide> '/a',
<ide> '/span'
<ide> public function testPagingLinksOptionsReplaceEmptyDisabledOptions() {
<ide> 'options' => array(
<ide> 'page' => 1,
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide> $result = $this->Paginator->prev('<< Previous', array('escape' => false));
<ide> public function testPagingLinksOptionsReplaceEmptyDisabledOptions() {
<ide> $result = $this->Paginator->next('Next >>', array('escape' => false));
<ide> $expected = array(
<ide> 'span' => array('class' => 'next'),
<del> 'a' => array('href' => '/index/page:2', 'rel' => 'next'),
<add> 'a' => array('href' => '/index?page=2', 'rel' => 'next'),
<ide> 'preg:/Next >>/',
<ide> '/a',
<ide> '/span'
<ide> public function testPagingLinksNotDefaultModel() {
<ide> 'options' => array(
<ide> 'page' => 1,
<ide> ),
<del> 'paramType' => 'named'
<ide> ),
<ide> 'Server' => array(
<ide> 'page' => 1,
<ide> public function testPagingLinksNotDefaultModel() {
<ide> 'options' => array(
<ide> 'page' => 1,
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide> $result = $this->Paginator->next('Next', array('model' => 'Client'));
<ide> $expected = array(
<ide> 'span' => array('class' => 'next'),
<del> 'a' => array('href' => '/index/page:2', 'rel' => 'next'),
<add> 'a' => array('href' => '/index?page=2', 'rel' => 'next'),
<ide> 'Next',
<ide> '/a',
<ide> '/span'
<ide> public function testPagingLinksNotDefaultModel() {
<ide> public function testGenericLinks() {
<ide> $result = $this->Paginator->link('Sort by title on page 5', array('sort' => 'title', 'page' => 5, 'direction' => 'desc'));
<ide> $expected = array(
<del> 'a' => array('href' => '/index/page:5/sort:title/direction:desc'),
<add> 'a' => array('href' => '/index?page=5&sort=title&direction=desc'),
<ide> 'Sort by title on page 5',
<ide> '/a'
<ide> );
<ide> public function testGenericLinks() {
<ide> $this->Paginator->request->params['paging']['Article']['options']['page'] = 2;
<ide> $result = $this->Paginator->link('Sort by title', array('sort' => 'title', 'direction' => 'desc'));
<ide> $expected = array(
<del> 'a' => array('href' => '/index/page:2/sort:title/direction:desc'),
<add> 'a' => array('href' => '/index?page=2&sort=title&direction=desc'),
<ide> 'Sort by title',
<ide> '/a'
<ide> );
<ide> public function testGenericLinks() {
<ide> $this->Paginator->request->params['paging']['Article']['options']['page'] = 4;
<ide> $result = $this->Paginator->link('Sort by title on page 4', array('sort' => 'Article.title', 'direction' => 'desc'));
<ide> $expected = array(
<del> 'a' => array('href' => '/index/page:4/sort:Article.title/direction:desc'),
<add> 'a' => array('href' => '/index?page=4&sort=Article.title&direction=desc'),
<ide> 'Sort by title on page 4',
<ide> '/a'
<ide> );
<ide> public function testGenericLinks() {
<ide> */
<ide> public function testGenericLinksWithPresetOptions() {
<ide> $result = $this->Paginator->link('Foo!', array('page' => 1));
<del> $this->assertTags($result, array('a' => array('href' => '/index/page:1'), 'Foo!', '/a'));
<add> $this->assertTags($result, array('a' => array('href' => '/index?page=1'), 'Foo!', '/a'));
<ide>
<ide> $this->Paginator->options(array('sort' => 'title', 'direction' => 'desc'));
<ide> $result = $this->Paginator->link('Foo!', array('page' => 1));
<ide> $this->assertTags($result, array(
<ide> 'a' => array(
<del> 'href' => '/index/page:1',
<add> 'href' => '/index?page=1',
<ide> 'sort' => 'title',
<ide> 'direction' => 'desc'
<ide> ),
<ide> public function testGenericLinksWithPresetOptions() {
<ide>
<ide> $this->Paginator->options(array('sort' => null, 'direction' => null));
<ide> $result = $this->Paginator->link('Foo!', array('page' => 1));
<del> $this->assertTags($result, array('a' => array('href' => '/index/page:1'), 'Foo!', '/a'));
<add> $this->assertTags($result, array('a' => array('href' => '/index?page=1'), 'Foo!', '/a'));
<ide>
<ide> $this->Paginator->options(array('url' => array(
<ide> 'sort' => 'title',
<ide> 'direction' => 'desc'
<ide> )));
<ide> $result = $this->Paginator->link('Foo!', array('page' => 1));
<ide> $this->assertTags($result, array(
<del> 'a' => array('href' => '/index/page:1/sort:title/direction:desc'),
<add> 'a' => array('href' => '/index?page=1&sort=title&direction=desc'),
<ide> 'Foo!',
<ide> '/a'
<ide> ));
<ide> public function testNumbers() {
<ide> 'options' => array(
<ide> 'page' => 1,
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide> $result = $this->Paginator->numbers();
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4')), '4', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=5')), '5', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=6')), '6', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=7')), '7', '/a', '/span',
<ide> ' | ',
<ide> array('span' => array('class' => 'current')), '8', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=9')), '9', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=10')), '10', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=11')), '11', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=12')), '12', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $result = $this->Paginator->numbers(array('tag' => 'li'));
<ide> $expected = array(
<del> array('li' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/li',
<add> array('li' => array()), array('a' => array('href' => '/index?page=4')), '4', '/a', '/li',
<ide> ' | ',
<del> array('li' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/li',
<add> array('li' => array()), array('a' => array('href' => '/index?page=5')), '5', '/a', '/li',
<ide> ' | ',
<del> array('li' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/li',
<add> array('li' => array()), array('a' => array('href' => '/index?page=6')), '6', '/a', '/li',
<ide> ' | ',
<del> array('li' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/li',
<add> array('li' => array()), array('a' => array('href' => '/index?page=7')), '7', '/a', '/li',
<ide> ' | ',
<ide> array('li' => array('class' => 'current')), '8', '/li',
<ide> ' | ',
<del> array('li' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/li',
<add> array('li' => array()), array('a' => array('href' => '/index?page=9')), '9', '/a', '/li',
<ide> ' | ',
<del> array('li' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/li',
<add> array('li' => array()), array('a' => array('href' => '/index?page=10')), '10', '/a', '/li',
<ide> ' | ',
<del> array('li' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/li',
<add> array('li' => array()), array('a' => array('href' => '/index?page=11')), '11', '/a', '/li',
<ide> ' | ',
<del> array('li' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/li',
<add> array('li' => array()), array('a' => array('href' => '/index?page=12')), '12', '/a', '/li',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $result = $this->Paginator->numbers(array('tag' => 'li', 'separator' => false));
<ide> $expected = array(
<del> array('li' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/li',
<del> array('li' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/li',
<del> array('li' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/li',
<del> array('li' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/li',
<add> array('li' => array()), array('a' => array('href' => '/index?page=4')), '4', '/a', '/li',
<add> array('li' => array()), array('a' => array('href' => '/index?page=5')), '5', '/a', '/li',
<add> array('li' => array()), array('a' => array('href' => '/index?page=6')), '6', '/a', '/li',
<add> array('li' => array()), array('a' => array('href' => '/index?page=7')), '7', '/a', '/li',
<ide> array('li' => array('class' => 'current')), '8', '/li',
<del> array('li' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/li',
<del> array('li' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/li',
<del> array('li' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/li',
<del> array('li' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/li',
<add> array('li' => array()), array('a' => array('href' => '/index?page=9')), '9', '/a', '/li',
<add> array('li' => array()), array('a' => array('href' => '/index?page=10')), '10', '/a', '/li',
<add> array('li' => array()), array('a' => array('href' => '/index?page=11')), '11', '/a', '/li',
<add> array('li' => array()), array('a' => array('href' => '/index?page=12')), '12', '/a', '/li',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $result = $this->Paginator->numbers(true);
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:1', 'rel' => 'first')), 'first', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=1', 'rel' => 'first')), 'first', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4')), '4', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=5')), '5', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=6')), '6', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=7')), '7', '/a', '/span',
<ide> ' | ',
<ide> array('span' => array('class' => 'current')), '8', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=9')), '9', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=10')), '10', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=11')), '11', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=12')), '12', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:15', 'rel' => 'last')), 'last', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=15', 'rel' => 'last')), 'last', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> public function testNumbers() {
<ide> 'options' => array(
<ide> 'page' => 1,
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide> $result = $this->Paginator->numbers();
<ide> $expected = array(
<ide> array('span' => array('class' => 'current')), '1', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=2')), '2', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=3')), '3', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4')), '4', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=5')), '5', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=6')), '6', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=7')), '7', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=8')), '8', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=9')), '9', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> public function testNumbers() {
<ide> 'options' => array(
<ide> 'page' => 1,
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide> $result = $this->Paginator->numbers();
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=7')), '7', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=8')), '8', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=9')), '9', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=10')), '10', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=11')), '11', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=12')), '12', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:13')), '13', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=13')), '13', '/a', '/span',
<ide> ' | ',
<ide> array('span' => array('class' => 'current')), '14', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:15')), '15', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=15')), '15', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> public function testNumbers() {
<ide> 'options' => array(
<ide> 'page' => 1,
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide>
<ide> $result = $this->Paginator->numbers(array('first' => 1, 'class' => 'page-link'));
<ide> $expected = array(
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> ' | ',
<ide> array('span' => array('class' => 'current page-link')), '2', '/span',
<ide> ' | ',
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=3')), '3', '/a', '/span',
<ide> ' | ',
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=4')), '4', '/a', '/span',
<ide> ' | ',
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=5')), '5', '/a', '/span',
<ide> ' | ',
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=6')), '6', '/a', '/span',
<ide> ' | ',
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=7')), '7', '/a', '/span',
<ide> ' | ',
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=8')), '8', '/a', '/span',
<ide> ' | ',
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=9')), '9', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $result = $this->Paginator->numbers(array('first' => 1, 'currentClass' => 'active'));
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> ' | ',
<ide> array('span' => array('class' => 'active')), '2', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=3')), '3', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4')), '4', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=5')), '5', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=6')), '6', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=7')), '7', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=8')), '8', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=9')), '9', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $result = $this->Paginator->numbers(array('first' => 1, 'class' => 'page-link', 'currentClass' => 'active'));
<ide> $expected = array(
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> ' | ',
<ide> array('span' => array('class' => 'active page-link')), '2', '/span',
<ide> ' | ',
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=3')), '3', '/a', '/span',
<ide> ' | ',
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=4')), '4', '/a', '/span',
<ide> ' | ',
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=5')), '5', '/a', '/span',
<ide> ' | ',
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=6')), '6', '/a', '/span',
<ide> ' | ',
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=7')), '7', '/a', '/span',
<ide> ' | ',
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=8')), '8', '/a', '/span',
<ide> ' | ',
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=9')), '9', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $result = $this->Paginator->numbers(array('last' => 1));
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> ' | ',
<ide> array('span' => array('class' => 'current')), '2', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=3')), '3', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4')), '4', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=5')), '5', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=6')), '6', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=7')), '7', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=8')), '8', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=9')), '9', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> public function testNumbers() {
<ide> 'options' => array(
<ide> 'page' => 1,
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide>
<ide> $result = $this->Paginator->numbers(array('first' => 1));
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> '...',
<del> array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=7')), '7', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=8')), '8', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=9')), '9', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=10')), '10', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=11')), '11', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=12')), '12', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:13')), '13', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=13')), '13', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:14')), '14', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=14')), '14', '/a', '/span',
<ide> ' | ',
<ide> array('span' => array('class' => 'current')), '15', '/span',
<ide>
<ide> public function testNumbers() {
<ide> 'options' => array(
<ide> 'page' => 1,
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide>
<ide> $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> '...',
<del> array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=6')), '6', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=7')), '7', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=8')), '8', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=9')), '9', '/a', '/span',
<ide> ' | ',
<ide> array('span' => array('class' => 'current')), '10', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:11')), '11', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=11')), '11', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:12')), '12', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=12')), '12', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:13')), '13', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=13')), '13', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:14')), '14', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=14')), '14', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:15')), '15', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=15')), '15', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> public function testNumbers() {
<ide> 'options' => array(
<ide> 'page' => 6,
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide>
<ide> $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=2')), '2', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=3')), '3', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4')), '4', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=5')), '5', '/a', '/span',
<ide> ' | ',
<ide> array('span' => array('class' => 'current')), '6', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=7')), '7', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:8')), '8', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=8')), '8', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:9')), '9', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=9')), '9', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:10')), '10', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=10')), '10', '/a', '/span',
<ide> '...',
<del> array('span' => array()), array('a' => array('href' => '/index/page:42')), '42', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=42')), '42', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> public function testNumbers() {
<ide> 'options' => array(
<ide> 'page' => 37,
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide>
<ide> $result = $this->Paginator->numbers(array('first' => 1, 'last' => 1));
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> '...',
<del> array('span' => array()), array('a' => array('href' => '/index/page:33')), '33', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=33')), '33', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:34')), '34', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=34')), '34', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:35')), '35', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=35')), '35', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:36')), '36', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=36')), '36', '/a', '/span',
<ide> ' | ',
<ide> array('span' => array('class' => 'current')), '37', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:38')), '38', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=38')), '38', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:39')), '39', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=39')), '39', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:40')), '40', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=40')), '40', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:41')), '41', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=41')), '41', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:42')), '42', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=42')), '42', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> public function testNumbers() {
<ide> 'options' => array(
<ide> 'page' => 1,
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide> $options = array('modulus' => 10);
<ide> $result = $this->Paginator->numbers($options);
<ide> $expected = array(
<ide> array('span' => array('class' => 'current')), '1', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=2')), '2', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=3')), '3', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> public function testNumbers() {
<ide> 'page' => 1,
<ide> 'order' => array('Client.name' => 'DESC'),
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide> $result = $this->Paginator->numbers(array('class' => 'page-link'));
<ide> $expected = array(
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:1/sort:Client.name/direction:DESC')), '1', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=1&sort=Client.name&direction=DESC')), '1', '/a', '/span',
<ide> ' | ',
<ide> array('span' => array('class' => 'current page-link')), '2', '/span',
<ide> ' | ',
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:3/sort:Client.name/direction:DESC')), '3', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=3&sort=Client.name&direction=DESC')), '3', '/a', '/span',
<ide> ' | ',
<del> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index/page:4/sort:Client.name/direction:DESC')), '4', '/a', '/span',
<add> array('span' => array('class' => 'page-link')), array('a' => array('href' => '/index?page=4&sort=Client.name&direction=DESC')), '4', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> public function testNumbers() {
<ide> 'options' => array(
<ide> 'page' => 4894,
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide>
<ide> $result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2));
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=2')), '2', '/a', '/span',
<ide> '...',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4894')), '4894', '/a', '/span',
<ide> ' | ',
<ide> array('span' => array('class' => 'current')), '4895', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4896')), '4896', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4897')), '4897', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $this->Paginator->request->params['paging']['Client']['page'] = 3;
<ide>
<ide> $result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2));
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=2')), '2', '/a', '/span',
<ide> ' | ',
<ide> array('span' => array('class' => 'current')), '3', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4')), '4', '/a', '/span',
<ide> '...',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4896')), '4896', '/a', '/span',
<ide> ' | ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4897')), '4897', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2, 'separator' => ' - '));
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=2')), '2', '/a', '/span',
<ide> ' - ',
<ide> array('span' => array('class' => 'current')), '3', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4')), '4', '/a', '/span',
<ide> '...',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4896')), '4896', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4897')), '4897', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 5, 'last' => 5, 'separator' => ' - '));
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=2')), '2', '/a', '/span',
<ide> ' - ',
<ide> array('span' => array('class' => 'current')), '3', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4')), '4', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=5')), '5', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=6')), '6', '/a', '/span',
<ide> '...',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4893')), '4893', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4893')), '4893', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4894')), '4894', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4895')), '4895', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4896')), '4896', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4897')), '4897', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $this->Paginator->request->params['paging']['Client']['page'] = 4893;
<ide> $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=2')), '2', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=3')), '3', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4')), '4', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=5')), '5', '/a', '/span',
<ide> '...',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4891')), '4891', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4891')), '4891', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4892')), '4892', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4892')), '4892', '/a', '/span',
<ide> ' - ',
<ide> array('span' => array('class' => 'current')), '4893', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4894')), '4894', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4895')), '4895', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4896')), '4896', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4897')), '4897', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $this->Paginator->request->params['paging']['Client']['page'] = 58;
<ide> $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=2')), '2', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=3')), '3', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4')), '4', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:5')), '5', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=5')), '5', '/a', '/span',
<ide> '...',
<del> array('span' => array()), array('a' => array('href' => '/index/page:56')), '56', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=56')), '56', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:57')), '57', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=57')), '57', '/a', '/span',
<ide> ' - ',
<ide> array('span' => array('class' => 'current')), '58', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:59')), '59', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=59')), '59', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:60')), '60', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=60')), '60', '/a', '/span',
<ide> '...',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4893')), '4893', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4893')), '4893', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4894')), '4894', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4895')), '4895', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4896')), '4896', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4897')), '4897', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $this->Paginator->request->params['paging']['Client']['page'] = 5;
<ide> $result = $this->Paginator->numbers(array('first' => 5, 'modulus' => 4, 'last' => 5, 'separator' => ' - '));
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=2')), '2', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:3')), '3', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=3')), '3', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4')), '4', '/a', '/span',
<ide> ' - ',
<ide> array('span' => array('class' => 'current')), '5', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:6')), '6', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=6')), '6', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:7')), '7', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=7')), '7', '/a', '/span',
<ide> '...',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4893')), '4893', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4893')), '4893', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4894')), '4894', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4894')), '4894', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4895')), '4895', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4895')), '4895', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4896')), '4896', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4897')), '4897', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $this->Paginator->request->params['paging']['Client']['page'] = 3;
<ide> $result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2, 'separator' => ' - ', 'ellipsis' => ' ~~~ '));
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=2')), '2', '/a', '/span',
<ide> ' - ',
<ide> array('span' => array('class' => 'current')), '3', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4')), '4', '/a', '/span',
<ide> ' ~~~ ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4896')), '4896', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4897')), '4897', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $this->Paginator->request->params['paging']['Client']['page'] = 3;
<ide> $result = $this->Paginator->numbers(array('first' => 2, 'modulus' => 2, 'last' => 2, 'separator' => ' - ', 'ellipsis' => '<span class="ellipsis">...</span>'));
<ide> $expected = array(
<del> array('span' => array()), array('a' => array('href' => '/index/page:1')), '1', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=1')), '1', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:2')), '2', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=2')), '2', '/a', '/span',
<ide> ' - ',
<ide> array('span' => array('class' => 'current')), '3', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4')), '4', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4')), '4', '/a', '/span',
<ide> array('span' => array('class' => 'ellipsis')), '...', '/span',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4896')), '4896', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4896')), '4896', '/a', '/span',
<ide> ' - ',
<del> array('span' => array()), array('a' => array('href' => '/index/page:4897')), '4897', '/a', '/span',
<add> array('span' => array()), array('a' => array('href' => '/index?page=4897')), '4897', '/a', '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide> }
<ide> public function testFirstAndLastTag() {
<ide> $result = $this->Paginator->first('<<', array('tag' => 'li', 'class' => 'first'));
<ide> $expected = array(
<ide> 'li' => array('class' => 'first'),
<del> 'a' => array('href' => '/index/page:1', 'rel' => 'first'),
<add> 'a' => array('href' => '/index?page=1', 'rel' => 'first'),
<ide> '<<',
<ide> '/a',
<ide> '/li'
<ide> public function testFirstAndLastTag() {
<ide> $expected = array(
<ide> '...',
<ide> 'li' => array('class' => 'last'),
<del> array('a' => array('href' => '/index/page:6')), '6', '/a',
<add> array('a' => array('href' => '/index?page=6')), '6', '/a',
<ide> '/li',
<ide> ' | ',
<ide> array('li' => array('class' => 'last')),
<del> array('a' => array('href' => '/index/page:7')), '7', '/a',
<add> array('a' => array('href' => '/index?page=7')), '7', '/a',
<ide> '/li',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide> public function testFirstEmpty() {
<ide> public function testFirstFullBaseUrl() {
<ide> $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'DESC');
<ide>
<del> $this->Paginator->options(array('url' => array('full_base' => true)));
<add> $this->Paginator->options(array('url' => array('_full' => true)));
<ide>
<ide> $result = $this->Paginator->first();
<ide> $expected = array(
<ide> '<span',
<ide> array('a' => array(
<del> 'href' => FULL_BASE_URL . '/index/page:1/sort:Article.title/direction:DESC', 'rel' => 'first'
<add> 'href' => FULL_BASE_URL . '/index?page=1&sort=Article.title&direction=DESC', 'rel' => 'first'
<ide> )),
<ide> '<< first',
<ide> '/a',
<ide> public function testFirstBoundaries() {
<ide> $result = $this->Paginator->first();
<ide> $expected = array(
<ide> '<span',
<del> 'a' => array('href' => '/index/page:1', 'rel' => 'first'),
<add> 'a' => array('href' => '/index?page=1', 'rel' => 'first'),
<ide> '<< first',
<ide> '/a',
<ide> '/span'
<ide> public function testFirstBoundaries() {
<ide> $result = $this->Paginator->first(2);
<ide> $expected = array(
<ide> '<span',
<del> array('a' => array('href' => '/index/page:1')), '1', '/a',
<add> array('a' => array('href' => '/index?page=1')), '1', '/a',
<ide> '/span',
<ide> ' | ',
<ide> '<span',
<del> array('a' => array('href' => '/index/page:2')), '2', '/a',
<add> array('a' => array('href' => '/index?page=2')), '2', '/a',
<ide> '/span'
<ide> );
<ide> $this->assertTags($result, $expected);
<ide> public function testLast() {
<ide> $result = $this->Paginator->last();
<ide> $expected = array(
<ide> '<span',
<del> 'a' => array('href' => '/index/page:7', 'rel' => 'last'),
<add> 'a' => array('href' => '/index?page=7', 'rel' => 'last'),
<ide> 'last >>',
<ide> '/a',
<ide> '/span'
<ide> public function testLast() {
<ide> $expected = array(
<ide> '...',
<ide> '<span',
<del> 'a' => array('href' => '/index/page:7'),
<add> 'a' => array('href' => '/index?page=7'),
<ide> '7',
<ide> '/a',
<ide> '/span'
<ide> public function testLast() {
<ide> $expected = array(
<ide> '...',
<ide> '<span',
<del> array('a' => array('href' => '/index/page:6')), '6', '/a',
<add> array('a' => array('href' => '/index?page=6')), '6', '/a',
<ide> '/span',
<ide> ' | ',
<ide> '<span',
<del> array('a' => array('href' => '/index/page:7')), '7', '/a',
<add> array('a' => array('href' => '/index?page=7')), '7', '/a',
<ide> '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide> public function testLastOptions() {
<ide> 'page' => 1,
<ide> 'order' => array('Client.name' => 'DESC'),
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide>
<ide> $result = $this->Paginator->last();
<ide> $expected = array(
<ide> '<span',
<ide> array('a' => array(
<del> 'href' => '/index/page:15/sort:Client.name/direction:DESC',
<add> 'href' => '/index?page=15&sort=Client.name&direction=DESC',
<ide> 'rel' => 'last'
<ide> )),
<ide> 'last >>', '/a',
<ide> public function testLastOptions() {
<ide> $expected = array(
<ide> '...',
<ide> '<span',
<del> array('a' => array('href' => '/index/page:15/sort:Client.name/direction:DESC')), '15', '/a',
<add> array('a' => array('href' => '/index?page=15&sort=Client.name&direction=DESC')), '15', '/a',
<ide> '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide> public function testLastOptions() {
<ide> $expected = array(
<ide> '...',
<ide> '<span',
<del> array('a' => array('href' => '/index/page:14/sort:Client.name/direction:DESC')), '14', '/a',
<add> array('a' => array('href' => '/index?page=14&sort=Client.name&direction=DESC')), '14', '/a',
<ide> '/span',
<ide> ' | ',
<ide> '<span',
<del> array('a' => array('href' => '/index/page:15/sort:Client.name/direction:DESC')), '15', '/a',
<add> array('a' => array('href' => '/index?page=15&sort=Client.name&direction=DESC')), '15', '/a',
<ide> '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide> public function testLastOptions() {
<ide> $expected = array(
<ide> array('span' => array('class' => 'ellipsis')), '...', '/span',
<ide> '<span',
<del> array('a' => array('href' => '/index/page:14/sort:Client.name/direction:DESC')), '14', '/a',
<add> array('a' => array('href' => '/index?page=14&sort=Client.name&direction=DESC')), '14', '/a',
<ide> '/span',
<ide> ' | ',
<ide> '<span',
<del> array('a' => array('href' => '/index/page:15/sort:Client.name/direction:DESC')), '15', '/a',
<add> array('a' => array('href' => '/index?page=15&sort=Client.name&direction=DESC')), '15', '/a',
<ide> '/span',
<ide> );
<ide> $this->assertTags($result, $expected);
<ide> public function testCounter() {
<ide> 'page' => 1,
<ide> 'order' => array('Client.name' => 'DESC'),
<ide> ),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide> $input = 'Page %page% of %pages%, showing %current% records out of %count% total, ';
<ide> public function testHasPage() {
<ide> * @return void
<ide> */
<ide> public function testWithPlugin() {
<del> Router::reload();
<ide> Router::setRequestInfo(array(
<ide> array(
<ide> 'pass' => array(), 'named' => array(), 'prefix' => null, 'form' => array(),
<ide> public function testWithPlugin() {
<ide>
<ide> $result = $this->Paginator->link('Page 3', array('page' => 3));
<ide> $expected = array(
<del> 'a' => array('href' => '/my_plugin/magazines/index/page:3'), 'Page 3', '/a'
<add> 'a' => array('href' => '/my_plugin/magazines/index?page=3'), 'Page 3', '/a'
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $this->Paginator->options(array('url' => array('action' => 'another_index')));
<ide> $result = $this->Paginator->link('Page 3', array('page' => 3));
<ide> $expected = array(
<del> 'a' => array('href' => '/my_plugin/magazines/another_index/page:3'), 'Page 3', '/a'
<add> 'a' => array('href' => '/my_plugin/magazines/another_index?page=3'), 'Page 3', '/a'
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $this->Paginator->options(array('url' => array('controller' => 'issues')));
<ide> $result = $this->Paginator->link('Page 3', array('page' => 3));
<ide> $expected = array(
<del> 'a' => array('href' => '/my_plugin/issues/index/page:3'), 'Page 3', '/a'
<add> 'a' => array('href' => '/my_plugin/issues/index?page=3'), 'Page 3', '/a'
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $this->Paginator->options(array('url' => array('plugin' => null)));
<ide> $result = $this->Paginator->link('Page 3', array('page' => 3));
<ide> $expected = array(
<del> 'a' => array('href' => '/magazines/index/page:3'), 'Page 3', '/a'
<add> 'a' => array('href' => '/magazines/index?page=3'), 'Page 3', '/a'
<ide> );
<ide> $this->assertTags($result, $expected);
<ide>
<ide> $this->Paginator->options(array('url' => array('plugin' => null, 'controller' => 'issues')));
<ide> $result = $this->Paginator->link('Page 3', array('page' => 3));
<ide> $expected = array(
<del> 'a' => array('href' => '/issues/index/page:3'), 'Page 3', '/a'
<add> 'a' => array('href' => '/issues/index?page=3'), 'Page 3', '/a'
<ide> );
<ide> $this->assertTags($result, $expected);
<ide> }
<ide> public function testWithPlugin() {
<ide> * @return void
<ide> */
<ide> public function testNextLinkUsingDotNotation() {
<del> Router::reload();
<del> Router::parse('/');
<ide> Router::setRequestInfo(array(
<del> array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'url' => array('url' => 'accounts/')),
<del> array('base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/', 'passedArgs' => array())
<add> array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array()),
<add> array('base' => '', 'here' => '/accounts/', 'webroot' => '/')
<ide> ));
<ide>
<ide> $this->Paginator->request->params['paging']['Article']['options']['order'] = array('Article.title' => 'asc');
<ide> public function testNextLinkUsingDotNotation() {
<ide> $expected = array(
<ide> 'span' => array('class' => 'next'),
<ide> 'a' => array(
<del> 'href' => '/officespace/accounts/index/page:2/sort:Article.title/direction:asc',
<add> 'href' => '/accounts/index?page=2&sort=Article.title&direction=asc',
<ide> 'rel' => 'next'
<ide> ),
<ide> 'Next',
<ide> public function testMockAjaxProviderClassInjection() {
<ide> 'pageCount' => 7,
<ide> 'defaults' => array(),
<ide> 'options' => array(),
<del> 'paramType' => 'named'
<ide> )
<ide> );
<ide> $Paginator->PaginatorMockJs = $mock;
<ide> public function testMockAjaxProviderClassInjection() {
<ide> $Paginator = new PaginatorHelper($this->View, array('ajax' => 'Form'));
<ide> }
<ide>
<del>/**
<del> * test that querystring urls can be generated.
<del> *
<del> * @return void
<del> */
<del> public function testQuerystringUrlGeneration() {
<del> $this->Paginator->request->params['paging']['Article']['paramType'] = 'querystring';
<del> $result = $this->Paginator->url(array('page' => '4'));
<del> $expected = '/?page=4';
<del> $this->assertEquals($expected, $result);
<del>
<del> $result = $this->Paginator->url(array('page' => '4', 'limit' => 10, 'something' => 'else'));
<del> $expected = '/index/something:else?page=4&limit=10';
<del> $this->assertEquals($expected, $result);
<del> }
<del>
<del>/**
<del> * test querystring paging link.
<del> *
<del> * @return void
<del> */
<del> public function testQuerystringNextAndPrev() {
<del> $this->Paginator->request->params['paging']['Article']['paramType'] = 'querystring';
<del> $this->Paginator->request->params['paging']['Article']['page'] = 2;
<del> $this->Paginator->request->params['paging']['Article']['nextPage'] = true;
<del> $this->Paginator->request->params['paging']['Article']['prevPage'] = true;
<del>
<del> $result = $this->Paginator->next('Next');
<del> $expected = array(
<del> 'span' => array('class' => 'next'),
<del> 'a' => array('href' => '/?page=3', 'rel' => 'next'),
<del> 'Next',
<del> '/a',
<del> '/span'
<del> );
<del> $this->assertTags($result, $expected);
<del>
<del> $result = $this->Paginator->prev('Prev');
<del> $expected = array(
<del> 'span' => array('class' => 'prev'),
<del> 'a' => array('href' => '/?page=1', 'rel' => 'prev'),
<del> 'Prev',
<del> '/a',
<del> '/span'
<del> );
<del> $this->assertTags($result, $expected);
<del> }
<del>
<del>/**
<del> * test that additional keys can be flagged as query string args.
<del> *
<del> * @return void
<del> */
<del> public function testOptionsConvertKeys() {
<del> $this->Paginator->options(array(
<del> 'convertKeys' => array('something'),
<del> 'Article' => array('paramType' => 'querystring')
<del> ));
<del> $result = $this->Paginator->url(array('page' => '4', 'something' => 'bar'));
<del> $expected = '/?page=4&something=bar';
<del> $this->assertEquals($expected, $result);
<del> }
<del>
<ide> /**
<ide> * test the current() method
<ide> *
<ide> public function testWithOnePage() {
<ide> 'options' => array(
<ide> 'page' => 1,
<ide> ),
<del> 'paramType' => 'named',
<ide> )
<ide> );
<ide> $this->assertFalse($this->Paginator->numbers());
<ide> public function testWithZeroPages() {
<ide> 'page' => 0,
<ide> 'conditions' => array()
<ide> ),
<del> 'paramType' => 'named',
<ide> )
<ide> );
<ide>
<ide><path>lib/Cake/View/Helper/PaginatorHelper.php
<ide> * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
<ide> */
<ide> namespace Cake\View\Helper;
<add>
<ide> use Cake\Core\App;
<ide> use Cake\Error;
<ide> use Cake\Utility\Inflector;
<ide> class PaginatorHelper extends Helper {
<ide> * - `escape` Defines if the title field for the link should be escaped (default: true).
<ide> * - `update` DOM id of the element updated with the results of the AJAX call.
<ide> * If this key isn't specified Paginator will use plain HTML links.
<del> * - `paging['paramType']` The type of parameters to use when creating links. Valid options are
<del> * 'querystring' and 'named'. See PaginatorComponent::$settings for more information.
<del> * - `convertKeys` - A list of keys in url arrays that should be converted to querysting params
<del> * if paramType == 'querystring'.
<ide> *
<ide> * @var array
<ide> */
<ide> public function url($options = array(), $asArray = false, $model = null) {
<ide> unset($url['order']);
<ide> $url = array_merge($url, compact('sort', 'direction'));
<ide> }
<del> $url = $this->_convertUrlKeys($url, $paging['paramType']);
<ide>
<ide> if ($asArray) {
<ide> return $url;
<ide> }
<ide> return parent::url($url);
<ide> }
<ide>
<del>/**
<del> * Converts the keys being used into the format set by options.paramType
<del> *
<del> * @param array $url Array of url params to convert
<del> * @param string $type
<del> * @return array converted url params.
<del> */
<del> protected function _convertUrlKeys($url, $type) {
<del> if ($type == 'named') {
<del> return $url;
<del> }
<del> if (!isset($url['?'])) {
<del> $url['?'] = array();
<del> }
<del> foreach ($this->options['convertKeys'] as $key) {
<del> if (isset($url[$key])) {
<del> $url['?'][$key] = $url[$key];
<del> unset($url[$key]);
<del> }
<del> }
<del> return $url;
<del> }
<del>
<ide> /**
<ide> * Protected method for generating prev/next links
<ide> *
| 2
|
Go
|
Go
|
fix compilation errors after vendoring
|
c53d7e71046581775a8888706c0fd6baddb81a0b
|
<ide><path>builder/builder-next/adapters/containerimage/pull.go
<ide> import (
<ide> pkgprogress "github.com/docker/docker/pkg/progress"
<ide> "github.com/docker/docker/reference"
<ide> "github.com/moby/buildkit/cache"
<add> gw "github.com/moby/buildkit/frontend/gateway/client"
<ide> "github.com/moby/buildkit/session"
<ide> "github.com/moby/buildkit/session/auth"
<ide> "github.com/moby/buildkit/source"
<ide> func (is *imageSource) resolveLocal(refStr string) ([]byte, error) {
<ide> return img.RawJSON(), nil
<ide> }
<ide>
<del>func (is *imageSource) ResolveImageConfig(ctx context.Context, ref string, platform *ocispec.Platform) (digest.Digest, []byte, error) {
<add>func (is *imageSource) ResolveImageConfig(ctx context.Context, ref string, opt gw.ResolveImageConfigOpt) (digest.Digest, []byte, error) {
<ide> if preferLocal {
<ide> dt, err := is.resolveLocal(ref)
<ide> if err == nil {
<ide> func (is *imageSource) ResolveImageConfig(ctx context.Context, ref string, platf
<ide> dt []byte
<ide> }
<ide> res, err := is.g.Do(ctx, ref, func(ctx context.Context) (interface{}, error) {
<del> dgst, dt, err := imageutil.Config(ctx, ref, is.getResolver(ctx), is.ContentStore, platform)
<add> dgst, dt, err := imageutil.Config(ctx, ref, is.getResolver(ctx), is.ContentStore, opt.Platform)
<ide> if err != nil {
<ide> return nil, err
<ide> }
<ide> func (p *puller) resolve(ctx context.Context) error {
<ide> return
<ide> }
<ide>
<del> _, dt, err := p.is.ResolveImageConfig(ctx, ref.String(), &p.platform)
<add> _, dt, err := p.is.ResolveImageConfig(ctx, ref.String(), gw.ResolveImageConfigOpt{Platform: &p.platform})
<ide> if err != nil {
<ide> p.resolveErr = err
<ide> resolveProgressDone(err)
<ide><path>builder/builder-next/exporter/export.go
<ide> package containerimage
<ide>
<ide> import (
<ide> "context"
<add> "encoding/json"
<ide> "fmt"
<ide> "strings"
<ide>
<ide> distref "github.com/docker/distribution/reference"
<ide> "github.com/docker/docker/image"
<ide> "github.com/docker/docker/layer"
<ide> "github.com/docker/docker/reference"
<del> "github.com/moby/buildkit/cache"
<ide> "github.com/moby/buildkit/exporter"
<add> "github.com/moby/buildkit/exporter/containerimage/exptypes"
<ide> digest "github.com/opencontainers/go-digest"
<add> "github.com/pkg/errors"
<ide> "github.com/sirupsen/logrus"
<ide> )
<ide>
<ide> const (
<del> keyImageName = "name"
<del> exporterImageConfig = "containerimage.config"
<add> keyImageName = "name"
<ide> )
<ide>
<ide> // Differ can make a moby layer from a snapshot
<ide> func (e *imageExporter) Resolve(ctx context.Context, opt map[string]string) (exp
<ide> }
<ide> i.targetNames = append(i.targetNames, ref)
<ide> }
<del> case exporterImageConfig:
<del> i.config = []byte(v)
<add> case exptypes.ExporterImageConfigKey:
<add> if i.meta == nil {
<add> i.meta = make(map[string][]byte)
<add> }
<add> i.meta[k] = []byte(v)
<ide> default:
<ide> logrus.Warnf("image exporter: unknown option %s", k)
<ide> }
<ide> func (e *imageExporter) Resolve(ctx context.Context, opt map[string]string) (exp
<ide> type imageExporterInstance struct {
<ide> *imageExporter
<ide> targetNames []distref.Named
<del> config []byte
<add> meta map[string][]byte
<ide> }
<ide>
<ide> func (e *imageExporterInstance) Name() string {
<ide> return "exporting to image"
<ide> }
<ide>
<del>func (e *imageExporterInstance) Export(ctx context.Context, ref cache.ImmutableRef, opt map[string][]byte) (map[string]string, error) {
<del> if config, ok := opt[exporterImageConfig]; ok {
<del> e.config = config
<add>func (e *imageExporterInstance) Export(ctx context.Context, inp exporter.Source) (map[string]string, error) {
<add>
<add> if len(inp.Refs) > 1 {
<add> return nil, fmt.Errorf("exporting multiple references to image store is currently unsupported")
<add> }
<add>
<add> ref := inp.Ref
<add> if ref != nil && len(inp.Refs) == 1 {
<add> return nil, fmt.Errorf("invalid exporter input: Ref and Refs are mutually exclusive")
<add> }
<add>
<add> // only one loop
<add> for _, v := range inp.Refs {
<add> ref = v
<add> }
<add>
<add> var config []byte
<add> switch len(inp.Refs) {
<add> case 0:
<add> config = inp.Metadata[exptypes.ExporterImageConfigKey]
<add> case 1:
<add> platformsBytes, ok := inp.Metadata[exptypes.ExporterPlatformsKey]
<add> if !ok {
<add> return nil, fmt.Errorf("cannot export image, missing platforms mapping")
<add> }
<add> var p exptypes.Platforms
<add> if err := json.Unmarshal(platformsBytes, &p); err != nil {
<add> return nil, errors.Wrapf(err, "failed to parse platforms passed to exporter")
<add> }
<add> if len(p.Platforms) != len(inp.Refs) {
<add> return nil, errors.Errorf("number of platforms does not match references %d %d", len(p.Platforms), len(inp.Refs))
<add> }
<add> config = inp.Metadata[fmt.Sprintf("%s/%s", exptypes.ExporterImageConfigKey, p.Platforms[0].ID)]
<ide> }
<del> config := e.config
<ide>
<ide> var diffs []digest.Digest
<ide> if ref != nil {
<ide><path>builder/builder-next/worker/worker.go
<ide> import (
<ide> "github.com/moby/buildkit/executor"
<ide> "github.com/moby/buildkit/exporter"
<ide> "github.com/moby/buildkit/frontend"
<add> gw "github.com/moby/buildkit/frontend/gateway/client"
<ide> "github.com/moby/buildkit/session"
<ide> "github.com/moby/buildkit/snapshot"
<ide> "github.com/moby/buildkit/solver"
<ide> func (w *Worker) ResolveOp(v solver.Vertex, s frontend.FrontendLLBBridge) (solve
<ide> case *pb.Op_Source:
<ide> return ops.NewSourceOp(v, op, baseOp.Platform, w.SourceManager, w)
<ide> case *pb.Op_Exec:
<del> return ops.NewExecOp(v, op, w.CacheManager, w.MetadataStore, w.Executor, w)
<add> return ops.NewExecOp(v, op, w.CacheManager, w.Opt.SessionManager, w.MetadataStore, w.Executor, w)
<ide> case *pb.Op_Build:
<ide> return ops.NewBuildOp(v, op, s, w)
<ide> }
<ide> func (w *Worker) ResolveOp(v solver.Vertex, s frontend.FrontendLLBBridge) (solve
<ide> }
<ide>
<ide> // ResolveImageConfig returns image config for an image
<del>func (w *Worker) ResolveImageConfig(ctx context.Context, ref string, platform *ocispec.Platform) (digest.Digest, []byte, error) {
<add>func (w *Worker) ResolveImageConfig(ctx context.Context, ref string, opt gw.ResolveImageConfigOpt) (digest.Digest, []byte, error) {
<ide> // ImageSource is typically source/containerimage
<ide> resolveImageConfig, ok := w.ImageSource.(resolveImageConfig)
<ide> if !ok {
<ide> return "", nil, errors.Errorf("worker %q does not implement ResolveImageConfig", w.ID())
<ide> }
<del> return resolveImageConfig.ResolveImageConfig(ctx, ref, platform)
<add> return resolveImageConfig.ResolveImageConfig(ctx, ref, opt)
<ide> }
<ide>
<ide> // Exec executes a process directly on a worker
<ide> func (w *Worker) DiskUsage(ctx context.Context, opt client.DiskUsageInfo) ([]*cl
<ide> }
<ide>
<ide> // Prune deletes reclaimable build cache
<del>func (w *Worker) Prune(ctx context.Context, ch chan client.UsageInfo) error {
<del> return w.CacheManager.Prune(ctx, ch)
<add>func (w *Worker) Prune(ctx context.Context, ch chan client.UsageInfo, info client.PruneInfo) error {
<add> return w.CacheManager.Prune(ctx, ch, info)
<ide> }
<ide>
<ide> // Exporter returns exporter by name
<ide> func oneOffProgress(ctx context.Context, id string) func(err error) error {
<ide> }
<ide>
<ide> type resolveImageConfig interface {
<del> ResolveImageConfig(ctx context.Context, ref string, platform *ocispec.Platform) (digest.Digest, []byte, error)
<add> ResolveImageConfig(ctx context.Context, ref string, opt gw.ResolveImageConfigOpt) (digest.Digest, []byte, error)
<ide> }
| 3
|
Text
|
Text
|
add @shigeki and @mscdex to tc
|
392e8fd64eb9cd1cd208f07416adc36f1c8189eb
|
<ide><path>README.md
<ide> information about the governance of the io.js project, see
<ide> * **Nikolai Vavilov** <vvnicholas@gmail.com> ([@seishun](https://github.com/seishun))
<ide> * **Nicu Micleușanu** <micnic90@gmail.com> ([@micnic](https://github.com/micnic))
<ide> * **Aleksey Smolenchuk** <lxe@lxe.co> ([@lxe](https://github.com/lxe))
<del>* **Shigeki Ohtsu** <ohtsu@iij.ad.jp> ([@shigeki](https://github.com/shigeki))
<add>* **Shigeki Ohtsu** <ohtsu@iij.ad.jp> ([@shigeki](https://github.com/shigeki)) (Technical Committee)
<ide> * **Sam Roberts** <vieuxtech@gmail.com> ([@sam-github](https://github.com/sam-github))
<ide> * **Wyatt Preul** <wpreul@gmail.com> ([@geek](https://github.com/geek))
<del>* **Brian White** <mscdex@mscdex.net> ([@mscdex](https://github.com/mscdex))
<add>* **Brian White** <mscdex@mscdex.net> ([@mscdex](https://github.com/mscdex)) (Technical Committee)
<ide> * **Christian Tellnes** <christian@tellnes.no> ([@tellnes](https://github.com/tellnes))
<ide> * **Robert Kowalski** <rok@kowalski.gd> ([@robertkowalski](https://github.com/robertkowalski))
<ide> * **Julian Duque** <julianduquej@gmail.com> ([@julianduque](https://github.com/julianduque))
| 1
|
Python
|
Python
|
update the docstring of numpy.array_api
|
21923a5fa71bfadf7dee0bb5b110cc2a5719eaac
|
<ide><path>numpy/array_api/__init__.py
<ide> """
<ide> A NumPy sub-namespace that conforms to the Python array API standard.
<ide>
<del>This submodule accompanies NEP 47, which proposes its inclusion in NumPy.
<add>This submodule accompanies NEP 47, which proposes its inclusion in NumPy. It
<add>is still considered experimental, and will issue a warning when imported.
<ide>
<ide> This is a proof-of-concept namespace that wraps the corresponding NumPy
<ide> functions to give a conforming implementation of the Python array API standard
<ide> in progress, but the existing tests pass on this module, with a few
<ide> exceptions:
<ide>
<del> - Device support is not yet implemented in NumPy
<del> (https://data-apis.github.io/array-api/latest/design_topics/device_support.html).
<del> As a result, the `device` attribute of the array object is missing, and
<del> array creation functions that take the `device` keyword argument will fail
<del> with NotImplementedError.
<del>
<ide> - DLPack support (see https://github.com/data-apis/array-api/pull/106) is
<ide> not included here, as it requires a full implementation in NumPy proper
<ide> first.
<ide>
<del> - The linear algebra extension in the spec will be added in a future pull
<del>request.
<del>
<ide> The test suite is not yet complete, and even the tests that exist are not
<del> guaranteed to give a comprehensive coverage of the spec. Therefore, those
<del> reviewing this submodule should refer to the standard documents themselves.
<del>
<del>- There is a custom array object, numpy.array_api.Array, which is returned
<del> by all functions in this module. All functions in the array API namespace
<add> guaranteed to give a comprehensive coverage of the spec. Therefore, when
<add> reviewing and using this submodule, you should refer to the standard
<add> documents themselves. There are some tests in numpy.array_api.tests, but
<add> they primarily focus on things that are not tested by the official array API
<add> test suite.
<add>
<add>- There is a custom array object, numpy.array_api.Array, which is returned by
<add> all functions in this module. All functions in the array API namespace
<ide> implicitly assume that they will only receive this object as input. The only
<ide> way to create instances of this object is to use one of the array creation
<ide> functions. It does not have a public constructor on the object itself. The
<del> object is a small wrapper Python class around numpy.ndarray. The main
<del> purpose of it is to restrict the namespace of the array object to only those
<del> dtypes and only those methods that are required by the spec, as well as to
<del> limit/change certain behavior that differs in the spec. In particular:
<add> object is a small wrapper class around numpy.ndarray. The main purpose of it
<add> is to restrict the namespace of the array object to only those dtypes and
<add> only those methods that are required by the spec, as well as to limit/change
<add> certain behavior that differs in the spec. In particular:
<ide>
<del> - The array API namespace does not have scalar objects, only 0-d arrays.
<del> Operations in on Array that would create a scalar in NumPy create a 0-d
<add> - The array API namespace does not have scalar objects, only 0-D arrays.
<add> Operations on Array that would create a scalar in NumPy create a 0-D
<ide> array.
<ide>
<ide> - Indexing: Only a subset of indices supported by NumPy are required by the
<ide> information.
<ide>
<ide> - Type promotion: Some type promotion rules are different in the spec. In
<del> particular, the spec does not have any value-based casting. The
<del> Array._promote_scalar method promotes Python scalars to arrays,
<del> disallowing cross-type promotions like int -> float64 that are not allowed
<del> in the spec. Array._normalize_two_args works around some type promotion
<del> quirks in NumPy, particularly, value-based casting that occurs when one
<del> argument of an operation is a 0-d array.
<add> particular, the spec does not have any value-based casting. The spec also
<add> does not require cross-kind casting, like integer -> floating-point. Only
<add> those promotions that are explicitly required by the array API
<add> specification are allowed in this module. See NEP 47 for more info.
<add>
<add> - Functions do not automatically call asarray() on their input, and will not
<add> work if the input type is not Array. The exception is array creation
<add> functions, and Python operators on the Array object, which accept Python
<add> scalars of the same type as the array dtype.
<ide>
<ide> - All functions include type annotations, corresponding to those given in the
<ide> spec (see _typing.py for definitions of some custom types). These do not
<ide> equality, but it was considered too much extra complexity to create custom
<ide> objects to represent dtypes.
<ide>
<del>- The wrapper functions in this module do not do any type checking for things
<del> that would be impossible without leaving the array_api namespace. For
<del> example, since the array API dtype objects are just the NumPy dtype objects,
<del> one could pass in a non-spec NumPy dtype into a function.
<del>
<ide> - All places where the implementations in this submodule are known to deviate
<del> from their corresponding functions in NumPy are marked with "# Note"
<del> comments. Reviewers should make note of these comments.
<add> from their corresponding functions in NumPy are marked with "# Note:"
<add> comments.
<ide>
<ide> Still TODO in this module are:
<ide>
<del>- Device support and DLPack support are not yet implemented. These require
<del> support in NumPy itself first.
<add>- DLPack support for numpy.ndarray is still in progress. See
<add> https://github.com/numpy/numpy/pull/19083.
<ide>
<del>- The a non-default value for the `copy` keyword argument is not yet
<del> implemented on asarray. This requires support in numpy.asarray() first.
<add>- The copy=False keyword argument to asarray() is not yet implemented. This
<add> requires support in numpy.asarray() first.
<ide>
<ide> - Some functions are not yet fully tested in the array API test suite, and may
<ide> require updates that are not yet known until the tests are written.
<ide>
<add>- The spec is still in an RFC phase and may still have minor updates, which
<add> will need to be reflected here.
<add>
<add>- The linear algebra extension in the spec will be added in a future pull
<add> request.
<add>
<add>- Complex number support in array API spec is planned but not yet finalized,
<add> as are the fft extension and certain linear algebra functions such as eig
<add> that require complex dtypes.
<add>
<ide> """
<ide>
<ide> import sys
| 1
|
PHP
|
PHP
|
put use in alphabetical order
|
2a993a6ee731985b9740e6392702acbe37e08b27
|
<ide><path>src/Routing/Router.php
<ide>
<ide> use Cake\Core\Configure;
<ide> use Cake\Http\ServerRequest;
<del>use Cake\Utility\Inflector;
<ide> use Cake\Routing\Exception\MissingRouteException;
<add>use Cake\Utility\Inflector;
<ide> use Psr\Http\Message\ServerRequestInterface;
<ide>
<ide> /**
| 1
|
PHP
|
PHP
|
add last dot and put anchors to regex
|
e72875f51fc3aba1fc29f97df18905ee34827b06
|
<ide><path>tests/TestCase/View/ViewTest.php
<ide> public function testPrefixElement()
<ide> public function testElementNonExistent()
<ide> {
<ide> $this->expectException(\Cake\View\Exception\MissingElementException::class);
<del> $this->expectExceptionMessageRegExp('$Element file \"Element[\\|/]non_existent_element\.ctp\" is missing$');
<add> $this->expectExceptionMessageRegExp('#^Element file \"Element[\\|/]non_existent_element\.ctp\" is missing\.$#');
<ide>
<ide> $this->View->element('non_existent_element');
<ide> }
<ide> public function testElementNonExistent()
<ide> public function testElementInexistentPluginElement()
<ide> {
<ide> $this->expectException(\Cake\View\Exception\MissingElementException::class);
<del> $this->expectExceptionMessageRegExp('$Element file "test_plugin\.Element[\\|/]plugin_element\.ctp\" is missing$');
<add> $this->expectExceptionMessageRegExp('#^Element file "test_plugin\.Element[\\|/]plugin_element\.ctp\" is missing\.$#');
<ide>
<ide> $this->View->element('test_plugin.plugin_element');
<ide> }
| 1
|
Text
|
Text
|
move one or more tsc members to emeritus
|
610696ac543bfad6146491450abac9f8ed8bceec
|
<ide><path>README.md
<ide> For information about the governance of the Node.js project, see
<ide> **Сковорода Никита Андреевич** <<chalkerx@gmail.com>> (he/him)
<ide> * [cjihrig](https://github.com/cjihrig) -
<ide> **Colin Ihrig** <<cjihrig@gmail.com>> (he/him)
<del>* [codebytere](https://github.com/codebytere) -
<del> **Shelley Vohr** <<shelley.vohr@gmail.com>> (she/her)
<ide> * [danielleadams](https://github.com/danielleadams) -
<ide> **Danielle Adams** <<adamzdanielle@gmail.com>> (she/her)
<ide> * [fhinkel](https://github.com/fhinkel) -
<ide> **Franziska Hinkelmann** <<franziska.hinkelmann@gmail.com>> (she/her)
<del>* [gabrielschulhof](https://github.com/gabrielschulhof) -
<del> **Gabriel Schulhof** <<gabrielschulhof@gmail.com>>
<ide> * [gireeshpunathil](https://github.com/gireeshpunathil) -
<ide> **Gireesh Punathil** <<gpunathi@in.ibm.com>> (he/him)
<ide> * [jasnell](https://github.com/jasnell) -
<ide> For information about the governance of the Node.js project, see
<ide> **Ben Noordhuis** <<info@bnoordhuis.nl>>
<ide> * [chrisdickinson](https://github.com/chrisdickinson) -
<ide> **Chris Dickinson** <<christopher.s.dickinson@gmail.com>>
<add>* [codebytere](https://github.com/codebytere) -
<add> **Shelley Vohr** <<shelley.vohr@gmail.com>> (she/her)
<ide> * [danbev](https://github.com/danbev) -
<ide> **Daniel Bevenius** <<daniel.bevenius@gmail.com>> (he/him)
<ide> * [evanlucas](https://github.com/evanlucas) -
<ide> **Evan Lucas** <<evanlucas@me.com>> (he/him)
<ide> * [Fishrock123](https://github.com/Fishrock123) -
<ide> **Jeremiah Senkpiel** <<fishrock123@rocketmail.com>> (he/they)
<add>* [gabrielschulhof](https://github.com/gabrielschulhof) -
<add> **Gabriel Schulhof** <<gabrielschulhof@gmail.com>>
<ide> * [gibfahn](https://github.com/gibfahn) -
<ide> **Gibson Fahnestock** <<gibfahn@gmail.com>> (he/him)
<ide> * [indutny](https://github.com/indutny) -
| 1
|
PHP
|
PHP
|
add failing test for
|
54aef7216f8daca839df4ad6a530bb4a76b3b937
|
<ide><path>lib/Cake/Test/Case/Utility/XmlTest.php
<ide> public function testWithModel() {
<ide> $this->assertEquals(str_replace(array("\r", "\n"), '', $obj->asXML()), $expected);
<ide> }
<ide>
<add>/**
<add> * Test ampersand in text elements.
<add> *
<add> * @return void
<add> */
<add> public function testAmpInText() {
<add> $data = array(
<add> 'outer' => array(
<add> 'inner' => array('name' => 'mark & mark')
<add> )
<add> );
<add> $obj = Xml::build($data);
<add> $result = $obj->asXml();
<add> $this->assertContains('mark & mark', $result);
<add> }
<ide> }
| 1
|
Go
|
Go
|
check tmpfs mounts before create anon volume
|
f464c31668db6fe781b3195f23dc786ee09e91c0
|
<ide><path>daemon/create_unix.go
<ide> func (daemon *Daemon) createContainerOSSpecificSettings(container *container.Con
<ide>
<ide> // Skip volumes for which we already have something mounted on that
<ide> // destination because of a --volume-from.
<del> if container.IsDestinationMounted(destination) {
<add> if container.HasMountFor(destination) {
<add> logrus.WithField("container", container.ID).WithField("destination", spec).Debug("mountpoint already exists, skipping anonymous volume")
<add> // Not an error, this could easily have come from the image config.
<ide> continue
<ide> }
<ide> path, err := container.GetResourcePath(destination)
<ide><path>integration/container/create_test.go
<ide> func TestCreateWithInvalidHealthcheckParams(t *testing.T) {
<ide> })
<ide> }
<ide> }
<add>
<add>// Make sure that anonymous volumes can be overritten by tmpfs
<add>// https://github.com/moby/moby/issues/40446
<add>func TestCreateTmpfsOverrideAnonymousVolume(t *testing.T) {
<add> skip.If(t, testEnv.DaemonInfo.OSType == "windows", "windows does not support tmpfs")
<add> defer setupTest(t)()
<add> client := testEnv.APIClient()
<add> ctx := context.Background()
<add>
<add> id := ctr.Create(ctx, t, client,
<add> ctr.WithVolume("/foo"),
<add> ctr.WithTmpfs("/foo"),
<add> ctr.WithVolume("/bar"),
<add> ctr.WithTmpfs("/bar:size=999"),
<add> ctr.WithCmd("/bin/sh", "-c", "mount | grep '/foo' | grep tmpfs && mount | grep '/bar' | grep tmpfs"),
<add> )
<add>
<add> defer func() {
<add> err := client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{Force: true})
<add> assert.NilError(t, err)
<add> }()
<add>
<add> inspect, err := client.ContainerInspect(ctx, id)
<add> assert.NilError(t, err)
<add> // tmpfs do not currently get added to inspect.Mounts
<add> // Normally an anoynmous volume would, except now tmpfs should prevent that.
<add> assert.Assert(t, is.Len(inspect.Mounts, 0))
<add>
<add> chWait, chErr := client.ContainerWait(ctx, id, container.WaitConditionNextExit)
<add> assert.NilError(t, client.ContainerStart(ctx, id, types.ContainerStartOptions{}))
<add>
<add> timeout := time.NewTimer(30 * time.Second)
<add> defer timeout.Stop()
<add>
<add> select {
<add> case <-timeout.C:
<add> t.Fatal("timeout waiting for container to exit")
<add> case status := <-chWait:
<add> var errMsg string
<add> if status.Error != nil {
<add> errMsg = status.Error.Message
<add> }
<add> assert.Equal(t, int(status.StatusCode), 0, errMsg)
<add> case err := <-chErr:
<add> assert.NilError(t, err)
<add> }
<add>}
<ide><path>integration/internal/container/ops.go
<ide> package container
<ide>
<ide> import (
<ide> "fmt"
<add> "strings"
<ide>
<ide> containertypes "github.com/docker/docker/api/types/container"
<ide> mounttypes "github.com/docker/docker/api/types/mount"
<ide> func WithMount(m mounttypes.Mount) func(*TestContainerConfig) {
<ide> }
<ide>
<ide> // WithVolume sets the volume of the container
<del>func WithVolume(name string) func(*TestContainerConfig) {
<add>func WithVolume(target string) func(*TestContainerConfig) {
<ide> return func(c *TestContainerConfig) {
<ide> if c.Config.Volumes == nil {
<ide> c.Config.Volumes = map[string]struct{}{}
<ide> }
<del> c.Config.Volumes[name] = struct{}{}
<add> c.Config.Volumes[target] = struct{}{}
<ide> }
<ide> }
<ide>
<ide> func WithBind(src, target string) func(*TestContainerConfig) {
<ide> }
<ide> }
<ide>
<add>// WithTmpfs sets a target path in the container to a tmpfs
<add>func WithTmpfs(target string) func(config *TestContainerConfig) {
<add> return func(c *TestContainerConfig) {
<add> if c.HostConfig.Tmpfs == nil {
<add> c.HostConfig.Tmpfs = make(map[string]string)
<add> }
<add>
<add> spec := strings.SplitN(target, ":", 2)
<add> var opts string
<add> if len(spec) > 1 {
<add> opts = spec[1]
<add> }
<add> c.HostConfig.Tmpfs[spec[0]] = opts
<add> }
<add>}
<add>
<ide> // WithIPv4 sets the specified ip for the specified network of the container
<ide> func WithIPv4(network, ip string) func(*TestContainerConfig) {
<ide> return func(c *TestContainerConfig) {
| 3
|
Mixed
|
Javascript
|
make rejectunauthorized default to true
|
348cc80a3cbf0f4271ed30418c6ed661bdeede7b
|
<ide><path>doc/api/tls.md
<ide> added: v0.11.8
<ide> -->
<ide>
<ide> * `options` {Object}
<del> * `rejectUnauthorized` {boolean}
<add> * `rejectUnauthorized` {boolean} If not `false`, the server certificate is verified
<add> against the list of supplied CAs. An `'error'` event is emitted if
<add> verification fails; `err.code` contains the OpenSSL error code. Defaults to
<add> `true`.
<ide> * `requestCert`
<ide> * `callback` {Function} A function that will be called when the renegotiation
<ide> request has been completed.
<ide> changes:
<ide> connection/disconnection/destruction of `socket` is the user's
<ide> responsibility, calling `tls.connect()` will not cause `net.connect()` to be
<ide> called.
<del> * `rejectUnauthorized` {boolean} If `true`, the server certificate is verified
<add> * `rejectUnauthorized` {boolean} If not `false`, the server certificate is verified
<ide> against the list of supplied CAs. An `'error'` event is emitted if
<ide> verification fails; `err.code` contains the OpenSSL error code. Defaults to
<ide> `true`.
<ide> changes:
<ide> * `requestCert` {boolean} If `true` the server will request a certificate from
<ide> clients that connect and attempt to verify that certificate. Defaults to
<ide> `false`.
<del> * `rejectUnauthorized` {boolean} If `true` the server will reject any
<add> * `rejectUnauthorized` {boolean} If not `false` the server will reject any
<ide> connection which is not authorized with the list of supplied CAs. This
<del> option only has an effect if `requestCert` is `true`. Defaults to `false`.
<add> option only has an effect if `requestCert` is `true`. Defaults to `true`.
<ide> * `NPNProtocols` {string[]|Buffer} An array of strings or a `Buffer` naming
<ide> possible NPN protocols. (Protocols should be ordered by their priority.)
<ide> * `ALPNProtocols` {string[]|Buffer} An array of strings or a `Buffer` naming
<ide> changes:
<ide> opened as a server.
<ide> * `requestCert` {boolean} `true` to specify whether a server should request a
<ide> certificate from a connecting client. Only applies when `isServer` is `true`.
<del>* `rejectUnauthorized` {boolean} `true` to specify whether a server should
<del> automatically reject clients with invalid certificates. Only applies when
<del> `isServer` is `true`.
<add>* `rejectUnauthorized` {boolean} If not `false` a server automatically reject clients
<add> with invalid certificates. Only applies when `isServer` is `true`.
<ide> * `options`
<ide> * `secureContext`: An optional TLS context object from
<ide> [`tls.createSecureContext()`][]
<ide><path>lib/_tls_wrap.js
<ide> Server.prototype.setTicketKeys = function setTicketKeys(keys) {
<ide>
<ide>
<ide> Server.prototype.setOptions = function(options) {
<del> if (typeof options.requestCert === 'boolean') {
<del> this.requestCert = options.requestCert;
<del> } else {
<del> this.requestCert = false;
<del> }
<del>
<del> if (typeof options.rejectUnauthorized === 'boolean') {
<del> this.rejectUnauthorized = options.rejectUnauthorized;
<del> } else {
<del> this.rejectUnauthorized = false;
<del> }
<add> this.requestCert = options.requestCert === true;
<add> this.rejectUnauthorized = options.rejectUnauthorized !== false;
<ide>
<ide> if (options.pfx) this.pfx = options.pfx;
<ide> if (options.key) this.key = options.key;
<ide> exports.connect = function(...args /* [port,] [host,] [options,] [cb] */) {
<ide> secureContext: context,
<ide> isServer: false,
<ide> requestCert: true,
<del> rejectUnauthorized: options.rejectUnauthorized,
<add> rejectUnauthorized: options.rejectUnauthorized !== false,
<ide> session: options.session,
<ide> NPNProtocols: NPN.NPNProtocols,
<ide> ALPNProtocols: ALPN.ALPNProtocols,
<ide><path>test/parallel/test-https-foafssl.js
<ide> const https = require('https');
<ide> const options = {
<ide> key: fs.readFileSync(common.fixturesDir + '/agent.key'),
<ide> cert: fs.readFileSync(common.fixturesDir + '/agent.crt'),
<del> requestCert: true
<add> requestCert: true,
<add> rejectUnauthorized: false
<ide> };
<ide>
<ide> const modulus = 'A6F44A9C25791431214F5C87AF9E040177A8BB89AC803F7E09BBC3A5519F' +
<ide><path>test/parallel/test-tls-session-cache.js
<ide> function doTest(testOptions, callback) {
<ide> key: key,
<ide> cert: cert,
<ide> ca: [cert],
<del> requestCert: true
<add> requestCert: true,
<add> rejectUnauthorized: false
<ide> };
<ide> let requestCount = 0;
<ide> let resumeCount = 0;
| 4
|
Text
|
Text
|
update links to docker hub
|
69004ff67eed6525d56a92fdc69466c41606151a
|
<ide><path>docs/admin/logging/fluentd.md
<ide> and [its documents](http://docs.fluentd.org/).
<ide>
<ide> To use this logging driver, start the `fluentd` daemon on a host. We recommend
<ide> that you use [the Fluentd docker
<del>image](https://registry.hub.docker.com/u/fluent/fluentd/). This image is
<add>image](https://hub.docker.com/r/fluent/fluentd/). This image is
<ide> especially useful if you want to aggregate multiple container logs on a each
<ide> host then, later, transfer the logs to another Fluentd node to create an
<ide> aggregate store.
<ide><path>docs/examples/mongodb.md
<ide> MongoDB pre-installed. We'll also see how to `push` that image to the
<ide> [Docker Hub registry](https://hub.docker.com) and share it with others!
<ide>
<ide> > **Note:** This guide will show the mechanics of building a MongoDB container, but
<del>> you will probably want to use the official image on [Docker Hub]( https://registry.hub.docker.com/_/mongo/)
<add>> you will probably want to use the official image on [Docker Hub]( https://hub.docker.com/_/mongo/)
<ide>
<ide> Using Docker and containers for deploying [MongoDB](https://www.mongodb.org/)
<ide> instances will bring several benefits, such as:
<ide> Although optional, it is handy to have comments at the beginning of a
<ide> > the *parent* of your *Dockerized MongoDB* image.
<ide>
<ide> We will build our image using the latest version of Ubuntu from the
<del>[Docker Hub Ubuntu](https://registry.hub.docker.com/_/ubuntu/) repository.
<add>[Docker Hub Ubuntu](https://hub.docker.com/_/ubuntu/) repository.
<ide>
<ide> # Format: FROM repository[:version]
<ide> FROM ubuntu:latest
<ide><path>docs/examples/nodejs_web_app.md
<ide> Open the `Dockerfile` in your favorite text editor
<ide>
<ide> Define the parent image you want to use to build your own image on
<ide> top of. Here, we'll use
<del>[CentOS](https://registry.hub.docker.com/_/centos/) (tag: `centos6`)
<add>[CentOS](https://hub.docker.com/_/centos/) (tag: `centos6`)
<ide> available on the [Docker Hub](https://hub.docker.com/):
<ide>
<ide> FROM centos:centos6
<ide><path>docs/examples/running_riak_service.md
<ide> Create an empty file called `Dockerfile`:
<ide> $ touch Dockerfile
<ide>
<ide> Next, define the parent image you want to use to build your image on top
<del>of. We'll use [Ubuntu](https://registry.hub.docker.com/_/ubuntu/) (tag:
<add>of. We'll use [Ubuntu](https://hub.docker.com/_/ubuntu/) (tag:
<ide> `trusty`), which is available on [Docker Hub](https://hub.docker.com):
<ide>
<ide> # Riak
<ide><path>docs/installation/linux/cruxlinux.md
<ide> or use it as part of your `FROM` line in your `Dockerfile(s)`.
<ide> $ docker pull crux
<ide> $ docker run -i -t crux
<ide>
<del>There are also user contributed [CRUX based image(s)](https://registry.hub.docker.com/repos/crux/) on the Docker Hub.
<add>There are also user contributed [CRUX based image(s)](https://hub.docker.com/_/crux/) on the Docker Hub.
<ide>
<ide>
<ide> ## Uninstallation
<ide><path>docs/reference/glossary.md
<ide> A repository is a set of Docker images. A repository can be shared by pushing it
<ide> to a [registry](#registry) server. The different images in the repository can be
<ide> labeled using [tags](#tag).
<ide>
<del>Here is an example of the shared [nginx repository](https://registry.hub.docker.com/_/nginx/)
<del>and its [tags](https://registry.hub.docker.com/_/nginx/tags/manage/)
<add>Here is an example of the shared [nginx repository](https://hub.docker.com/_/nginx/)
<add>and its [tags](https://hub.docker.com/r/library/nginx/tags/)
<ide>
<ide> ## Swarm
<ide>
<ide><path>docs/userguide/containers/dockerimages.md
<ide> used Docker images that already exist, for example the `ubuntu` image and the
<ide>
<ide> You also discovered that Docker stores downloaded images on the Docker host. If
<ide> an image isn't already present on the host then it'll be downloaded from a
<del>registry: by default the [Docker Hub Registry](https://registry.hub.docker.com).
<add>registry: by default the [Docker Hub Registry](https://hub.docker.com).
<ide>
<ide> In this section you're going to explore Docker images a bit more
<ide> including:
<ide>
<ide> * Managing and working with images locally on your Docker host.
<ide> * Creating basic images.
<del>* Uploading images to [Docker Hub Registry](https://registry.hub.docker.com).
<add>* Uploading images to [Docker Hub Registry](https://hub.docker.com).
<ide>
<ide> ## Listing images on the host
<ide>
<ide> You can also reference by digest in `create`, `run`, and `rmi` commands, as well
<ide> Once you've built or created a new image you can push it to [Docker
<ide> Hub](https://hub.docker.com) using the `docker push` command. This
<ide> allows you to share it with others, either publicly, or push it into [a
<del>private repository](https://registry.hub.docker.com/plans/).
<add>private repository](https://hub.docker.com/account/billing-plans/).
<ide>
<ide> $ docker push ouruser/sinatra
<ide> The push refers to a repository [ouruser/sinatra] (len: 1)
<ide><path>docs/userguide/containers/dockerrepos.md
<ide> information [here](https://docs.docker.com/docker-hub/).
<ide>
<ide> Sometimes you have images you don't want to make public and share with
<ide> everyone. So Docker Hub allows you to have private repositories. You can
<del>sign up for a plan [here](https://registry.hub.docker.com/plans/).
<add>sign up for a plan [here](https://hub.docker.com/account/billing-plans/).
<ide>
<ide> ### Organizations and teams
<ide>
<ide> One of the useful aspects of private repositories is that you can share
<ide> them only with members of your organization or team. Docker Hub lets you
<ide> create organizations where you can collaborate with your colleagues and
<ide> manage private repositories. You can learn how to create and manage an organization
<del>[here](https://registry.hub.docker.com/account/organizations/).
<add>[here](https://hub.docker.com/organizations/).
<ide>
<ide> ### Automated Builds
<ide>
<ide> triggering a build and update when you push a commit.
<ide> #### To setup an Automated Build
<ide>
<ide> 1. Create a [Docker Hub account](https://hub.docker.com/) and login.
<del>2. Link your GitHub or Bitbucket account through the ["Link Accounts"](https://registry.hub.docker.com/account/accounts/) menu.
<del>3. [Configure an Automated Build](https://registry.hub.docker.com/builds/add/).
<add>2. Link your GitHub or Bitbucket account on the ["Linked Accounts & Services"](https://hub.docker.com/account/authorized-services/) page.
<add>3. Select "Create Automated Build" from the "Create" dropdown menu
<ide> 4. Pick a GitHub or Bitbucket project that has a `Dockerfile` that you want to build.
<ide> 5. Pick the branch you want to build (the default is the `master` branch).
<ide> 6. Give the Automated Build a name.
<ide><path>docs/userguide/eng-image/dockerfile_best-practices.md
<ide> various instructions available for use in a `Dockerfile`.
<ide> [Dockerfile reference for the FROM instruction](../../reference/builder.md#from)
<ide>
<ide> Whenever possible, use current Official Repositories as the basis for your
<del>image. We recommend the [Debian image](https://registry.hub.docker.com/_/debian/)
<add>image. We recommend the [Debian image](https://hub.docker.com/_/debian/)
<ide> since it’s very tightly controlled and kept extremely minimal (currently under
<ide> 100 mb), while still being a full distribution.
<ide>
<ide> The `ENTRYPOINT` instruction can also be used in combination with a helper
<ide> script, allowing it to function in a similar way to the command above, even
<ide> when starting the tool may require more than one step.
<ide>
<del>For example, the [Postgres Official Image](https://registry.hub.docker.com/_/postgres/)
<add>For example, the [Postgres Official Image](https://hub.docker.com/_/postgres/)
<ide> uses the following script as its `ENTRYPOINT`:
<ide>
<ide> ```bash
<ide> allowing the `Dockerfile` author to make a choice.
<ide>
<ide> These Official Repositories have exemplary `Dockerfile`s:
<ide>
<del>* [Go](https://registry.hub.docker.com/_/golang/)
<del>* [Perl](https://registry.hub.docker.com/_/perl/)
<del>* [Hy](https://registry.hub.docker.com/_/hylang/)
<del>* [Rails](https://registry.hub.docker.com/_/rails)
<add>* [Go](https://hub.docker.com/_/golang/)
<add>* [Perl](https://hub.docker.com/_/perl/)
<add>* [Hy](https://hub.docker.com/_/hylang/)
<add>* [Rails](https://hub.docker.com/_/rails)
<ide>
<ide> ## Additional resources:
<ide>
| 9
|
Python
|
Python
|
add more weekday operator and sensor examples
|
dd6b2e4e6cb89d9eea2f3db790cb003a2e89aeff
|
<ide><path>airflow/example_dags/example_branch_day_of_week_operator.py
<ide> from airflow import DAG
<ide> from airflow.operators.empty import EmptyOperator
<ide> from airflow.operators.weekday import BranchDayOfWeekOperator
<add>from airflow.utils.weekday import WeekDay
<ide>
<ide> with DAG(
<ide> dag_id="example_weekday_branch_operator",
<ide> # [START howto_operator_day_of_week_branch]
<ide> empty_task_1 = EmptyOperator(task_id='branch_true')
<ide> empty_task_2 = EmptyOperator(task_id='branch_false')
<add> empty_task_3 = EmptyOperator(task_id='branch_weekend')
<add> empty_task_4 = EmptyOperator(task_id='branch_mid_week')
<ide>
<ide> branch = BranchDayOfWeekOperator(
<ide> task_id="make_choice",
<ide> follow_task_ids_if_true="branch_true",
<ide> follow_task_ids_if_false="branch_false",
<ide> week_day="Monday",
<ide> )
<add> branch_weekend = BranchDayOfWeekOperator(
<add> task_id="make_weekend_choice",
<add> follow_task_ids_if_true="branch_weekend",
<add> follow_task_ids_if_false="branch_mid_week",
<add> week_day={WeekDay.SATURDAY, WeekDay.SUNDAY},
<add> )
<ide>
<del> # Run empty_task_1 if branch executes on Monday
<add> # Run empty_task_1 if branch executes on Monday, empty_task_2 otherwise
<ide> branch >> [empty_task_1, empty_task_2]
<add> # Run empty_task_3 if it's a weekend, empty_task_4 otherwise
<add> empty_task_2 >> branch_weekend >> [empty_task_3, empty_task_4]
<ide> # [END howto_operator_day_of_week_branch]
<ide><path>airflow/operators/weekday.py
<ide> class BranchDayOfWeekOperator(BaseBranchOperator):
<ide> For more information on how to use this operator, take a look at the guide:
<ide> :ref:`howto/operator:BranchDayOfWeekOperator`
<ide>
<add> **Example** (with single day): ::
<add>
<add> from airflow.operators.empty import EmptyOperator
<add>
<add> monday = EmptyOperator(task_id='monday')
<add> other_day = EmptyOperator(task_id='other_day')
<add>
<add> monday_check = DayOfWeekSensor(
<add> task_id='monday_check',
<add> week_day='Monday',
<add> use_task_logical_date=True,
<add> follow_task_ids_if_true='monday',
<add> follow_task_ids_if_false='other_day',
<add> dag=dag)
<add> monday_check >> [monday, other_day]
<add>
<add> **Example** (with :class:`~airflow.utils.weekday.WeekDay` enum): ::
<add>
<add> # import WeekDay Enum
<add> from airflow.utils.weekday import WeekDay
<add> from airflow.operators.empty import EmptyOperator
<add>
<add> workday = EmptyOperator(task_id='workday')
<add> weekend = EmptyOperator(task_id='weekend')
<add> weekend_check = BranchDayOfWeekOperator(
<add> task_id='weekend_check',
<add> week_day={WeekDay.SATURDAY, WeekDay.SUNDAY},
<add> use_task_logical_date=True,
<add> follow_task_ids_if_true='weekend',
<add> follow_task_ids_if_false='workday',
<add> dag=dag)
<add> # add downstream dependencies as you would do with any branch operator
<add> weekend_check >> [workday, weekend]
<add>
<ide> :param follow_task_ids_if_true: task id or task ids to follow if criteria met
<ide> :param follow_task_ids_if_false: task id or task ids to follow if criteria does not met
<ide> :param week_day: Day of the week to check (full name). Optionally, a set
<ide> class BranchDayOfWeekOperator(BaseBranchOperator):
<ide> * ``{WeekDay.TUESDAY}``
<ide> * ``{WeekDay.SATURDAY, WeekDay.SUNDAY}``
<ide>
<add> To use `WeekDay` enum, import it from `airflow.utils.weekday`
<add>
<ide> :param use_task_logical_date: If ``True``, uses task's logical date to compare
<ide> with is_today. Execution Date is Useful for backfilling.
<ide> If ``False``, uses system's day of the week.
<add> :param use_task_execution_day: deprecated parameter, same effect as `use_task_logical_date`
<ide> """
<ide>
<ide> def __init__(
<ide> self,
<ide> *,
<ide> follow_task_ids_if_true: Union[str, Iterable[str]],
<ide> follow_task_ids_if_false: Union[str, Iterable[str]],
<del> week_day: Union[str, Iterable[str]],
<add> week_day: Union[str, Iterable[str], WeekDay, Iterable[WeekDay]],
<ide> use_task_logical_date: bool = False,
<ide> use_task_execution_day: bool = False,
<ide> **kwargs,
<ide><path>airflow/sensors/weekday.py
<ide> # specific language governing permissions and limitations
<ide> # under the License.
<ide> import warnings
<add>from typing import Iterable, Union
<ide>
<ide> from airflow.exceptions import RemovedInAirflow3Warning
<ide> from airflow.sensors.base import BaseSensorOperator
<ide> class DayOfWeekSensor(BaseSensorOperator):
<ide> * ``{WeekDay.TUESDAY}``
<ide> * ``{WeekDay.SATURDAY, WeekDay.SUNDAY}``
<ide>
<add> To use ``WeekDay`` enum, import it from ``airflow.utils.weekday``
<add>
<ide> :param use_task_logical_date: If ``True``, uses task's logical date to compare
<ide> with week_day. Execution Date is Useful for backfilling.
<ide> If ``False``, uses system's day of the week. Useful when you
<ide> don't want to run anything on weekdays on the system.
<add> :param use_task_execution_day: deprecated parameter, same effect as `use_task_logical_date`
<ide> """
<ide>
<del> def __init__(self, *, week_day, use_task_logical_date=False, use_task_execution_day=False, **kwargs):
<add> def __init__(
<add> self,
<add> *,
<add> week_day: Union[str, Iterable[str], WeekDay, Iterable[WeekDay]],
<add> use_task_logical_date: bool = False,
<add> use_task_execution_day: bool = False,
<add> **kwargs,
<add> ) -> None:
<ide> super().__init__(**kwargs)
<ide> self.week_day = week_day
<ide> self.use_task_logical_date = use_task_logical_date
<ide> def __init__(self, *, week_day, use_task_logical_date=False, use_task_execution_
<ide> )
<ide> self._week_day_num = WeekDay.validate_week_day(week_day)
<ide>
<del> def poke(self, context: Context):
<add> def poke(self, context: Context) -> bool:
<ide> self.log.info(
<ide> 'Poking until weekday is in %s, Today is %s',
<ide> self.week_day,
| 3
|
Python
|
Python
|
preserve int division
|
3042959faf7734d4a42e2cc88552ca3d025b2958
|
<ide><path>airflow/www/app.py
<ide> from __future__ import print_function
<add>from __future__ import division
<ide> from builtins import str
<add>from past.utils import old_div
<ide> import copy
<ide> from datetime import datetime, timedelta
<ide> import dateutil.parser
<ide> def landing_times(self):
<ide> for ti in task.get_task_instances(session, from_date):
<ide> if ti.end_date:
<ide> data.append([
<del> ti.execution_date.isoformat(), (
<add> ti.execution_date.isoformat(), old_div((
<ide> ti.end_date - (
<ide> ti.execution_date + task.schedule_interval)
<del> ).total_seconds()/(60*60)
<add> ).total_seconds(),(60*60))
<ide> ])
<ide> all_data.append({'data': data, 'name': task.task_id})
<ide>
| 1
|
PHP
|
PHP
|
keep the former methods around
|
4da6fbd953589822ca804621e38771e77e3128c3
|
<ide><path>src/TestSuite/TestCase.php
<ide> public function assertTextNotContains($needle, $haystack, $message = '', $ignore
<ide> $this->assertNotContains($needle, $haystack, $message, $ignoreCase);
<ide> }
<ide>
<add>/**
<add> * Asserts HTML tags.
<add> *
<add> * @param array $expected An array, see above
<add> * @param string $string An HTML/XHTML/XML string
<add> * @param string $fullDebug Whether or not more verbose output should be used.
<add> * @return void
<add> * @deprecated 3.0. Use assertHtml() instead.
<add> */
<add> public function assertTags($string, $expected, $fullDebug = false) {
<add> static::assertHtml($expected, $string, $fullDebug);
<add> }
<add>
<ide> /**
<ide> * Asserts HTML tags.
<ide> *
<ide> protected function _normalizePath($path) {
<ide>
<ide> // @codingStandardsIgnoreStart
<ide>
<add>/**
<add> * Compatibility function to test if a value is between an acceptable range.
<add> *
<add> * @param float $result
<add> * @param float $expected
<add> * @param float $margin the rage of acceptation
<add> * @param string $message the text to display if the assertion is not correct
<add> * @return void
<add> * @deprecated 3.0. Use assertWithinRange() instead.
<add> */
<add> protected static function assertWithinMargin($result, $expected, $margin, $message = '') {
<add> static::assertWithinRange($expected, $result, $margin, $message);
<add> }
<add>
<ide> /**
<ide> * Compatibility function to test if a value is between an acceptable range.
<ide> *
| 1
|
Mixed
|
Javascript
|
prefer path over port in connect
|
6f1caadb85f70bb902c078d9b7a96e3c4b36b31f
|
<ide><path>doc/api/net.md
<ide> For TCP connections, available `options` are:
<ide> For [IPC][] connections, available `options` are:
<ide>
<ide> * `path` {string} Required. Path the client should connect to.
<del> See [Identifying paths for IPC connections][].
<add> See [Identifying paths for IPC connections][]. If provided, the TCP-specific
<add> options above are ignored.
<ide>
<ide> Returns `socket`.
<ide>
<ide><path>lib/_tls_wrap.js
<ide> exports.connect = function(...args /* [port,] [host,] [options,] [cb] */) {
<ide> tls.convertALPNProtocols(options.ALPNProtocols, ALPN);
<ide>
<ide> var socket = new TLSSocket(options.socket, {
<del> pipe: options.path && !options.port,
<add> pipe: !!options.path,
<ide> secureContext: context,
<ide> isServer: false,
<ide> requestCert: true,
<ide> exports.connect = function(...args /* [port,] [host,] [options,] [cb] */) {
<ide> socket.once('secureConnect', cb);
<ide>
<ide> if (!options.socket) {
<del> var connect_opt;
<del> if (options.path && !options.port) {
<del> connect_opt = { path: options.path };
<del> } else {
<del> connect_opt = {
<del> port: options.port,
<del> host: options.host,
<del> family: options.family,
<del> localAddress: options.localAddress,
<del> lookup: options.lookup
<del> };
<del> }
<del> socket.connect(connect_opt, function() {
<add> const connectOpt = {
<add> path: options.path,
<add> port: options.port,
<add> host: options.host,
<add> family: options.family,
<add> localAddress: options.localAddress,
<add> lookup: options.lookup
<add> };
<add> socket.connect(connectOpt, function() {
<ide> socket._start();
<ide> });
<ide> }
<ide><path>test/parallel/test-tls-net-connect-prefer-path.js
<add>'use strict';
<add>const common = require('../common');
<add>
<add>// This tests that both tls and net will ignore host and port if path is
<add>// provided.
<add>
<add>if (!common.hasCrypto)
<add> common.skip('missing crypto');
<add>
<add>common.refreshTmpDir();
<add>
<add>const tls = require('tls');
<add>const net = require('net');
<add>const fs = require('fs');
<add>const assert = require('assert');
<add>
<add>function libName(lib) {
<add> return lib === net ? 'net' : 'tls';
<add>}
<add>
<add>function mkServer(lib, tcp, cb) {
<add> const handler = (socket) => {
<add> socket.write(`${libName(lib)}:${
<add> server.address().port || server.address()
<add> }`);
<add> socket.end();
<add> };
<add> const args = [handler];
<add> if (lib === tls) {
<add> args.unshift({
<add> cert: fs.readFileSync(`${common.fixturesDir}/test_cert.pem`),
<add> key: fs.readFileSync(`${common.fixturesDir}/test_key.pem`)
<add> });
<add> }
<add> const server = lib.createServer(...args);
<add> server.listen(tcp ? 0 : common.PIPE, common.mustCall(() => cb(server)));
<add>}
<add>
<add>function testLib(lib, cb) {
<add> mkServer(lib, true, (tcpServer) => {
<add> mkServer(lib, false, (unixServer) => {
<add> const client = lib.connect({
<add> path: unixServer.address(),
<add> port: tcpServer.address().port,
<add> host: 'localhost',
<add> rejectUnauthorized: false
<add> }, () => {
<add> const bufs = [];
<add> client.on('data', common.mustCall((d) => {
<add> bufs.push(d);
<add> }));
<add> client.on('end', common.mustCall(() => {
<add> const resp = Buffer.concat(bufs).toString();
<add> assert.strictEqual(`${libName(lib)}:${unixServer.address()}`, resp);
<add> tcpServer.close();
<add> unixServer.close();
<add> cb();
<add> }));
<add> });
<add> });
<add> });
<add>}
<add>
<add>testLib(net, common.mustCall(() => testLib(tls, common.mustCall())));
| 3
|
Ruby
|
Ruby
|
fix class_option description for api generators
|
846f35203db958b0730018e23c30d9feaee3aa27
|
<ide><path>railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
<ide> class ScaffoldControllerGenerator < NamedBase # :nodoc:
<ide> class_option :orm, banner: "NAME", type: :string, required: true,
<ide> desc: "ORM to generate the controller for"
<ide> class_option :api, type: :boolean,
<del> desc: "Preconfigure smaller stack for API only apps"
<add> desc: "Generates API controller"
<ide>
<ide> argument :attributes, type: :array, default: [], banner: "field:type field:type"
<ide>
<ide><path>railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
<ide> class ScaffoldGenerator < Base # :nodoc:
<ide> check_class_collision suffix: "ControllerTest"
<ide>
<ide> class_option :api, type: :boolean,
<del> desc: "Preconfigure smaller stack for API only apps"
<add> desc: "Generates API functional tests"
<ide>
<ide> argument :attributes, type: :array, default: [], banner: "field:type field:type"
<ide>
| 2
|
Text
|
Text
|
add example to goroutines
|
e48814fd15cbecc6803ff6ae89a3d3346d59386b
|
<ide><path>guide/english/go/goroutines/index.md
<ide> title: Goroutines
<ide> ---
<ide> ## Goroutines
<ide>
<del>This is a stub. [Help our community expand it](https://github.com/freecodecamp/guides/tree/master/src/pages/go/goroutines/index.md).
<add>Goroutines are functions or methods that run concurrently with other functions or methods. Goroutines can be thought of as light weight threads. The cost of creating a Goroutine is tiny when compared to a thread.
<ide>
<del>[This quick style guide will help ensure your pull request gets accepted](https://github.com/freecodecamp/guides/blob/master/README.md).
<add>Prefix the function or method call with the keyword `go` and you will have a new Goroutine running concurrently.
<ide>
<del><!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
<add>Let's look at an example:
<ide>
<del>Goroutines are functions or methods that run concurrently with other functions or methods. Goroutines can be thought of as light weight threads. The cost of creating a Goroutine is tiny when compared to a thread.
<add> func say(s string) {
<add> fmt.Println(s)
<add> time.Sleep(100 * time.Millisecond)
<add> fmt.Println(s)
<add> }
<ide>
<del>Prefix the function or method call with the keyword `go` and you will have a new Goroutine running concurrently.
<add> func main() {
<add> go say("hello")
<add> say("world")
<add> }
<add>
<add>Output:
<add>
<add> world
<add> hello
<add> hello
<add> world
<add>
<add>You can observe that since we called `say("hello")` in a goroutine, it'll run concurrently and will print the output in no particular order in regards to the regualar function call `say("world")`.
<ide>
<ide> #### More Information:
<ide> * [A Tour of Go](https://tour.golang.org/concurrency/1)
| 1
|
Python
|
Python
|
fix benchmark non standard model
|
aefc0c04294307dfe0eef42b607d4c877e72ed5b
|
<ide><path>src/transformers/benchmark/benchmark.py
<ide> def _prepare_inference_func(self, model_name: str, batch_size: int, sequence_len
<ide> if self.args.torchscript:
<ide> config.torchscript = True
<ide>
<del> has_model_class_in_config = hasattr(config, "architecture") and len(config.architectures) > 1
<add> has_model_class_in_config = hasattr(config, "architectures") and len(config.architectures) > 0
<ide> if not self.args.only_pretrain_model and has_model_class_in_config:
<ide> try:
<ide> model_class = config.architectures[0]
<ide> def encoder_forward():
<ide> def _prepare_train_func(self, model_name: str, batch_size: int, sequence_length: int) -> Callable[[], None]:
<ide> config = self.config_dict[model_name]
<ide>
<del> has_model_class_in_config = hasattr(config, "architecture") and len(config.architectures) > 1
<add> has_model_class_in_config = hasattr(config, "architectures") and len(config.architectures) > 0
<ide> if not self.args.only_pretrain_model and has_model_class_in_config:
<ide> try:
<ide> model_class = config.architectures[0]
<ide><path>src/transformers/benchmark/benchmark_tf.py
<ide> def _prepare_inference_func(self, model_name: str, batch_size: int, sequence_len
<ide> if self.args.fp16:
<ide> raise NotImplementedError("Mixed precision is currently not supported.")
<ide>
<del> has_model_class_in_config = hasattr(config, "architecture") and len(config.architectures) > 1
<add> has_model_class_in_config = hasattr(config, "architectures") and len(config.architectures) > 0
<ide> if not self.args.only_pretrain_model and has_model_class_in_config:
<ide> try:
<ide> model_class = "TF" + config.architectures[0] # prepend 'TF' for tensorflow model
<ide> def _prepare_train_func(self, model_name: str, batch_size: int, sequence_length:
<ide> if self.args.fp16:
<ide> raise NotImplementedError("Mixed precision is currently not supported.")
<ide>
<del> has_model_class_in_config = hasattr(config, "architecture") and len(config.architectures) > 1
<add> has_model_class_in_config = hasattr(config, "architectures") and len(config.architectures) > 0
<ide> if not self.args.only_pretrain_model and has_model_class_in_config:
<ide> try:
<ide> model_class = "TF" + config.architectures[0] # prepend 'TF' for tensorflow model
| 2
|
Python
|
Python
|
fix model layer for resnet v1.
|
89edd1c3687bb7fd364390a6ecfbfeb5b65eaaf4
|
<ide><path>official/resnet/resnet_model.py
<ide> def __init__(self, resnet_size, bottleneck, num_classes, num_filters,
<ide> self.block_strides = block_strides
<ide> self.final_size = final_size
<ide> self.dtype = dtype
<add> self.pre_activation = resnet_version == 2
<ide>
<ide> def _custom_dtype_getter(self, getter, name, shape=None, dtype=DEFAULT_DTYPE,
<ide> *args, **kwargs):
<ide> def __call__(self, inputs, training):
<ide> strides=self.block_strides[i], training=training,
<ide> name='block_layer{}'.format(i + 1), data_format=self.data_format)
<ide>
<del> inputs = batch_norm(inputs, training, self.data_format)
<del> inputs = tf.nn.relu(inputs)
<add> # Only apply the BN and ReLU for model that does pre_activation in each
<add> # building/bottleneck block, eg resnet V2.
<add> if self.pre_activation:
<add> inputs = batch_norm(inputs, training, self.data_format)
<add> inputs = tf.nn.relu(inputs)
<ide>
<ide> # The current top layer has shape
<ide> # `batch_size x pool_size x pool_size x final_size`.
| 1
|
Go
|
Go
|
simplify id generation
|
141b5fc7d77fbe99fd42fb603688b842a5be34dd
|
<ide><path>image.go
<ide> package docker
<ide>
<ide> import (
<del> "bytes"
<del> "crypto/sha256"
<add> "crypto/rand"
<add> "encoding/hex"
<ide> "encoding/json"
<ide> "fmt"
<ide> "io"
<ide> "io/ioutil"
<del> "math/rand"
<ide> "os"
<ide> "path"
<ide> "strings"
<ide> func ValidateId(id string) error {
<ide> }
<ide>
<ide> func GenerateId() string {
<del> // FIXME: don't seed every time
<del> rand.Seed(time.Now().UTC().UnixNano())
<del> randomBytes := bytes.NewBuffer([]byte(fmt.Sprintf("%x", rand.Int())))
<del> id, _ := ComputeId(randomBytes) // can't fail
<del> return id
<del>}
<del>
<del>// ComputeId reads from `content` until EOF, then returns a SHA of what it read, as a string.
<del>func ComputeId(content io.Reader) (string, error) {
<del> h := sha256.New()
<del> if _, err := io.Copy(h, content); err != nil {
<del> return "", err
<add> id := make([]byte, 32)
<add> _, err := io.ReadFull(rand.Reader, id)
<add> if err != nil {
<add> panic(err) // This shouldn't happen
<ide> }
<del> return fmt.Sprintf("%x", h.Sum(nil)), nil
<add> return hex.EncodeToString(id)
<ide> }
<ide>
<ide> // Image includes convenience proxy functions to its graph
| 1
|
Javascript
|
Javascript
|
remove firefox cors workaround
|
0ca5426184f6900048588f3d2c2a4a65f9abe248
|
<ide><path>src/ng/httpBackend.js
<ide> function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument,
<ide> if (xhr.readyState == 4) {
<ide> var responseHeaders = xhr.getAllResponseHeaders();
<ide>
<del> // TODO(vojta): remove once Firefox 21 gets released.
<del> // begin: workaround to overcome Firefox CORS http response headers bug
<del> // https://bugzilla.mozilla.org/show_bug.cgi?id=608735
<del> // Firefox already patched in nightly. Should land in Firefox 21.
<del>
<del> // CORS "simple response headers" http://www.w3.org/TR/cors/
<del> var value,
<del> simpleHeaders = ["Cache-Control", "Content-Language", "Content-Type",
<del> "Expires", "Last-Modified", "Pragma"];
<del> if (!responseHeaders) {
<del> responseHeaders = "";
<del> forEach(simpleHeaders, function (header) {
<del> var value = xhr.getResponseHeader(header);
<del> if (value) {
<del> responseHeaders += header + ": " + value + "\n";
<del> }
<del> });
<del> }
<del> // end of the workaround.
<del>
<ide> // responseText is the old-school way of retrieving response (supported by IE8 & 9)
<ide> // response and responseType properties were introduced in XHR Level2 spec (supported by IE10)
<ide> completeRequest(callback,
<ide><path>test/ng/httpBackendSpec.js
<ide> describe('$httpBackend', function() {
<ide> };
<ide>
<ide> this.getAllResponseHeaders = valueFn('');
<del> // for temporary Firefox CORS workaround
<del> // see https://github.com/angular/angular.js/issues/1468
<del> this.getResponseHeader = valueFn('');
<ide> }
<ide>
<ide> callback.andCallFake(function(status, response) {
| 2
|
Python
|
Python
|
add support for texture folder
|
1998ee5fc09bbfffceb15794665e2da31cde0ba6
|
<ide><path>utils/exporters/blender/addons/io_three/__init__.py
<ide> bl_info = {
<ide> 'name': "Three.js Format",
<ide> 'author': "repsac, mrdoob, yomotsu, mpk, jpweeks",
<del> 'version': (1, 2, 2),
<add> 'version': (1, 2, 3),
<ide> 'blender': (2, 7, 3),
<ide> 'location': "File > Export",
<ide> 'description': "Export Three.js formatted JSON files.",
<ide> def execute(self, context):
<ide> raise Exception("filename not set")
<ide>
<ide> settings = save_settings_export(self.properties)
<add> settings['addon_version'] = bl_info['version']
<ide>
<ide> filepath = self.filepath
<ide> if settings[constants.COMPRESSION] == constants.MSGPACK:
<ide><path>utils/exporters/blender/addons/io_three/exporter/__init__.py
<ide> import os
<ide> import sys
<ide> import traceback
<del>from .. import constants, logger, exceptions
<add>from .. import constants, logger, exceptions, dialogs
<ide> from . import scene, geometry, api, base_classes
<ide>
<ide>
<ide> def _error_handler(func):
<ide>
<ide> def inner(filepath, options, *args, **kwargs):
<ide> level = options.get(constants.LOGGING, constants.DEBUG)
<add> version = options.get('addon_version')
<ide> logger.init('io_three.export.log', level=level)
<add> if version is not None:
<add> logger.debug("Addon Version %s", version)
<ide> api.init()
<ide>
<ide> try:
<ide> def export_scene(filepath, options):
<ide>
<ide> @_error_handler
<ide> def export_geometry(filepath, options, node=None):
<add> msg = ""
<add> exception = None
<ide> if node is None:
<ide> node = api.active_object()
<ide> if node is None:
<del> msg = 'Nothing selected'
<add> msg = "Nothing selected"
<ide> logger.error(msg)
<del> raise exceptions.SelectionError(msg)
<add> exception = exceptions.SelectionError
<ide> if node.type != 'MESH':
<del> msg = 'Not a valid mesh object'
<del> raise exceptions.GeometryError(msg)
<add> msg = "%s is not a valid mesh object" % node.name
<add> logger.error(msg)
<add> exception = exceptions.GeometryError
<ide>
<add> if exception is not None:
<add> if api.batch_mode():
<add> raise exception(msg)
<add> else:
<add> dialogs.error(msg)
<add> return
<add>
<ide> mesh = api.object.mesh(node, options)
<ide> parent = base_classes.BaseScene(filepath, options)
<ide> geo = geometry.Geometry(mesh, parent)
<ide><path>utils/exporters/blender/addons/io_three/exporter/api/__init__.py
<ide> def active_object():
<ide> return bpy.context.scene.objects.active
<ide>
<ide>
<add>def batch_mode():
<add> """
<add>
<add> :return: Whether or not the session is interactive
<add> :rtype: bool
<add>
<add> """
<add> return bpy.context.area is None
<add>
<add>
<ide> def init():
<ide> """Initializing the api module. Required first step before
<ide> initializing the actual export process.
| 3
|
PHP
|
PHP
|
fix broken feature
|
9e4a866cfb0420f4ea6cb4e86b1fbd97a4b8c264
|
<ide><path>src/Illuminate/Database/Seeder.php
<ide> abstract class Seeder
<ide> protected $command;
<ide>
<ide> /**
<del> * Seed the given connection from the given path.
<add> * Run the given seeder class.
<ide> *
<ide> * @param array|string $class
<ide> * @param bool $silent
<del> * @param mixed ...$parameters
<add> * @param array $parameters
<ide> * @return $this
<ide> */
<del> public function call($class, $silent = false, ...$parameters)
<add> public function call($class, $silent = false, array $parameters = [])
<ide> {
<ide> $classes = Arr::wrap($class);
<ide>
<ide> public function call($class, $silent = false, ...$parameters)
<ide>
<ide> $startTime = microtime(true);
<ide>
<del> $seeder->__invoke(...$parameters);
<add> $seeder->__invoke($parameters);
<ide>
<ide> $runTime = number_format((microtime(true) - $startTime) * 1000, 2);
<ide>
<ide> public function call($class, $silent = false, ...$parameters)
<ide> }
<ide>
<ide> /**
<del> * Silently seed the given connection from the given path.
<add> * Run the given seeder class.
<ide> *
<ide> * @param array|string $class
<del> * @param mixed ...$parameters
<add> * @param array $parameters
<ide> * @return void
<ide> */
<del> public function callSilent($class, ...$parameters)
<add> public function callWith($class, array $parameters = [])
<ide> {
<del> $this->call($class, true, ...$parameters);
<add> $this->call($class, false, $parameters);
<add> }
<add>
<add> /**
<add> * Silently run the given seeder class.
<add> *
<add> * @param array|string $class
<add> * @param array $parameters
<add> * @return void
<add> */
<add> public function callSilent($class, array $parameters = [])
<add> {
<add> $this->call($class, true, $parameters);
<ide> }
<ide>
<ide> /**
<ide> public function setCommand(Command $command)
<ide> /**
<ide> * Run the database seeds.
<ide> *
<del> * @param mixed ...$parameters
<add> * @param array $parameters
<ide> * @return mixed
<ide> *
<ide> * @throws \InvalidArgumentException
<ide> */
<del> public function __invoke(...$parameters)
<add> public function __invoke(array $parameters = [])
<ide> {
<ide> if (! method_exists($this, 'run')) {
<ide> throw new InvalidArgumentException('Method [run] missing from '.get_class($this));
<ide><path>tests/Database/DatabaseSeederTest.php
<ide> public function testSendParamsOnCallMethodWithDeps()
<ide> $seeder = new TestDepsSeeder;
<ide> $seeder->setContainer($container);
<ide>
<del> $seeder->__invoke('test1', 'test2');
<add> $seeder->__invoke(['test1', 'test2']);
<ide>
<ide> $container->shouldHaveReceived('call')->once()->with([$seeder, 'run'], ['test1', 'test2']);
<ide> }
| 2
|
Python
|
Python
|
check basedir for dataset path
|
a98eec34f7b7df642252733af31f42ec67209071
|
<ide><path>keras/datasets/data_utils.py
<ide> def http_error_default(self, url, fp, errcode, errmsg, headers):
<ide>
<ide>
<ide> def get_file(fname, origin, untar=False):
<del> datadir = os.path.expanduser(os.path.join('~', '.keras', 'datasets'))
<del> if not os.access(datadir, os.W_OK):
<del> datadir = os.path.join('/tmp', '.keras', 'datasets')
<add> datadir_base = os.path.expanduser(os.path.join('~', '.keras'))
<add> if not os.access(datadir_base, os.W_OK):
<add> datadir_base = os.path.join('/tmp', '.keras')
<add> datadir = os.path.join(datadir_base, 'datasets')
<ide> if not os.path.exists(datadir):
<ide> os.makedirs(datadir)
<ide>
| 1
|
Python
|
Python
|
add type hints for m2m
|
2848c9ce42eba9717fc4cf60ebbbeb0f18ee5c9a
|
<ide><path>src/transformers/models/m2m_100/modeling_m2m_100.py
<ide>
<ide> import math
<ide> import random
<del>from typing import Optional, Tuple, Union
<add>from typing import List, Optional, Tuple, Union
<ide>
<ide> import torch
<ide> from torch import nn
<ide> def __init__(self, config: M2M100Config, embed_tokens: Optional[nn.Embedding] =
<ide>
<ide> def forward(
<ide> self,
<del> input_ids=None,
<del> attention_mask=None,
<del> head_mask=None,
<del> inputs_embeds=None,
<del> output_attentions=None,
<del> output_hidden_states=None,
<del> return_dict=None,
<add> input_ids: Optional[torch.Tensor] = None,
<add> attention_mask: Optional[torch.Tensor] = None,
<add> head_mask: Optional[torch.Tensor] = None,
<add> inputs_embeds: Optional[torch.Tensor] = None,
<add> output_attentions: Optional[bool] = None,
<add> output_hidden_states: Optional[bool] = None,
<add> return_dict: Optional[bool] = None,
<ide> ):
<ide> r"""
<ide> Args:
<ide> def __init__(self, config: M2M100Config, embed_tokens: Optional[nn.Embedding] =
<ide>
<ide> def forward(
<ide> self,
<del> input_ids=None,
<del> attention_mask=None,
<del> encoder_hidden_states=None,
<del> encoder_attention_mask=None,
<del> head_mask=None,
<del> cross_attn_head_mask=None,
<del> past_key_values=None,
<del> inputs_embeds=None,
<del> use_cache=None,
<del> output_attentions=None,
<del> output_hidden_states=None,
<del> return_dict=None,
<add> input_ids: Optional[torch.Tensor] = None,
<add> attention_mask: Optional[torch.Tensor] = None,
<add> encoder_hidden_states: Optional[torch.Tensor] = None,
<add> encoder_attention_mask: Optional[torch.Tensor] = None,
<add> head_mask: Optional[torch.Tensor] = None,
<add> cross_attn_head_mask: Optional[torch.Tensor] = None,
<add> past_key_values: Optional[List[torch.FloatTensor]] = None,
<add> inputs_embeds: Optional[torch.Tensor] = None,
<add> use_cache: Optional[bool] = None,
<add> output_attentions: Optional[bool] = None,
<add> output_hidden_states: Optional[bool] = None,
<add> return_dict: Optional[bool] = None,
<ide> ):
<ide> r"""
<ide> Args:
| 1
|
Go
|
Go
|
migrate some calls to new client function
|
6977f468bbcf43864a5acf6c89c331a9180169e5
|
<ide><path>integration-cli/daemon/daemon.go
<ide> func (d *Daemon) WaitRun(contID string) error {
<ide>
<ide> // Info returns the info struct for this daemon
<ide> func (d *Daemon) Info(t require.TestingT) types.Info {
<del> apiclient, err := request.NewClientForHost(d.Sock())
<add> apiclient, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
<ide> require.NoError(t, err)
<ide> info, err := apiclient.Info(context.Background())
<ide> require.NoError(t, err)
<ide><path>integration-cli/docker_api_containers_test.go
<ide> func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *check.C) {
<ide> Image: "busybox",
<ide> }
<ide>
<del> cli, err := request.NewEnvClientWithVersion("v1.18")
<add> cli, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion("v1.18"))
<add> c.Assert(err, checker.IsNil)
<ide>
<ide> _, err = cli.ContainerCreate(context.Background(), &config, &containertypes.HostConfig{}, &networktypes.NetworkingConfig{}, "")
<ide> c.Assert(err, checker.IsNil)
<ide><path>integration-cli/docker_api_images_test.go
<ide> func (s *DockerSuite) TestAPIImagesSizeCompatibility(c *check.C) {
<ide> Labels map[string]string
<ide> }
<ide>
<del> cli, err = request.NewEnvClientWithVersion("v1.24")
<add> cli, err = client.NewClientWithOpts(client.FromEnv, client.WithVersion("v1.24"))
<ide> c.Assert(err, checker.IsNil)
<ide> defer cli.Close()
<ide>
<ide><path>integration-cli/docker_api_inspect_unix_test.go
<ide> package main
<ide> import (
<ide> "encoding/json"
<ide>
<add> "github.com/docker/docker/client"
<ide> "github.com/docker/docker/integration-cli/checker"
<del> "github.com/docker/docker/integration-cli/request"
<ide> "github.com/go-check/check"
<ide> "golang.org/x/net/context"
<ide> )
<ide> func (s *DockerSuite) TestInspectAPICpusetInConfigPre120(c *check.C) {
<ide>
<ide> name := "cpusetinconfig-pre120"
<ide> dockerCmd(c, "run", "--name", name, "--cpuset-cpus", "0", "busybox", "true")
<del> cli, err := request.NewEnvClientWithVersion("v1.19")
<add> cli, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion("v1.19"))
<ide> c.Assert(err, checker.IsNil)
<ide> defer cli.Close()
<ide> _, body, err := cli.ContainerInspectWithRaw(context.Background(), name, false)
<ide><path>integration-cli/docker_utils_test.go
<ide> func waitInspectWithArgs(name, expr, expected string, timeout time.Duration, arg
<ide> }
<ide>
<ide> func getInspectBody(c *check.C, version, id string) []byte {
<del> cli, err := request.NewEnvClientWithVersion(version)
<add> cli, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion(version))
<ide> c.Assert(err, check.IsNil)
<ide> defer cli.Close()
<ide> _, body, err := cli.ContainerInspectWithRaw(context.Background(), id, false)
<ide><path>integration-cli/request/request.go
<ide> import (
<ide> "strings"
<ide> "time"
<ide>
<del> "github.com/docker/docker/api"
<ide> dclient "github.com/docker/docker/client"
<ide> "github.com/docker/docker/opts"
<ide> "github.com/docker/docker/pkg/ioutils"
<ide> func NewHTTPClient(host string) (*http.Client, error) {
<ide>
<ide> // NewClient returns a new Docker API client
<ide> func NewClient() (dclient.APIClient, error) {
<del> return NewClientForHost(DaemonHost())
<del>}
<del>
<del>// NewClientForHost returns a Docker API client for the host
<del>func NewClientForHost(host string) (dclient.APIClient, error) {
<del> httpClient, err := NewHTTPClient(host)
<del> if err != nil {
<del> return nil, err
<del> }
<del> return dclient.NewClient(host, api.DefaultVersion, httpClient, nil)
<add> return dclient.NewClientWithOpts(dclient.WithHost(DaemonHost()))
<ide> }
<ide>
<ide> // FIXME(vdemeester) httputil.ClientConn is deprecated, use http.Client instead (closer to actual client)
<ide> func DaemonHost() string {
<ide> }
<ide> return daemonURLStr
<ide> }
<del>
<del>// NewEnvClientWithVersion returns a docker client with a specified version.
<del>// See: github.com/docker/docker/client `NewEnvClient()`
<del>func NewEnvClientWithVersion(version string) (*dclient.Client, error) {
<del> if version == "" {
<del> return nil, errors.New("version not specified")
<del> }
<del>
<del> var httpClient *http.Client
<del> if os.Getenv("DOCKER_CERT_PATH") != "" {
<del> tlsConfig, err := getTLSConfig()
<del> if err != nil {
<del> return nil, err
<del> }
<del> httpClient = &http.Client{
<del> Transport: &http.Transport{
<del> TLSClientConfig: tlsConfig,
<del> },
<del> }
<del> }
<del>
<del> host := os.Getenv("DOCKER_HOST")
<del> if host == "" {
<del> host = dclient.DefaultDockerHost
<del> }
<del>
<del> cli, err := dclient.NewClient(host, version, httpClient, nil)
<del> if err != nil {
<del> return cli, err
<del> }
<del> return cli, nil
<del>}
<ide><path>integration/container/kill_test.go
<ide> import (
<ide> func TestKillContainerInvalidSignal(t *testing.T) {
<ide> defer setupTest(t)()
<ide> client := request.NewAPIClient(t)
<del> t.Parallel()
<ide> ctx := context.Background()
<ide> c, err := client.ContainerCreate(ctx,
<ide> &container.Config{
<ide> func TestKillContainer(t *testing.T) {
<ide> for _, tc := range testCases {
<ide> tc := tc
<ide> t.Run(tc.doc, func(t *testing.T) {
<del> t.Parallel()
<ide> ctx := context.Background()
<ide> c, err := client.ContainerCreate(ctx,
<ide> &container.Config{
<ide> func TestKillWithStopSignalAndRestartPolicies(t *testing.T) {
<ide> for _, tc := range testCases {
<ide> tc := tc
<ide> t.Run(tc.doc, func(t *testing.T) {
<del> t.Parallel()
<ide> ctx := context.Background()
<ide> c, err := client.ContainerCreate(ctx,
<ide> &container.Config{
<ide> func TestKillWithStopSignalAndRestartPolicies(t *testing.T) {
<ide> func TestKillStoppedContainer(t *testing.T) {
<ide> skip.If(t, testEnv.OSType != "linux") // Windows only supports 1.25 or later
<ide> defer setupTest(t)()
<del> t.Parallel()
<ide> ctx := context.Background()
<ide> client := request.NewAPIClient(t)
<ide> c, err := client.ContainerCreate(ctx,
<ide> func TestKillStoppedContainer(t *testing.T) {
<ide> func TestKillStoppedContainerAPIPre120(t *testing.T) {
<ide> skip.If(t, testEnv.OSType != "linux") // Windows only supports 1.25 or later
<ide> defer setupTest(t)()
<del> t.Parallel()
<ide> ctx := context.Background()
<ide> client := request.NewAPIClient(t, client.WithVersion("1.19"))
<ide> c, err := client.ContainerCreate(ctx,
<ide><path>integration/network/inspect_test.go
<ide> import (
<ide> "github.com/docker/docker/api/types/swarm"
<ide> "github.com/docker/docker/client"
<ide> "github.com/docker/docker/integration-cli/daemon"
<del> "github.com/docker/docker/integration-cli/request"
<ide> "github.com/gotestyourself/gotestyourself/poll"
<ide> "github.com/stretchr/testify/require"
<ide> "golang.org/x/net/context"
<ide> func TestInspectNetwork(t *testing.T) {
<ide> defer setupTest(t)()
<ide> d := newSwarm(t)
<ide> defer d.Stop(t)
<del> client, err := request.NewClientForHost(d.Sock())
<add> client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
<ide> require.NoError(t, err)
<ide>
<ide> overlayName := "overlay1"
<ide><path>integration/secret/secret_test.go
<ide> import (
<ide> "testing"
<ide>
<ide> swarmtypes "github.com/docker/docker/api/types/swarm"
<del> "github.com/docker/docker/integration-cli/request"
<add> "github.com/docker/docker/client"
<ide> "github.com/docker/docker/integration/util/swarm"
<ide> "github.com/gotestyourself/gotestyourself/skip"
<ide> "github.com/stretchr/testify/assert"
<ide> func TestSecretInspect(t *testing.T) {
<ide> defer setupTest(t)()
<ide> d := swarm.NewSwarm(t, testEnv)
<ide> defer d.Stop(t)
<del> client, err := request.NewClientForHost(d.Sock())
<add> client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
<ide> require.NoError(t, err)
<ide>
<ide> ctx := context.Background()
<ide><path>integration/service/create_test.go
<ide> import (
<ide> "github.com/docker/docker/api/types/filters"
<ide> swarmtypes "github.com/docker/docker/api/types/swarm"
<ide> "github.com/docker/docker/client"
<del> "github.com/docker/docker/integration-cli/request"
<ide> "github.com/docker/docker/integration/util/swarm"
<ide> "github.com/gotestyourself/gotestyourself/poll"
<ide> "github.com/stretchr/testify/assert"
<ide> func TestCreateServiceMultipleTimes(t *testing.T) {
<ide> defer setupTest(t)()
<ide> d := swarm.NewSwarm(t, testEnv)
<ide> defer d.Stop(t)
<del> client, err := request.NewClientForHost(d.Sock())
<add> client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
<ide> require.NoError(t, err)
<ide>
<ide> overlayName := "overlay1"
<ide> func TestCreateWithDuplicateNetworkNames(t *testing.T) {
<ide> defer setupTest(t)()
<ide> d := swarm.NewSwarm(t, testEnv)
<ide> defer d.Stop(t)
<del> client, err := request.NewClientForHost(d.Sock())
<add> client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
<ide> require.NoError(t, err)
<ide>
<ide> name := "foo"
<ide> func TestCreateServiceSecretFileMode(t *testing.T) {
<ide> defer setupTest(t)()
<ide> d := swarm.NewSwarm(t, testEnv)
<ide> defer d.Stop(t)
<del> client, err := request.NewClientForHost(d.Sock())
<add> client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
<ide> require.NoError(t, err)
<ide>
<ide> ctx := context.Background()
<ide> func TestCreateServiceConfigFileMode(t *testing.T) {
<ide> defer setupTest(t)()
<ide> d := swarm.NewSwarm(t, testEnv)
<ide> defer d.Stop(t)
<del> client, err := request.NewClientForHost(d.Sock())
<add> client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
<ide> require.NoError(t, err)
<ide>
<ide> ctx := context.Background()
<ide><path>integration/service/inspect_test.go
<ide> import (
<ide> "github.com/docker/docker/api/types/filters"
<ide> swarmtypes "github.com/docker/docker/api/types/swarm"
<ide> "github.com/docker/docker/client"
<del> "github.com/docker/docker/integration-cli/request"
<ide> "github.com/docker/docker/integration/util/swarm"
<ide> "github.com/gotestyourself/gotestyourself/poll"
<ide> "github.com/gotestyourself/gotestyourself/skip"
<ide> func TestInspect(t *testing.T) {
<ide> defer setupTest(t)()
<ide> d := swarm.NewSwarm(t, testEnv)
<ide> defer d.Stop(t)
<del> client, err := request.NewClientForHost(d.Sock())
<add> client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
<ide> require.NoError(t, err)
<ide>
<ide> var before = time.Now()
<ide><path>integration/service/network_test.go
<ide> import (
<ide> "github.com/docker/docker/api/types"
<ide> "github.com/docker/docker/api/types/container"
<ide> "github.com/docker/docker/api/types/network"
<del> "github.com/docker/docker/integration-cli/request"
<add> "github.com/docker/docker/client"
<ide> "github.com/docker/docker/integration/util/swarm"
<ide> "github.com/stretchr/testify/assert"
<ide> "github.com/stretchr/testify/require"
<ide> func TestDockerNetworkConnectAlias(t *testing.T) {
<ide> defer setupTest(t)()
<ide> d := swarm.NewSwarm(t, testEnv)
<ide> defer d.Stop(t)
<del> client, err := request.NewClientForHost(d.Sock())
<add> client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
<ide> require.NoError(t, err)
<ide> ctx := context.Background()
<ide>
<ide><path>internal/test/environment/environment.go
<ide> type PlatformDefaults struct {
<ide>
<ide> // New creates a new Execution struct
<ide> func New() (*Execution, error) {
<del> client, err := client.NewEnvClient()
<add> client, err := client.NewClientWithOpts(client.FromEnv)
<ide> if err != nil {
<ide> return nil, errors.Wrapf(err, "failed to create client")
<ide> }
| 13
|
Python
|
Python
|
add first draft of spacy+keras integration example
|
f60cefc048c921e053d6ff8bc23f0f33ecb13187
|
<ide><path>examples/deep_learning_keras.py
<add>import numpy
<add>from collections import defaultdict
<add>
<add>import spacy
<add>
<add>
<add>class SentimentAnalyser(object):
<add> @classmethod
<add> def load(cls, path, nlp):
<add> pass
<add>
<add> def __init__(self, model):
<add> self._model = model
<add>
<add> def __call__(self, doc):
<add> X = get_features([doc], self.max_length)
<add> y = self._keras_model.predict(X)
<add> self.set_sentiment(doc, y)
<add>
<add> def pipe(self, docs, batch_size=1000, n_threads=2):
<add> for minibatch in partition_all(batch_size, docs):
<add> Xs = _get_features(minibatch)
<add> ys = self._model.predict(X)
<add> for i, doc in enumerate(minibatch):
<add> doc.user_data['sentiment'] = ys[i]
<add>
<add> def set_sentiment(self, doc, y):
<add> doc.user_data['sentiment'] = y
<add>
<add>
<add>def compile_lstm(embeddings, shape, settings, optimizer):
<add> model = Sequential()
<add> model.add(
<add> Embedding(
<add> embeddings.shape[1],
<add> embeddings.shape[0],
<add> input_length=shape['max_length'],
<add> trainable=False,
<add> weights=[embeddings]
<add> )
<add> )
<add> model.add(Bidirectional(LSTM(shape['nr_hidden'])))
<add> model.add(Dropout(settings['dropout']))
<add> model.add(Dense(shape['nr_class'], activation='sigmoid'))
<add> return model
<add>
<add>
<add>def get_embeddings(vocab):
<add> '''
<add> Get a numpy vector of the word embeddings. The Lexeme.rank attribute will
<add> be the index into the table. We're going to be "decadent" here and use
<add> 1m vectors, because we're not going to fine-tune them.
<add> '''
<add> max_rank = max(lex.rank for lex in nlp.vocab if lex.has_vector)
<add> vectors = numpy.ndarray((max_rank+1, nlp.vocab.vectors_length), dtype='float32')
<add> for lex in vocab:
<add> if lex.has_vector:
<add> vectors[lex.rank] = lex.vector
<add> return vectors
<add>
<add>
<add>def get_features(docs, max_length):
<add> Xs = numpy.zeros(len(docs), max_length, dtype='int32')
<add> for i, doc in enumerate(minibatch):
<add> for j, token in enumerate(doc[:max_length]):
<add> Xs[i, j] = token.rank if token.has_vector else 0
<add> return Xs
<add>
<add>
<add>def train(train_texts, train_labels, dev_texts, dev_labels,
<add> lstm_shape, lstm_settings, lstm_optimizer, batch_size=100, nb_epoch=5):
<add> nlp = spacy.load('en', parser=False, tagger=False, entity=False)
<add> model = _compile_model(
<add> _get_embeddings(
<add> nlp.vocab),
<add> lstm_shape,
<add> lstm_settings,
<add> lstm_optimizer)
<add> model.fit(
<add> _get_features(
<add> nlp.pipe(
<add> train_texts)),
<add> train_ys,
<add> _get_features(
<add> nlp.pipe(
<add> dev_texts)),
<add> dev_ys,
<add> nb_epoch=nb_epoch,
<add> batch_size=batch_size)
<add> model.save(model_dir)
<add>
<add>
<add>def demonstrate_runtime(model_dir, texts):
<add> '''Demonstrate runtime usage of the custom sentiment model with spaCy.
<add>
<add> Here we return a dictionary mapping entities to the average sentiment of the
<add> documents they occurred in.
<add> '''
<add> def create_pipeline(nlp):
<add> '''
<add> This could be a lambda, but named functions are easier to read in Python.
<add> '''
<add> return [nlp.tagger, nlp.entity, SentimentAnalyser.load(model_dir, nlp)]
<add>
<add> nlp = spacy.load('en', create_pipeline=create_pipeline)
<add> entity_sentiments = defaultdict(float)
<add> entity_freqs = defaultdict(int)
<add> for doc in nlp.pipe(texts, batch_size=1000, n_threads=4):
<add> sentiment = doc.user_data['sentiment']
<add> for ent in doc.ents:
<add> entity_sentiments[ent.text] += sentiment
<add> entity_freqs[ent.text] += 1
<add> # Compute estimate of P(sentiment | entity)
<add> for entity, sentiment in entity_freqs.items():
<add> entity_sentiments[entity] /= entity_freqs[entity]
<add> return entity_sentiments
<add>
<add>
<add>def read_data(data_dir, limit=0):
<add> examples = []
<add> for subdir, label in (('pos', 1), ('neg', 0)):
<add> for filename in (data_dir / subdir).iterdir():
<add> with filename.open() as file_:
<add> text = filename.read()
<add> examples.append((text, label))
<add> random.shuffle(examples)
<add> if limit >= 1:
<add> examples = examples[:limit]
<add> return zip(*examples) # Unzips into two lists
<add>
<add>
<add>@plac.annotations(
<add> language=("The language to train", "positional", None, str, ['en','de', 'zh']),
<add> train_loc=("Location of training file or directory"),
<add> dev_loc=("Location of development file or directory"),
<add> model_dir=("Location of output model directory",),
<add> is_runtime=("Demonstrate run-time usage", "flag", "r", bool),
<add> nr_hidden=("Number of hidden units", "flag", "H", int),
<add> max_length=("Maximum sentence length", "flag", "L", int),
<add> dropout=("Dropout", "flag", "d", float),
<add> nr_epoch=("Number of training epochs", "flag", "i", int),
<add> batch_size=("Size of minibatches for training LSTM", "flag", "b", int),
<add> nr_examples=("Limit to N examples", "flag", "n", int)
<add>)
<add>def main(model_dir, train_dir, dev_dir,
<add> is_runtime=False,
<add> nr_hidden=64, max_length=100, # Shape
<add> dropout=0.5, # General NN config
<add> nb_epoch=5, batch_size=100, nr_examples=-1): # Training params
<add> if is_runtime:
<add> dev_texts, dev_labels = read_dev(dev_dir)
<add> demonstrate_runtime(model_dir, dev_texts)
<add> else:
<add> train_texts, train_labels = read_data(train_dir, limit=nr_examples)
<add> dev_texts, dev_labels = read_dev(dev_dir)
<add> lstm = train(train_texts, train_labels, dev_texts, dev_labels,
<add> {'nr_hidden': nr_hidden, 'max_length': max_length},
<add> {'dropout': 0.5},
<add> {},
<add> nb_epoch=nb_epoch, batch_size=batch_size)
<add>
<add>
<add>if __name__ == '__main__':
<add> plac.call(main)
| 1
|
PHP
|
PHP
|
remove duplicate linebreks
|
b4c81de41528e65d61e12b5959a6b24921e4c497
|
<ide><path>src/Illuminate/Console/Scheduling/Event.php
<ide> public function buildCommand()
<ide> $command = $this->command.' > '.$this->output.' 2>&1 &';
<ide> }
<ide>
<del>
<ide> return $this->user ? 'sudo -u '.$this->user.' '.$command : $command;
<ide> }
<ide>
<ide><path>src/Illuminate/Database/Eloquent/Model.php
<ide> public function getRelation($relation)
<ide> return $this->relations[$relation];
<ide> }
<ide>
<del>
<ide> /**
<ide> * Determine if the given relation is loaded.
<ide> *
<ide><path>src/Illuminate/Foundation/helpers.php
<ide> function factory()
<ide> }
<ide> }
<ide>
<del>
<ide> if ( ! function_exists('get'))
<ide> {
<ide> /**
<ide><path>src/Illuminate/Support/helpers.php
<ide> function array_sort_recursive($array) {
<ide> }
<ide> }
<ide>
<del>
<ide> if ( ! function_exists('snake_case'))
<ide> {
<ide> /**
| 4
|
Python
|
Python
|
add migration docs for legacy_tf_layers/pooling.py
|
a4f3d7d988712ba33bb91079517d77d1f4c616dc
|
<ide><path>keras/legacy_tf_layers/pooling.py
<ide> class AveragePooling1D(keras_layers.AveragePooling1D, base.Layer):
<ide> `(batch, length, channels)` while `channels_first` corresponds to
<ide> inputs with shape `(batch, channels, length)`.
<ide> name: A string, the name of the layer.
<add>
<add>
<add> @compatibility(TF2)
<add> This API is not compatible with eager execution or `tf.function`.
<add>
<add> Please refer to [tf.layers section of the migration guide]
<add> (https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
<add> to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
<add> layer is `tf.keras.layers.AveragePooling1D`.
<add>
<add>
<add> #### Structural Mapping to Native TF2
<add>
<add> None of the supported arguments have changed name.
<add>
<add> Before:
<add>
<add> ```python
<add> pooling = tf.compat.v1.layers.AveragePooling1D(pool_size=2, strides=2)
<add> ```
<add>
<add> After:
<add>
<add> ```python
<add> pooling = tf.keras.layers.AveragePooling1D(pool_size=2, strides=2)
<add> ```
<add> @end_compatibility
<ide> """
<ide>
<ide> def __init__(self, pool_size, strides,
<ide> def average_pooling1d(inputs, pool_size, strides,
<ide>
<ide> Raises:
<ide> ValueError: if eager execution is enabled.
<add>
<add>
<add> @compatibility(TF2)
<add> This API is not compatible with eager execution or `tf.function`.
<add>
<add> Please refer to [tf.layers section of the migration guide]
<add> (https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
<add> to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
<add> layer is `tf.keras.layers.AveragePooling1D`.
<add>
<add>
<add> #### Structural Mapping to Native TF2
<add>
<add> None of the supported arguments have changed name.
<add>
<add> Before:
<add>
<add> ```python
<add> y = tf.compat.v1.layers.average_pooling1d(x, pool_size=2, strides=2)
<add> ```
<add>
<add> After:
<add>
<add> To migrate code using TF1 functional layers use the [Keras Functional API]
<add> (https://www.tensorflow.org/guide/keras/functional):
<add>
<add> ```python
<add> x = tf.keras.Input((28, 28, 1))
<add> y = tf.keras.layers.AveragePooling1D(pool_size=2, strides=2)(x)
<add> model = tf.keras.Model(x, y)
<add> ```
<add> @end_compatibility
<ide> """
<ide> warnings.warn('`tf.layers.average_pooling1d` is deprecated and '
<ide> 'will be removed in a future version. '
<ide> class MaxPooling1D(keras_layers.MaxPooling1D, base.Layer):
<ide> `(batch, length, channels)` while `channels_first` corresponds to
<ide> inputs with shape `(batch, channels, length)`.
<ide> name: A string, the name of the layer.
<add>
<add>
<add> @compatibility(TF2)
<add> This API is not compatible with eager execution or `tf.function`.
<add>
<add> Please refer to [tf.layers section of the migration guide]
<add> (https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
<add> to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
<add> layer is `tf.keras.layers.MaxPooling1D`.
<add>
<add>
<add> #### Structural Mapping to Native TF2
<add>
<add> None of the supported arguments have changed name.
<add>
<add> Before:
<add>
<add> ```python
<add> pooling = tf.compat.v1.layers.MaxPooling1D(pool_size=2, strides=2)
<add> ```
<add>
<add> After:
<add>
<add> ```python
<add> pooling = tf.keras.layers.MaxPooling1D(pool_size=2, strides=2)
<add> ```
<add> @end_compatibility
<ide> """
<ide>
<ide> def __init__(self, pool_size, strides,
<ide> def max_pooling1d(inputs, pool_size, strides,
<ide>
<ide> Raises:
<ide> ValueError: if eager execution is enabled.
<add>
<add>
<add> @compatibility(TF2)
<add> This API is not compatible with eager execution or `tf.function`.
<add>
<add> Please refer to [tf.layers section of the migration guide]
<add> (https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
<add> to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
<add> layer is `tf.keras.layers.MaxPooling1D`.
<add>
<add>
<add> #### Structural Mapping to Native TF2
<add>
<add> None of the supported arguments have changed name.
<add>
<add> Before:
<add>
<add> ```python
<add> y = tf.compat.v1.layers.max_pooling1d(x, pool_size=2, strides=2)
<add> ```
<add>
<add> After:
<add>
<add> To migrate code using TF1 functional layers use the [Keras Functional API]
<add> (https://www.tensorflow.org/guide/keras/functional):
<add>
<add> ```python
<add> x = tf.keras.Input((28, 28, 1))
<add> y = tf.keras.layers.MaxPooling1D(pool_size=2, strides=2)(x)
<add> model = tf.keras.Model(x, y)
<add> ```
<add> @end_compatibility
<ide> """
<ide> warnings.warn('`tf.layers.max_pooling1d` is deprecated and '
<ide> 'will be removed in a future version. '
<ide> class AveragePooling2D(keras_layers.AveragePooling2D, base.Layer):
<ide> `(batch, height, width, channels)` while `channels_first` corresponds to
<ide> inputs with shape `(batch, channels, height, width)`.
<ide> name: A string, the name of the layer.
<add>
<add>
<add> @compatibility(TF2)
<add> This API is not compatible with eager execution or `tf.function`.
<add>
<add> Please refer to [tf.layers section of the migration guide]
<add> (https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
<add> to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
<add> layer is `tf.keras.layers.AveragePooling2D`.
<add>
<add>
<add> #### Structural Mapping to Native TF2
<add>
<add> None of the supported arguments have changed name.
<add>
<add> Before:
<add>
<add> ```python
<add> pooling = tf.compat.v1.layers.AveragePooling2D(pool_size=2, strides=2)
<add> ```
<add>
<add> After:
<add>
<add> ```python
<add> pooling = tf.keras.layers.AveragePooling2D(pool_size=2, strides=2)
<add> ```
<add> @end_compatibility
<ide> """
<ide>
<ide> def __init__(self, pool_size, strides,
<ide> def average_pooling2d(inputs,
<ide>
<ide> Raises:
<ide> ValueError: if eager execution is enabled.
<add>
<add>
<add> @compatibility(TF2)
<add> This API is not compatible with eager execution or `tf.function`.
<add>
<add> Please refer to [tf.layers section of the migration guide]
<add> (https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
<add> to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
<add> layer is `tf.keras.layers.AveragePooling2D`.
<add>
<add>
<add> #### Structural Mapping to Native TF2
<add>
<add> None of the supported arguments have changed name.
<add>
<add> Before:
<add>
<add> ```python
<add> y = tf.compat.v1.layers.average_pooling2d(x, pool_size=2, strides=2)
<add> ```
<add>
<add> After:
<add>
<add> To migrate code using TF1 functional layers use the [Keras Functional API]
<add> (https://www.tensorflow.org/guide/keras/functional):
<add>
<add> ```python
<add> x = tf.keras.Input((28, 28, 1))
<add> y = tf.keras.layers.AveragePooling2D(pool_size=2, strides=2)(x)
<add> model = tf.keras.Model(x, y)
<add> ```
<add> @end_compatibility
<ide> """
<ide> warnings.warn('`tf.layers.average_pooling2d` is deprecated and '
<ide> 'will be removed in a future version. '
<ide> class MaxPooling2D(keras_layers.MaxPooling2D, base.Layer):
<ide> `(batch, height, width, channels)` while `channels_first` corresponds to
<ide> inputs with shape `(batch, channels, height, width)`.
<ide> name: A string, the name of the layer.
<add>
<add>
<add> @compatibility(TF2)
<add> This API is not compatible with eager execution or `tf.function`.
<add>
<add> Please refer to [tf.layers section of the migration guide]
<add> (https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
<add> to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
<add> layer is `tf.keras.layers.MaxPooling2D`.
<add>
<add>
<add> #### Structural Mapping to Native TF2
<add>
<add> None of the supported arguments have changed name.
<add>
<add> Before:
<add>
<add> ```python
<add> pooling = tf.compat.v1.layers.MaxPooling2D(pool_size=2, strides=2)
<add> ```
<add>
<add> After:
<add>
<add> ```python
<add> pooling = tf.keras.layers.MaxPooling2D(pool_size=2, strides=2)
<add> ```
<add> @end_compatibility
<ide> """
<ide>
<ide> def __init__(self, pool_size, strides,
<ide> def max_pooling2d(inputs,
<ide>
<ide> Raises:
<ide> ValueError: if eager execution is enabled.
<add>
<add>
<add> @compatibility(TF2)
<add> This API is not compatible with eager execution or `tf.function`.
<add>
<add> Please refer to [tf.layers section of the migration guide]
<add> (https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
<add> to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
<add> layer is `tf.keras.layers.MaxPooling2D`.
<add>
<add>
<add> #### Structural Mapping to Native TF2
<add>
<add> None of the supported arguments have changed name.
<add>
<add> Before:
<add>
<add> ```python
<add> y = tf.compat.v1.layers.max_pooling2d(x, pool_size=2, strides=2)
<add> ```
<add>
<add> After:
<add>
<add> To migrate code using TF1 functional layers use the [Keras Functional API]
<add> (https://www.tensorflow.org/guide/keras/functional):
<add>
<add> ```python
<add> x = tf.keras.Input((28, 28, 1))
<add> y = tf.keras.layers.MaxPooling2D(pool_size=2, strides=2)(x)
<add> model = tf.keras.Model(x, y)
<add> ```
<add> @end_compatibility
<ide> """
<ide> warnings.warn('`tf.layers.max_pooling2d` is deprecated and '
<ide> 'will be removed in a future version. '
<ide> class AveragePooling3D(keras_layers.AveragePooling3D, base.Layer):
<ide> corresponds to inputs with shape
<ide> `(batch, channels, depth, height, width)`.
<ide> name: A string, the name of the layer.
<add>
<add>
<add> @compatibility(TF2)
<add> This API is not compatible with eager execution or `tf.function`.
<add>
<add> Please refer to [tf.layers section of the migration guide]
<add> (https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
<add> to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
<add> layer is `tf.keras.layers.AveragePooling3D`.
<add>
<add>
<add> #### Structural Mapping to Native TF2
<add>
<add> None of the supported arguments have changed name.
<add>
<add> Before:
<add>
<add> ```python
<add> pooling = tf.compat.v1.layers.AveragePooling3D(pool_size=2, strides=2)
<add> ```
<add>
<add> After:
<add>
<add> ```python
<add> pooling = tf.keras.layers.AveragePooling3D(pool_size=2, strides=2)
<add> ```
<add> @end_compatibility
<ide> """
<ide>
<ide> def __init__(self, pool_size, strides,
<ide> def average_pooling3d(inputs,
<ide>
<ide> Raises:
<ide> ValueError: if eager execution is enabled.
<add>
<add>
<add> @compatibility(TF2)
<add> This API is not compatible with eager execution or `tf.function`.
<add>
<add> Please refer to [tf.layers section of the migration guide]
<add> (https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
<add> to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
<add> layer is `tf.keras.layers.AveragePooling3D`.
<add>
<add>
<add> #### Structural Mapping to Native TF2
<add>
<add> None of the supported arguments have changed name.
<add>
<add> Before:
<add>
<add> ```python
<add> y = tf.compat.v1.layers.average_pooling3d(x, pool_size=2, strides=2)
<add> ```
<add>
<add> After:
<add>
<add> To migrate code using TF1 functional layers use the [Keras Functional API]
<add> (https://www.tensorflow.org/guide/keras/functional):
<add>
<add> ```python
<add> x = tf.keras.Input((28, 28, 1))
<add> y = tf.keras.layers.AveragePooling3D(pool_size=2, strides=2)(x)
<add> model = tf.keras.Model(x, y)
<add> ```
<add> @end_compatibility
<ide> """
<ide> warnings.warn('`tf.layers.average_pooling3d` is deprecated and '
<ide> 'will be removed in a future version. '
<ide> class MaxPooling3D(keras_layers.MaxPooling3D, base.Layer):
<ide> corresponds to inputs with shape
<ide> `(batch, channels, depth, height, width)`.
<ide> name: A string, the name of the layer.
<add>
<add>
<add> @compatibility(TF2)
<add> This API is not compatible with eager execution or `tf.function`.
<add>
<add> Please refer to [tf.layers section of the migration guide]
<add> (https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
<add> to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
<add> layer is `tf.keras.layers.MaxPooling3D`.
<add>
<add>
<add> #### Structural Mapping to Native TF2
<add>
<add> None of the supported arguments have changed name.
<add>
<add> Before:
<add>
<add> ```python
<add> pooling = tf.compat.v1.layers.MaxPooling3D(pool_size=2, strides=2)
<add> ```
<add>
<add> After:
<add>
<add> ```python
<add> pooling = tf.keras.layers.MaxPooling3D(pool_size=2, strides=2)
<add> ```
<add> @end_compatibility
<ide> """
<ide>
<ide> def __init__(self, pool_size, strides,
<ide> def max_pooling3d(inputs,
<ide>
<ide> Raises:
<ide> ValueError: if eager execution is enabled.
<add>
<add>
<add> @compatibility(TF2)
<add> This API is not compatible with eager execution or `tf.function`.
<add>
<add> Please refer to [tf.layers section of the migration guide]
<add> (https://www.tensorflow.org/guide/migrate#models_based_on_tflayers)
<add> to migrate a TensorFlow v1 model to Keras. The corresponding TensorFlow v2
<add> layer is `tf.keras.layers.MaxPooling3D`.
<add>
<add>
<add> #### Structural Mapping to Native TF2
<add>
<add> None of the supported arguments have changed name.
<add>
<add> Before:
<add>
<add> ```python
<add> y = tf.compat.v1.layers.max_pooling3d(x, pool_size=2, strides=2)
<add> ```
<add>
<add> After:
<add>
<add> To migrate code using TF1 functional layers use the [Keras Functional API]
<add> (https://www.tensorflow.org/guide/keras/functional):
<add>
<add> ```python
<add> x = tf.keras.Input((28, 28, 1))
<add> y = tf.keras.layers.MaxPooling3D(pool_size=2, strides=2)(x)
<add> model = tf.keras.Model(x, y)
<add> ```
<add> @end_compatibility
<ide> """
<ide> warnings.warn('`tf.layers.max_pooling3d` is deprecated and '
<ide> 'will be removed in a future version. '
| 1
|
Python
|
Python
|
fix model by making inputs a dict
|
d7aa51b4b6e20ded2056c20429cce3f2147591c1
|
<ide><path>official/recommendation/ncf_keras_main.py
<ide> def _get_keras_model(params):
<ide> softmax_logits = MetricLayer(params)([softmax_logits, dup_mask_input])
<ide>
<ide> keras_model = tf.keras.Model(
<del> inputs=[
<del> user_input,
<del> item_input,
<del> valid_pt_mask_input,
<del> dup_mask_input,
<del> label_input],
<add> inputs={
<add> movielens.USER_COLUMN: user_input,
<add> movielens.ITEM_COLUMN: item_input,
<add> rconst.VALID_POINT_MASK: valid_pt_mask_input,
<add> rconst.DUPLICATE_MASK: dup_mask_input,
<add> rconst.TRAIN_LABEL_KEY: label_input},
<ide> outputs=softmax_logits)
<ide>
<ide> loss_obj = tf.keras.losses.SparseCategoricalCrossentropy(
| 1
|
Text
|
Text
|
add more places docker.service can be at
|
c0a1b2d6e99d5c6e29a016da39c1313a54c1cb34
|
<ide><path>docs/sources/articles/systemd.md
<ide> If the `docker.service` file is set to use an `EnvironmentFile`
<ide> (often pointing to `/etc/sysconfig/docker`) then you can modify the
<ide> referenced file.
<ide>
<del>Or, you may need to edit the `docker.service` file, which can be in `/usr/lib/systemd/system`
<del>or `/etc/systemd/service`.
<add>Or, you may need to edit the `docker.service` file, which can be in
<add>`/usr/lib/systemd/system`, `/etc/systemd/service`, or `/lib/systemd/system`.
<ide>
<ide> ### Runtime directory and storage driver
<ide>
| 1
|
Java
|
Java
|
introduce delegatingfilterproxy constructors
|
948aa4f589c65581a6d294095670cb83b65297da
|
<ide><path>org.springframework.web/src/main/java/org/springframework/web/filter/DelegatingFilterProxy.java
<ide> import javax.servlet.ServletRequest;
<ide> import javax.servlet.ServletResponse;
<ide>
<add>import org.springframework.context.ConfigurableApplicationContext;
<add>import org.springframework.util.Assert;
<ide> import org.springframework.web.context.WebApplicationContext;
<ide> import org.springframework.web.context.support.WebApplicationContextUtils;
<ide>
<ide> * of the {@code Filter.init} and {@code Filter.destroy} lifecycle methods
<ide> * on the target bean, letting the servlet container manage the filter lifecycle.
<ide> *
<del> * <p>This class is inspired by Acegi Security's FilterToBeanProxy class,
<del> * written by Ben Alex.
<add> * <p>As of Spring 3.1, {@code DelegatingFilterProxy} has been updated to optionally accept
<add> * constructor parameters when using Servlet 3.0's instance-based filter registration
<add> * methods, usually in conjunction with Spring 3.1's
<add> * {@link org.springframework.web.WebApplicationInitializer} SPI. These constructors allow
<add> * for providing the delegate Filter bean directly, or providing the application context
<add> * and bean name to fetch, avoiding the need to look up the application context from the
<add> * ServletContext.
<add> *
<add> * <p>This class was originally inspired by Spring Security's {@code FilterToBeanProxy}
<add> * class, written by Ben Alex.
<ide> *
<ide> * @author Juergen Hoeller
<ide> * @author Sam Brannen
<add> * @author Chris Beams
<ide> * @since 1.2
<ide> * @see #setTargetBeanName
<ide> * @see #setTargetFilterLifecycle
<ide> * @see javax.servlet.Filter#doFilter
<ide> * @see javax.servlet.Filter#init
<ide> * @see javax.servlet.Filter#destroy
<add> * @see #DelegatingFilterProxy(Filter)
<add> * @see #DelegatingFilterProxy(String)
<add> * @see #DelegatingFilterProxy(String, WebApplicationContext)
<add> * @see javax.servlet.ServletContext#addFilter(String, Filter)
<add> * @see org.springframework.web.WebApplicationInitializer
<ide> */
<ide> public class DelegatingFilterProxy extends GenericFilterBean {
<ide>
<ide> private String contextAttribute;
<ide>
<add> private WebApplicationContext webApplicationContext;
<add>
<ide> private String targetBeanName;
<ide>
<ide> private boolean targetFilterLifecycle = false;
<ide> public class DelegatingFilterProxy extends GenericFilterBean {
<ide> private final Object delegateMonitor = new Object();
<ide>
<ide>
<add> /**
<add> * Create a new {@code DelegatingFilterProxy}. For traditional (pre-Servlet 3.0) use
<add> * in {@code web.xml}.
<add> * @see #setTargetBeanName(String)
<add> */
<add> public DelegatingFilterProxy() {
<add> }
<add>
<add> /**
<add> * Create a new {@code DelegatingFilterProxy} with the given {@link Filter} delegate.
<add> * Bypasses entirely the need for interacting with a Spring application context,
<add> * specifying the {@linkplain #setTargetBeanName target bean name}, etc.
<add> * <p>For use in Servlet 3.0+ environments where instance-based registration of
<add> * filters is supported.
<add> * @param delegate the {@code Filter} instance that this proxy will delegate to and
<add> * manage the lifecycle for (must not be {@code null}).
<add> * @see #doFilter(ServletRequest, ServletResponse, FilterChain)
<add> * @see #invokeDelegate(Filter, ServletRequest, ServletResponse, FilterChain)
<add> * @see #destroy()
<add> * @see #setEnvironment(org.springframework.core.env.Environment)
<add> */
<add> public DelegatingFilterProxy(Filter delegate) {
<add> Assert.notNull(delegate, "delegate Filter object must not be null");
<add> this.delegate = delegate;
<add> }
<add>
<add> /**
<add> * Create a new {@code DelegatingFilterProxy} that will retrieve the named target
<add> * bean from the Spring {@code WebApplicationContext} found in the {@code ServletContext}
<add> * (either the 'root' application context or the context named by
<add> * {@link #setContextAttribute}).
<add> * <p>For use in Servlet 3.0+ environments where instance-based registration of
<add> * filters is supported.
<add> * <p>The target bean must implement the standard Servlet Filter.
<add> * @param targetBeanName name of the target filter bean to look up in the Spring
<add> * application context (must not be {@code null}).
<add> * @see #findWebApplicationContext()
<add> * @see #setEnvironment(org.springframework.core.env.Environment)
<add> */
<add> public DelegatingFilterProxy(String targetBeanName) {
<add> this(targetBeanName, null);
<add> }
<add>
<add> /**
<add> * Create a new {@code DelegatingFilterProxy} that will retrieve the named target
<add> * bean from the given Spring {@code WebApplicationContext}.
<add> * <p>For use in Servlet 3.0+ environments where instance-based registration of
<add> * filters is supported.
<add> * <p>The target bean must implement the standard Servlet Filter interface.
<add> * <p>The given {@code WebApplicationContext} may or may not be refreshed when passed
<add> * in. If it has not, and if the context implements {@link ConfigurableApplicationContext},
<add> * a {@link ConfigurableApplicationContext#refresh() refresh()} will be attempted before
<add> * retrieving the named target bean.
<add> * <p>This proxy's {@code Environment} will be inherited from the given
<add> * {@code WebApplicationContext}.
<add> * @param targetBeanName name of the target filter bean in the Spring application
<add> * context (must not be {@code null}).
<add> * @param wac the application context from which the target filter will be retrieved;
<add> * if {@code null}, an application context will be looked up from {@code ServletContext}
<add> * as a fallback.
<add> * @see #findWebApplicationContext()
<add> * @see #setEnvironment(org.springframework.core.env.Environment)
<add> */
<add> public DelegatingFilterProxy(String targetBeanName, WebApplicationContext wac) {
<add> Assert.hasText(targetBeanName, "target Filter bean name must not be null or empty");
<add> this.setTargetBeanName(targetBeanName);
<add> this.webApplicationContext = wac;
<add> if (wac != null) {
<add> this.setEnvironment(wac.getEnvironment());
<add> }
<add> }
<add>
<ide> /**
<ide> * Set the name of the ServletContext attribute which should be used to retrieve the
<ide> * {@link WebApplicationContext} from which to load the delegate {@link Filter} bean.
<ide> protected boolean isTargetFilterLifecycle() {
<ide>
<ide> @Override
<ide> protected void initFilterBean() throws ServletException {
<del> // If no target bean name specified, use filter name.
<del> if (this.targetBeanName == null) {
<del> this.targetBeanName = getFilterName();
<del> }
<del>
<del> // Fetch Spring root application context and initialize the delegate early,
<del> // if possible. If the root application context will be started after this
<del> // filter proxy, we'll have to resort to lazy initialization.
<ide> synchronized (this.delegateMonitor) {
<del> WebApplicationContext wac = findWebApplicationContext();
<del> if (wac != null) {
<del> this.delegate = initDelegate(wac);
<add> if (this.delegate == null) {
<add> // If no target bean name specified, use filter name.
<add> if (this.targetBeanName == null) {
<add> this.targetBeanName = getFilterName();
<add> }
<add>
<add> // Fetch Spring root application context and initialize the delegate early,
<add> // if possible. If the root application context will be started after this
<add> // filter proxy, we'll have to resort to lazy initialization.
<add> WebApplicationContext wac = findWebApplicationContext();
<add> if (wac != null) {
<add> this.delegate = initDelegate(wac);
<add> }
<ide> }
<ide> }
<ide> }
<ide> public void destroy() {
<ide>
<ide>
<ide> /**
<del> * Retrieve a <code>WebApplicationContext</code> from the <code>ServletContext</code>
<del> * attribute with the {@link #setContextAttribute configured name}. The
<del> * <code>WebApplicationContext</code> must have already been loaded and stored in the
<del> * <code>ServletContext</code> before this filter gets initialized (or invoked).
<add> * Return the {@code WebApplicationContext} passed in at construction time, if available.
<add> * Otherwise, attempt to retrieve a {@code WebApplicationContext} from the
<add> * {@code ServletContext} attribute with the {@linkplain #setContextAttribute
<add> * configured name} if set. Otherwise look up a {@code WebApplicationContext} under
<add> * the well-known "root" application context attribute. The
<add> * {@code WebApplicationContext} must have already been loaded and stored in the
<add> * {@code ServletContext} before this filter gets initialized (or invoked).
<ide> * <p>Subclasses may override this method to provide a different
<del> * <code>WebApplicationContext</code> retrieval strategy.
<del> * @return the WebApplicationContext for this proxy, or <code>null</code> if not found
<add> * {@code WebApplicationContext} retrieval strategy.
<add> * @return the {@code WebApplicationContext} for this proxy, or {@code null} if not
<add> * found
<add> * @see #DelegatingFilterProxy(String, WebApplicationContext)
<ide> * @see #getContextAttribute()
<add> * @see WebApplicationContextUtils#getWebApplicationContext(javax.servlet.ServletContext)
<add> * @see WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
<ide> */
<ide> protected WebApplicationContext findWebApplicationContext() {
<add> if (this.webApplicationContext != null) {
<add> // the user has injected a context at construction time -> use it
<add> if (this.webApplicationContext instanceof ConfigurableApplicationContext) {
<add> if (!((ConfigurableApplicationContext)this.webApplicationContext).isActive()) {
<add> // the context has not yet been refreshed -> do so before returning it
<add> ((ConfigurableApplicationContext)this.webApplicationContext).refresh();
<add> }
<add> }
<add> return this.webApplicationContext;
<add> }
<ide> String attrName = getContextAttribute();
<ide> if (attrName != null) {
<ide> return WebApplicationContextUtils.getWebApplicationContext(getServletContext(), attrName);
<ide><path>org.springframework.web/src/test/java/org/springframework/web/filter/DelegatingFilterProxyTests.java
<del>/* Copyright 2004, 2005 Acegi Technology Pty Limited
<add>/*
<add> * Copyright 2004, 2005 Acegi Technology Pty Limited
<add> * Copyright 2006-2011 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> import javax.servlet.ServletRequest;
<ide> import javax.servlet.ServletResponse;
<ide>
<del>import junit.framework.TestCase;
<del>
<add>import static org.junit.Assert.*;
<add>import org.junit.Test;
<ide> import org.springframework.mock.web.MockFilterConfig;
<ide> import org.springframework.mock.web.MockHttpServletRequest;
<ide> import org.springframework.mock.web.MockHttpServletResponse;
<ide>
<ide> /**
<ide> * @author Juergen Hoeller
<add> * @author Chris Beams
<ide> * @since 08.05.2005
<ide> */
<del>public class DelegatingFilterProxyTests extends TestCase {
<add>public class DelegatingFilterProxyTests {
<ide>
<add> @Test
<ide> public void testDelegatingFilterProxy() throws ServletException, IOException {
<ide> ServletContext sc = new MockServletContext();
<ide>
<ide> public void testDelegatingFilterProxy() throws ServletException, IOException {
<ide> assertNull(targetFilter.filterConfig);
<ide> }
<ide>
<add> @Test
<add> public void testDelegatingFilterProxyAndCustomContextAttribute() throws ServletException, IOException {
<add> ServletContext sc = new MockServletContext();
<add>
<add> StaticWebApplicationContext wac = new StaticWebApplicationContext();
<add> wac.setServletContext(sc);
<add> wac.registerSingleton("targetFilter", MockFilter.class);
<add> wac.refresh();
<add> sc.setAttribute("CUSTOM_ATTR", wac);
<add>
<add> MockFilter targetFilter = (MockFilter) wac.getBean("targetFilter");
<add>
<add> MockFilterConfig proxyConfig = new MockFilterConfig(sc);
<add> proxyConfig.addInitParameter("targetBeanName", "targetFilter");
<add> proxyConfig.addInitParameter("contextAttribute", "CUSTOM_ATTR");
<add> DelegatingFilterProxy filterProxy = new DelegatingFilterProxy();
<add> filterProxy.init(proxyConfig);
<add>
<add> MockHttpServletRequest request = new MockHttpServletRequest();
<add> MockHttpServletResponse response = new MockHttpServletResponse();
<add> filterProxy.doFilter(request, response, null);
<add>
<add> assertNull(targetFilter.filterConfig);
<add> assertEquals(Boolean.TRUE, request.getAttribute("called"));
<add>
<add> filterProxy.destroy();
<add> assertNull(targetFilter.filterConfig);
<add> }
<add>
<add> @Test
<add> public void testDelegatingFilterProxyWithFilterDelegateInstance() throws ServletException, IOException {
<add> MockFilter targetFilter = new MockFilter();
<add>
<add> DelegatingFilterProxy filterProxy = new DelegatingFilterProxy(targetFilter);
<add> filterProxy.init(new MockFilterConfig(new MockServletContext()));
<add>
<add> MockHttpServletRequest request = new MockHttpServletRequest();
<add> MockHttpServletResponse response = new MockHttpServletResponse();
<add> filterProxy.doFilter(request, response, null);
<add>
<add> assertNull(targetFilter.filterConfig);
<add> assertEquals(Boolean.TRUE, request.getAttribute("called"));
<add>
<add> filterProxy.destroy();
<add> assertNull(targetFilter.filterConfig);
<add> }
<add>
<add> @Test
<add> public void testDelegatingFilterProxyWithTargetBeanName() throws ServletException, IOException {
<add> MockServletContext sc = new MockServletContext();
<add>
<add> StaticWebApplicationContext wac = new StaticWebApplicationContext();
<add> wac.setServletContext(sc);
<add> wac.registerSingleton("targetFilter", MockFilter.class);
<add> wac.refresh();
<add> sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
<add>
<add> MockFilter targetFilter = (MockFilter) wac.getBean("targetFilter");
<add>
<add> DelegatingFilterProxy filterProxy = new DelegatingFilterProxy("targetFilter");
<add> filterProxy.init(new MockFilterConfig(sc));
<add>
<add> MockHttpServletRequest request = new MockHttpServletRequest();
<add> MockHttpServletResponse response = new MockHttpServletResponse();
<add> filterProxy.doFilter(request, response, null);
<add>
<add> assertNull(targetFilter.filterConfig);
<add> assertEquals(Boolean.TRUE, request.getAttribute("called"));
<add>
<add> filterProxy.destroy();
<add> assertNull(targetFilter.filterConfig);
<add> }
<add>
<add> @Test
<add> public void testDelegatingFilterProxyWithTargetBeanNameAndNotYetRefreshedApplicationContext() throws ServletException, IOException {
<add> MockServletContext sc = new MockServletContext();
<add>
<add> StaticWebApplicationContext wac = new StaticWebApplicationContext();
<add> wac.setServletContext(sc);
<add> wac.registerSingleton("targetFilter", MockFilter.class);
<add> // wac.refresh();
<add> // note that the context is not set as the ROOT attribute in the ServletContext!
<add>
<add> DelegatingFilterProxy filterProxy = new DelegatingFilterProxy("targetFilter", wac);
<add> filterProxy.init(new MockFilterConfig(sc));
<add>
<add> MockHttpServletRequest request = new MockHttpServletRequest();
<add> MockHttpServletResponse response = new MockHttpServletResponse();
<add> filterProxy.doFilter(request, response, null);
<add>
<add> MockFilter targetFilter = (MockFilter) wac.getBean("targetFilter");
<add>
<add> assertNull(targetFilter.filterConfig);
<add> assertEquals(Boolean.TRUE, request.getAttribute("called"));
<add>
<add> filterProxy.destroy();
<add> assertNull(targetFilter.filterConfig);
<add> }
<add>
<add> @Test(expected=IllegalStateException.class)
<add> public void testDelegatingFilterProxyWithTargetBeanNameAndNoApplicationContext() throws ServletException, IOException {
<add> MockServletContext sc = new MockServletContext();
<add>
<add> DelegatingFilterProxy filterProxy = new DelegatingFilterProxy("targetFilter", null);
<add> filterProxy.init(new MockFilterConfig(sc));
<add>
<add> MockHttpServletRequest request = new MockHttpServletRequest();
<add> MockHttpServletResponse response = new MockHttpServletResponse();
<add> filterProxy.doFilter(request, response, null); // throws
<add> }
<add>
<add> @Test
<ide> public void testDelegatingFilterProxyWithFilterName() throws ServletException, IOException {
<ide> ServletContext sc = new MockServletContext();
<ide>
<ide> public void testDelegatingFilterProxyWithFilterName() throws ServletException, I
<ide> assertNull(targetFilter.filterConfig);
<ide> }
<ide>
<add> @Test
<ide> public void testDelegatingFilterProxyWithLazyContextStartup() throws ServletException, IOException {
<ide> ServletContext sc = new MockServletContext();
<ide>
<ide> public void testDelegatingFilterProxyWithLazyContextStartup() throws ServletExce
<ide> assertNull(targetFilter.filterConfig);
<ide> }
<ide>
<add> @Test
<ide> public void testDelegatingFilterProxyWithTargetFilterLifecycle() throws ServletException, IOException {
<ide> ServletContext sc = new MockServletContext();
<ide>
| 2
|
Javascript
|
Javascript
|
add failing test for http client
|
194eeac0d9e607080d4f9bcf74a9470015931eef
|
<ide><path>test/test-http-client-race.js
<add>include("mjsunit.js");
<add>PORT = 8888;
<add>
<add>var server = new node.http.Server(function (req, res) {
<add> res.sendHeader(200, [["content-type", "text/plain"]]);
<add> res.sendBody("hello world\n");
<add> res.finish();
<add>})
<add>server.listen(PORT);
<add>
<add>var client = new node.http.Client(PORT);
<add>
<add>var body1 = "";
<add>var body2 = "";
<add>
<add>client.get("/").finish(function (res1) {
<add> res1.setBodyEncoding("utf8");
<add>
<add> res1.onBody = function (chunk) { body1 += chunk; };
<add>
<add> res1.onBodyComplete = function () {
<add> client.get("/").finish(function (res2) {
<add> res2.setBodyEncoding("utf8");
<add> res2.onBody = function (chunk) { body2 += chunk; };
<add> res2.onBodyComplete = function () {
<add> server.close();
<add> };
<add> });
<add> };
<add>});
<add>
<add>function onExit () {
<add> assertEqual("hello world\n", body1);
<add> assertEqual("hello world\n", body2);
<add>}
| 1
|
Python
|
Python
|
pass the smp setting on to the api
|
4c6e2d51ce52fdbbc43c88e6d7674eca5d145134
|
<ide><path>libcloud/drivers/elastichosts.py
<ide> def create_node(self, **kwargs):
<ide>
<ide> node_data = {}
<ide> node_data.update({'name': kwargs['name'], 'cpu': size.cpu, 'mem': size.ram, 'ide:0:0': drive_uuid,
<del> 'boot': 'ide:0:0'})
<add> 'boot': 'ide:0:0', 'smp': smp})
<ide> node_data.update({'nic:0:model': nic_model, 'nic:0:dhcp': 'auto'})
<ide>
<ide> if vnc_password:
| 1
|
PHP
|
PHP
|
fix lint error
|
003ee93675acb03b1cb6cee19c624c4e81b9692d
|
<ide><path>src/Validation/Validation.php
<ide> public static function extension($check, $extensions = ['gif', 'jpeg', 'png', 'j
<ide> {
<ide> if (is_array($check)) {
<ide> $check = isset($check['name']) ? $check['name'] : array_shift($check);
<add>
<ide> return static::extension($check, $extensions);
<ide> }
<ide> $extension = strtolower(pathinfo($check, PATHINFO_EXTENSION));
| 1
|
Mixed
|
Python
|
move transformerdecoderlayer to modeling/
|
58e805e093620e04168c2e07c92fc60e1e87d553
|
<ide><path>official/nlp/modeling/layers/README.md
<ide> assemble new layers, networks, or models.
<ide> initialization parameters.
<ide>
<ide> * [MultiHeadAttention](attention.py) implements an optionally masked attention
<del> between two tensors, from_tensor and to_tensor, as described in
<add> between query, key, value tensors as described in
<ide> ["Attention Is All You Need"](https://arxiv.org/abs/1706.03762). If
<ide> `from_tensor` and `to_tensor` are the same, then this is self-attention.
<ide>
<ide> * [CachedAttention](attention.py) implements an attention layer with cache
<ide> used for auto-agressive decoding.
<ide>
<add>* [MultiChannelAttention](multi_channel_attention.py) implements an variant of
<add> multi-head attention which can be used to merge multiple streams for
<add> cross-attentions.
<add>
<ide> * [TalkingHeadsAttention](talking_heads_attention.py) implements the talking
<ide> heads attention, as decribed in
<ide> ["Talking-Heads Attention"](https://arxiv.org/abs/2003.02436).
<ide><path>official/nlp/modeling/layers/__init__.py
<ide> from official.nlp.modeling.layers.gated_feedforward import GatedFeedforward
<ide> from official.nlp.modeling.layers.masked_lm import MaskedLM
<ide> from official.nlp.modeling.layers.masked_softmax import MaskedSoftmax
<add>from official.nlp.modeling.layers.multi_channel_attention import *
<ide> from official.nlp.modeling.layers.on_device_embedding import OnDeviceEmbedding
<ide> from official.nlp.modeling.layers.position_embedding import PositionEmbedding
<ide> from official.nlp.modeling.layers.rezero_transformer import ReZeroTransformer
<add><path>official/nlp/modeling/layers/multi_channel_attention.py
<del><path>official/nlp/nhnet/multi_channel_attention.py
<ide> # See the License for the specific language governing permissions and
<ide> # limitations under the License.
<ide> # ==============================================================================
<del>"""Multi-channel decoder."""
<add>"""Multi-channel Attention."""
<add># pylint: disable=g-classes-have-attributes
<ide>
<ide> from __future__ import absolute_import
<ide> from __future__ import division
<ide>
<ide> import tensorflow as tf
<ide> from official.modeling import tf_utils
<del>from official.nlp.modeling import layers
<del>
<del>
<del>class DocAttention(tf.keras.layers.Layer):
<del> """Documents Attention layer."""
<add>from official.nlp.modeling.layers import attention
<add>from official.nlp.modeling.layers import dense_einsum
<add>from official.nlp.modeling.layers import masked_softmax
<add>
<add>
<add>class VotingAttention(tf.keras.layers.Layer):
<add> """Voting Attention layer.
<add>
<add> Arguments:
<add> num_heads: the number of attention heads.
<add> head_size: per-head hidden size.
<add> kernel_initializer: Initializer for dense layer kernels.
<add> bias_initializer: Initializer for dense layer biases.
<add> kernel_regularizer: Regularizer for dense layer kernels.
<add> bias_regularizer: Regularizer for dense layer biases.
<add> activity_regularizer: Regularizer for dense layer activity.
<add> kernel_constraint: Constraint for dense layer kernels.
<add> bias_constraint: Constraint for dense layer kernels.
<add> """
<ide>
<ide> def __init__(self,
<ide> num_heads,
<ide> def __init__(self,
<ide> kernel_constraint=None,
<ide> bias_constraint=None,
<ide> **kwargs):
<del> super(DocAttention, self).__init__(**kwargs)
<add> super(VotingAttention, self).__init__(**kwargs)
<ide> self._num_heads = num_heads
<ide> self._head_size = head_size
<ide> self._kernel_initializer = tf.keras.initializers.get(kernel_initializer)
<ide> def __init__(self,
<ide> self._bias_constraint = tf.keras.constraints.get(bias_constraint)
<ide>
<ide> def build(self, unused_input_shapes):
<del> self._query_dense = layers.DenseEinsum(
<add> self._query_dense = dense_einsum.DenseEinsum(
<ide> output_shape=(self._num_heads, self._head_size),
<ide> kernel_initializer=self._kernel_initializer,
<ide> bias_initializer=self._bias_initializer,
<ide> def build(self, unused_input_shapes):
<ide> bias_constraint=self._bias_constraint,
<ide> dtype=self.dtype,
<ide> name="encdocatt_query")
<del> self._key_dense = layers.DenseEinsum(
<add> self._key_dense = dense_einsum.DenseEinsum(
<ide> output_shape=(self._num_heads, self._head_size),
<ide> kernel_initializer=self._kernel_initializer,
<ide> bias_initializer=self._bias_initializer,
<ide> def build(self, unused_input_shapes):
<ide> bias_constraint=self._bias_constraint,
<ide> dtype=self.dtype,
<ide> name="encdocatt_key")
<del> super(DocAttention, self).build(unused_input_shapes)
<add> super(VotingAttention, self).build(unused_input_shapes)
<ide>
<ide> def call(self, encoder_outputs, doc_attention_mask):
<ide> num_docs = tf_utils.get_shape_list(encoder_outputs, expected_rank=[4])[1]
<ide> def call(self, encoder_outputs, doc_attention_mask):
<ide> return tf.nn.softmax(doc_attention_probs + infadder)
<ide>
<ide>
<del>class MultiChannelAttention(layers.MultiHeadAttention):
<del> """Multi-channel Attention layer."""
<add>class MultiChannelAttention(attention.MultiHeadAttention):
<add> """Multi-channel Attention layer.
<add>
<add> Introduced in: https://arxiv.org/abs/2001.09386. Expects multiple
<add> cross-attention target sequences.
<add> """
<ide>
<ide> def build(self, input_shape):
<ide> super(MultiChannelAttention, self).build(input_shape)
<del> self._masked_softmax = layers.MaskedSoftmax(mask_expansion_axes=[2])
<add> self._masked_softmax = masked_softmax.MaskedSoftmax(mask_expansion_axes=[2])
<ide>
<ide> def call(self, inputs, attention_mask=None):
<ide> from_tensor = inputs[0]
<add><path>official/nlp/modeling/layers/multi_channel_attention_test.py
<del><path>official/nlp/nhnet/multi_channel_attention_test.py
<ide> import numpy as np
<ide> import tensorflow as tf
<ide>
<del>from official.nlp.nhnet import multi_channel_attention
<add>from official.nlp.modeling.layers import multi_channel_attention
<ide>
<ide>
<ide> class MultiChannelAttentionTest(tf.test.TestCase):
<ide>
<ide> def test_doc_attention(self):
<ide> num_heads = 2
<del> doc_attention = multi_channel_attention.DocAttention(num_heads, head_size=8)
<add> doc_attention = multi_channel_attention.VotingAttention(
<add> num_heads, head_size=8)
<ide> num_docs = 3
<ide> inputs = np.zeros((2, num_docs, 10, 16), dtype=np.float32)
<ide> doc_mask = np.zeros((2, num_docs), dtype=np.float32)
<ide><path>official/nlp/modeling/layers/transformer.py
<ide>
<ide> from official.nlp.modeling.layers import attention
<ide> from official.nlp.modeling.layers import dense_einsum
<add>from official.nlp.modeling.layers import multi_channel_attention
<ide> from official.nlp.modeling.layers.util import tf_function_if_eager
<ide>
<ide>
<ide> class CompiledTransformer(Transformer):
<ide> @tf_function_if_eager(experimental_compile=True)
<ide> def call(self, inputs):
<ide> return super(CompiledTransformer, self).call(inputs)
<add>
<add>
<add>@tf.keras.utils.register_keras_serializable(package="Text")
<add>class TransformerDecoderLayer(tf.keras.layers.Layer):
<add> """Single transformer layer for decoder.
<add>
<add> It has three sub-layers:
<add> (1) a multi-head self-attention mechanism.
<add> (2) a encoder-decoder attention.
<add> (3) a positionwise fully connected feed-forward network.
<add> """
<add>
<add> def __init__(self,
<add> hidden_size=768,
<add> num_attention_heads=12,
<add> intermediate_size=3072,
<add> intermediate_activation="relu",
<add> hidden_dropout_prob=0.0,
<add> attention_probs_dropout_prob=0.0,
<add> initializer_range=0.02,
<add> multi_channel_cross_attention=False,
<add> **kwargs):
<add> super(TransformerDecoderLayer, self).__init__(**kwargs)
<add> self.hidden_size = hidden_size
<add> self.num_attention_heads = num_attention_heads
<add> self.intermediate_size = intermediate_size
<add> self.intermediate_activation = tf.keras.activations.get(
<add> intermediate_activation)
<add> self.hidden_dropout_prob = hidden_dropout_prob
<add> self.attention_probs_dropout_prob = attention_probs_dropout_prob
<add> self.multi_channel_cross_attention = multi_channel_cross_attention
<add> self._kernel_initializer = tf.keras.initializers.TruncatedNormal(
<add> stddev=initializer_range)
<add> self._bias_initializer = tf.keras.initializers.get("zeros")
<add> if self.multi_channel_cross_attention:
<add> self._cross_attention_cls = multi_channel_attention.MultiChannelAttention
<add> else:
<add> self._cross_attention_cls = attention.MultiHeadAttention
<add>
<add> if self.hidden_size % self.num_attention_heads != 0:
<add> raise ValueError(
<add> "The hidden size (%d) is not a multiple of the number of attention "
<add> "heads (%d)" % (self.hidden_size, self.num_attention_heads))
<add> self.attention_head_size = int(self.hidden_size / self.num_attention_heads)
<add>
<add> def build(self, input_shape):
<add> # Self attention.
<add> self.self_attention = attention.CachedAttention(
<add> num_heads=self.num_attention_heads,
<add> key_size=self.attention_head_size,
<add> dropout=self.attention_probs_dropout_prob,
<add> kernel_initializer=self._kernel_initializer,
<add> name="self_attention")
<add> self.self_attention_output_dense = dense_einsum.DenseEinsum(
<add> output_shape=self.hidden_size,
<add> num_summed_dimensions=2,
<add> kernel_initializer=self._kernel_initializer,
<add> bias_initializer=self._bias_initializer,
<add> name="self_attention_output")
<add> self.self_attention_dropout = tf.keras.layers.Dropout(
<add> rate=self.hidden_dropout_prob)
<add> self.self_attention_layer_norm = (
<add> tf.keras.layers.LayerNormalization(
<add> name="self_attention_layer_norm", axis=-1, epsilon=1e-12))
<add> # Encoder-decoder attention.
<add> self.encdec_attention = self._cross_attention_cls(
<add> num_heads=self.num_attention_heads,
<add> key_size=self.attention_head_size,
<add> dropout=self.attention_probs_dropout_prob,
<add> output_shape=self.hidden_size,
<add> kernel_initializer=self._kernel_initializer,
<add> name="attention/encdec")
<add>
<add> self.encdec_attention_dropout = tf.keras.layers.Dropout(
<add> rate=self.hidden_dropout_prob)
<add> self.encdec_attention_layer_norm = (
<add> tf.keras.layers.LayerNormalization(
<add> name="attention/encdec_output_layer_norm", axis=-1, epsilon=1e-12))
<add>
<add> # Feed-forward projection.
<add> self.intermediate_dense = dense_einsum.DenseEinsum(
<add> output_shape=self.intermediate_size,
<add> activation=None,
<add> kernel_initializer=self._kernel_initializer,
<add> bias_initializer=self._bias_initializer,
<add> name="intermediate")
<add> self.intermediate_activation_layer = tf.keras.layers.Activation(
<add> self.intermediate_activation)
<add> self.output_dense = dense_einsum.DenseEinsum(
<add> output_shape=self.hidden_size,
<add> kernel_initializer=self._kernel_initializer,
<add> bias_initializer=self._bias_initializer,
<add> name="output")
<add> self.output_dropout = tf.keras.layers.Dropout(rate=self.hidden_dropout_prob)
<add> self.output_layer_norm = tf.keras.layers.LayerNormalization(
<add> name="output_layer_norm", axis=-1, epsilon=1e-12)
<add> super(TransformerDecoderLayer, self).build(input_shape)
<add>
<add> def common_layers_with_encoder(self):
<add> """Gets layer objects that can make a Transformer encoder block."""
<add> return [
<add> self.self_attention, self.self_attention_layer_norm,
<add> self.intermediate_dense, self.output_dense, self.output_layer_norm
<add> ]
<add>
<add> def call(self, inputs, cache=None, decode_loop_step=None):
<add> if self.multi_channel_cross_attention:
<add> if len(inputs) != 5:
<add> raise ValueError(
<add> "TransformerDecoderLayer must have 5 inputs, when it uses "
<add> "multi_channel_cross_attention. But it got: %d" % len(inputs))
<add> elif len(inputs) != 4:
<add> raise ValueError(
<add> "TransformerDecoderLayer must have 4 inputs, but it got: %d" %
<add> len(inputs))
<add> input_tensor, memory, attention_mask, self_attention_mask = inputs[:4]
<add> self_attention_inputs = [input_tensor, input_tensor]
<add> self_attention_output, cache = self.self_attention(
<add> self_attention_inputs,
<add> attention_mask=self_attention_mask,
<add> cache=cache,
<add> decode_loop_step=decode_loop_step)
<add> self_attention_output = self.self_attention_dropout(self_attention_output)
<add> self_attention_output = self.self_attention_layer_norm(
<add> input_tensor + self_attention_output)
<add>
<add> cross_attn_inputs = [self_attention_output, memory]
<add> if self.multi_channel_cross_attention:
<add> # Accesses the 5-th input tensor for the doc-attention probabilities.
<add> cross_attn_inputs.append(inputs[-1])
<add> attention_output = self.encdec_attention(cross_attn_inputs, attention_mask)
<add> attention_output = self.encdec_attention_dropout(attention_output)
<add> attention_output = self.encdec_attention_layer_norm(self_attention_output +
<add> attention_output)
<add>
<add> intermediate_output = self.intermediate_dense(attention_output)
<add> intermediate_output = self.intermediate_activation_layer(
<add> intermediate_output)
<add> layer_output = self.output_dense(intermediate_output)
<add> layer_output = self.output_dropout(layer_output)
<add> layer_output = self.output_layer_norm(layer_output + attention_output)
<add> return layer_output, cache
<ide><path>official/nlp/modeling/layers/transformer_test.py
<ide> def test_dynamic_layer_sequence(self, transformer_cls):
<ide> self.assertAllEqual([1, input_length, width], output_data.shape)
<ide>
<ide>
<add>def _create_cache(batch_size, init_decode_length, num_heads, head_size):
<add> return {
<add> 'key':
<add> tf.zeros([batch_size, init_decode_length, num_heads, head_size],
<add> dtype=tf.float32),
<add> 'value':
<add> tf.zeros([batch_size, init_decode_length, num_heads, head_size],
<add> dtype=tf.float32)
<add> }
<add>
<add>
<add>@keras_parameterized.run_all_keras_modes
<add>class TransformerDecoderLayerTest(keras_parameterized.TestCase):
<add>
<add> def test_decoder_block_with_cache(self):
<add> num_attention_heads = 2
<add> hidden_size = 16
<add> decoder_block = transformer.TransformerDecoderLayer(
<add> hidden_size=hidden_size,
<add> num_attention_heads=num_attention_heads,
<add> intermediate_size=32,
<add> intermediate_activation='relu',
<add> hidden_dropout_prob=0.1,
<add> attention_probs_dropout_prob=0.1,
<add> initializer_range=0.1)
<add> # Forward path.
<add> dummy_tensor = tf.zeros([2, 4, 16], dtype=tf.float32)
<add> dummy_mask = tf.zeros([2, 4, 4], dtype=tf.float32)
<add> inputs = [dummy_tensor, dummy_tensor, dummy_mask, dummy_mask]
<add> cache = _create_cache(2, 0, num_attention_heads,
<add> hidden_size // num_attention_heads)
<add> output, cache = decoder_block(inputs, cache)
<add> self.assertEqual(output.shape, (2, 4, hidden_size))
<add> self.assertEqual(cache['value'].shape, (2, 4, 2, 8))
<add>
<add>
<ide> if __name__ == '__main__':
<ide> tf.test.main()
<ide><path>official/nlp/nhnet/decoder.py
<ide> import tensorflow as tf
<ide> from official.modeling import tf_utils
<ide> from official.nlp.modeling import layers
<del>from official.nlp.nhnet import multi_channel_attention
<add>from official.nlp.modeling.layers import transformer
<ide> from official.nlp.transformer import model_utils as transformer_utils
<ide>
<ide>
<del>class TransformerDecoderBlock(tf.keras.layers.Layer):
<del> """Single transformer layer for decoder.
<del>
<del> It has three sub-layers:
<del> (1) a multi-head self-attention mechanism.
<del> (2) a encoder-decoder attention.
<del> (3) a positionwise fully connected feed-forward network.
<del> """
<del>
<del> def __init__(self,
<del> hidden_size=768,
<del> num_attention_heads=12,
<del> intermediate_size=3072,
<del> intermediate_activation="gelu",
<del> hidden_dropout_prob=0.0,
<del> attention_probs_dropout_prob=0.0,
<del> initializer_range=0.02,
<del> multi_channel_cross_attention=False,
<del> **kwargs):
<del> super(TransformerDecoderBlock, self).__init__(**kwargs)
<del> self.hidden_size = hidden_size
<del> self.num_attention_heads = num_attention_heads
<del> self.intermediate_size = intermediate_size
<del> self.intermediate_activation = tf_utils.get_activation(
<del> intermediate_activation)
<del> self.hidden_dropout_prob = hidden_dropout_prob
<del> self.attention_probs_dropout_prob = attention_probs_dropout_prob
<del> self.multi_channel_cross_attention = multi_channel_cross_attention
<del> self._kernel_initializer = tf.keras.initializers.TruncatedNormal(
<del> stddev=initializer_range)
<del> self._bias_initializer = tf.keras.initializers.get("zeros")
<del> if self.multi_channel_cross_attention:
<del> self._cross_attention_cls = multi_channel_attention.MultiChannelAttention
<del> else:
<del> self._cross_attention_cls = layers.MultiHeadAttention
<del>
<del> if self.hidden_size % self.num_attention_heads != 0:
<del> raise ValueError(
<del> "The hidden size (%d) is not a multiple of the number of attention "
<del> "heads (%d)" % (self.hidden_size, self.num_attention_heads))
<del> self.attention_head_size = int(self.hidden_size / self.num_attention_heads)
<del>
<del> def build(self, input_shape):
<del> # Self attention.
<del> self.self_attention = layers.CachedAttention(
<del> num_heads=self.num_attention_heads,
<del> key_size=self.attention_head_size,
<del> dropout=self.attention_probs_dropout_prob,
<del> kernel_initializer=self._kernel_initializer,
<del> name="self_attention")
<del> self.self_attention_output_dense = layers.DenseEinsum(
<del> output_shape=self.hidden_size,
<del> num_summed_dimensions=2,
<del> kernel_initializer=self._kernel_initializer,
<del> bias_initializer=self._bias_initializer,
<del> name="self_attention_output")
<del> self.self_attention_dropout = tf.keras.layers.Dropout(
<del> rate=self.hidden_dropout_prob)
<del> self.self_attention_layer_norm = (
<del> tf.keras.layers.LayerNormalization(
<del> name="self_attention_layer_norm", axis=-1, epsilon=1e-12))
<del> # Encoder-decoder attention.
<del> self.encdec_attention = self._cross_attention_cls(
<del> num_heads=self.num_attention_heads,
<del> key_size=self.attention_head_size,
<del> dropout=self.attention_probs_dropout_prob,
<del> output_shape=self.hidden_size,
<del> kernel_initializer=self._kernel_initializer,
<del> name="attention/encdec")
<del>
<del> self.encdec_attention_dropout = tf.keras.layers.Dropout(
<del> rate=self.hidden_dropout_prob)
<del> self.encdec_attention_layer_norm = (
<del> tf.keras.layers.LayerNormalization(
<del> name="attention/encdec_output_layer_norm", axis=-1, epsilon=1e-12))
<del>
<del> # Feed-forward projection.
<del> self.intermediate_dense = layers.DenseEinsum(
<del> output_shape=self.intermediate_size,
<del> activation=None,
<del> kernel_initializer=self._kernel_initializer,
<del> bias_initializer=self._bias_initializer,
<del> name="intermediate")
<del> self.intermediate_activation_layer = tf.keras.layers.Activation(
<del> self.intermediate_activation)
<del> self.output_dense = layers.DenseEinsum(
<del> output_shape=self.hidden_size,
<del> kernel_initializer=self._kernel_initializer,
<del> bias_initializer=self._bias_initializer,
<del> name="output")
<del> self.output_dropout = tf.keras.layers.Dropout(rate=self.hidden_dropout_prob)
<del> self.output_layer_norm = tf.keras.layers.LayerNormalization(
<del> name="output_layer_norm", axis=-1, epsilon=1e-12)
<del> super(TransformerDecoderBlock, self).build(input_shape)
<del>
<del> def common_layers_with_encoder(self):
<del> """Gets layer objects that can make a Transformer encoder block."""
<del> return [
<del> self.self_attention, self.self_attention_layer_norm,
<del> self.intermediate_dense, self.output_dense, self.output_layer_norm
<del> ]
<del>
<del> def call(self, inputs, cache=None, decode_loop_step=None):
<del> if self.multi_channel_cross_attention:
<del> if len(inputs) != 5:
<del> raise ValueError(
<del> "TransformerDecoderBlock must have 5 inputs, when it uses "
<del> "multi_channel_cross_attention. But it got: %d" % len(inputs))
<del> elif len(inputs) != 4:
<del> raise ValueError(
<del> "TransformerDecoderBlock must have 4 inputs, but it got: %d" %
<del> len(inputs))
<del> input_tensor, memory, attention_mask, self_attention_mask = inputs[:4]
<del> self_attention_inputs = [input_tensor, input_tensor]
<del> self_attention_output, cache = self.self_attention(
<del> self_attention_inputs,
<del> attention_mask=self_attention_mask,
<del> cache=cache,
<del> decode_loop_step=decode_loop_step)
<del> self_attention_output = self.self_attention_dropout(self_attention_output)
<del> self_attention_output = self.self_attention_layer_norm(
<del> input_tensor + self_attention_output)
<del>
<del> cross_attn_inputs = [self_attention_output, memory]
<del> if self.multi_channel_cross_attention:
<del> # Accesses the 5-th input tensor for the doc-attention probabilities.
<del> cross_attn_inputs.append(inputs[-1])
<del> attention_output = self.encdec_attention(cross_attn_inputs, attention_mask)
<del> attention_output = self.encdec_attention_dropout(attention_output)
<del> attention_output = self.encdec_attention_layer_norm(self_attention_output +
<del> attention_output)
<del>
<del> intermediate_output = self.intermediate_dense(attention_output)
<del> intermediate_output = self.intermediate_activation_layer(
<del> intermediate_output)
<del> layer_output = self.output_dense(intermediate_output)
<del> layer_output = self.output_dropout(layer_output)
<del> layer_output = self.output_layer_norm(layer_output + attention_output)
<del> return layer_output, cache
<del>
<del>
<ide> class TransformerDecoder(tf.keras.layers.Layer):
<ide> """Transformer decoder stack."""
<ide>
<ide> def build(self, unused_input_shapes):
<ide> self.layers = []
<ide> for i in range(self.num_hidden_layers):
<ide> self.layers.append(
<del> TransformerDecoderBlock(
<add> transformer.TransformerDecoderLayer(
<ide> hidden_size=self.hidden_size,
<ide> num_attention_heads=self.num_attention_heads,
<ide> intermediate_size=self.intermediate_size,
<ide><path>official/nlp/nhnet/decoder_test.py
<ide> from official.nlp.nhnet import utils
<ide>
<ide>
<del>def _create_cache(batch_size, init_decode_length, num_heads, head_size):
<del> return {
<del> "key":
<del> tf.zeros([batch_size, init_decode_length, num_heads, head_size],
<del> dtype=tf.float32),
<del> "value":
<del> tf.zeros([batch_size, init_decode_length, num_heads, head_size],
<del> dtype=tf.float32)
<del> }
<del>
<del>
<ide> class DecoderTest(tf.test.TestCase):
<ide>
<ide> def setUp(self):
<ide> def test_transformer_decoder(self):
<ide> decoder_block.build(None)
<ide> self.assertEqual(len(decoder_block.layers), self._config.num_hidden_layers)
<ide>
<del> def test_decoder_block_with_cache(self):
<del> decoder_block = decoder.TransformerDecoderBlock(
<del> hidden_size=self._config.hidden_size,
<del> num_attention_heads=self._config.num_attention_heads,
<del> intermediate_size=self._config.intermediate_size,
<del> intermediate_activation=self._config.hidden_act,
<del> hidden_dropout_prob=self._config.hidden_dropout_prob,
<del> attention_probs_dropout_prob=self._config.attention_probs_dropout_prob,
<del> initializer_range=self._config.initializer_range)
<del> # Forward path.
<del> dummy_tensor = tf.zeros([2, 4, self._config.hidden_size], dtype=tf.float32)
<del> dummy_mask = tf.zeros([2, 4, 4], dtype=tf.float32)
<del> inputs = [dummy_tensor, dummy_tensor, dummy_mask, dummy_mask]
<del> cache = _create_cache(
<del> 2, 0, self._config.num_attention_heads,
<del> self._config.hidden_size // self._config.num_attention_heads)
<del> output, cache = decoder_block(inputs, cache)
<del> self.assertEqual(output.shape, (2, 4, self._config.hidden_size))
<del> self.assertEqual(cache["value"].shape, (2, 4, 2, 8))
<del>
<ide> def test_bert_decoder(self):
<ide> seq_length = 10
<ide> encoder_input_ids = tf.keras.layers.Input(
<ide><path>official/nlp/nhnet/models.py
<ide> from official.modeling import tf_utils
<ide> from official.modeling.hyperparams import params_dict
<ide> from official.nlp.modeling import networks
<add>from official.nlp.modeling.layers import multi_channel_attention
<ide> from official.nlp.nhnet import configs
<ide> from official.nlp.nhnet import decoder
<del>from official.nlp.nhnet import multi_channel_attention
<ide> from official.nlp.nhnet import utils
<ide> from official.nlp.transformer import beam_search
<ide>
<ide> class NHNet(Bert2Bert):
<ide>
<ide> def __init__(self, params, bert_layer, decoder_layer, name=None):
<ide> super(NHNet, self).__init__(params, bert_layer, decoder_layer, name=name)
<del> self.doc_attention = multi_channel_attention.DocAttention(
<add> self.doc_attention = multi_channel_attention.VotingAttention(
<ide> num_heads=params.num_decoder_attn_heads,
<ide> head_size=params.hidden_size // params.num_decoder_attn_heads)
<ide>
| 9
|
PHP
|
PHP
|
remove duplicate check
|
e9a82e9dbacf7225386c0885f4727e311eb0e886
|
<ide><path>src/Illuminate/Session/Store.php
<ide> public function getOldInput($key = null, $default = null)
<ide> // Input that is flashed to the session can be easily retrieved by the
<ide> // developer, making repopulating old forms and the like much more
<ide> // convenient, since the request's previous input is available.
<del> if (is_null($key)) return $input;
<del>
<ide> return array_get($input, $key, $default);
<ide> }
<ide>
| 1
|
Java
|
Java
|
update timing module to support web workers
|
e4766b79797119015caa68f0641645829fbd9591
|
<ide><path>ReactAndroid/src/main/java/com/facebook/react/modules/core/JSTimersExecution.java
<ide> package com.facebook.react.modules.core;
<ide>
<ide> import com.facebook.react.bridge.JavaScriptModule;
<add>import com.facebook.react.bridge.SupportsWebWorkers;
<ide> import com.facebook.react.bridge.WritableArray;
<ide>
<add>@SupportsWebWorkers
<ide> public interface JSTimersExecution extends JavaScriptModule {
<ide>
<ide> public void callTimers(WritableArray timerIDs);
<ide><path>ReactAndroid/src/main/java/com/facebook/react/modules/core/Timing.java
<ide> import javax.annotation.Nullable;
<ide>
<ide> import java.util.Comparator;
<add>import java.util.HashMap;
<add>import java.util.Map;
<ide> import java.util.PriorityQueue;
<ide> import java.util.concurrent.atomic.AtomicBoolean;
<ide>
<ide>
<ide> import com.facebook.infer.annotation.Assertions;
<ide> import com.facebook.react.bridge.Arguments;
<add>import com.facebook.react.bridge.ExecutorToken;
<ide> import com.facebook.react.bridge.LifecycleEventListener;
<add>import com.facebook.react.bridge.OnExecutorUnregisteredListener;
<ide> import com.facebook.react.bridge.ReactApplicationContext;
<ide> import com.facebook.react.bridge.ReactContextBaseJavaModule;
<ide> import com.facebook.react.bridge.ReactMethod;
<ide> /**
<ide> * Native module for JS timer execution. Timers fire on frame boundaries.
<ide> */
<del>public final class Timing extends ReactContextBaseJavaModule implements LifecycleEventListener {
<add>public final class Timing extends ReactContextBaseJavaModule implements LifecycleEventListener,
<add> OnExecutorUnregisteredListener {
<ide>
<ide> private static class Timer {
<ide>
<add> private final ExecutorToken mExecutorToken;
<ide> private final int mCallbackID;
<ide> private final boolean mRepeat;
<ide> private final int mInterval;
<ide> private long mTargetTime;
<ide>
<del> private Timer(int callbackID, long initialTargetTime, int duration, boolean repeat) {
<add> private Timer(
<add> ExecutorToken executorToken,
<add> int callbackID,
<add> long initialTargetTime,
<add> int duration,
<add> boolean repeat) {
<add> mExecutorToken = executorToken;
<ide> mCallbackID = callbackID;
<ide> mTargetTime = initialTargetTime;
<ide> mInterval = duration;
<ide> private Timer(int callbackID, long initialTargetTime, int duration, boolean repe
<ide>
<ide> private class FrameCallback implements Choreographer.FrameCallback {
<ide>
<add> // Temporary map for constructing the individual arrays of timers per ExecutorToken
<add> private final HashMap<ExecutorToken, WritableArray> mTimersToCall = new HashMap<>();
<add>
<ide> /**
<ide> * Calls all timers that have expired since the last time this frame callback was called.
<ide> */
<ide> public void doFrame(long frameTimeNanos) {
<ide> }
<ide>
<ide> long frameTimeMillis = frameTimeNanos / 1000000;
<del> WritableArray timersToCall = null;
<ide> synchronized (mTimerGuard) {
<ide> while (!mTimers.isEmpty() && mTimers.peek().mTargetTime < frameTimeMillis) {
<ide> Timer timer = mTimers.poll();
<del> if (timersToCall == null) {
<del> timersToCall = Arguments.createArray();
<add> WritableArray timersForContext = mTimersToCall.get(timer.mExecutorToken);
<add> if (timersForContext == null) {
<add> timersForContext = Arguments.createArray();
<add> mTimersToCall.put(timer.mExecutorToken, timersForContext);
<ide> }
<del> timersToCall.pushInt(timer.mCallbackID);
<add> timersForContext.pushInt(timer.mCallbackID);
<ide> if (timer.mRepeat) {
<ide> timer.mTargetTime = frameTimeMillis + timer.mInterval;
<ide> mTimers.add(timer);
<ide> public void doFrame(long frameTimeNanos) {
<ide> }
<ide> }
<ide>
<del> if (timersToCall != null) {
<del> Assertions.assertNotNull(mJSTimersModule).callTimers(timersToCall);
<add> for (Map.Entry<ExecutorToken, WritableArray> entry : mTimersToCall.entrySet()) {
<add> getReactApplicationContext().getJSModule(entry.getKey(), JSTimersExecution.class)
<add> .callTimers(entry.getValue());
<ide> }
<add> mTimersToCall.clear();
<ide>
<ide> Assertions.assertNotNull(mReactChoreographer)
<ide> .postFrameCallback(ReactChoreographer.CallbackType.TIMERS_EVENTS, this);
<ide> public void doFrame(long frameTimeNanos) {
<ide>
<ide> private final Object mTimerGuard = new Object();
<ide> private final PriorityQueue<Timer> mTimers;
<del> private final SparseArray<Timer> mTimerIdsToTimers;
<add> private final HashMap<ExecutorToken, SparseArray<Timer>> mTimerIdsToTimers;
<ide> private final AtomicBoolean isPaused = new AtomicBoolean(true);
<ide> private final FrameCallback mFrameCallback = new FrameCallback();
<ide> private @Nullable ReactChoreographer mReactChoreographer;
<del> private @Nullable JSTimersExecution mJSTimersModule;
<ide> private boolean mFrameCallbackPosted = false;
<ide>
<ide> public Timing(ReactApplicationContext reactContext) {
<ide> public int compare(Timer lhs, Timer rhs) {
<ide> }
<ide> }
<ide> });
<del> mTimerIdsToTimers = new SparseArray<Timer>();
<add> mTimerIdsToTimers = new HashMap<>();
<ide> }
<ide>
<ide> @Override
<ide> public void initialize() {
<ide> // Safe to acquire choreographer here, as initialize() is invoked from UI thread.
<ide> mReactChoreographer = ReactChoreographer.getInstance();
<del> mJSTimersModule = getReactApplicationContext().getCatalystInstance()
<del> .getJSModule(JSTimersExecution.class);
<ide> getReactApplicationContext().addLifecycleEventListener(this);
<ide> }
<ide>
<ide> public String getName() {
<ide> return "RKTiming";
<ide> }
<ide>
<add> @Override
<add> public boolean supportsWebWorkers() {
<add> return true;
<add> }
<add>
<add> @Override
<add> public void onExecutorDestroyed(ExecutorToken executorToken) {
<add> synchronized (mTimerGuard) {
<add> SparseArray<Timer> timersForContext = mTimerIdsToTimers.remove(executorToken);
<add> if (timersForContext == null) {
<add> return;
<add> }
<add> for (int i = 0; i < timersForContext.size(); i++) {
<add> Timer timer = timersForContext.get(timersForContext.keyAt(i));
<add> mTimers.remove(timer);
<add> }
<add> }
<add> }
<add>
<ide> @ReactMethod
<ide> public void createTimer(
<add> ExecutorToken executorToken,
<ide> final int callbackID,
<ide> final int duration,
<ide> final double jsSchedulingTime,
<ide> public void createTimer(
<ide> 0,
<ide> jsSchedulingTime - SystemClock.currentTimeMillis() + duration);
<ide> long initialTargetTime = SystemClock.nanoTime() / 1000000 + adjustedDuration;
<del> Timer timer = new Timer(callbackID, initialTargetTime, duration, repeat);
<add> Timer timer = new Timer(executorToken, callbackID, initialTargetTime, duration, repeat);
<ide> synchronized (mTimerGuard) {
<ide> mTimers.add(timer);
<del> mTimerIdsToTimers.put(callbackID, timer);
<add> SparseArray<Timer> timersForContext = mTimerIdsToTimers.get(executorToken);
<add> if (timersForContext == null) {
<add> timersForContext = new SparseArray<>();
<add> mTimerIdsToTimers.put(executorToken, timersForContext);
<add> }
<add> timersForContext.put(callbackID, timer);
<ide> }
<ide> }
<ide>
<ide> @ReactMethod
<del> public void deleteTimer(int timerId) {
<add> public void deleteTimer(ExecutorToken executorToken, int timerId) {
<ide> synchronized (mTimerGuard) {
<del> Timer timer = mTimerIdsToTimers.get(timerId);
<add> Timer timer = mTimerIdsToTimers.get(executorToken).get(timerId);
<ide> if (timer != null) {
<ide> // We may have already called/removed it
<ide> mTimerIdsToTimers.remove(timerId);
<ide><path>ReactAndroid/src/test/java/com/facebook/react/modules/timing/TimingModuleTest.java
<ide> import android.view.Choreographer;
<ide>
<ide> import com.facebook.react.bridge.Arguments;
<add>import com.facebook.react.bridge.ExecutorToken;
<ide> import com.facebook.react.bridge.ReactApplicationContext;
<ide> import com.facebook.react.bridge.CatalystInstance;
<ide> import com.facebook.react.bridge.JavaOnlyArray;
<ide> public class TimingModuleTest {
<ide> private PostFrameCallbackHandler mPostFrameCallbackHandler;
<ide> private long mCurrentTimeNs;
<ide> private JSTimersExecution mJSTimersMock;
<add> private ExecutorToken mExecutorTokenMock;
<ide>
<ide> @Rule
<ide> public PowerMockRule rule = new PowerMockRule();
<ide> public Object answer(InvocationOnMock invocation) throws Throwable {
<ide>
<ide> mTiming = new Timing(reactContext);
<ide> mJSTimersMock = mock(JSTimersExecution.class);
<del> when(reactInstance.getJSModule(JSTimersExecution.class)).thenReturn(mJSTimersMock);
<add> mExecutorTokenMock = mock(ExecutorToken.class);
<add> when(reactContext.getJSModule(mExecutorTokenMock, JSTimersExecution.class)).thenReturn(mJSTimersMock);
<ide> mTiming.initialize();
<ide> }
<ide>
<ide> private void stepChoreographerFrame() {
<ide> @Test
<ide> public void testSimpleTimer() {
<ide> mTiming.onHostResume();
<del> mTiming.createTimer(1, 0, 0, false);
<add> mTiming.createTimer(mExecutorTokenMock, 1, 0, 0, false);
<ide> stepChoreographerFrame();
<ide> verify(mJSTimersMock).callTimers(JavaOnlyArray.of(1));
<ide> reset(mJSTimersMock);
<ide> public void testSimpleTimer() {
<ide>
<ide> @Test
<ide> public void testSimpleRecurringTimer() {
<del> mTiming.createTimer(100, 0, 0, true);
<add> mTiming.createTimer(mExecutorTokenMock, 100, 0, 0, true);
<ide> mTiming.onHostResume();
<ide> stepChoreographerFrame();
<ide> verify(mJSTimersMock).callTimers(JavaOnlyArray.of(100));
<ide> public void testSimpleRecurringTimer() {
<ide> @Test
<ide> public void testCancelRecurringTimer() {
<ide> mTiming.onHostResume();
<del> mTiming.createTimer(105, 0, 0, true);
<add> mTiming.createTimer(mExecutorTokenMock, 105, 0, 0, true);
<ide>
<ide> stepChoreographerFrame();
<ide> verify(mJSTimersMock).callTimers(JavaOnlyArray.of(105));
<ide>
<ide> reset(mJSTimersMock);
<del> mTiming.deleteTimer(105);
<add> mTiming.deleteTimer(mExecutorTokenMock, 105);
<ide> stepChoreographerFrame();
<ide> verifyNoMoreInteractions(mJSTimersMock);
<ide> }
<ide>
<ide> @Test
<ide> public void testPausingAndResuming() {
<ide> mTiming.onHostResume();
<del> mTiming.createTimer(41, 0, 0, true);
<add> mTiming.createTimer(mExecutorTokenMock, 41, 0, 0, true);
<ide>
<ide> stepChoreographerFrame();
<ide> verify(mJSTimersMock).callTimers(JavaOnlyArray.of(41));
| 3
|
Javascript
|
Javascript
|
add file attribute to timings data
|
80533f5d6259654892e557dcf3d70e549453cb69
|
<ide><path>run-tests.js
<ide> const timings = []
<ide> for (const timing of timings) {
<ide> const timeInSeconds = timing.time / 1000
<ide> junitData += `
<del> <testsuite name="${
<del> timing.file
<del> }" tests="1" errors="0" failures="0" skipped="0" timestamp="${new Date().toJSON()}" time="${timeInSeconds}">
<add> <testsuite name="${timing.file}" file="${
<add> timing.file
<add> }" tests="1" errors="0" failures="0" skipped="0" timestamp="${new Date().toJSON()}" time="${timeInSeconds}">
<ide> <testcase classname="tests suite should pass" name="${
<ide> timing.file
<ide> }" time="${timeInSeconds}"></testcase>
| 1
|
Python
|
Python
|
use only simple types
|
492e5b6591a9e7413478c66a038e1a30b0a59326
|
<ide><path>keras/callbacks.py
<ide> import re
<ide> import sys
<ide> import time
<del>from typing import Iterable
<del>from typing import Optional
<del>from typing import Union
<ide>
<ide> import numpy as np
<ide> import tensorflow.compat.v2 as tf
<ide> class BaseLogger(Callback):
<ide> All others will be averaged in `on_epoch_end`.
<ide> """
<ide>
<del> def __init__(self, stateful_metrics: Optional[Iterable[str]] = None):
<add> def __init__(self, stateful_metrics=None):
<ide> super().__init__()
<ide> self.stateful_metrics = set(stateful_metrics or [])
<ide>
<ide> class ProgbarLogger(Callback):
<ide> def __init__(
<ide> self,
<ide> count_mode: str = "samples",
<del> stateful_metrics: Optional[Iterable[str]] = None,
<add> stateful_metrics=None
<ide> ):
<ide> # when we drop support for python 3.7, replace 'count_mode: str'
<ide> # with 'count_mode: Literal["samples", "steps"]'
<ide> class ModelCheckpoint(Callback):
<ide>
<ide> def __init__(
<ide> self,
<del> filepath: Union[str, os.PathLike],
<add> filepath,
<ide> monitor: str = "val_loss",
<ide> verbose: int = 0,
<ide> save_best_only: bool = False,
<ide> save_weights_only: bool = False,
<ide> mode: str = "auto",
<del> save_freq: Union[int, str] = "epoch",
<del> options: Union[
<del> tf.train.CheckpointOptions, tf.saved_model.SaveOptions, None
<del> ] = None,
<del> initial_value_threshold: Optional[float] = None,
<add> save_freq="epoch",
<add> options=None,
<add> initial_value_threshold=None,
<ide> **kwargs,
<ide> ):
<ide> super().__init__()
| 1
|
Python
|
Python
|
add imports in official/nlp/modeling/__init__.py
|
0c53959ef0183737209557236501c94406db8cf9
|
<ide><path>official/nlp/modeling/__init__.py
<del>
<add># Copyright 2021 The TensorFlow Authors. All Rights Reserved.
<add>#
<add># Licensed under the Apache License, Version 2.0 (the "License");
<add># you may not use this file except in compliance with the License.
<add># You may obtain a copy of the License at
<add>#
<add># http://www.apache.org/licenses/LICENSE-2.0
<add>#
<add># Unless required by applicable law or agreed to in writing, software
<add># distributed under the License is distributed on an "AS IS" BASIS,
<add># WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<add># See the License for the specific language governing permissions and
<add># limitations under the License.
<add># ==============================================================================
<add>"""Modeling package definition."""
<add>from official.nlp.modeling import layers
<add>from official.nlp.modeling import losses
<add>from official.nlp.modeling import models
<add>from official.nlp.modeling import networks
| 1
|
Text
|
Text
|
replace link to the line on github with rdoc link
|
4c6481f08fdc45af76b162e313f68b6fc6ef14f4
|
<ide><path>guides/source/rails_application_templates.md
<ide> Advanced Usage
<ide> --------------
<ide>
<ide> The application template is evaluated in the context of a
<del>`Rails::Generators::AppGenerator` instance. It uses the `apply` action
<del>provided by
<del>[Thor](https://github.com/erikhuda/thor/blob/master/lib/thor/actions.rb#L207).
<add>`Rails::Generators::AppGenerator` instance. It uses the
<add>[`apply`](https://rdoc.info/github/wycats/thor/Thor/Actions#apply-instance_method)
<add>action provided by Thor.
<add>
<ide> This means you can extend and change the instance to match your needs.
<ide>
<ide> For example by overwriting the `source_paths` method to contain the
| 1
|
Text
|
Text
|
use serial comma in assert docs
|
67843f81b5312d12e24b241a3ca1e4425c8cc436
|
<ide><path>doc/api/assert.md
<ide> are also recursively evaluated by the following rules.
<ide> objects.
<ide> * [`Symbol`][] properties are not compared.
<ide> * [`WeakMap`][] and [`WeakSet`][] comparison does not rely on their values.
<del>* [`RegExp`][] lastIndex, flags and source are always compared, even if these
<add>* [`RegExp`][] lastIndex, flags, and source are always compared, even if these
<ide> are not enumerable properties.
<ide>
<ide> The following example does not throw an [`AssertionError`][] because the
<ide> are recursively evaluated also by the following rules.
<ide> reference.
<ide> * [`WeakMap`][] and [`WeakSet`][] comparison does not rely on their values. See
<ide> below for further details.
<del>* [`RegExp`][] lastIndex, flags and source are always compared, even if these
<add>* [`RegExp`][] lastIndex, flags, and source are always compared, even if these
<ide> are not enumerable properties.
<ide>
<ide> ```mjs
<ide> benefit in catching a rejection and then rejecting it again. Instead, consider
<ide> adding a comment next to the specific code path that should not reject and keep
<ide> error messages as expressive as possible.
<ide>
<del>If specified, `error` can be a [`Class`][], [`RegExp`][] or a validation
<add>If specified, `error` can be a [`Class`][], [`RegExp`][], or a validation
<ide> function. See [`assert.throws()`][] for more details.
<ide>
<ide> Besides the async nature to await the completion behaves identically to
<ide> parameter, then an [`AssertionError`][] is thrown. If the error is of a
<ide> different type, or if the `error` parameter is undefined, the error is
<ide> propagated back to the caller.
<ide>
<del>If specified, `error` can be a [`Class`][], [`RegExp`][] or a validation
<add>If specified, `error` can be a [`Class`][], [`RegExp`][], or a validation
<ide> function. See [`assert.throws()`][] for more details.
<ide>
<ide> The following, for instance, will throw the [`TypeError`][] because there is no
| 1
|
Python
|
Python
|
add constraints and regularizers modules
|
babc0b9dd873de40ba459027a27865c330b4f58b
|
<ide><path>keras/constraints.py
<add>from __future__ import absolute_import
<add>import theano
<add>import theano.tensor as T
<add>import numpy as np
<add>
<add>def maxnorm(m=2):
<add> def maxnorm_wrap(p):
<add> norms = T.sqrt(T.sum(T.sqr(p), axis=0))
<add> desired = T.clip(norms, 0, m)
<add> p = p * (desired / (1e-7 + norms))
<add> return p
<add> return maxnorm_wrap
<add>
<add>def nonneg(p):
<add> p *= T.ge(p,0)
<add> return p
<ide>\ No newline at end of file
<ide><path>keras/regularizers.py
<add>from __future__ import absolute_import
<add>import theano
<add>import theano.tensor as T
<add>import numpy as np
<add>
<add>def l1(lam=.01):
<add> def l1wrap(g,p):
<add> g += T.sgn(p) * lam
<add> return g
<add> return l1wrap
<add>
<add>def l2(lam=.01):
<add> def l2wrap(g,p):
<add> g += p * lam
<add> return g
<add> return l2wrap
<add>
<add>def ident(g,*l):
<add> return g
<ide>\ No newline at end of file
| 2
|
Javascript
|
Javascript
|
fix incorrect update of the webworker template
|
a6f0ca9c07a02d48dff86deca46d5926edbb9fc5
|
<ide><path>lib/webworker/WebWorkerChunkTemplatePlugin.js
<ide> class WebWorkerChunkTemplatePlugin {
<ide> chunkTemplate.plugin("render", (modules, chunk) => {
<ide> const chunkCallbackName = chunkTemplate.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (chunkTemplate.outputOptions.library || ""));
<ide> const source = new ConcatSource();
<del> source.add(`${chunkCallbackName}(${JSON.stringify(chunk.ids)},`);
<add> source.add(`self[${JSON.stringify(chunkCallbackName)}](${JSON.stringify(chunk.ids)},`);
<ide> source.add(modules);
<ide> source.add(")");
<ide> return source;
<ide><path>lib/webworker/WebWorkerMainTemplatePlugin.js
<ide> class WebWorkerMainTemplatePlugin {
<ide> mainTemplate.plugin("require-ensure", (_, chunk, hash) => {
<ide> const chunkFilename = mainTemplate.outputOptions.chunkFilename;
<ide> return mainTemplate.asString([
<del> "return new Promise(function(resolve) {",
<add> "promises.push(Promise.resolve().then(function() {",
<ide> mainTemplate.indent([
<ide> "// \"1\" is the signal for \"already loaded\"",
<ide> "if(!installedChunks[chunkId]) {",
<ide> class WebWorkerMainTemplatePlugin {
<ide> }) + ");"
<ide> ]),
<ide> "}",
<del> "resolve();"
<ide> ]),
<del> "});"
<add> "}));"
<ide> ]);
<ide> });
<ide> mainTemplate.plugin("bootstrap", (source, chunk, hash) => {
<ide> if(chunk.getNumberOfChunks() > 0) {
<ide> const chunkCallbackName = mainTemplate.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (mainTemplate.outputOptions.library || ""));
<ide> return mainTemplate.asString([
<ide> source,
<del> `mainTemplate[${JSON.stringify(chunkCallbackName)}] = function webpackChunkCallback(chunkIds, moreModules) {`,
<add> `self[${JSON.stringify(chunkCallbackName)}] = function webpackChunkCallback(chunkIds, moreModules) {`,
<ide> mainTemplate.indent([
<ide> "for(var moduleId in moreModules) {",
<ide> mainTemplate.indent(mainTemplate.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")),
| 2
|
Text
|
Text
|
change the statement for or operator
|
994d0a161eeec2377791716e8e5581f2b812dfd6
|
<ide><path>guide/english/logic/truth-tables/index.md
<ide> Here is the truth table for the OR operator
<ide> | T | F | T |
<ide> | T | T | T |
<ide>
<del>Just like above the OR operator operates on two variables, notice that the only time the OR operator evaluates to True is when `x` & `y` negate eachother.
<add>Just like above the OR operator operates on two variables, notice that the only time the OR operator evaluates to False is when both `x` & `y` are False.
<ide>
<ide> Let's do one more, let's do the table for the Negation, this operates on one value instead of two
<ide>
| 1
|
Java
|
Java
|
fix invalid characters in source files
|
211f0bbf885a3d291f45c4a10db6cc5c0243b14f
|
<ide><path>spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
<ide> /*
<del> * Copyright 2002-2020 the original author or authors.
<add> * Copyright 2002-2021 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> else if (mbd.isPrototype()) {
<ide> else {
<ide> String scopeName = mbd.getScope();
<ide> if (!StringUtils.hasLength(scopeName)) {
<del> throw new IllegalStateException("No scope name defined for bean ´" + beanName + "'");
<add> throw new IllegalStateException("No scope name defined for bean '" + beanName + "'");
<ide> }
<ide> Scope scope = this.scopes.get(scopeName);
<ide> if (scope == null) {
<ide><path>spring-expression/src/main/java/org/springframework/expression/BeanResolver.java
<ide> /*
<del> * Copyright 2002-2018 the original author or authors.
<add> * Copyright 2002-2021 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> * A bean resolver can be registered with the evaluation context and will kick in
<ide> * for bean references: {@code @myBeanName} and {@code &myBeanName} expressions.
<del> * The <tt>&</tt> variant syntax allows access to the factory bean where relevant.
<add> * The {@code &} variant syntax allows access to the factory bean where relevant.
<ide> *
<ide> * @author Andy Clement
<ide> * @since 3.0.3
<ide> public interface BeanResolver {
<ide>
<ide> /**
<ide> * Look up a bean by the given name and return a corresponding instance for it.
<del> * For attempting access to a factory bean, the name needs a <tt>&</tt> prefix.
<add> * For attempting access to a factory bean, the name needs a {@code &} prefix.
<ide> * @param context the current evaluation context
<ide> * @param beanName the name of the bean to look up
<ide> * @return an object representing the bean
<ide><path>spring-expression/src/main/java/org/springframework/expression/TypeComparator.java
<ide> /*
<del> * Copyright 2002-2017 the original author or authors.
<add> * Copyright 2002-2021 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 interface TypeComparator {
<ide> * Compare two given objects.
<ide> * @param firstObject the first object
<ide> * @param secondObject the second object
<del> * @return 0 if they are equal, <0 if the first is smaller than the second,
<del> * or >0 if the first is larger than the second
<add> * @return 0 if they are equal, a negative integer if the first is smaller than
<add> * the second, or a positive integer if the first is larger than the second
<ide> * @throws EvaluationException if a problem occurs during comparison
<ide> * (or if they are not comparable in the first place)
<add> * @see Comparable#compareTo
<ide> */
<ide> int compare(@Nullable Object firstObject, @Nullable Object secondObject) throws EvaluationException;
<ide>
<ide><path>spring-expression/src/main/java/org/springframework/expression/spel/ast/BeanReference.java
<ide> import org.springframework.expression.spel.SpelMessage;
<ide>
<ide> /**
<del> * Represents a bean reference to a type, for example <tt>@foo</tt> or <tt>@'foo.bar'</tt>.
<del> * For a FactoryBean the syntax <tt>&foo</tt> can be used to access the factory itself.
<add> * Represents a bean reference to a type, for example {@code @foo} or {@code @'foo.bar'}.
<add> * For a FactoryBean the syntax {@code &foo} can be used to access the factory itself.
<ide> *
<ide> * @author Andy Clement
<ide> */
| 4
|
Go
|
Go
|
use formatter in docker checkpoint ls
|
f9d2636787e2c1c1bff02f51fded9094236e235a
|
<ide><path>cli/command/checkpoint/list.go
<ide> package checkpoint
<ide>
<ide> import (
<del> "fmt"
<del> "text/tabwriter"
<del>
<ide> "golang.org/x/net/context"
<ide>
<ide> "github.com/docker/docker/api/types"
<ide> "github.com/docker/docker/cli"
<ide> "github.com/docker/docker/cli/command"
<add> "github.com/docker/docker/cli/command/formatter"
<ide> "github.com/spf13/cobra"
<ide> )
<ide>
<ide> func runList(dockerCli *command.DockerCli, container string, opts listOptions) e
<ide> return err
<ide> }
<ide>
<del> w := tabwriter.NewWriter(dockerCli.Out(), 20, 1, 3, ' ', 0)
<del> fmt.Fprintf(w, "CHECKPOINT NAME")
<del> fmt.Fprintf(w, "\n")
<del>
<del> for _, checkpoint := range checkpoints {
<del> fmt.Fprintf(w, "%s\t", checkpoint.Name)
<del> fmt.Fprint(w, "\n")
<add> cpCtx := formatter.Context{
<add> Output: dockerCli.Out(),
<add> Format: formatter.NewCheckpointFormat(formatter.TableFormatKey),
<ide> }
<del>
<del> w.Flush()
<del> return nil
<add> return formatter.CheckpointWrite(cpCtx, checkpoints)
<ide> }
<ide><path>cli/command/formatter/checkpoint.go
<add>package formatter
<add>
<add>import "github.com/docker/docker/api/types"
<add>
<add>const (
<add> defaultCheckpointFormat = "table {{.Name}}"
<add>
<add> checkpointNameHeader = "CHECKPOINT NAME"
<add>)
<add>
<add>// NewCheckpointFormat returns a format for use with a checkpoint Context
<add>func NewCheckpointFormat(source string) Format {
<add> switch source {
<add> case TableFormatKey:
<add> return defaultCheckpointFormat
<add> }
<add> return Format(source)
<add>}
<add>
<add>// CheckpointWrite writes formatted checkpoints using the Context
<add>func CheckpointWrite(ctx Context, checkpoints []types.Checkpoint) error {
<add> render := func(format func(subContext subContext) error) error {
<add> for _, checkpoint := range checkpoints {
<add> if err := format(&checkpointContext{c: checkpoint}); err != nil {
<add> return err
<add> }
<add> }
<add> return nil
<add> }
<add> return ctx.Write(newCheckpointContext(), render)
<add>}
<add>
<add>type checkpointContext struct {
<add> HeaderContext
<add> c types.Checkpoint
<add>}
<add>
<add>func newCheckpointContext() *checkpointContext {
<add> cpCtx := checkpointContext{}
<add> cpCtx.header = volumeHeaderContext{
<add> "Name": checkpointNameHeader,
<add> }
<add> return &cpCtx
<add>}
<add>
<add>func (c *checkpointContext) MarshalJSON() ([]byte, error) {
<add> return marshalJSON(c)
<add>}
<add>
<add>func (c *checkpointContext) Name() string {
<add> return c.c.Name
<add>}
<ide><path>cli/command/formatter/checkpoint_test.go
<add>package formatter
<add>
<add>import (
<add> "bytes"
<add> "testing"
<add>
<add> "github.com/docker/docker/api/types"
<add> "github.com/stretchr/testify/assert"
<add>)
<add>
<add>func TestCheckpointContextFormatWrite(t *testing.T) {
<add> cases := []struct {
<add> context Context
<add> expected string
<add> }{
<add> {
<add> Context{Format: NewCheckpointFormat(defaultCheckpointFormat)},
<add> `CHECKPOINT NAME
<add>checkpoint-1
<add>checkpoint-2
<add>checkpoint-3
<add>`,
<add> },
<add> {
<add> Context{Format: NewCheckpointFormat("{{.Name}}")},
<add> `checkpoint-1
<add>checkpoint-2
<add>checkpoint-3
<add>`,
<add> },
<add> {
<add> Context{Format: NewCheckpointFormat("{{.Name}}:")},
<add> `checkpoint-1:
<add>checkpoint-2:
<add>checkpoint-3:
<add>`,
<add> },
<add> }
<add>
<add> checkpoints := []types.Checkpoint{
<add> {"checkpoint-1"},
<add> {"checkpoint-2"},
<add> {"checkpoint-3"},
<add> }
<add> for _, testcase := range cases {
<add> out := bytes.NewBufferString("")
<add> testcase.context.Output = out
<add> err := CheckpointWrite(testcase.context, checkpoints)
<add> if err != nil {
<add> assert.Error(t, err, testcase.expected)
<add> } else {
<add> assert.Equal(t, out.String(), testcase.expected)
<add> }
<add> }
<add>}
| 3
|
Ruby
|
Ruby
|
add a test for reflection keys as strings, fixes
|
be8d1a9b57175732f9dafe23f790da82d4b06135
|
<ide><path>activerecord/test/cases/reflection_test.rb
<ide> def test_reflection_should_not_raise_error_when_compared_to_other_object
<ide> assert_not_equal Object.new, Firm._reflections['clients']
<ide> end
<ide>
<add> def test_reflections_should_return_keys_as_strings
<add> assert Category.reflections.keys.all? { |key| key.is_a? String }, "Model.reflections is expected to return string for keys"
<add> end
<add>
<ide> def test_has_and_belongs_to_many_reflection
<ide> assert_equal :has_and_belongs_to_many, Category.reflections['posts'].macro
<ide> assert_equal :posts, Category.reflect_on_all_associations(:has_and_belongs_to_many).first.name
| 1
|
Text
|
Text
|
add jungminu to collaborators
|
5c6aac4d2775c192051bd3b053302d8cc78d0aa0
|
<ide><path>README.md
<ide> information about the governance of the Node.js project, see
<ide> * [jbergstroem](https://github.com/jbergstroem) - **Johan Bergström** <bugs@bergstroem.nu>
<ide> * [joaocgreis](https://github.com/joaocgreis) - **João Reis** <reis@janeasystems.com>
<ide> * [julianduque](https://github.com/julianduque) - **Julian Duque** <julianduquej@gmail.com>
<add>* [JungMinu](https://github.com/JungMinu) - **Minwoo Jung** <jmwsoft@gmail.com>
<ide> * [lxe](https://github.com/lxe) - **Aleksey Smolenchuk** <lxe@lxe.co>
<ide> * [mhdawson](https://github.com/mhdawson) - **Michael Dawson** <michael_dawson@ca.ibm.com>
<ide> * [micnic](https://github.com/micnic) - **Nicu Micleușanu** <micnic90@gmail.com>
| 1
|
Go
|
Go
|
remove redundant assignment to ep.network
|
7fa78a97c4c54e1a79b65e725302635efe4c59a9
|
<ide><path>libnetwork/store.go
<ide> func (n *network) getEndpointsFromStore() ([]*endpoint, error) {
<ide>
<ide> for _, kvo := range kvol {
<ide> ep := kvo.(*endpoint)
<del> ep.network = n
<ide> epl = append(epl, ep)
<ide> }
<ide> }
| 1
|
Python
|
Python
|
add microversion support
|
009d1e8c24d1700da02da57b4122280a6bca34a3
|
<ide><path>libcloud/compute/drivers/openstack.py
<ide> class OpenStack_1_1_NodeDriver(OpenStackNodeDriver):
<ide> _networks_url_prefix = "/os-networks"
<ide>
<ide> def __init__(self, *args, **kwargs):
<add> self.ex_force_microversion = str(kwargs.pop("ex_force_microversion", None))
<ide> self._ex_force_api_version = str(kwargs.pop("ex_force_api_version", None))
<ide> super(OpenStack_1_1_NodeDriver, self).__init__(*args, **kwargs)
<ide>
<add> def _set_microversion(self, headers=None):
<add> """Add the microversion header to the specified headers"""
<add> res = {}
<add> if self.ex_force_microversion:
<add> if headers:
<add> res.update(headers)
<add> res["OpenStack-API-Version:"] = "compute %s" % self.ex_force_microversion
<add> return res
<add>
<ide> def create_node(
<ide> self,
<ide> name,
<ide> def create_node(
<ide> if ex_os_scheduler_hints:
<ide> data["os:scheduler_hints"] = ex_os_scheduler_hints
<ide>
<del> resp = self.connection.request("/servers", method="POST", data=data)
<add> resp = self.connection.request("/servers", method="POST", data=data,
<add> headers=self._set_microversion())
<ide>
<ide> create_response = resp.object["server"]
<ide> server_resp = self.connection.request("/servers/%s" % create_response["id"])
| 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.