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
Text
Text
update versions in updating.md for 2.0.0b1 release
5ac1738d52840ac59f75bb93627d45ce22029409
<ide><path>UPDATING.md <ide> assists users migrating to a new version. <ide> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> <ide> **Table of contents** <ide> <del>- [Airflow Master](#airflow-master) <add>- [Airflow 2.0.0b1](#airflow-200b1) <ide> - [Airflow 2.0.0a1](#airflow-200a1) <ide> - [Airflow 1.10.13](#airflow-11013) <ide> - [Airflow 1.10.12](#airflow-11012) <ide> assists users migrating to a new version. <ide> <ide> <!-- END doctoc generated TOC please keep comment here to allow auto update --> <ide> <del>## Airflow Master <add>## Airflow 2.0.0b1 <ide> <ide> ### Default value for `[celery] operation_timeout` has changed to `1.0` <ide>
1
Java
Java
initialize resourceurlprovider only once
2bf6b41bcc02ac137d2fc4b2731057c55157d16f
<ide><path>spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java <ide> /* <del> * Copyright 2002-2014 the original author or authors. <add> * Copyright 2002-2015 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 void onApplicationEvent(ContextRefreshedEvent event) { <ide> if (this.handlerMap.isEmpty() && logger.isDebugEnabled()) { <ide> logger.debug("No resource handling mappings found"); <ide> } <add> if(!this.handlerMap.isEmpty()) { <add> this.autodetect = false; <add> } <ide> } <ide> } <ide> <ide><path>spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlProviderTests.java <ide> /* <del> * Copyright 2002-2014 the original author or authors. <add> * Copyright 2002-2015 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 java.util.List; <ide> import java.util.Map; <ide> <add>import org.hamcrest.Matchers; <ide> import org.junit.Before; <ide> import org.junit.Test; <ide> <add>import org.springframework.context.annotation.Bean; <add>import org.springframework.context.annotation.Configuration; <ide> import org.springframework.core.io.ClassPathResource; <ide> import org.springframework.core.io.Resource; <add>import org.springframework.mock.web.test.MockServletContext; <add>import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; <add>import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping; <ide> <ide> import static org.junit.Assert.*; <ide> <ide> private void initTranslator() { <ide> this.translator.setHandlerMap(this.handlerMap); <ide> } <ide> <add> // SPR-12592 <add> @Test <add> public void initializeOnce() throws Exception { <add> AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); <add> context.setServletContext(new MockServletContext()); <add> context.register(HandlerMappingConfiguration.class); <add> context.refresh(); <add> ResourceUrlProvider translator = context.getBean(ResourceUrlProvider.class); <add> assertThat(translator.getHandlerMap(), Matchers.hasKey("/resources/**")); <add> assertFalse(translator.isAutodetect()); <add> } <add> <add> @Configuration <add> public static class HandlerMappingConfiguration { <add> @Bean <add> public SimpleUrlHandlerMapping simpleUrlHandlerMapping() { <add> ResourceHttpRequestHandler handler = new ResourceHttpRequestHandler(); <add> HashMap<String, ResourceHttpRequestHandler> handlerMap = new HashMap<String, ResourceHttpRequestHandler>(); <add> handlerMap.put("/resources/**", handler); <add> SimpleUrlHandlerMapping hm = new SimpleUrlHandlerMapping(); <add> hm.setUrlMap(handlerMap); <add> return hm; <add> } <add> <add> @Bean <add> public ResourceUrlProvider resourceUrlProvider() { <add> return new ResourceUrlProvider(); <add> } <add> } <add> <ide> }
2
Javascript
Javascript
remove some unnecessary returns
98dace337254ca1e26a35873afaa010be1ff3bf9
<ide><path>src/config.js <ide> export default class Config { <ide> this.legacyScopeAliases = {} <ide> <ide> this.requestLoad = _.debounce(() => { <del> return this.loadUserConfig() <add> this.loadUserConfig() <ide> } <ide> , 100) <ide> <ide> const debouncedSave = _.debounce(() => { <ide> this.savePending = false <del> return this.save() <add> this.save() <ide> } <ide> , 100) <ide> this.requestSave = () => { <ide> export default class Config { <ide> } <ide> <ide> removeLegacyScopeAlias (languageId) { <del> return delete this.legacyScopeAliases[languageId] <add> delete this.legacyScopeAliases[languageId] <ide> } <ide> <ide> /* <ide> export default class Config { <ide> } <ide> <ide> beginTransaction () { <del> return this.transactDepth++ <add> this.transactDepth++ <ide> } <ide> <ide> endTransaction () { <ide> this.transactDepth-- <del> return this.emitChangeEvent() <add> this.emitChangeEvent() <ide> } <ide> <ide> pushAtKeyPath (keyPath, value) {
1
Java
Java
fix typo in mockfilterchain
060b37ca8db5a3b822029800348a3fe0f0b1b15f
<ide><path>spring-orm/src/test/java/org/springframework/mock/web/MockFilterChain.java <ide> /* <del> * Copyright 2002-2009 the original author or authors. <add> * Copyright 2002-2012 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 org.springframework.util.Assert; <ide> <ide> /** <del> * Mock implementation of the {@link javax.servlet.FilterConfig} interface. <add> * Mock implementation of the {@link javax.servlet.FilterChain} interface. <ide> * <ide> * <p>Used for testing the web framework; also useful for testing <ide> * custom {@link javax.servlet.Filter} implementations. <ide> * <ide> * @author Juergen Hoeller <ide> * @since 2.0.3 <del> * @see org.springframework.mock.web.MockFilterConfig <del> * @see org.springframework.mock.web.PassThroughFilterChain <add> * @see MockFilterConfig <add> * @see PassThroughFilterChain <ide> */ <ide> public class MockFilterChain implements FilterChain { <ide> <ide><path>spring-test/src/main/java/org/springframework/mock/web/MockFilterChain.java <ide> /* <del> * Copyright 2002-2009 the original author or authors. <add> * Copyright 2002-2012 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 org.springframework.util.Assert; <ide> <ide> /** <del> * Mock implementation of the {@link javax.servlet.FilterConfig} interface. <add> * Mock implementation of the {@link javax.servlet.FilterChain} interface. <ide> * <ide> * <p>Used for testing the web framework; also useful for testing <ide> * custom {@link javax.servlet.Filter} implementations. <ide><path>spring-web/src/test/java/org/springframework/mock/web/MockFilterChain.java <ide> /* <del> * Copyright 2002-2011 the original author or authors. <add> * Copyright 2002-2012 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 org.springframework.util.Assert; <ide> <ide> /** <del> * Mock implementation of the {@link javax.servlet.FilterConfig} interface. <add> * Mock implementation of the {@link javax.servlet.FilterChain} interface. <ide> * <ide> * <p>Used for testing the web framework; also useful for testing <ide> * custom {@link javax.servlet.Filter} implementations. <ide><path>spring-webmvc/src/test/java/org/springframework/mock/web/MockFilterChain.java <ide> /* <del> * Copyright 2002-2009 the original author or authors. <add> * Copyright 2002-2012 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 org.springframework.util.Assert; <ide> <ide> /** <del> * Mock implementation of the {@link javax.servlet.FilterConfig} interface. <add> * Mock implementation of the {@link javax.servlet.FilterChain} interface. <ide> * <del> * <p>Used for testing the web framework; also usefol for testing <add> * <p>Used for testing the web framework; also useful for testing <ide> * custom {@link javax.servlet.Filter} implementations. <ide> * <ide> * @author Juergen Hoeller
4
Python
Python
remove unused variable
6f09be91e695d74f19aac084808b998ecf6eb24e
<ide><path>keras/preprocessing/image.py <ide> def fit(self, x, <ide> if self.zca_whitening: <ide> flat_x = np.reshape(x, (x.shape[0], x.shape[1] * x.shape[2] * x.shape[3])) <ide> num_examples = flat_x.shape[0] <del> u, s, vt = linalg.svd(flat_x / np.sqrt(num_examples)) <del> s_expand = np.hstack((s, np.zeros(vt.shape[0] - num_examples, dtype=flat_x.dtype))) <add> _, s, vt = linalg.svd(flat_x / np.sqrt(num_examples)) <add> s_expand = np.hstack((s, np.zeros(vt.shape[0] - num_examples, <add> dtype=flat_x.dtype))) <ide> self.principal_components = (vt.T / np.sqrt(s_expand ** 2 + self.zca_epsilon)).dot(vt) <ide> <ide>
1
Text
Text
fix broken prerequisite link
b21751da907cb2889aa9ca95ebf6c4c66e6131a6
<ide><path>docs/sources/project/set-up-dev-env.md <ide> You use the `docker` repository and its `Dockerfile` to create a Docker image, <ide> run a Docker container, and develop code in the container. Docker itself builds, <ide> tests, and releases new Docker versions using this container. <ide> <del>If you followed the procedures that <a href="./set-up-prereqs" target="_blank"> <add>If you followed the procedures that <a href="./software-required" target="_blank"> <ide> set up the prerequisites</a>, you should have a fork of the `docker/docker` <ide> repository. You also created a branch called `dry-run-test`. In this section, <ide> you continue working with your fork on this branch.
1
Python
Python
fix lgtm error display
04962c0d17b82f349e0453b06b76d9f594e2b024
<ide><path>data_structures/heap/binomial_heap.py <ide> def deleteMin(self): <ide> # No right subtree corner case <ide> # The structure of the tree implies that this should be the bottom root <ide> # and there is at least one other root <del> if self.min_node.right == None: <add> if self.min_node.right is None: <ide> # Update size <ide> self.size -= 1 <ide> <ide><path>divide_and_conquer/convex_hull.py <ide> def _validate_input(points): <ide> else: <ide> raise ValueError("Expecting an iterable of type Point, list or tuple. " <ide> "Found objects of type {} instead" <del> .format(["point", "list", "tuple"], type(points[0]))) <add> .format(type(points[0]))) <ide> elif not hasattr(points, "__iter__"): <ide> raise ValueError("Expecting an iterable object " <ide> "but got an non-iterable type {}".format(points)) <ide><path>neural_network/convolution_neural_network.py <ide> def convolution(self, data): <ide> <ide> <ide> if __name__ == '__main__': <del> pass <ide> ''' <ide> I will put the example on other file <del>''' <add> ''' <ide><path>strings/boyer_moore_search.py <ide> def bad_character_heuristic(self): <ide> positions.append(i) <ide> else: <ide> match_index = self.match_in_pattern(self.text[mismatch_index]) <del> i = mismatch_index - match_index #shifting index <add> i = mismatch_index - match_index #shifting index lgtm [py/multiple-definition] <ide> return positions <ide> <ide>
4
Ruby
Ruby
fix default formula prune
0245b2cfea973c849f3bd7a8d4ab973dc466fe5f
<ide><path>Library/Homebrew/formula_installer.rb <ide> def expand_requirements <ide> <ide> if (req.optional? || req.recommended?) && build.without?(req) <ide> Requirement.prune <del> elsif req.build? && use_default_formula <add> elsif req.build? && use_default_formula && req_dependency.installed? <ide> Requirement.prune <ide> elsif install_requirement_formula?(req_dependency, req, install_bottle_for_dependent) <ide> deps.unshift(req_dependency)
1
PHP
PHP
add throws tag to findorcreate
f0e2e64af8ccc689b9d62298d6de3c60d35a2c4d
<ide><path>src/ORM/Table.php <ide> protected function _transactionCommitted($atomic, $primary) <ide> * is persisted. <ide> * @param array $options The options to use when saving. <ide> * @return \Cake\Datasource\EntityInterface An entity. <add> * @throws \Cake\ORM\Exception\PersistenceFailedException When the entity couldn't be saved <ide> */ <ide> public function findOrCreate($search, callable $callback = null, $options = []) <ide> { <ide> public function findOrCreate($search, callable $callback = null, $options = []) <ide> * is persisted. <ide> * @param array $options The options to use when saving. <ide> * @return \Cake\Datasource\EntityInterface An entity. <add> * @throws \Cake\ORM\Exception\PersistenceFailedException When the entity couldn't be saved <ide> */ <ide> protected function _processFindOrCreate($search, callable $callback = null, $options = []) <ide> {
1
PHP
PHP
use consistent uppercase for doctype
55e459049c09572998cbbb8e277224cf91cd4102
<ide><path>src/Illuminate/Foundation/Exceptions/views/illustrated-layout.blade.php <del><!doctype html> <add><!DOCTYPE html> <ide> <html lang="en"> <ide> <head> <ide> <title>@yield('title')</title>
1
Java
Java
inline disposability in obs.concatmap(completable)
1b0cd2a40a45ec57e0b6ccf961f084a30c3165c7
<ide><path>src/main/java/io/reactivex/internal/operators/observable/ObservableConcatMap.java <ide> package io.reactivex.internal.operators.observable; <ide> <ide> import java.util.concurrent.Callable; <del>import java.util.concurrent.atomic.AtomicInteger; <add>import java.util.concurrent.atomic.*; <ide> <ide> import io.reactivex.*; <ide> import io.reactivex.disposables.Disposable; <ide> public void subscribeActual(Observer<? super U> s) { <ide> <ide> private static final long serialVersionUID = 8828587559905699186L; <ide> final Observer<? super U> actual; <del> final SequentialDisposable sa; <ide> final Function<? super T, ? extends ObservableSource<? extends U>> mapper; <del> final Observer<U> inner; <add> final InnerObserver<U> inner; <ide> final int bufferSize; <ide> <ide> SimpleQueue<T> queue; <ide> public void subscribeActual(Observer<? super U> s) { <ide> this.mapper = mapper; <ide> this.bufferSize = bufferSize; <ide> this.inner = new InnerObserver<U>(actual, this); <del> this.sa = new SequentialDisposable(); <ide> } <ide> @Override <ide> public void onSubscribe(Disposable s) { <ide> public boolean isDisposed() { <ide> @Override <ide> public void dispose() { <ide> disposed = true; <del> sa.dispose(); <add> inner.dispose(); <ide> s.dispose(); <ide> <ide> if (getAndIncrement() == 0) { <ide> queue.clear(); <ide> } <ide> } <ide> <del> void innerSubscribe(Disposable s) { <del> sa.update(s); <del> } <del> <ide> void drain() { <ide> if (getAndIncrement() != 0) { <ide> return; <ide> void drain() { <ide> } <ide> } <ide> <del> static final class InnerObserver<U> implements Observer<U> { <add> static final class InnerObserver<U> extends AtomicReference<Disposable> implements Observer<U> { <add> <add> private static final long serialVersionUID = -7449079488798789337L; <add> <ide> final Observer<? super U> actual; <ide> final SourceObserver<?, ?> parent; <ide> <ide> void drain() { <ide> <ide> @Override <ide> public void onSubscribe(Disposable s) { <del> parent.innerSubscribe(s); <add> DisposableHelper.set(this, s); <ide> } <ide> <ide> @Override <ide> public void onError(Throwable t) { <ide> public void onComplete() { <ide> parent.innerComplete(); <ide> } <add> <add> void dispose() { <add> DisposableHelper.dispose(this); <add> } <ide> } <ide> } <ide> <ide> public void onComplete() { <ide> <ide> final DelayErrorInnerObserver<R> observer; <ide> <del> final SequentialDisposable arbiter; <del> <ide> final boolean tillTheEnd; <ide> <ide> SimpleQueue<T> queue; <ide> public void onComplete() { <ide> this.tillTheEnd = tillTheEnd; <ide> this.error = new AtomicThrowable(); <ide> this.observer = new DelayErrorInnerObserver<R>(actual, this); <del> this.arbiter = new SequentialDisposable(); <ide> } <ide> <ide> @Override <ide> public boolean isDisposed() { <ide> public void dispose() { <ide> cancelled = true; <ide> d.dispose(); <del> arbiter.dispose(); <add> observer.dispose(); <ide> } <ide> <ide> @SuppressWarnings("unchecked") <ide> void drain() { <ide> } <ide> } <ide> <del> static final class DelayErrorInnerObserver<R> implements Observer<R> { <add> static final class DelayErrorInnerObserver<R> extends AtomicReference<Disposable> implements Observer<R> { <add> <add> private static final long serialVersionUID = 2620149119579502636L; <ide> <ide> final Observer<? super R> actual; <ide> <ide> void drain() { <ide> <ide> @Override <ide> public void onSubscribe(Disposable d) { <del> parent.arbiter.replace(d); <add> DisposableHelper.replace(this, d); <ide> } <ide> <ide> @Override <ide> public void onComplete() { <ide> p.active = false; <ide> p.drain(); <ide> } <add> <add> void dispose() { <add> DisposableHelper.dispose(this); <add> } <ide> } <ide> } <ide> } <ide><path>src/main/java/io/reactivex/internal/operators/observable/ObservableConcatMapCompletable.java <ide> */ <ide> package io.reactivex.internal.operators.observable; <ide> <add>import java.util.concurrent.atomic.*; <add> <ide> import io.reactivex.*; <ide> import io.reactivex.disposables.Disposable; <ide> import io.reactivex.exceptions.Exceptions; <ide> import io.reactivex.functions.Function; <ide> import io.reactivex.internal.disposables.DisposableHelper; <del>import io.reactivex.internal.disposables.SequentialDisposable; <ide> import io.reactivex.internal.functions.ObjectHelper; <del>import io.reactivex.internal.fuseable.QueueDisposable; <del>import io.reactivex.internal.fuseable.SimpleQueue; <add>import io.reactivex.internal.fuseable.*; <ide> import io.reactivex.internal.queue.SpscLinkedArrayQueue; <ide> import io.reactivex.plugins.RxJavaPlugins; <ide> <del>import java.util.concurrent.atomic.AtomicInteger; <del> <ide> public final class ObservableConcatMapCompletable<T> extends Completable { <ide> <ide> final ObservableSource<T> source; <ide> public void subscribeActual(CompletableObserver observer) { <ide> <ide> private static final long serialVersionUID = 6893587405571511048L; <ide> final CompletableObserver actual; <del> final SequentialDisposable sa; <ide> final Function<? super T, ? extends CompletableSource> mapper; <del> final CompletableObserver inner; <add> final InnerObserver inner; <ide> final int bufferSize; <ide> <ide> SimpleQueue<T> queue; <ide> public void subscribeActual(CompletableObserver observer) { <ide> this.mapper = mapper; <ide> this.bufferSize = bufferSize; <ide> this.inner = new InnerObserver(actual, this); <del> this.sa = new SequentialDisposable(); <ide> } <ide> @Override <ide> public void onSubscribe(Disposable s) { <ide> public boolean isDisposed() { <ide> @Override <ide> public void dispose() { <ide> disposed = true; <del> sa.dispose(); <add> inner.dispose(); <ide> s.dispose(); <ide> <ide> if (getAndIncrement() == 0) { <ide> queue.clear(); <ide> } <ide> } <ide> <del> void innerSubscribe(Disposable s) { <del> sa.update(s); <del> } <del> <ide> void drain() { <ide> if (getAndIncrement() != 0) { <ide> return; <ide> void drain() { <ide> } <ide> } <ide> <del> static final class InnerObserver implements CompletableObserver { <add> static final class InnerObserver extends AtomicReference<Disposable> implements CompletableObserver { <add> private static final long serialVersionUID = -5987419458390772447L; <ide> final CompletableObserver actual; <ide> final SourceObserver<?> parent; <ide> <ide> static final class InnerObserver implements CompletableObserver { <ide> <ide> @Override <ide> public void onSubscribe(Disposable s) { <del> parent.innerSubscribe(s); <add> DisposableHelper.set(this, s); <ide> } <ide> <ide> @Override <ide> public void onError(Throwable t) { <ide> public void onComplete() { <ide> parent.innerComplete(); <ide> } <add> <add> void dispose() { <add> DisposableHelper.dispose(this); <add> } <ide> } <ide> } <ide> }
2
Python
Python
remove unused variables
d36d304657c2c86600e95d41f2b7324d14a029e9
<ide><path>libcloud/loadbalancer/drivers/gogrid.py <ide> # See the License for the specific language governing permissions and <ide> # limitations under the License. <ide> <del>import os <ide> import time <ide> <del>try: <del> import json <del>except ImportError: <del> import simplejson <del> <ide> from libcloud.common.types import LibcloudError <ide> from libcloud.common.gogrid import GoGridConnection, BaseGoGridDriver <ide> from libcloud.loadbalancer.base import LB, LBMember, LBDriver
1
PHP
PHP
apply fixes from styleci
0798479b95fd241c829b0e36a1d6f8573a586738
<ide><path>src/Illuminate/Testing/TestResponse.php <ide> use Illuminate\Support\Traits\Tappable; <ide> use Illuminate\Testing\Assert as PHPUnit; <ide> use Illuminate\Testing\Constraints\SeeInOrder; <del>use Illuminate\Testing\Fluent\Assert as FluentAssert; <ide> use Illuminate\Testing\Fluent\AssertableJson; <del>use Illuminate\Testing\Fluent\FluentAssertableJson; <ide> use LogicException; <ide> use Symfony\Component\HttpFoundation\StreamedResponse; <ide> <ide><path>tests/Testing/TestResponseTest.php <ide> use Illuminate\Encryption\Encrypter; <ide> use Illuminate\Filesystem\Filesystem; <ide> use Illuminate\Http\Response; <del>use Illuminate\Testing\Fluent\Assert; <ide> use Illuminate\Testing\Fluent\AssertableJson; <ide> use Illuminate\Testing\TestResponse; <ide> use JsonSerializable;
2
Python
Python
add variable definitions to usage example
5591008d0f9c037156c7721d0874ee95d45a7196
<ide><path>keras/optimizers/optimizer_v2/optimizer_v2.py <ide> class OptimizerV2(tf.__internal__.tracking.Trackable): <ide> opt = tf.keras.optimizers.SGD(learning_rate=0.1) <ide> # `loss` is a callable that takes no argument and returns the value <ide> # to minimize. <add> var1 = tf.Variable(2.0) <add> var2 = tf.Variable(5.0) <ide> loss = lambda: 3 * var1 * var1 + 2 * var2 * var2 <ide> # In graph mode, returns op that minimizes the loss by updating the listed <ide> # variables.
1
Javascript
Javascript
allow zero values for level and strategy
95dcd11dde4fff1ad69b5b5bd9e6c55a9ff1c4a0
<ide><path>lib/zlib.js <ide> function Zlib(opts, mode) { <ide> self.emit('error', error); <ide> }; <ide> <add> var level = exports.Z_DEFAULT_COMPRESSION; <add> if (typeof opts.level === 'number') level = opts.level; <add> <add> var strategy = exports.Z_DEFAULT_STRATEGY; <add> if (typeof opts.strategy === 'number') strategy = opts.strategy; <add> <ide> this._binding.init(opts.windowBits || exports.Z_DEFAULT_WINDOWBITS, <del> opts.level || exports.Z_DEFAULT_COMPRESSION, <add> level, <ide> opts.memLevel || exports.Z_DEFAULT_MEMLEVEL, <del> opts.strategy || exports.Z_DEFAULT_STRATEGY, <add> strategy, <ide> opts.dictionary); <ide> <ide> this._buffer = new Buffer(this._chunkSize);
1
Python
Python
use smaller tests for pr 10741
4bebf05532f466ffe81b95c8b25c23dd00867f30
<ide><path>numpy/core/tests/test_scalar_methods.py <ide> """ <ide> from __future__ import division, absolute_import, print_function <ide> <add>import os <ide> import fractions <add>import platform <add> <add>import pytest <ide> import numpy as np <ide> <ide> from numpy.testing import ( <ide> dec <ide> ) <ide> <del>float_types = [np.half, np.single, np.double, np.longdouble] <del> <del>def test_float_as_integer_ratio(): <del> # derived from the cpython test "test_floatasratio" <del> for ftype in float_types: <del> for f, ratio in [ <del> (0.875, (7, 8)), <del> (-0.875, (-7, 8)), <del> (0.0, (0, 1)), <del> (11.5, (23, 2)), <del> ]: <del> assert_equal(ftype(f).as_integer_ratio(), ratio) <del> <del> rstate = np.random.RandomState(0) <del> fi = np.finfo(ftype) <del> for i in range(1000): <del> exp = rstate.randint(fi.minexp, fi.maxexp - 1) <del> frac = rstate.rand() <del> f = np.ldexp(frac, exp, dtype=ftype) <del> <del> n, d = f.as_integer_ratio() <del> <del> try: <del> dn = np.longdouble(str(n)) <del> df = np.longdouble(str(d)) <del> except (OverflowError, RuntimeWarning): <del> # the values may not fit in any float type <del> continue <add>class TestAsIntegerRatio(object): <add> # derived in part from the cpython test "test_floatasratio" <ide> <del> assert_equal( <del> dn / df, f, <del> "{}/{} (dtype={})".format(n, d, ftype.__name__)) <add> @pytest.mark.parametrize("ftype", [ <add> np.half, np.single, np.double, np.longdouble]) <add> @pytest.mark.parametrize("f, ratio", [ <add> (0.875, (7, 8)), <add> (-0.875, (-7, 8)), <add> (0.0, (0, 1)), <add> (11.5, (23, 2)), <add> ]) <add> def test_small(self, ftype, f, ratio): <add> assert_equal(ftype(f).as_integer_ratio(), ratio) <ide> <add> @pytest.mark.parametrize("ftype", [ <add> np.half, np.single, np.double, np.longdouble]) <add> def test_simple_fractions(self, ftype): <ide> R = fractions.Fraction <ide> assert_equal(R(0, 1), <ide> R(*ftype(0.0).as_integer_ratio())) <ide> def test_float_as_integer_ratio(): <ide> assert_equal(R(-2100, 1), <ide> R(*ftype(-2100.0).as_integer_ratio())) <ide> <add> @pytest.mark.parametrize("ftype", [ <add> np.half, np.single, np.double, np.longdouble]) <add> def test_errors(self, ftype): <ide> assert_raises(OverflowError, ftype('inf').as_integer_ratio) <ide> assert_raises(OverflowError, ftype('-inf').as_integer_ratio) <ide> assert_raises(ValueError, ftype('nan').as_integer_ratio) <ide> <add> def test_against_known_values(self): <add> R = fractions.Fraction <add> assert_equal(R(1075, 512), <add> R(*np.half(2.1).as_integer_ratio())) <add> assert_equal(R(-1075, 512), <add> R(*np.half(-2.1).as_integer_ratio())) <add> assert_equal(R(4404019, 2097152), <add> R(*np.single(2.1).as_integer_ratio())) <add> assert_equal(R(-4404019, 2097152), <add> R(*np.single(-2.1).as_integer_ratio())) <add> assert_equal(R(4728779608739021, 2251799813685248), <add> R(*np.double(2.1).as_integer_ratio())) <add> assert_equal(R(-4728779608739021, 2251799813685248), <add> R(*np.double(-2.1).as_integer_ratio())) <add> # longdouble is platform depedent <ide> <del> assert_equal(R(1075, 512), <del> R(*np.half(2.1).as_integer_ratio())) <del> assert_equal(R(-1075, 512), <del> R(*np.half(-2.1).as_integer_ratio())) <del> assert_equal(R(4404019, 2097152), <del> R(*np.single(2.1).as_integer_ratio())) <del> assert_equal(R(-4404019, 2097152), <del> R(*np.single(-2.1).as_integer_ratio())) <del> assert_equal(R(4728779608739021, 2251799813685248), <del> R(*np.double(2.1).as_integer_ratio())) <del> assert_equal(R(-4728779608739021, 2251799813685248), <del> R(*np.double(-2.1).as_integer_ratio())) <del> # longdouble is platform depedent <add> @pytest.mark.parametrize("ftype, frac_vals, exp_vals", [ <add> # dtype test cases generated using hypothesis <add> # first five generated cases per dtype <add> (np.half, [0.0, 0.01154830649280303, 0.31082276347447274, <add> 0.527350517124794, 0.8308562335072596], <add> [0, 1, 0, -8, 12]), <add> (np.single, [0.0, 0.09248576989263226, 0.8160498218131407, <add> 0.17389442853722373, 0.7956044195067877], <add> [0, 12, 10, 17, -26]), <add> (np.double, [0.0, 0.031066908499895136, 0.5214135908877832, <add> 0.45780736035689296, 0.5906586745934036], <add> [0, -801, 51, 194, -653]), <add> pytest.param( <add> np.longdouble, <add> [0.0, 0.20492557202724854, 0.4277180662199366, 0.9888085019891495, <add> 0.9620175814461964], <add> [0, -7400, 14266, -7822, -8721], <add> marks=[ <add> pytest.mark.skipif( <add> np.finfo(np.double) == np.finfo(np.longdouble), <add> reason="long double is same as double"), <add> pytest.mark.skipif( <add> platform.machine().startswith("ppc"), <add> reason="IBM double double"), <add> ] <add> ) <add> ]) <add> def test_roundtrip(self, ftype, frac_vals, exp_vals): <add> for frac, exp in zip(frac_vals, exp_vals): <add> f = np.ldexp(frac, exp, dtype=ftype) <add> n, d = f.as_integer_ratio() <ide> <add> try: <add> # workaround for gh-9968 <add> nf = np.longdouble(str(n)) <add> df = np.longdouble(str(d)) <add> except (OverflowError, RuntimeWarning): <add> # the values may not fit in any float type <add> pytest.skip("longdouble too small on this platform") <ide> <del>if __name__ == "__main__": <del> run_module_suite() <add> assert_equal(nf / df, f, "{}/{}".format(n, d))
1
Javascript
Javascript
expose accessibility prop. fix
4f187074bfc08ddf7a708475ec613bae454100b4
<ide><path>Libraries/Components/Touchable/TouchableBounce.js <ide> var TouchableBounce = React.createClass({ <ide> mixins: [Touchable.Mixin, NativeMethodsMixin], <ide> <ide> propTypes: { <add> /** <add> * When true, indicates that the view is an accessibility element. By default, <add> * all the touchable elements are accessible. <add> */ <add> accessible: React.PropTypes.bool, <add> <ide> onPress: React.PropTypes.func, <ide> onPressIn: React.PropTypes.func, <ide> onPressOut: React.PropTypes.func, <ide> var TouchableBounce = React.createClass({ <ide> return ( <ide> <Animated.View <ide> style={[{transform: [{scale: this.state.scale}]}, this.props.style]} <del> accessible={true} <add> accessible={this.props.accessible !== false} <ide> accessibilityLabel={this.props.accessibilityLabel} <ide> accessibilityComponentType={this.props.accessibilityComponentType} <ide> accessibilityTraits={this.props.accessibilityTraits} <ide><path>Libraries/Components/Touchable/TouchableHighlight.js <ide> var TouchableHighlight = React.createClass({ <ide> render: function() { <ide> return ( <ide> <View <del> accessible={true} <add> accessible={this.props.accessible !== false} <ide> accessibilityLabel={this.props.accessibilityLabel} <ide> accessibilityComponentType={this.props.accessibilityComponentType} <ide> accessibilityTraits={this.props.accessibilityTraits} <ide><path>Libraries/Components/Touchable/TouchableOpacity.js <ide> var TouchableOpacity = React.createClass({ <ide> render: function() { <ide> return ( <ide> <Animated.View <del> accessible={true} <add> accessible={this.props.accessible !== false} <ide> accessibilityLabel={this.props.accessibilityLabel} <ide> accessibilityComponentType={this.props.accessibilityComponentType} <ide> accessibilityTraits={this.props.accessibilityTraits}
3
Javascript
Javascript
pass present moment to a calendar function
980c2d976cb980ae492aaa2b24aa4c2548160661
<ide><path>moment.js <ide> diff < 1 ? 'sameDay' : <ide> diff < 2 ? 'nextDay' : <ide> diff < 7 ? 'nextWeek' : 'sameElse'; <del> return this.format(this.localeData().calendar(format, this)); <add> return this.format(this.localeData().calendar(format, this, moment(now))); <ide> }, <ide> <ide> isLeapYear : function () {
1
Ruby
Ruby
remove amd-power-gadget from prerelease exceptions
9f9eaa3e6e0837b9bfc8661bbf818aa73ed8493f
<ide><path>Library/Homebrew/utils/shared_audits.rb <ide> def github_release_data(user, repo, tag) <ide> end <ide> <ide> GITHUB_PRERELEASE_ALLOWLIST = { <del> "amd-power-gadget" => :all, <ide> "elm-format" => "0.8.3", <ide> "extraterm" => :all, <ide> "freetube" => :all,
1
Javascript
Javascript
fix template in ember.radiobutton
cd4b0b2c14c99c1c78e87c9014d4686b2b8d39af
<ide><path>packages/ember-handlebars/lib/controls/radio_button.js <ide> Ember.RadioButton = Ember.View.extend({ <ide> <ide> classNames: ['ember-radio-button'], <ide> <del> defaultTemplate: Ember.Handlebars.compile('<input type="radio" {{bindAttr disabled="disabled" name="group" value="val" checked="checked"}}>{{title}}</input>'), <add> defaultTemplate: Ember.Handlebars.compile('<label><input type="radio" {{bindAttr disabled="disabled" name="group" value="val" checked="checked"}}>{{title}}</label>'), <ide> <ide> change: function() { <ide> Ember.run.once(this, this._updateElementValue);
1
Ruby
Ruby
add migrator class for migrating renamed formulae
832c5875b01bf86652f53be1543742907da1febb
<ide><path>Library/Homebrew/migrator.rb <add>require "formula" <add>require "keg" <add>require "tab" <add>require "tap_migrations" <add> <add>class Migrator <add> class MigratorNoOldnameError < RuntimeError <add> def initialize(formula) <add> super "#{formula.name} doesn't replace any formula." <add> end <add> end <add> <add> class MigratorNoOldpathError < RuntimeError <add> def initialize(formula) <add> super "#{HOMEBREW_CELLAR/formula.oldname} doesn't exist." <add> end <add> end <add> <add> class MigratorDifferentTapsError < RuntimeError <add> def initialize(formula, tap) <add> if tap.nil? <add> super <<-EOS.undent <add> #{formula.name} from #{formula.tap} is given, but old name #{formula.oldname} wasn't installed from taps or core formulae <add> <add> You can try `brew migrate --force #{formula.oldname}`. <add> EOS <add> else <add> user, repo = tap.split("/") <add> repo.sub!("homebrew-", "") <add> name = "fully-qualified #{user}/#{repo}/#{formula.oldname}" <add> name = formula.oldname if tap == "Homebrew/homebrew" <add> super <<-EOS.undent <add> #{formula.name} from #{formula.tap} is given, but old name #{formula.oldname} was installed from #{tap} <add> <add> Please try to use #{name} to refer the formula <add> EOS <add> end <add> end <add> end <add> <add> attr_reader :formula <add> attr_reader :oldname, :oldpath, :old_pin_record, :old_opt_record <add> attr_reader :old_linked_keg_record, :oldkeg, :old_tabs, :old_tap <add> attr_reader :newname, :newpath, :new_pin_record <add> attr_reader :old_pin_link_record <add> <add> def initialize(formula) <add> @oldname = formula.oldname <add> @newname = formula.name <add> raise MigratorNoOldnameError.new(formula) unless oldname <add> <add> @formula = formula <add> @oldpath = HOMEBREW_CELLAR/formula.oldname <add> raise MigratorNoOldpathError.new(formula) unless oldpath.exist? <add> <add> @old_tabs = oldpath.subdirs.each.map { |d| Tab.for_keg(Keg.new(d)) } <add> @old_tap = old_tabs.first.tap <add> raise MigratorDifferentTapsError.new(formula, old_tap) unless from_same_taps? <add> <add> @newpath = HOMEBREW_CELLAR/formula.name <add> <add> if @oldkeg = get_linked_oldkeg <add> @old_linked_keg_record = oldkeg.linked_keg_record if oldkeg.linked? <add> @old_opt_record = oldkeg.opt_record if oldkeg.optlinked? <add> end <add> <add> @old_pin_record = HOMEBREW_LIBRARY/"PinnedKegs"/oldname <add> @new_pin_record = HOMEBREW_LIBRARY/"PinnedKegs"/newname <add> @pinned = old_pin_record.symlink? <add> @old_pin_link_record = old_pin_record.readlink if @pinned <add> end <add> <add> # Fix INSTALL_RECEIPTS for tap-migrated formula. <add> def fix_tabs <add> old_tabs.each do |tab| <add> tab.source["tap"] = formula.tap <add> tab.write <add> end <add> end <add> <add> def from_same_taps? <add> if old_tap == nil && formula.core_formula? && ARGV.force? <add> true <add> elsif formula.tap == old_tap <add> true <add> # Homebrew didn't use to update tabs while performing tap-migrations, <add> # so there can be INSTALL_RECEIPT's containing wrong information about <add> # tap (tap is Homebrew/homebrew if installed formula migrates to a tap), so <add> # we check if there is an entry about oldname migrated to tap and if <add> # newname's tap is the same as tap to which oldname migrated, then we <add> # can perform migrations and the taps for oldname and newname are the same. <add> elsif TAP_MIGRATIONS && (rec = TAP_MIGRATIONS[formula.oldname]) \ <add> && rec == formula.tap.sub("homebrew-", "") <add> fix_tabs <add> true <add> elsif formula.tap <add> false <add> end <add> end <add> <add> def get_linked_oldkeg <add> kegs = oldpath.subdirs.map { |d| Keg.new(d) } <add> kegs.detect(&:linked?) || kegs.detect(&:optlinked?) <add> end <add> <add> def pinned? <add> @pinned <add> end <add> <add> def oldkeg_linked? <add> !!oldkeg <add> end <add> <add> def migrate <add> if newpath.exist? <add> onoe "#{newpath} already exists; remove it manually and run brew migrate #{oldname}." <add> return <add> end <add> <add> begin <add> oh1 "Migrating #{Tty.green}#{oldname}#{Tty.white} to #{Tty.green}#{newname}#{Tty.reset}" <add> unlink_oldname <add> move_to_new_directory <add> repin <add> link_newname <add> link_oldname_opt <add> link_oldname_cellar <add> update_tabs <add> rescue Interrupt <add> ignore_interrupts { backup_oldname } <add> rescue Exception => e <add> onoe "error occured while migrating." <add> puts e if ARGV.debug? <add> puts "Backuping..." <add> ignore_interrupts { backup_oldname } <add> end <add> end <add> <add> # move everything from Cellar/oldname to Cellar/newname <add> def move_to_new_directory <add> puts "Moving to: #{newpath}" <add> FileUtils.mv(oldpath, newpath) <add> end <add> <add> def repin <add> if pinned? <add> # old_pin_record is a relative symlink and when we try to to read it <add> # from <dir> we actually try to find file <add> # <dir>/../<...>/../Cellar/name/version. <add> # To repin formula we need to update the link thus that it points to <add> # the right directory. <add> # NOTE: old_pin_record.realpath.sub(oldname, newname) is unacceptable <add> # here, because it resolves every symlink for old_pin_record and then <add> # substitutes oldname with newname. It breaks things like <add> # Pathname#make_relative_symlink, where Pathname#relative_path_from <add> # is used to find relative path from source to destination parent and <add> # it assumes no symlinks. <add> src_oldname = old_pin_record.dirname.join(old_pin_link_record).expand_path <add> new_pin_record.make_relative_symlink(src_oldname.sub(oldname, newname)) <add> old_pin_record.delete <add> end <add> end <add> <add> def unlink_oldname <add> oh1 "Unlinking #{Tty.green}#{oldname}#{Tty.reset}" <add> oldpath.subdirs.each do |d| <add> keg = Keg.new(d) <add> keg.unlink <add> end <add> end <add> <add> def link_newname <add> oh1 "Linking #{Tty.green}#{newname}#{Tty.reset}" <add> keg = Keg.new(formula.installed_prefix) <add> <add> if formula.keg_only? <add> begin <add> keg.optlink <add> rescue Keg::LinkError => e <add> onoe "Failed to create #{formula.opt_prefix}" <add> puts e <add> raise <add> end <add> return <add> end <add> <add> keg.remove_linked_keg_record if keg.linked? <add> <add> begin <add> keg.link <add> rescue Keg::ConflictError => e <add> onoe "Error while executing `brew link` step on #{newname}" <add> puts e <add> puts <add> puts "Possible conflicting files are:" <add> mode = OpenStruct.new(:dry_run => true, :overwrite => true) <add> keg.link(mode) <add> raise <add> rescue Keg::LinkError => e <add> onoe "Error while linking" <add> puts e <add> puts <add> puts "You can try again using:" <add> puts " brew link #{formula.name}" <add> rescue Exception => e <add> onoe "An unexpected error occurred during linking" <add> puts e <add> puts e.backtrace <add> ignore_interrupts { keg.unlink } <add> raise e <add> end <add> end <add> <add> # Link keg to opt if it was linked before migrating. <add> def link_oldname_opt <add> if old_opt_record <add> old_opt_record.delete if old_opt_record.symlink? || old_opt_record.exist? <add> old_opt_record.make_relative_symlink(formula.installed_prefix) <add> end <add> end <add> <add> # After migtaion every INSTALL_RECEIPT.json has wrong path to the formula <add> # so we must update INSTALL_RECEIPTs <add> def update_tabs <add> new_tabs = newpath.subdirs.map { |d| Tab.for_keg(Keg.new(d)) } <add> new_tabs.each do |tab| <add> tab.source["path"] = formula.path.to_s if tab.source["path"] <add> tab.write <add> end <add> end <add> <add> # Remove opt/oldname link if it belongs to newname. <add> def unlink_oldname_opt <add> return unless old_opt_record <add> if old_opt_record.symlink? && formula.installed_prefix.exist? \ <add> && formula.installed_prefix.realpath == old_opt_record.realpath <add> old_opt_record.unlink <add> old_opt_record.parent.rmdir_if_possible <add> end <add> end <add> <add> # Remove oldpath if it exists <add> def link_oldname_cellar <add> oldpath.delete if oldpath.symlink? || oldpath.exist? <add> oldpath.make_relative_symlink(formula.rack) <add> end <add> <add> # Remove Cellar/oldname link if it belongs to newname. <add> def unlink_oldname_cellar <add> if (oldpath.symlink? && !oldpath.exist?) || (oldpath.symlink? \ <add> && formula.rack.exist? && formula.rack.realpath == oldpath.realpath) <add> oldpath.unlink <add> end <add> end <add> <add> # Backup everything if errors occured while migrating. <add> def backup_oldname <add> unlink_oldname_opt <add> unlink_oldname_cellar <add> backup_oldname_cellar <add> backup_old_tabs <add> <add> if pinned? && !old_pin_record.symlink? <add> src_oldname = old_pin_record.dirname.join(old_pin_link_record).expand_path <add> old_pin_record.make_relative_symlink(src_oldname) <add> new_pin_record.delete <add> end <add> <add> if newpath.exist? <add> newpath.subdirs.each do |d| <add> newname_keg = Keg.new(d) <add> newname_keg.unlink <add> newname_keg.uninstall <add> end <add> end <add> <add> if oldkeg_linked? <add> begin <add> # The keg used to be linked and when we backup everything we restore <add> # Cellar/oldname, the target also gets restored, so we are able to <add> # create a keg using its old path <add> keg = Keg.new(Pathname.new(oldkeg.to_s)) <add> keg.link <add> rescue Keg::LinkError <add> keg.unlink <add> raise <add> rescue Keg::AlreadyLinkedError <add> keg.unlink <add> retry <add> end <add> end <add> end <add> <add> def backup_oldname_cellar <add> unless oldpath.exist? <add> FileUtils.mv(newpath, oldpath) <add> end <add> end <add> <add> def backup_old_tabs <add> old_tabs.each(&:write) <add> end <add>end
1
Python
Python
fix imdb get_word_index documentation
354bd35ff47aab7834c3576829dab5d3802fd41a
<ide><path>keras/datasets/imdb.py <ide> def load_data(path='imdb.npz', num_words=None, skip_top=0, <ide> <ide> <ide> def get_word_index(path='imdb_word_index.json'): <del> """Retrieves the dictionary mapping word indices back to words. <add> """Retrieves the dictionary mapping words to word indices. <ide> <ide> # Arguments <ide> path: where to cache the data (relative to `~/.keras/dataset`). <ide><path>keras/datasets/reuters.py <ide> def load_data(path='reuters.npz', num_words=None, skip_top=0, <ide> <ide> <ide> def get_word_index(path='reuters_word_index.json'): <del> """Retrieves the dictionary mapping word indices back to words. <add> """Retrieves the dictionary mapping words to word indices. <ide> <ide> # Arguments <ide> path: where to cache the data (relative to `~/.keras/dataset`).
2
Javascript
Javascript
update morph of gltf2loader
ee87cc5c239c4286f558d5be1c0b30871bec78a2
<ide><path>examples/js/loaders/GLTF2Loader.js <ide> THREE.GLTF2Loader = ( function () { <ide> var targets = primitive.targets; <ide> var morphAttributes = geometry.morphAttributes; <ide> <add> morphAttributes.position = []; <add> morphAttributes.normal = []; <add> <add> material.morphTargets = true; <add> <ide> for ( var i = 0, il = targets.length; i < il; i ++ ) { <ide> <ide> var target = targets[ i ]; <ide> var attributeName = 'morphTarget' + i; <ide> <del> if ( target.POSITION !== undefined ) { <del> <del> material.morphTargets = true; <add> var positionAttribute, normalAttribute; <ide> <del> if ( morphAttributes.position === undefined ) morphAttributes.position = []; <add> if ( target.POSITION !== undefined ) { <ide> <ide> // Three.js morph formula is <ide> // position <ide> THREE.GLTF2Loader = ( function () { <ide> // So morphTarget value will depend on mesh's position, then cloning attribute <ide> // for the case if attribute is shared among two or more meshes. <ide> <del> var attribute = dependencies.accessors[ target.POSITION ].clone(); <del> attribute.name = attributeName; <add> positionAttribute = dependencies.accessors[ target.POSITION ].clone(); <ide> var position = geometry.attributes.position; <ide> <del> for ( var j = 0, jl = attribute.array.length; j < jl; j ++ ) { <add> for ( var j = 0, jl = positionAttribute.array.length; j < jl; j ++ ) { <ide> <del> attribute.array[ j ] += position.array[ j ]; <add> positionAttribute.array[ j ] += position.array[ j ]; <ide> <ide> } <ide> <del> morphAttributes.position.push( attribute ); <add> } else { <add> <add> // Copying the original position not to affect the final position. <add> // See the formula above. <add> positionAttribute = geometry.attributes.position.clone(); <ide> <ide> } <ide> <ide> if ( target.NORMAL !== undefined ) { <ide> <ide> material.morphNormals = true; <ide> <del> if ( morphAttributes.normal === undefined ) morphAttributes.normal = []; <del> <ide> // see target.POSITION's comment <ide> <del> var attribute = dependencies.accessors[ target.NORMAL ].clone(); <del> attribute.name = attributeName; <add> normalAttribute = dependencies.accessors[ target.NORMAL ].clone(); <ide> var normal = geometry.attributes.normal; <ide> <del> for ( var j = 0, jl = attribute.array.length; j < jl; j ++ ) { <add> for ( var j = 0, jl = normalAttribute.array.length; j < jl; j ++ ) { <ide> <del> attribute.array[ j ] += normal.array[ j ]; <add> normalAttribute.array[ j ] += normal.array[ j ]; <ide> <ide> } <ide> <del> morphAttributes.normal.push( attribute ); <add> } else { <add> <add> normalAttribute = geometry.attributes.normal.clone(); <ide> <ide> } <ide> <ide> THREE.GLTF2Loader = ( function () { <ide> <ide> } <ide> <add> positionAttribute.name = attributeName; <add> normalAttribute.name = attributeName; <add> <add> morphAttributes.position.push( positionAttribute ); <add> morphAttributes.normal.push( normalAttribute ); <add> <ide> } <ide> <ide> meshNode.updateMorphTargets();
1
Java
Java
remove unnecessary subscription
6383157b2961749ab46b8d05653ffb5f757f0be8
<ide><path>rxjava-core/src/main/java/rx/joins/JoinObserver1.java <ide> import java.util.LinkedList; <ide> import java.util.List; <ide> import java.util.Queue; <add>import java.util.concurrent.atomic.AtomicBoolean; <add> <ide> import rx.Notification; <ide> import rx.Observable; <del>import rx.subscriptions.SingleAssignmentSubscription; <add>import rx.operators.SafeObservableSubscription; <ide> import rx.util.functions.Action1; <ide> <ide> /** <ide> private final Action1<Throwable> onError; <ide> private final List<ActivePlan0> activePlans; <ide> private final Queue<Notification<T>> queue; <del> private final SingleAssignmentSubscription subscription; <add> private final SafeObservableSubscription subscription; <ide> private volatile boolean done; <add> private final AtomicBoolean subscribed = new AtomicBoolean(false); <ide> <ide> public JoinObserver1(Observable<T> source, Action1<Throwable> onError) { <ide> this.source = source; <ide> this.onError = onError; <ide> queue = new LinkedList<Notification<T>>(); <del> subscription = new SingleAssignmentSubscription(); <add> subscription = new SafeObservableSubscription(); <ide> activePlans = new ArrayList<ActivePlan0>(); <ide> } <ide> public Queue<Notification<T>> queue() { <ide> public void addActivePlan(ActivePlan0 activePlan) { <ide> } <ide> @Override <ide> public void subscribe(Object gate) { <del> this.gate = gate; <del> subscription.set(source.materialize().subscribe(this)); <add> if (subscribed.compareAndSet(false, true)) { <add> this.gate = gate; <add> subscription.wrap(source.materialize().subscribe(this)); <add> } else { <add> throw new IllegalStateException("Can only be subscribed to once."); <add> } <ide> } <ide> <ide> @Override <ide><path>rxjava-core/src/main/java/rx/subscriptions/SingleAssignmentSubscription.java <del>/** <del> * Copyright 2013 Netflix, Inc. <del> * <del> * Licensed under the Apache License, Version 2.0 (the "License"); <del> * you may not use this file except in compliance with the License. <del> * You may obtain a copy of the License at <del> * <del> * http://www.apache.org/licenses/LICENSE-2.0 <del> * <del> * Unless required by applicable law or agreed to in writing, software <del> * distributed under the License is distributed on an "AS IS" BASIS, <del> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <del> * See the License for the specific language governing permissions and <del> * limitations under the License. <del> */ <del> <del>package rx.subscriptions; <del> <del>import java.util.concurrent.atomic.AtomicReference; <del>import rx.Subscription; <del> <del>/** <del> * A subscription that allows only a single resource to be assigned. <del> * <p> <del> * If this subscription is live, no other subscription may be set() and <del> * yields an {@link IllegalStateException}. <del> * <p> <del> * If the unsubscribe has been called, setting a new subscription will <del> * unsubscribe it immediately. <del> */ <del>public final class SingleAssignmentSubscription implements Subscription { <del> /** Holds the current resource. */ <del> private final AtomicReference<Subscription> current = new AtomicReference<Subscription>(); <del> /** Sentinel for the unsubscribed state. */ <del> private static final Subscription UNSUBSCRIBED_SENTINEL = new Subscription() { <del> @Override <del> public void unsubscribe() { <del> } <del> }; <del> /** <del> * Returns the current subscription or null if not yet set. <del> */ <del> public Subscription get() { <del> Subscription s = current.get(); <del> if (s == UNSUBSCRIBED_SENTINEL) { <del> return Subscriptions.empty(); <del> } <del> return s; <del> } <del> /** <del> * Sets a new subscription if not already set. <del> * @param s the new subscription <del> * @throws IllegalStateException if this subscription is live and contains <del> * another subscription. <del> */ <del> public void set(Subscription s) { <del> if (current.compareAndSet(null, s)) { <del> return; <del> } <del> if (current.get() != UNSUBSCRIBED_SENTINEL) { <del> throw new IllegalStateException("Subscription already set"); <del> } <del> if (s != null) { <del> s.unsubscribe(); <del> } <del> } <del> @Override <del> public void unsubscribe() { <del> Subscription old = current.getAndSet(UNSUBSCRIBED_SENTINEL); <del> if (old != null) { <del> old.unsubscribe(); <del> } <del> } <del> /** <del> * Test if this subscription is already unsubscribed. <del> */ <del> public boolean isUnsubscribed() { <del> return current.get() == UNSUBSCRIBED_SENTINEL; <del> } <del> <del>}
2
Java
Java
add blank line between java and javax imports
deba2ed1b3d422bbdd86b8573402e5a1cb1eb699
<ide><path>integration-tests/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java <ide> import java.io.IOException; <ide> import java.lang.reflect.Method; <ide> import java.util.List; <add> <ide> import javax.servlet.ServletException; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>integration-tests/src/test/java/org/springframework/context/annotation/jsr330/ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests.java <ide> import java.lang.annotation.Retention; <ide> import java.lang.annotation.RetentionPolicy; <ide> import java.lang.annotation.Target; <add> <ide> import javax.inject.Named; <ide> import javax.inject.Singleton; <ide> <ide><path>integration-tests/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementIntegrationTests.java <ide> import java.util.Arrays; <ide> import java.util.Collections; <ide> import java.util.List; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java <ide> <ide> import java.util.ArrayList; <ide> import java.util.List; <add> <ide> import javax.accessibility.Accessible; <ide> import javax.swing.JFrame; <ide> import javax.swing.RootPaneContainer; <ide><path>spring-aspects/src/test/java/org/springframework/cache/config/AnnotatedJCacheableService.java <ide> import java.io.IOException; <ide> import java.util.concurrent.ConcurrentHashMap; <ide> import java.util.concurrent.atomic.AtomicLong; <add> <ide> import javax.cache.annotation.CacheDefaults; <ide> import javax.cache.annotation.CacheKey; <ide> import javax.cache.annotation.CachePut; <ide><path>spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java <ide> package org.springframework.transaction.aspectj; <ide> <ide> import java.io.IOException; <add> <ide> import javax.transaction.Transactional; <ide> <ide> import org.junit.jupiter.api.BeforeEach; <ide><path>spring-beans/src/main/java/org/springframework/beans/factory/config/ProviderCreatingFactoryBean.java <ide> package org.springframework.beans.factory.config; <ide> <ide> import java.io.Serializable; <add> <ide> import javax.inject.Provider; <ide> <ide> import org.springframework.beans.BeansException; <ide><path>spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java <ide> import java.util.function.Consumer; <ide> import java.util.function.Predicate; <ide> import java.util.stream.Stream; <add> <ide> import javax.inject.Provider; <ide> <ide> import org.springframework.beans.BeanUtils; <ide><path>spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java <ide> import java.io.InputStream; <ide> import java.util.HashSet; <ide> import java.util.Set; <add> <ide> import javax.xml.parsers.ParserConfigurationException; <ide> <ide> import org.w3c.dom.Document; <ide><path>spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java <ide> import java.util.Set; <ide> import java.util.concurrent.Callable; <ide> import java.util.stream.Collectors; <add> <ide> import javax.annotation.Priority; <ide> import javax.security.auth.Subject; <ide> <ide><path>spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java <ide> import java.util.List; <ide> import java.util.Map; <ide> import java.util.Optional; <add> <ide> import javax.inject.Inject; <ide> import javax.inject.Named; <ide> import javax.inject.Provider; <ide><path>spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java <ide> package org.springframework.beans.factory.config; <ide> <ide> import java.util.Date; <add> <ide> import javax.inject.Provider; <ide> <ide> import org.junit.jupiter.api.AfterEach; <ide><path>spring-beans/src/test/java/org/springframework/beans/factory/serviceloader/ServiceLoaderTests.java <ide> <ide> import java.util.List; <ide> import java.util.ServiceLoader; <add> <ide> import javax.xml.parsers.DocumentBuilderFactory; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java <ide> import java.util.PropertyPermission; <ide> import java.util.Set; <ide> import java.util.function.Consumer; <add> <ide> import javax.security.auth.AuthPermission; <ide> import javax.security.auth.Subject; <ide> <ide><path>spring-context-indexer/src/main/java/org/springframework/context/index/processor/CandidateComponentsIndexer.java <ide> import java.util.LinkedHashSet; <ide> import java.util.List; <ide> import java.util.Set; <add> <ide> import javax.annotation.processing.Completion; <ide> import javax.annotation.processing.ProcessingEnvironment; <ide> import javax.annotation.processing.Processor; <ide><path>spring-context-indexer/src/main/java/org/springframework/context/index/processor/IndexedStereotypesProvider.java <ide> import java.util.HashSet; <ide> import java.util.LinkedHashSet; <ide> import java.util.Set; <add> <ide> import javax.lang.model.element.AnnotationMirror; <ide> import javax.lang.model.element.Element; <ide> import javax.lang.model.element.ElementKind; <ide><path>spring-context-indexer/src/main/java/org/springframework/context/index/processor/MetadataCollector.java <ide> import java.util.HashSet; <ide> import java.util.List; <ide> import java.util.Set; <add> <ide> import javax.annotation.processing.ProcessingEnvironment; <ide> import javax.annotation.processing.RoundEnvironment; <ide> import javax.lang.model.element.Element; <ide><path>spring-context-indexer/src/main/java/org/springframework/context/index/processor/MetadataStore.java <ide> import java.io.IOException; <ide> import java.io.InputStream; <ide> import java.io.OutputStream; <add> <ide> import javax.annotation.processing.ProcessingEnvironment; <ide> import javax.tools.FileObject; <ide> import javax.tools.StandardLocation; <ide><path>spring-context-indexer/src/main/java/org/springframework/context/index/processor/PackageInfoStereotypesProvider.java <ide> <ide> import java.util.HashSet; <ide> import java.util.Set; <add> <ide> import javax.lang.model.element.Element; <ide> import javax.lang.model.element.ElementKind; <ide> <ide><path>spring-context-indexer/src/main/java/org/springframework/context/index/processor/StandardStereotypesProvider.java <ide> <ide> import java.util.LinkedHashSet; <ide> import java.util.Set; <add> <ide> import javax.lang.model.element.AnnotationMirror; <ide> import javax.lang.model.element.Element; <ide> import javax.lang.model.element.ElementKind; <ide><path>spring-context-indexer/src/main/java/org/springframework/context/index/processor/StereotypesProvider.java <ide> package org.springframework.context.index.processor; <ide> <ide> import java.util.Set; <add> <ide> import javax.lang.model.element.Element; <ide> <ide> /** <ide><path>spring-context-indexer/src/main/java/org/springframework/context/index/processor/TypeHelper.java <ide> import java.util.ArrayList; <ide> import java.util.Collections; <ide> import java.util.List; <add> <ide> import javax.annotation.processing.ProcessingEnvironment; <ide> import javax.lang.model.element.AnnotationMirror; <ide> import javax.lang.model.element.Element; <ide><path>spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java <ide> import java.io.FileInputStream; <ide> import java.io.IOException; <ide> import java.nio.file.Path; <add> <ide> import javax.annotation.ManagedBean; <ide> import javax.inject.Named; <ide> import javax.persistence.Converter; <ide><path>spring-context-indexer/src/test/java/org/springframework/context/index/test/TestCompiler.java <ide> import java.util.Collections; <ide> import java.util.List; <ide> import java.util.stream.Collectors; <add> <ide> import javax.annotation.processing.Processor; <ide> import javax.tools.JavaCompiler; <ide> import javax.tools.JavaFileObject; <ide><path>spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCache.java <ide> package org.springframework.cache.jcache; <ide> <ide> import java.util.concurrent.Callable; <add> <ide> import javax.cache.Cache; <ide> import javax.cache.processor.EntryProcessor; <ide> import javax.cache.processor.EntryProcessorException; <ide><path>spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java <ide> <ide> import java.util.Collection; <ide> import java.util.LinkedHashSet; <add> <ide> import javax.cache.CacheManager; <ide> import javax.cache.Caching; <ide> <ide><path>spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheManagerFactoryBean.java <ide> <ide> import java.net.URI; <ide> import java.util.Properties; <add> <ide> import javax.cache.CacheManager; <ide> import javax.cache.Caching; <ide> <ide><path>spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractJCacheKeyOperation.java <ide> import java.lang.annotation.Annotation; <ide> import java.util.ArrayList; <ide> import java.util.List; <add> <ide> import javax.cache.annotation.CacheInvocationParameter; <ide> import javax.cache.annotation.CacheMethodDetails; <ide> <ide><path>spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractJCacheOperation.java <ide> import java.util.LinkedHashSet; <ide> import java.util.List; <ide> import java.util.Set; <add> <ide> import javax.cache.annotation.CacheInvocationParameter; <ide> import javax.cache.annotation.CacheKey; <ide> import javax.cache.annotation.CacheMethodDetails; <ide><path>spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractKeyCacheInterceptor.java <ide> package org.springframework.cache.jcache.interceptor; <ide> <ide> import java.lang.annotation.Annotation; <add> <ide> import javax.cache.annotation.CacheKeyInvocationContext; <ide> <ide> import org.springframework.cache.interceptor.CacheErrorHandler; <ide><path>spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AnnotationJCacheOperationSource.java <ide> import java.lang.reflect.Method; <ide> import java.util.ArrayList; <ide> import java.util.List; <add> <ide> import javax.cache.annotation.CacheDefaults; <ide> import javax.cache.annotation.CacheKeyGenerator; <ide> import javax.cache.annotation.CacheMethodDetails; <ide><path>spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CachePutOperation.java <ide> <ide> import java.lang.reflect.Method; <ide> import java.util.List; <add> <ide> import javax.cache.annotation.CacheInvocationParameter; <ide> import javax.cache.annotation.CacheMethodDetails; <ide> import javax.cache.annotation.CachePut; <ide><path>spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/CacheResolverAdapter.java <ide> <ide> import java.util.Collection; <ide> import java.util.Collections; <add> <ide> import javax.cache.annotation.CacheInvocationContext; <ide> <ide> import org.springframework.cache.Cache; <ide><path>spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/DefaultCacheInvocationContext.java <ide> import java.lang.reflect.Method; <ide> import java.util.Arrays; <ide> import java.util.Set; <add> <ide> import javax.cache.annotation.CacheInvocationContext; <ide> import javax.cache.annotation.CacheInvocationParameter; <ide> <ide><path>spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/DefaultCacheKeyInvocationContext.java <ide> package org.springframework.cache.jcache.interceptor; <ide> <ide> import java.lang.annotation.Annotation; <add> <ide> import javax.cache.annotation.CacheInvocationParameter; <ide> import javax.cache.annotation.CacheKeyInvocationContext; <ide> <ide><path>spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/DefaultCacheMethodDetails.java <ide> import java.util.Collections; <ide> import java.util.LinkedHashSet; <ide> import java.util.Set; <add> <ide> import javax.cache.annotation.CacheMethodDetails; <ide> <ide> /** <ide><path>spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/JCacheOperation.java <ide> package org.springframework.cache.jcache.interceptor; <ide> <ide> import java.lang.annotation.Annotation; <add> <ide> import javax.cache.annotation.CacheInvocationParameter; <ide> import javax.cache.annotation.CacheMethodDetails; <ide> <ide><path>spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/KeyGeneratorAdapter.java <ide> import java.lang.reflect.Method; <ide> import java.util.ArrayList; <ide> import java.util.List; <add> <ide> import javax.cache.annotation.CacheInvocationParameter; <ide> import javax.cache.annotation.CacheKeyGenerator; <ide> import javax.cache.annotation.CacheKeyInvocationContext; <ide><path>spring-context-support/src/main/java/org/springframework/mail/javamail/ConfigurableMimeFileTypeMap.java <ide> import java.io.File; <ide> import java.io.IOException; <ide> import java.io.InputStream; <add> <ide> import javax.activation.FileTypeMap; <ide> import javax.activation.MimetypesFileTypeMap; <ide> <ide><path>spring-context-support/src/main/java/org/springframework/mail/javamail/InternetAddressEditor.java <ide> package org.springframework.mail.javamail; <ide> <ide> import java.beans.PropertyEditorSupport; <add> <ide> import javax.mail.internet.AddressException; <ide> import javax.mail.internet.InternetAddress; <ide> <ide><path>spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSender.java <ide> package org.springframework.mail.javamail; <ide> <ide> import java.io.InputStream; <add> <ide> import javax.mail.internet.MimeMessage; <ide> <ide> import org.springframework.mail.MailException; <ide><path>spring-context-support/src/main/java/org/springframework/mail/javamail/JavaMailSenderImpl.java <ide> import java.util.List; <ide> import java.util.Map; <ide> import java.util.Properties; <add> <ide> import javax.activation.FileTypeMap; <ide> import javax.mail.Address; <ide> import javax.mail.AuthenticationFailedException; <ide><path>spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMailMessage.java <ide> package org.springframework.mail.javamail; <ide> <ide> import java.util.Date; <add> <ide> import javax.mail.MessagingException; <ide> import javax.mail.internet.MimeMessage; <ide> <ide><path>spring-context-support/src/main/java/org/springframework/mail/javamail/MimeMessageHelper.java <ide> import java.io.OutputStream; <ide> import java.io.UnsupportedEncodingException; <ide> import java.util.Date; <add> <ide> import javax.activation.DataHandler; <ide> import javax.activation.DataSource; <ide> import javax.activation.FileDataSource; <ide><path>spring-context-support/src/main/java/org/springframework/scheduling/commonj/TimerManagerFactoryBean.java <ide> <ide> import java.util.LinkedList; <ide> import java.util.List; <add> <ide> import javax.naming.NamingException; <ide> <ide> import commonj.timers.Timer; <ide><path>spring-context-support/src/main/java/org/springframework/scheduling/commonj/WorkManagerTaskExecutor.java <ide> import java.util.concurrent.Callable; <ide> import java.util.concurrent.Future; <ide> import java.util.concurrent.FutureTask; <add> <ide> import javax.naming.NamingException; <ide> <ide> import commonj.work.Work; <ide><path>spring-context-support/src/main/java/org/springframework/scheduling/quartz/LocalDataSourceJobStore.java <ide> <ide> import java.sql.Connection; <ide> import java.sql.SQLException; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.quartz.SchedulerConfigException; <ide><path>spring-context-support/src/main/java/org/springframework/scheduling/quartz/SchedulerFactoryBean.java <ide> import java.util.Properties; <ide> import java.util.concurrent.Executor; <ide> import java.util.concurrent.TimeUnit; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.quartz.Scheduler; <ide><path>spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java <ide> <ide> import java.util.ArrayList; <ide> import java.util.List; <add> <ide> import javax.cache.Cache; <ide> import javax.cache.CacheManager; <ide> <ide><path>spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AbstractCacheOperationTests.java <ide> <ide> import java.lang.annotation.Annotation; <ide> import java.lang.reflect.Method; <add> <ide> import javax.cache.annotation.CacheInvocationParameter; <ide> import javax.cache.annotation.CacheMethodDetails; <ide> <ide><path>spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotatedJCacheableService.java <ide> import java.io.IOException; <ide> import java.util.concurrent.ConcurrentHashMap; <ide> import java.util.concurrent.atomic.AtomicLong; <add> <ide> import javax.cache.annotation.CacheDefaults; <ide> import javax.cache.annotation.CacheKey; <ide> import javax.cache.annotation.CachePut; <ide><path>spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotationCacheOperationSourceTests.java <ide> <ide> import java.lang.reflect.Method; <ide> import java.util.Comparator; <add> <ide> import javax.cache.annotation.CacheDefaults; <ide> import javax.cache.annotation.CacheKeyGenerator; <ide> import javax.cache.annotation.CacheRemove; <ide><path>spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CachePutOperationTests.java <ide> package org.springframework.cache.jcache.interceptor; <ide> <ide> import java.io.IOException; <add> <ide> import javax.cache.annotation.CacheInvocationParameter; <ide> import javax.cache.annotation.CacheMethodDetails; <ide> import javax.cache.annotation.CachePut; <ide><path>spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResolverAdapterTests.java <ide> import java.lang.annotation.Annotation; <ide> import java.lang.reflect.Method; <ide> import java.util.Collection; <add> <ide> import javax.cache.annotation.CacheInvocationContext; <ide> import javax.cache.annotation.CacheMethodDetails; <ide> import javax.cache.annotation.CacheResolver; <ide><path>spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResultOperationTests.java <ide> import java.io.IOException; <ide> import java.lang.annotation.Annotation; <ide> import java.util.Set; <add> <ide> import javax.cache.annotation.CacheInvocationParameter; <ide> import javax.cache.annotation.CacheKey; <ide> import javax.cache.annotation.CacheMethodDetails; <ide><path>spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheErrorHandlerTests.java <ide> <ide> import java.util.Arrays; <ide> import java.util.concurrent.atomic.AtomicLong; <add> <ide> import javax.cache.annotation.CacheDefaults; <ide> import javax.cache.annotation.CachePut; <ide> import javax.cache.annotation.CacheRemove; <ide><path>spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheKeyGeneratorTests.java <ide> import java.lang.reflect.Method; <ide> import java.util.Arrays; <ide> import java.util.concurrent.atomic.AtomicLong; <add> <ide> import javax.cache.annotation.CacheDefaults; <ide> import javax.cache.annotation.CacheKey; <ide> import javax.cache.annotation.CacheResult; <ide><path>spring-context-support/src/test/java/org/springframework/cache/jcache/support/TestableCacheKeyGenerator.java <ide> package org.springframework.cache.jcache.support; <ide> <ide> import java.lang.annotation.Annotation; <add> <ide> import javax.cache.annotation.CacheKeyGenerator; <ide> import javax.cache.annotation.CacheKeyInvocationContext; <ide> import javax.cache.annotation.GeneratedCacheKey; <ide><path>spring-context-support/src/test/java/org/springframework/cache/jcache/support/TestableCacheResolver.java <ide> package org.springframework.cache.jcache.support; <ide> <ide> import java.lang.annotation.Annotation; <add> <ide> import javax.cache.Cache; <ide> import javax.cache.annotation.CacheInvocationContext; <ide> import javax.cache.annotation.CacheResolver; <ide><path>spring-context-support/src/test/java/org/springframework/cache/jcache/support/TestableCacheResolverFactory.java <ide> package org.springframework.cache.jcache.support; <ide> <ide> import java.lang.annotation.Annotation; <add> <ide> import javax.cache.annotation.CacheMethodDetails; <ide> import javax.cache.annotation.CacheResolver; <ide> import javax.cache.annotation.CacheResolverFactory; <ide><path>spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java <ide> import java.util.GregorianCalendar; <ide> import java.util.List; <ide> import java.util.Properties; <add> <ide> import javax.activation.FileTypeMap; <ide> import javax.mail.Address; <ide> import javax.mail.Message; <ide><path>spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java <ide> <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/MethodValidationTests.java <ide> <ide> import java.lang.annotation.Retention; <ide> import java.lang.annotation.RetentionPolicy; <add> <ide> import javax.validation.ValidationException; <ide> import javax.validation.Validator; <ide> import javax.validation.constraints.Max; <ide><path>spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/SpringValidatorAdapterTests.java <ide> import java.util.Locale; <ide> import java.util.Map; <ide> import java.util.Set; <add> <ide> import javax.validation.Constraint; <ide> import javax.validation.ConstraintValidator; <ide> import javax.validation.ConstraintValidatorContext; <ide><path>spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/ValidatorFactoryTests.java <ide> import java.util.List; <ide> import java.util.Optional; <ide> import java.util.Set; <add> <ide> import javax.validation.Constraint; <ide> import javax.validation.ConstraintValidator; <ide> import javax.validation.ConstraintValidatorContext; <ide><path>spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java <ide> import java.util.Map; <ide> import java.util.Set; <ide> import java.util.concurrent.ConcurrentHashMap; <add> <ide> import javax.annotation.PostConstruct; <ide> import javax.annotation.PreDestroy; <ide> import javax.annotation.Resource; <ide><path>spring-context/src/main/java/org/springframework/context/annotation/MBeanExportConfiguration.java <ide> package org.springframework.context.annotation; <ide> <ide> import java.util.Map; <add> <ide> import javax.management.MBeanServer; <ide> import javax.naming.NamingException; <ide> <ide><path>spring-context/src/main/java/org/springframework/context/support/LiveBeansView.java <ide> import java.util.Iterator; <ide> import java.util.LinkedHashSet; <ide> import java.util.Set; <add> <ide> import javax.management.MBeanServer; <ide> import javax.management.ObjectName; <ide> <ide><path>spring-context/src/main/java/org/springframework/ejb/access/AbstractRemoteSlsbInvokerInterceptor.java <ide> import java.lang.reflect.InvocationTargetException; <ide> import java.lang.reflect.Method; <ide> import java.rmi.RemoteException; <add> <ide> import javax.ejb.EJBHome; <ide> import javax.ejb.EJBObject; <ide> import javax.naming.NamingException; <ide><path>spring-context/src/main/java/org/springframework/ejb/access/AbstractSlsbInvokerInterceptor.java <ide> <ide> import java.lang.reflect.InvocationTargetException; <ide> import java.lang.reflect.Method; <add> <ide> import javax.naming.Context; <ide> import javax.naming.NamingException; <ide> <ide><path>spring-context/src/main/java/org/springframework/ejb/access/LocalSlsbInvokerInterceptor.java <ide> <ide> import java.lang.reflect.InvocationTargetException; <ide> import java.lang.reflect.Method; <add> <ide> import javax.ejb.CreateException; <ide> import javax.ejb.EJBLocalHome; <ide> import javax.ejb.EJBLocalObject; <ide><path>spring-context/src/main/java/org/springframework/ejb/access/SimpleRemoteSlsbInvokerInterceptor.java <ide> <ide> import java.lang.reflect.InvocationTargetException; <ide> import java.rmi.RemoteException; <add> <ide> import javax.ejb.CreateException; <ide> import javax.ejb.EJBObject; <ide> import javax.naming.NamingException; <ide><path>spring-context/src/main/java/org/springframework/format/number/money/CurrencyUnitFormatter.java <ide> package org.springframework.format.number.money; <ide> <ide> import java.util.Locale; <add> <ide> import javax.money.CurrencyUnit; <ide> import javax.money.Monetary; <ide> <ide><path>spring-context/src/main/java/org/springframework/format/number/money/Jsr354NumberFormatAnnotationFormatterFactory.java <ide> import java.util.Currency; <ide> import java.util.Locale; <ide> import java.util.Set; <add> <ide> import javax.money.CurrencyUnit; <ide> import javax.money.Monetary; <ide> import javax.money.MonetaryAmount; <ide><path>spring-context/src/main/java/org/springframework/format/number/money/MonetaryAmountFormatter.java <ide> package org.springframework.format.number.money; <ide> <ide> import java.util.Locale; <add> <ide> import javax.money.MonetaryAmount; <ide> import javax.money.format.MonetaryAmountFormat; <ide> import javax.money.format.MonetaryFormats; <ide><path>spring-context/src/main/java/org/springframework/jmx/access/ConnectorDelegate.java <ide> <ide> import java.io.IOException; <ide> import java.util.Map; <add> <ide> import javax.management.MBeanServerConnection; <ide> import javax.management.remote.JMXConnector; <ide> import javax.management.remote.JMXConnectorFactory; <ide><path>spring-context/src/main/java/org/springframework/jmx/access/MBeanClientInterceptor.java <ide> import java.util.Collections; <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.management.Attribute; <ide> import javax.management.InstanceNotFoundException; <ide> import javax.management.IntrospectionException; <ide><path>spring-context/src/main/java/org/springframework/jmx/access/NotificationListenerRegistrar.java <ide> import java.net.MalformedURLException; <ide> import java.util.Arrays; <ide> import java.util.Map; <add> <ide> import javax.management.MBeanServerConnection; <ide> import javax.management.ObjectName; <ide> import javax.management.remote.JMXServiceURL; <ide><path>spring-context/src/main/java/org/springframework/jmx/export/MBeanExporter.java <ide> import java.util.List; <ide> import java.util.Map; <ide> import java.util.Set; <add> <ide> import javax.management.DynamicMBean; <ide> import javax.management.JMException; <ide> import javax.management.MBeanException; <ide><path>spring-context/src/main/java/org/springframework/jmx/export/assembler/AbstractConfigurableMBeanInfoAssembler.java <ide> import java.util.HashMap; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.management.modelmbean.ModelMBeanNotificationInfo; <ide> <ide> import org.springframework.jmx.export.metadata.JmxMetadataUtils; <ide><path>spring-context/src/main/java/org/springframework/jmx/export/assembler/AbstractReflectiveMBeanInfoAssembler.java <ide> import java.lang.reflect.Method; <ide> import java.util.ArrayList; <ide> import java.util.List; <add> <ide> import javax.management.Descriptor; <ide> import javax.management.JMException; <ide> import javax.management.MBeanOperationInfo; <ide><path>spring-context/src/main/java/org/springframework/jmx/export/assembler/MetadataMBeanInfoAssembler.java <ide> <ide> import java.beans.PropertyDescriptor; <ide> import java.lang.reflect.Method; <add> <ide> import javax.management.Descriptor; <ide> import javax.management.MBeanParameterInfo; <ide> import javax.management.modelmbean.ModelMBeanNotificationInfo; <ide><path>spring-context/src/main/java/org/springframework/jmx/export/naming/IdentityNamingStrategy.java <ide> package org.springframework.jmx.export.naming; <ide> <ide> import java.util.Hashtable; <add> <ide> import javax.management.MalformedObjectNameException; <ide> import javax.management.ObjectName; <ide> <ide><path>spring-context/src/main/java/org/springframework/jmx/export/naming/KeyNamingStrategy.java <ide> <ide> import java.io.IOException; <ide> import java.util.Properties; <add> <ide> import javax.management.MalformedObjectNameException; <ide> import javax.management.ObjectName; <ide> <ide><path>spring-context/src/main/java/org/springframework/jmx/export/naming/MetadataNamingStrategy.java <ide> package org.springframework.jmx.export.naming; <ide> <ide> import java.util.Hashtable; <add> <ide> import javax.management.MalformedObjectNameException; <ide> import javax.management.ObjectName; <ide> <ide><path>spring-context/src/main/java/org/springframework/jmx/support/ConnectorServerFactoryBean.java <ide> import java.util.HashMap; <ide> import java.util.Map; <ide> import java.util.Properties; <add> <ide> import javax.management.JMException; <ide> import javax.management.MBeanServer; <ide> import javax.management.MalformedObjectNameException; <ide><path>spring-context/src/main/java/org/springframework/jmx/support/JmxUtils.java <ide> import java.lang.reflect.Method; <ide> import java.util.Hashtable; <ide> import java.util.List; <add> <ide> import javax.management.DynamicMBean; <ide> import javax.management.JMX; <ide> import javax.management.MBeanParameterInfo; <ide><path>spring-context/src/main/java/org/springframework/jmx/support/MBeanRegistrationSupport.java <ide> <ide> import java.util.LinkedHashSet; <ide> import java.util.Set; <add> <ide> import javax.management.InstanceAlreadyExistsException; <ide> import javax.management.InstanceNotFoundException; <ide> import javax.management.JMException; <ide><path>spring-context/src/main/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBean.java <ide> import java.util.HashMap; <ide> import java.util.Map; <ide> import java.util.Properties; <add> <ide> import javax.management.MBeanServerConnection; <ide> import javax.management.remote.JMXConnector; <ide> import javax.management.remote.JMXConnectorFactory; <ide><path>spring-context/src/main/java/org/springframework/jmx/support/NotificationListenerHolder.java <ide> import java.util.Collections; <ide> import java.util.LinkedHashSet; <ide> import java.util.Set; <add> <ide> import javax.management.MalformedObjectNameException; <ide> import javax.management.NotificationFilter; <ide> import javax.management.NotificationListener; <ide><path>spring-context/src/main/java/org/springframework/jmx/support/ObjectNameManager.java <ide> package org.springframework.jmx.support; <ide> <ide> import java.util.Hashtable; <add> <ide> import javax.management.MalformedObjectNameException; <ide> import javax.management.ObjectName; <ide> <ide><path>spring-context/src/main/java/org/springframework/jmx/support/WebSphereMBeanServerFactoryBean.java <ide> <ide> import java.lang.reflect.InvocationTargetException; <ide> import java.lang.reflect.Method; <add> <ide> import javax.management.MBeanServer; <ide> <ide> import org.springframework.beans.factory.FactoryBean; <ide><path>spring-context/src/main/java/org/springframework/jndi/JndiObjectFactoryBean.java <ide> <ide> import java.lang.reflect.Method; <ide> import java.lang.reflect.Modifier; <add> <ide> import javax.naming.Context; <ide> import javax.naming.NamingException; <ide> <ide><path>spring-context/src/main/java/org/springframework/jndi/JndiTemplate.java <ide> <ide> import java.util.Hashtable; <ide> import java.util.Properties; <add> <ide> import javax.naming.Context; <ide> import javax.naming.InitialContext; <ide> import javax.naming.NameNotFoundException; <ide><path>spring-context/src/main/java/org/springframework/jndi/support/SimpleJndiBeanFactory.java <ide> import java.util.HashSet; <ide> import java.util.Map; <ide> import java.util.Set; <add> <ide> import javax.naming.NameNotFoundException; <ide> import javax.naming.NamingException; <ide> <ide><path>spring-context/src/main/java/org/springframework/remoting/rmi/JndiRmiClientInterceptor.java <ide> import java.lang.reflect.InvocationTargetException; <ide> import java.lang.reflect.Method; <ide> import java.rmi.RemoteException; <add> <ide> import javax.naming.Context; <ide> import javax.naming.NamingException; <ide> <ide><path>spring-context/src/main/java/org/springframework/remoting/rmi/JndiRmiServiceExporter.java <ide> import java.rmi.Remote; <ide> import java.rmi.RemoteException; <ide> import java.util.Properties; <add> <ide> import javax.naming.NamingException; <ide> <ide> import org.springframework.beans.factory.DisposableBean; <ide><path>spring-context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutor.java <ide> import java.util.concurrent.Executor; <ide> import java.util.concurrent.Executors; <ide> import java.util.concurrent.Future; <add> <ide> import javax.enterprise.concurrent.ManagedExecutors; <ide> import javax.enterprise.concurrent.ManagedTask; <ide> <ide><path>spring-context/src/main/java/org/springframework/scheduling/concurrent/ConcurrentTaskScheduler.java <ide> import java.util.concurrent.ScheduledExecutorService; <ide> import java.util.concurrent.ScheduledFuture; <ide> import java.util.concurrent.TimeUnit; <add> <ide> import javax.enterprise.concurrent.LastExecution; <ide> import javax.enterprise.concurrent.ManagedScheduledExecutorService; <ide> <ide><path>spring-context/src/main/java/org/springframework/scheduling/concurrent/DefaultManagedAwareThreadFactory.java <ide> <ide> import java.util.Properties; <ide> import java.util.concurrent.ThreadFactory; <add> <ide> import javax.naming.NamingException; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-context/src/main/java/org/springframework/scheduling/concurrent/DefaultManagedTaskExecutor.java <ide> <ide> import java.util.Properties; <ide> import java.util.concurrent.Executor; <add> <ide> import javax.naming.NamingException; <ide> <ide> import org.springframework.beans.factory.InitializingBean; <ide><path>spring-context/src/main/java/org/springframework/scheduling/concurrent/DefaultManagedTaskScheduler.java <ide> <ide> import java.util.Properties; <ide> import java.util.concurrent.ScheduledExecutorService; <add> <ide> import javax.naming.NamingException; <ide> <ide> import org.springframework.beans.factory.InitializingBean; <ide><path>spring-context/src/main/java/org/springframework/scripting/support/StandardScriptEvaluator.java <ide> <ide> import java.io.IOException; <ide> import java.util.Map; <add> <ide> import javax.script.Bindings; <ide> import javax.script.ScriptEngine; <ide> import javax.script.ScriptEngineManager; <ide><path>spring-context/src/main/java/org/springframework/scripting/support/StandardScriptFactory.java <ide> <ide> import java.io.IOException; <ide> import java.lang.reflect.InvocationTargetException; <add> <ide> import javax.script.Invocable; <ide> import javax.script.ScriptEngine; <ide> import javax.script.ScriptEngineManager; <ide><path>spring-context/src/main/java/org/springframework/scripting/support/StandardScriptUtils.java <ide> import java.util.List; <ide> import java.util.Map; <ide> import java.util.Set; <add> <ide> import javax.script.Bindings; <ide> import javax.script.ScriptContext; <ide> import javax.script.ScriptEngine; <ide><path>spring-context/src/main/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessor.java <ide> <ide> import java.util.Iterator; <ide> import java.util.Set; <add> <ide> import javax.validation.ConstraintViolation; <ide> import javax.validation.Validation; <ide> import javax.validation.Validator; <ide><path>spring-context/src/main/java/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.java <ide> import java.util.List; <ide> import java.util.Map; <ide> import java.util.Properties; <add> <ide> import javax.validation.Configuration; <ide> import javax.validation.ConstraintValidatorFactory; <ide> import javax.validation.MessageInterpolator; <ide><path>spring-context/src/main/java/org/springframework/validation/beanvalidation/LocaleContextMessageInterpolator.java <ide> package org.springframework.validation.beanvalidation; <ide> <ide> import java.util.Locale; <add> <ide> import javax.validation.MessageInterpolator; <ide> <ide> import org.springframework.context.i18n.LocaleContextHolder; <ide><path>spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationInterceptor.java <ide> <ide> import java.lang.reflect.Method; <ide> import java.util.Set; <add> <ide> import javax.validation.ConstraintViolation; <ide> import javax.validation.ConstraintViolationException; <ide> import javax.validation.Validation; <ide><path>spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java <ide> package org.springframework.validation.beanvalidation; <ide> <ide> import java.lang.annotation.Annotation; <add> <ide> import javax.validation.Validator; <ide> import javax.validation.ValidatorFactory; <ide> <ide><path>spring-context/src/main/java/org/springframework/validation/beanvalidation/SpringValidatorAdapter.java <ide> import java.util.Map; <ide> import java.util.Set; <ide> import java.util.TreeMap; <add> <ide> import javax.validation.ConstraintViolation; <ide> import javax.validation.ElementKind; <ide> import javax.validation.Path; <ide><path>spring-context/src/test/java/example/scannable/AutowiredQualifierFooService.java <ide> package example.scannable; <ide> <ide> import java.util.concurrent.Future; <add> <ide> import javax.annotation.PostConstruct; <ide> <ide> import org.springframework.beans.factory.annotation.Autowired; <ide><path>spring-context/src/test/java/example/scannable/FooServiceImpl.java <ide> import java.util.Comparator; <ide> import java.util.List; <ide> import java.util.concurrent.Future; <add> <ide> import javax.annotation.PostConstruct; <ide> <ide> import org.springframework.beans.factory.BeanFactory; <ide><path>spring-context/src/test/java/org/springframework/beans/factory/support/InjectAnnotationAutowireContextTests.java <ide> import java.lang.annotation.Retention; <ide> import java.lang.annotation.RetentionPolicy; <ide> import java.lang.annotation.Target; <add> <ide> import javax.inject.Inject; <ide> import javax.inject.Named; <ide> import javax.inject.Qualifier; <ide><path>spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java <ide> import java.util.concurrent.Executors; <ide> import java.util.concurrent.TimeUnit; <ide> import java.util.concurrent.atomic.AtomicBoolean; <add> <ide> import javax.annotation.Resource; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java <ide> package org.springframework.context.annotation; <ide> <ide> import java.util.Properties; <add> <ide> import javax.annotation.PostConstruct; <ide> import javax.annotation.PreDestroy; <ide> import javax.annotation.Resource; <ide><path>spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java <ide> import java.util.Arrays; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.annotation.PostConstruct; <ide> <ide> import org.junit.jupiter.api.BeforeEach; <ide><path>spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java <ide> import java.util.Collections; <ide> import java.util.Iterator; <ide> import java.util.Properties; <add> <ide> import javax.inject.Inject; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-context/src/test/java/org/springframework/context/annotation/Spr3775InitDestroyLifecycleTests.java <ide> import java.util.ArrayList; <ide> import java.util.Arrays; <ide> import java.util.List; <add> <ide> import javax.annotation.PostConstruct; <ide> import javax.annotation.PreDestroy; <ide> <ide><path>spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java <ide> import java.lang.annotation.RetentionPolicy; <ide> import java.util.List; <ide> import java.util.Optional; <add> <ide> import javax.inject.Provider; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java <ide> import java.util.List; <ide> import java.util.Set; <ide> import java.util.function.Supplier; <add> <ide> import javax.annotation.Resource; <ide> import javax.inject.Provider; <ide> <ide><path>spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java <ide> import java.util.concurrent.CompletableFuture; <ide> import java.util.concurrent.CountDownLatch; <ide> import java.util.concurrent.TimeUnit; <add> <ide> import javax.annotation.PostConstruct; <ide> <ide> import org.junit.jupiter.api.AfterEach; <ide><path>spring-context/src/test/java/org/springframework/context/support/LiveBeansViewTests.java <ide> <ide> import java.lang.management.ManagementFactory; <ide> import java.util.Set; <add> <ide> import javax.management.MalformedObjectNameException; <ide> import javax.management.ObjectName; <ide> <ide><path>spring-context/src/test/java/org/springframework/ejb/access/LocalStatelessSessionProxyFactoryBeanTests.java <ide> package org.springframework.ejb.access; <ide> <ide> import java.lang.reflect.Proxy; <add> <ide> import javax.ejb.CreateException; <ide> import javax.ejb.EJBLocalHome; <ide> import javax.ejb.EJBLocalObject; <ide><path>spring-context/src/test/java/org/springframework/ejb/access/SimpleRemoteSlsbInvokerInterceptorTests.java <ide> <ide> import java.rmi.ConnectException; <ide> import java.rmi.RemoteException; <add> <ide> import javax.ejb.CreateException; <ide> import javax.ejb.EJBHome; <ide> import javax.ejb.EJBObject; <ide><path>spring-context/src/test/java/org/springframework/ejb/access/SimpleRemoteStatelessSessionProxyFactoryBeanTests.java <ide> <ide> import java.lang.reflect.Proxy; <ide> import java.rmi.RemoteException; <add> <ide> import javax.ejb.CreateException; <ide> import javax.ejb.EJBHome; <ide> import javax.ejb.EJBObject; <ide><path>spring-context/src/test/java/org/springframework/format/number/money/MoneyFormattingTests.java <ide> package org.springframework.format.number.money; <ide> <ide> import java.util.Locale; <add> <ide> import javax.money.CurrencyUnit; <ide> import javax.money.MonetaryAmount; <ide> <ide><path>spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java <ide> import java.net.BindException; <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.management.Descriptor; <ide> import javax.management.MBeanServerConnection; <ide> import javax.management.remote.JMXConnectorServer; <ide><path>spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java <ide> <ide> import java.net.BindException; <ide> import java.net.MalformedURLException; <add> <ide> import javax.management.MBeanServerConnection; <ide> import javax.management.remote.JMXConnector; <ide> import javax.management.remote.JMXConnectorFactory; <ide><path>spring-context/src/test/java/org/springframework/jmx/export/CustomEditorConfigurerTests.java <ide> import java.text.ParseException; <ide> import java.text.SimpleDateFormat; <ide> import java.util.Date; <add> <ide> import javax.management.ObjectName; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java <ide> import java.util.HashMap; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.management.Attribute; <ide> import javax.management.InstanceNotFoundException; <ide> import javax.management.JMException; <ide><path>spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java <ide> <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.management.Attribute; <ide> import javax.management.AttributeChangeNotification; <ide> import javax.management.MalformedObjectNameException; <ide><path>spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractMetadataAssemblerTests.java <ide> <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.management.Descriptor; <ide> import javax.management.MBeanInfo; <ide> import javax.management.MBeanParameterInfo; <ide><path>spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerMappedTests.java <ide> package org.springframework.jmx.export.assembler; <ide> <ide> import java.util.Properties; <add> <ide> import javax.management.MBeanAttributeInfo; <ide> import javax.management.modelmbean.ModelMBeanAttributeInfo; <ide> import javax.management.modelmbean.ModelMBeanInfo; <ide><path>spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerComboTests.java <ide> package org.springframework.jmx.export.assembler; <ide> <ide> import java.util.Properties; <add> <ide> import javax.management.MBeanAttributeInfo; <ide> import javax.management.modelmbean.ModelMBeanAttributeInfo; <ide> import javax.management.modelmbean.ModelMBeanInfo; <ide><path>spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerMappedTests.java <ide> package org.springframework.jmx.export.assembler; <ide> <ide> import java.util.Properties; <add> <ide> import javax.management.MBeanAttributeInfo; <ide> import javax.management.modelmbean.ModelMBeanAttributeInfo; <ide> import javax.management.modelmbean.ModelMBeanInfo; <ide><path>spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerNotMappedTests.java <ide> package org.springframework.jmx.export.assembler; <ide> <ide> import java.util.Properties; <add> <ide> import javax.management.MBeanAttributeInfo; <ide> import javax.management.modelmbean.ModelMBeanAttributeInfo; <ide> import javax.management.modelmbean.ModelMBeanInfo; <ide><path>spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerTests.java <ide> <ide> import java.lang.reflect.Method; <ide> import java.util.Properties; <add> <ide> import javax.management.modelmbean.ModelMBeanAttributeInfo; <ide> import javax.management.modelmbean.ModelMBeanInfo; <ide> <ide><path>spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerMappedTests.java <ide> package org.springframework.jmx.export.assembler; <ide> <ide> import java.util.Properties; <add> <ide> import javax.management.MBeanAttributeInfo; <ide> import javax.management.modelmbean.ModelMBeanAttributeInfo; <ide> import javax.management.modelmbean.ModelMBeanInfo; <ide><path>spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java <ide> <ide> import java.io.IOException; <ide> import java.net.MalformedURLException; <add> <ide> import javax.management.InstanceNotFoundException; <ide> import javax.management.MBeanServer; <ide> import javax.management.MBeanServerConnection; <ide><path>spring-context/src/test/java/org/springframework/jmx/support/JmxUtilsTests.java <ide> package org.springframework.jmx.support; <ide> <ide> import java.beans.PropertyDescriptor; <add> <ide> import javax.management.DynamicMBean; <ide> import javax.management.MBeanServer; <ide> import javax.management.MBeanServerFactory; <ide><path>spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java <ide> package org.springframework.jmx.support; <ide> <ide> import java.net.MalformedURLException; <add> <ide> import javax.management.MBeanServerConnection; <ide> import javax.management.remote.JMXConnectorServer; <ide> import javax.management.remote.JMXConnectorServerFactory; <ide><path>spring-context/src/test/java/org/springframework/jmx/support/MBeanServerFactoryBeanTests.java <ide> <ide> import java.lang.management.ManagementFactory; <ide> import java.util.List; <add> <ide> import javax.management.MBeanServer; <ide> import javax.management.MBeanServerFactory; <ide> <ide><path>spring-context/src/test/java/org/springframework/jndi/JndiLocatorDelegateTests.java <ide> package org.springframework.jndi; <ide> <ide> import java.lang.reflect.Field; <add> <ide> import javax.naming.spi.NamingManager; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-context/src/test/java/org/springframework/jndi/SimpleNamingContextTests.java <ide> import java.util.Hashtable; <ide> import java.util.Map; <ide> import java.util.logging.Logger; <add> <ide> import javax.naming.Binding; <ide> import javax.naming.Context; <ide> import javax.naming.InitialContext; <ide><path>spring-context/src/test/java/org/springframework/tests/mock/jndi/ExpectedLookupTemplate.java <ide> <ide> import java.util.Map; <ide> import java.util.concurrent.ConcurrentHashMap; <add> <ide> import javax.naming.NamingException; <ide> <ide> import org.springframework.jndi.JndiTemplate; <ide><path>spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContext.java <ide> import java.util.Hashtable; <ide> import java.util.Iterator; <ide> import java.util.Map; <add> <ide> import javax.naming.Binding; <ide> import javax.naming.Context; <ide> import javax.naming.Name; <ide><path>spring-context/src/test/java/org/springframework/tests/mock/jndi/SimpleNamingContextBuilder.java <ide> package org.springframework.tests.mock.jndi; <ide> <ide> import java.util.Hashtable; <add> <ide> import javax.naming.Context; <ide> import javax.naming.NamingException; <ide> import javax.naming.spi.InitialContextFactory; <ide><path>spring-context/src/test/java/org/springframework/util/MBeanTestUtils.java <ide> <ide> import java.lang.management.ManagementFactory; <ide> import java.lang.reflect.Field; <add> <ide> import javax.management.MBeanServer; <ide> import javax.management.MBeanServerFactory; <ide> <ide><path>spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationTests.java <ide> <ide> import java.lang.annotation.Retention; <ide> import java.lang.annotation.RetentionPolicy; <add> <ide> import javax.validation.ValidationException; <ide> import javax.validation.Validator; <ide> import javax.validation.constraints.Max; <ide><path>spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java <ide> import java.util.List; <ide> import java.util.Locale; <ide> import java.util.Set; <add> <ide> import javax.validation.Constraint; <ide> import javax.validation.ConstraintValidator; <ide> import javax.validation.ConstraintValidatorContext; <ide><path>spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java <ide> import java.util.List; <ide> import java.util.Optional; <ide> import java.util.Set; <add> <ide> import javax.validation.Constraint; <ide> import javax.validation.ConstraintValidator; <ide> import javax.validation.ConstraintValidatorContext; <ide><path>spring-core/src/main/java/org/springframework/lang/NonNull.java <ide> import java.lang.annotation.Retention; <ide> import java.lang.annotation.RetentionPolicy; <ide> import java.lang.annotation.Target; <add> <ide> import javax.annotation.Nonnull; <ide> import javax.annotation.meta.TypeQualifierNickname; <ide> <ide><path>spring-core/src/main/java/org/springframework/lang/NonNullApi.java <ide> import java.lang.annotation.Retention; <ide> import java.lang.annotation.RetentionPolicy; <ide> import java.lang.annotation.Target; <add> <ide> import javax.annotation.Nonnull; <ide> import javax.annotation.meta.TypeQualifierDefault; <ide> <ide><path>spring-core/src/main/java/org/springframework/lang/NonNullFields.java <ide> import java.lang.annotation.Retention; <ide> import java.lang.annotation.RetentionPolicy; <ide> import java.lang.annotation.Target; <add> <ide> import javax.annotation.Nonnull; <ide> import javax.annotation.meta.TypeQualifierDefault; <ide> <ide><path>spring-core/src/main/java/org/springframework/lang/Nullable.java <ide> import java.lang.annotation.Retention; <ide> import java.lang.annotation.RetentionPolicy; <ide> import java.lang.annotation.Target; <add> <ide> import javax.annotation.Nonnull; <ide> import javax.annotation.meta.TypeQualifierNickname; <ide> import javax.annotation.meta.When; <ide><path>spring-core/src/main/java/org/springframework/util/SocketUtils.java <ide> import java.util.Random; <ide> import java.util.SortedSet; <ide> import java.util.TreeSet; <add> <ide> import javax.net.ServerSocketFactory; <ide> <ide> /** <ide><path>spring-core/src/main/java/org/springframework/util/xml/AbstractStaxHandler.java <ide> import java.util.HashMap; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.xml.XMLConstants; <ide> import javax.xml.namespace.QName; <ide> import javax.xml.stream.XMLStreamException; <ide><path>spring-core/src/main/java/org/springframework/util/xml/AbstractStaxXMLReader.java <ide> <ide> import java.util.LinkedHashMap; <ide> import java.util.Map; <add> <ide> import javax.xml.namespace.QName; <ide> import javax.xml.stream.Location; <ide> import javax.xml.stream.XMLStreamException; <ide><path>spring-core/src/main/java/org/springframework/util/xml/AbstractXMLEventReader.java <ide> package org.springframework.util.xml; <ide> <ide> import java.util.NoSuchElementException; <add> <ide> import javax.xml.stream.XMLEventReader; <ide> import javax.xml.stream.XMLStreamException; <ide> <ide><path>spring-core/src/main/java/org/springframework/util/xml/ListBasedXMLEventReader.java <ide> import java.util.ArrayList; <ide> import java.util.List; <ide> import java.util.NoSuchElementException; <add> <ide> import javax.xml.stream.XMLStreamConstants; <ide> import javax.xml.stream.XMLStreamException; <ide> import javax.xml.stream.events.Characters; <ide><path>spring-core/src/main/java/org/springframework/util/xml/SimpleNamespaceContext.java <ide> import java.util.LinkedHashSet; <ide> import java.util.Map; <ide> import java.util.Set; <add> <ide> import javax.xml.XMLConstants; <ide> import javax.xml.namespace.NamespaceContext; <ide> <ide><path>spring-core/src/main/java/org/springframework/util/xml/StaxEventHandler.java <ide> import java.util.ArrayList; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.xml.namespace.QName; <ide> import javax.xml.stream.Location; <ide> import javax.xml.stream.XMLEventFactory; <ide><path>spring-core/src/main/java/org/springframework/util/xml/StaxEventXMLReader.java <ide> package org.springframework.util.xml; <ide> <ide> import java.util.Iterator; <add> <ide> import javax.xml.namespace.QName; <ide> import javax.xml.stream.Location; <ide> import javax.xml.stream.XMLEventReader; <ide><path>spring-core/src/main/java/org/springframework/util/xml/StaxStreamHandler.java <ide> package org.springframework.util.xml; <ide> <ide> import java.util.Map; <add> <ide> import javax.xml.XMLConstants; <ide> import javax.xml.namespace.QName; <ide> import javax.xml.stream.XMLStreamException; <ide><path>spring-core/src/main/java/org/springframework/util/xml/StaxUtils.java <ide> <ide> import java.util.List; <ide> import java.util.function.Supplier; <add> <ide> import javax.xml.stream.XMLEventFactory; <ide> import javax.xml.stream.XMLEventReader; <ide> import javax.xml.stream.XMLEventWriter; <ide><path>spring-core/src/main/java/org/springframework/util/xml/XMLEventStreamReader.java <ide> package org.springframework.util.xml; <ide> <ide> import java.util.Iterator; <add> <ide> import javax.xml.namespace.NamespaceContext; <ide> import javax.xml.namespace.QName; <ide> import javax.xml.stream.Location; <ide><path>spring-core/src/main/java/org/springframework/util/xml/XMLEventStreamWriter.java <ide> import java.util.ArrayList; <ide> import java.util.Iterator; <ide> import java.util.List; <add> <ide> import javax.xml.namespace.NamespaceContext; <ide> import javax.xml.namespace.QName; <ide> import javax.xml.stream.XMLEventFactory; <ide><path>spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java <ide> import java.util.Date; <ide> import java.util.List; <ide> import java.util.Set; <add> <ide> import javax.annotation.Nonnull; <ide> import javax.annotation.ParametersAreNonnullByDefault; <ide> import javax.annotation.Resource; <ide><path>spring-core/src/test/java/org/springframework/core/annotation/AnnotationAwareOrderComparatorTests.java <ide> <ide> import java.util.ArrayList; <ide> import java.util.List; <add> <ide> import javax.annotation.Priority; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-core/src/test/java/org/springframework/core/annotation/AnnotationFilterTests.java <ide> <ide> import java.lang.annotation.Retention; <ide> import java.lang.annotation.RetentionPolicy; <add> <ide> import javax.annotation.Nonnull; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java <ide> import java.util.Collections; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.annotation.Nullable; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java <ide> import java.util.List; <ide> import java.util.Map; <ide> import java.util.Set; <add> <ide> import javax.annotation.Nonnull; <ide> import javax.annotation.ParametersAreNonnullByDefault; <ide> <ide><path>spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java <ide> import java.util.NoSuchElementException; <ide> import java.util.stream.Collectors; <ide> import java.util.stream.Stream; <add> <ide> import javax.annotation.Resource; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTests.java <ide> <ide> package org.springframework.core.type; <ide> <add>import example.type.AnnotationTypeFilterTestsTypes; <ide> import example.type.InheritedAnnotation; <ide> import example.type.NonInheritedAnnotation; <ide> import org.junit.jupiter.api.Test; <ide><path>spring-core/src/test/java/org/springframework/core/type/AspectJTypeFilterTests.java <ide> <ide> package org.springframework.core.type; <ide> <add>import example.type.AspectJTypeFilterTestsTypes; <ide> import org.junit.jupiter.api.Test; <ide> <ide> import org.springframework.core.type.classreading.MetadataReader; <ide><path>spring-core/src/test/java/org/springframework/util/Base64UtilsTests.java <ide> package org.springframework.util; <ide> <ide> import java.io.UnsupportedEncodingException; <add> <ide> import javax.xml.bind.DatatypeConverter; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-core/src/test/java/org/springframework/util/SocketUtilsTests.java <ide> import java.net.InetAddress; <ide> import java.net.ServerSocket; <ide> import java.util.SortedSet; <add> <ide> import javax.net.ServerSocketFactory; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java <ide> <ide> import java.io.StringReader; <ide> import java.io.StringWriter; <add> <ide> import javax.xml.parsers.DocumentBuilder; <ide> import javax.xml.parsers.DocumentBuilderFactory; <ide> import javax.xml.stream.XMLStreamException; <ide><path>spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTestCase.java <ide> <ide> import java.io.ByteArrayInputStream; <ide> import java.io.InputStream; <add> <ide> import javax.xml.stream.XMLInputFactory; <ide> import javax.xml.stream.XMLStreamException; <ide> import javax.xml.transform.Transformer; <ide><path>spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java <ide> package org.springframework.util.xml; <ide> <ide> import java.io.StringReader; <add> <ide> import javax.xml.parsers.DocumentBuilder; <ide> import javax.xml.parsers.DocumentBuilderFactory; <ide> <ide><path>spring-core/src/test/java/org/springframework/util/xml/ListBasedXMLEventReaderTests.java <ide> import java.io.StringWriter; <ide> import java.util.ArrayList; <ide> import java.util.List; <add> <ide> import javax.xml.stream.XMLEventReader; <ide> import javax.xml.stream.XMLEventWriter; <ide> import javax.xml.stream.XMLInputFactory; <ide><path>spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java <ide> import java.util.Iterator; <ide> import java.util.LinkedHashSet; <ide> import java.util.Set; <add> <ide> import javax.xml.XMLConstants; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-core/src/test/java/org/springframework/util/xml/StaxEventXMLReaderTests.java <ide> <ide> import java.io.InputStream; <ide> import java.io.StringReader; <add> <ide> import javax.xml.stream.XMLEventReader; <ide> import javax.xml.stream.XMLInputFactory; <ide> import javax.xml.stream.XMLStreamException; <ide><path>spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java <ide> import java.io.Reader; <ide> import java.io.StringReader; <ide> import java.io.StringWriter; <add> <ide> import javax.xml.stream.XMLEventWriter; <ide> import javax.xml.stream.XMLOutputFactory; <ide> import javax.xml.stream.XMLStreamWriter; <ide><path>spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java <ide> <ide> import java.io.StringReader; <ide> import java.io.StringWriter; <add> <ide> import javax.xml.parsers.DocumentBuilder; <ide> import javax.xml.parsers.DocumentBuilderFactory; <ide> import javax.xml.stream.XMLEventReader; <ide><path>spring-core/src/test/java/org/springframework/util/xml/StaxStreamXMLReaderTests.java <ide> <ide> import java.io.InputStream; <ide> import java.io.StringReader; <add> <ide> import javax.xml.namespace.QName; <ide> import javax.xml.stream.XMLInputFactory; <ide> import javax.xml.stream.XMLStreamException; <ide><path>spring-core/src/test/java/org/springframework/util/xml/StaxUtilsTests.java <ide> <ide> import java.io.StringReader; <ide> import java.io.StringWriter; <add> <ide> import javax.xml.stream.XMLInputFactory; <ide> import javax.xml.stream.XMLOutputFactory; <ide> import javax.xml.stream.XMLStreamReader; <ide><path>spring-core/src/test/java/org/springframework/util/xml/TransformerUtilsTests.java <ide> package org.springframework.util.xml; <ide> <ide> import java.util.Properties; <add> <ide> import javax.xml.transform.ErrorListener; <ide> import javax.xml.transform.OutputKeys; <ide> import javax.xml.transform.Result; <ide><path>spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java <ide> <ide> import java.io.StringReader; <ide> import java.io.StringWriter; <add> <ide> import javax.xml.stream.XMLEventReader; <ide> import javax.xml.stream.XMLInputFactory; <ide> import javax.xml.transform.Transformer; <ide><path>spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java <ide> package org.springframework.util.xml; <ide> <ide> import java.io.StringWriter; <add> <ide> import javax.xml.stream.XMLEventFactory; <ide> import javax.xml.stream.XMLEventWriter; <ide> import javax.xml.stream.XMLOutputFactory; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java <ide> import java.util.LinkedHashMap; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.dao.DataAccessException; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/core/SqlRowSetResultSetExtractor.java <ide> <ide> import java.sql.ResultSet; <ide> import java.sql.SQLException; <add> <ide> import javax.sql.rowset.CachedRowSet; <ide> import javax.sql.rowset.RowSetFactory; <ide> import javax.sql.rowset.RowSetProvider; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java <ide> import java.util.Locale; <ide> import java.util.Map; <ide> import java.util.Set; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataProviderFactory.java <ide> <ide> import java.util.Arrays; <ide> import java.util.List; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/TableMetaDataContext.java <ide> import java.util.List; <ide> import java.util.Map; <ide> import java.util.Set; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java <ide> import java.util.List; <ide> import java.util.Map; <ide> import java.util.function.Consumer; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.dao.DataAccessException; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcCall.java <ide> import java.util.List; <ide> import java.util.Map; <ide> import java.util.Set; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcInsert.java <ide> import java.util.HashMap; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcCall.java <ide> import java.util.Arrays; <ide> import java.util.LinkedHashSet; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.jdbc.core.JdbcTemplate; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsert.java <ide> <ide> import java.util.Arrays; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.jdbc.core.JdbcTemplate; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/core/support/JdbcBeanDefinitionReader.java <ide> package org.springframework.jdbc.core.support; <ide> <ide> import java.util.Properties; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.beans.factory.support.BeanDefinitionRegistry; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/core/support/JdbcDaoSupport.java <ide> package org.springframework.jdbc.core.support; <ide> <ide> import java.sql.Connection; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.dao.support.DaoSupport; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/datasource/AbstractDataSource.java <ide> import java.io.PrintWriter; <ide> import java.sql.SQLException; <ide> import java.util.logging.Logger; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceTransactionManager.java <ide> import java.sql.Connection; <ide> import java.sql.SQLException; <ide> import java.sql.Statement; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.beans.factory.InitializingBean; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceUtils.java <ide> import java.sql.Connection; <ide> import java.sql.SQLException; <ide> import java.sql.Statement; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DelegatingDataSource.java <ide> import java.sql.Connection; <ide> import java.sql.SQLException; <ide> import java.util.logging.Logger; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.beans.factory.InitializingBean; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/datasource/LazyConnectionDataSourceProxy.java <ide> import java.sql.Connection; <ide> import java.sql.ResultSet; <ide> import java.sql.SQLException; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/datasource/SmartDataSource.java <ide> package org.springframework.jdbc.datasource; <ide> <ide> import java.sql.Connection; <add> <ide> import javax.sql.DataSource; <ide> <ide> /** <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy.java <ide> import java.sql.Connection; <ide> import java.sql.SQLException; <ide> import java.sql.Statement; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.lang.Nullable; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/datasource/WebSphereDataSourceAdapter.java <ide> import java.lang.reflect.Method; <ide> import java.sql.Connection; <ide> import java.sql.SQLException; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/AbstractEmbeddedDatabaseConfigurer.java <ide> import java.sql.Connection; <ide> import java.sql.SQLException; <ide> import java.sql.Statement; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/DerbyEmbeddedDatabaseConfigurer.java <ide> <ide> import java.sql.SQLException; <ide> import java.util.Properties; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.apache.commons.logging.LogFactory; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactory.java <ide> import java.sql.SQLException; <ide> import java.util.UUID; <ide> import java.util.logging.Logger; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/datasource/embedded/SimpleDriverDataSourceFactory.java <ide> package org.springframework.jdbc.datasource.embedded; <ide> <ide> import java.sql.Driver; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.jdbc.datasource.SimpleDriverDataSource; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/DatabasePopulatorUtils.java <ide> package org.springframework.jdbc.datasource.init; <ide> <ide> import java.sql.Connection; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.dao.DataAccessException; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulator.java <ide> import java.util.ArrayList; <ide> import java.util.Arrays; <ide> import java.util.List; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.core.io.Resource; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/AbstractRoutingDataSource.java <ide> import java.sql.SQLException; <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.beans.factory.InitializingBean; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookup.java <ide> import java.util.Collections; <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.lang.Nullable; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/object/BatchSqlUpdate.java <ide> import java.util.ArrayList; <ide> import java.util.Deque; <ide> import java.util.List; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.dao.DataAccessException; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/object/MappingSqlQuery.java <ide> import java.sql.ResultSet; <ide> import java.sql.SQLException; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.lang.Nullable; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/object/MappingSqlQueryWithParameters.java <ide> import java.sql.ResultSet; <ide> import java.sql.SQLException; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.jdbc.core.RowMapper; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/object/RdbmsOperation.java <ide> import java.util.LinkedList; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlCall.java <ide> <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.jdbc.core.CallableStatementCreator; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlFunction.java <ide> <ide> import java.sql.ResultSet; <ide> import java.sql.SQLException; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.dao.TypeMismatchDataAccessException; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlQuery.java <ide> <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.dao.DataAccessException; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/object/SqlUpdate.java <ide> package org.springframework.jdbc.object; <ide> <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.dao.DataAccessException; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/object/StoredProcedure.java <ide> <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.dao.DataAccessException; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/object/UpdatableSqlQuery.java <ide> import java.sql.ResultSet; <ide> import java.sql.SQLException; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.jdbc.core.RowMapper; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/support/DatabaseStartupValidator.java <ide> import java.sql.SQLException; <ide> import java.sql.Statement; <ide> import java.util.concurrent.TimeUnit; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/support/JdbcUtils.java <ide> import java.sql.Types; <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslator.java <ide> import java.sql.BatchUpdateException; <ide> import java.sql.SQLException; <ide> import java.util.Arrays; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.dao.CannotAcquireLockException; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/support/SQLErrorCodesFactory.java <ide> <ide> import java.util.Collections; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.apache.commons.logging.Log; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/support/incrementer/AbstractIdentityColumnMaxValueIncrementer.java <ide> import java.sql.ResultSet; <ide> import java.sql.SQLException; <ide> import java.sql.Statement; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.dao.DataAccessException; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/support/incrementer/AbstractSequenceMaxValueIncrementer.java <ide> import java.sql.ResultSet; <ide> import java.sql.SQLException; <ide> import java.sql.Statement; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.dao.DataAccessException; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/support/incrementer/MySQLMaxValueIncrementer.java <ide> import java.sql.ResultSet; <ide> import java.sql.SQLException; <ide> import java.sql.Statement; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.springframework.dao.DataAccessException; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/support/xml/Jdbc4SqlXmlHandler.java <ide> import java.sql.ResultSet; <ide> import java.sql.SQLException; <ide> import java.sql.SQLXML; <add> <ide> import javax.xml.transform.Result; <ide> import javax.xml.transform.Source; <ide> import javax.xml.transform.dom.DOMResult; <ide><path>spring-jdbc/src/main/java/org/springframework/jdbc/support/xml/SqlXmlHandler.java <ide> import java.io.Reader; <ide> import java.sql.ResultSet; <ide> import java.sql.SQLException; <add> <ide> import javax.xml.transform.Result; <ide> import javax.xml.transform.Source; <ide> <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/config/InitializeDatabaseIntegrationTests.java <ide> <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.AfterEach; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTests.java <ide> package org.springframework.jdbc.config; <ide> <ide> import java.util.function.Predicate; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateQueryTests.java <ide> import java.sql.Statement; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.BeforeEach; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java <ide> import java.util.LinkedList; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.BeforeEach; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplateTests.java <ide> import java.util.LinkedList; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.BeforeEach; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterQueryTests.java <ide> import java.util.HashMap; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.AfterEach; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/CallMetaDataContextTests.java <ide> import java.util.ArrayList; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.AfterEach; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcCallTests.java <ide> import java.sql.ResultSet; <ide> import java.sql.SQLException; <ide> import java.sql.Types; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.BeforeEach; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertTests.java <ide> import java.sql.DatabaseMetaData; <ide> import java.sql.ResultSet; <ide> import java.util.HashMap; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.AfterEach; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/TableMetaDataContextTests.java <ide> import java.util.ArrayList; <ide> import java.util.Date; <ide> import java.util.List; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.BeforeEach; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcBeanDefinitionReaderTests.java <ide> import java.sql.Connection; <ide> import java.sql.ResultSet; <ide> import java.sql.Statement; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcDaoSupportTests.java <ide> <ide> import java.util.ArrayList; <ide> import java.util.List; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java <ide> import java.util.HashMap; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> import javax.transaction.RollbackException; <ide> import javax.transaction.Status; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java <ide> import java.sql.SQLException; <ide> import java.sql.Savepoint; <ide> import java.sql.Statement; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.AfterEach; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DelegatingDataSourceTests.java <ide> import java.io.ByteArrayOutputStream; <ide> import java.io.PrintWriter; <ide> import java.sql.Connection; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/datasource/TestDataSourceWrapper.java <ide> <ide> import java.sql.Connection; <ide> import java.sql.SQLException; <add> <ide> import javax.sql.DataSource; <ide> <ide> public class TestDataSourceWrapper extends AbstractDataSource { <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapterTests.java <ide> <ide> import java.sql.Connection; <ide> import java.sql.SQLException; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookupTests.java <ide> <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/object/BatchSqlUpdateTests.java <ide> import java.sql.DatabaseMetaData; <ide> import java.sql.PreparedStatement; <ide> import java.sql.Types; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericSqlQueryTests.java <ide> import java.util.HashMap; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.BeforeEach; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericStoredProcedureTests.java <ide> import java.sql.Types; <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/object/RdbmsOperationTests.java <ide> import java.sql.Types; <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlQueryTests.java <ide> import java.util.HashMap; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.BeforeEach; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlUpdateTests.java <ide> import java.sql.Types; <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.AfterEach; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/object/StoredProcedureTests.java <ide> import java.util.HashMap; <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.AfterEach; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/support/DataFieldMaxValueIncrementerTests.java <ide> import java.sql.ResultSet; <ide> import java.sql.SQLException; <ide> import java.sql.Statement; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodesFactoryTests.java <ide> import java.sql.DatabaseMetaData; <ide> import java.sql.SQLException; <ide> import java.util.Arrays; <add> <ide> import javax.sql.DataSource; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java <ide> import java.util.Map; <ide> import java.util.concurrent.ConcurrentHashMap; <ide> import java.util.concurrent.ConcurrentMap; <add> <ide> import javax.jms.Connection; <ide> import javax.jms.ConnectionFactory; <ide> import javax.jms.Destination; <ide><path>spring-jms/src/main/java/org/springframework/jms/connection/ChainedExceptionListener.java <ide> <ide> import java.util.ArrayList; <ide> import java.util.List; <add> <ide> import javax.jms.ExceptionListener; <ide> import javax.jms.JMSException; <ide> <ide><path>spring-jms/src/main/java/org/springframework/jms/connection/JmsResourceHolder.java <ide> import java.util.HashMap; <ide> import java.util.LinkedList; <ide> import java.util.Map; <add> <ide> import javax.jms.Connection; <ide> import javax.jms.ConnectionFactory; <ide> import javax.jms.JMSException; <ide><path>spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java <ide> import java.util.LinkedHashSet; <ide> import java.util.List; <ide> import java.util.Set; <add> <ide> import javax.jms.Connection; <ide> import javax.jms.ConnectionFactory; <ide> import javax.jms.ExceptionListener; <ide><path>spring-jms/src/main/java/org/springframework/jms/connection/TransactionAwareConnectionFactoryProxy.java <ide> import java.lang.reflect.Proxy; <ide> import java.util.ArrayList; <ide> import java.util.List; <add> <ide> import javax.jms.Connection; <ide> import javax.jms.ConnectionFactory; <ide> import javax.jms.JMSContext; <ide><path>spring-jms/src/main/java/org/springframework/jms/core/JmsMessageOperations.java <ide> package org.springframework.jms.core; <ide> <ide> import java.util.Map; <add> <ide> import javax.jms.Destination; <ide> <ide> import org.springframework.lang.Nullable; <ide><path>spring-jms/src/main/java/org/springframework/jms/core/JmsMessagingTemplate.java <ide> package org.springframework.jms.core; <ide> <ide> import java.util.Map; <add> <ide> import javax.jms.ConnectionFactory; <ide> import javax.jms.Destination; <ide> import javax.jms.JMSException; <ide><path>spring-jms/src/main/java/org/springframework/jms/listener/AbstractJmsListeningContainer.java <ide> import java.util.Iterator; <ide> import java.util.LinkedList; <ide> import java.util.List; <add> <ide> import javax.jms.Connection; <ide> import javax.jms.JMSException; <ide> <ide><path>spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java <ide> import java.util.HashSet; <ide> import java.util.Set; <ide> import java.util.concurrent.Executor; <add> <ide> import javax.jms.Connection; <ide> import javax.jms.JMSException; <ide> import javax.jms.MessageConsumer; <ide><path>spring-jms/src/main/java/org/springframework/jms/listener/SimpleMessageListenerContainer.java <ide> import java.util.HashSet; <ide> import java.util.Set; <ide> import java.util.concurrent.Executor; <add> <ide> import javax.jms.Connection; <ide> import javax.jms.ConnectionFactory; <ide> import javax.jms.Destination; <ide><path>spring-jms/src/main/java/org/springframework/jms/listener/adapter/MessageListenerAdapter.java <ide> package org.springframework.jms.listener.adapter; <ide> <ide> import java.lang.reflect.InvocationTargetException; <add> <ide> import javax.jms.JMSException; <ide> import javax.jms.Message; <ide> import javax.jms.MessageListener; <ide><path>spring-jms/src/main/java/org/springframework/jms/listener/endpoint/StandardJmsActivationSpecFactory.java <ide> package org.springframework.jms.listener.endpoint; <ide> <ide> import java.util.Map; <add> <ide> import javax.jms.JMSException; <ide> import javax.jms.Queue; <ide> import javax.jms.Session; <ide><path>spring-jms/src/main/java/org/springframework/jms/support/JmsMessageHeaderAccessor.java <ide> <ide> import java.util.List; <ide> import java.util.Map; <add> <ide> import javax.jms.Destination; <ide> <ide> import org.springframework.lang.Nullable; <ide><path>spring-jms/src/main/java/org/springframework/jms/support/SimpleJmsHeaderMapper.java <ide> import java.util.HashSet; <ide> import java.util.Map; <ide> import java.util.Set; <add> <ide> import javax.jms.Destination; <ide> import javax.jms.JMSException; <ide> import javax.jms.Message; <ide><path>spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java <ide> import java.io.UnsupportedEncodingException; <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.jms.BytesMessage; <ide> import javax.jms.JMSException; <ide> import javax.jms.Message; <ide><path>spring-jms/src/main/java/org/springframework/jms/support/converter/MarshallingMessageConverter.java <ide> import java.io.IOException; <ide> import java.io.StringReader; <ide> import java.io.StringWriter; <add> <ide> import javax.jms.BytesMessage; <ide> import javax.jms.JMSException; <ide> import javax.jms.Message; <ide><path>spring-jms/src/main/java/org/springframework/jms/support/converter/MessagingMessageConverter.java <ide> package org.springframework.jms.support.converter; <ide> <ide> import java.util.Map; <add> <ide> import javax.jms.JMSException; <ide> import javax.jms.Session; <ide> <ide><path>spring-jms/src/main/java/org/springframework/jms/support/converter/SimpleMessageConverter.java <ide> import java.util.Enumeration; <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.jms.BytesMessage; <ide> import javax.jms.JMSException; <ide> import javax.jms.MapMessage; <ide><path>spring-jms/src/main/java/org/springframework/jms/support/destination/JndiDestinationResolver.java <ide> <ide> import java.util.Map; <ide> import java.util.concurrent.ConcurrentHashMap; <add> <ide> import javax.jms.Destination; <ide> import javax.jms.JMSException; <ide> import javax.jms.Queue; <ide><path>spring-jms/src/test/java/org/springframework/jms/StubTextMessage.java <ide> <ide> import java.util.Enumeration; <ide> import java.util.concurrent.ConcurrentHashMap; <add> <ide> import javax.jms.Destination; <ide> import javax.jms.JMSException; <ide> import javax.jms.TextMessage; <ide><path>spring-jms/src/test/java/org/springframework/jms/annotation/AbstractJmsAnnotationDrivenTests.java <ide> package org.springframework.jms.annotation; <ide> <ide> import java.lang.reflect.Method; <add> <ide> import javax.jms.JMSException; <ide> import javax.jms.Session; <ide> <ide><path>spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java <ide> <ide> import java.lang.annotation.Retention; <ide> import java.lang.annotation.RetentionPolicy; <add> <ide> import javax.jms.JMSException; <ide> import javax.jms.MessageListener; <ide> <ide><path>spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryIntegrationTests.java <ide> import java.lang.reflect.Method; <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.jms.JMSException; <ide> import javax.jms.Message; <ide> import javax.jms.MessageListener; <ide><path>spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java <ide> import java.util.Iterator; <ide> import java.util.Map; <ide> import java.util.Set; <add> <ide> import javax.jms.ConnectionFactory; <ide> import javax.jms.Message; <ide> import javax.jms.MessageListener; <ide><path>spring-jms/src/test/java/org/springframework/jms/config/MethodJmsListenerEndpointTests.java <ide> import java.util.Arrays; <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.jms.Destination; <ide> import javax.jms.InvalidDestinationException; <ide> import javax.jms.JMSException; <ide><path>spring-jms/src/test/java/org/springframework/jms/core/JmsMessagingTemplateTests.java <ide> import java.io.Writer; <ide> import java.util.HashMap; <ide> import java.util.Map; <add> <ide> import javax.jms.Destination; <ide> import javax.jms.JMSException; <ide> import javax.jms.MessageFormatException; <ide><path>spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTests.java <ide> import java.io.PrintWriter; <ide> import java.io.StringWriter; <ide> import java.util.List; <add> <ide> import javax.jms.Connection; <ide> import javax.jms.ConnectionFactory; <ide> import javax.jms.DeliveryMode; <ide><path>spring-jms/src/test/java/org/springframework/jms/core/support/JmsGatewaySupportTests.java <ide> <ide> import java.util.ArrayList; <ide> import java.util.List; <add> <ide> import javax.jms.ConnectionFactory; <ide> <ide> import org.junit.jupiter.api.Test; <ide><path>spring-jms/src/test/java/org/springframework/jms/listener/DefaultMessageListenerContainerTests.java <ide> <ide> import java.util.concurrent.CountDownLatch; <ide> import java.util.concurrent.TimeUnit; <add> <ide> import javax.jms.Connection; <ide> import javax.jms.ConnectionFactory; <ide> import javax.jms.Destination; <ide><path>spring-jms/src/test/java/org/springframework/jms/listener/SimpleMessageListenerContainerTests.java <ide> <ide> import java.util.HashSet; <ide> import java.util.Set; <add> <ide> import javax.jms.Connection; <ide> import javax.jms.ConnectionFactory; <ide> import javax.jms.ExceptionListener; <ide><path>spring-jms/src/test/java/org/springframework/jms/listener/adapter/MessageListenerAdapterTests.java <ide> <ide> import java.io.ByteArrayInputStream; <ide> import java.io.Serializable; <add> <ide> import javax.jms.BytesMessage; <ide> import javax.jms.InvalidDestinationException; <ide> import javax.jms.JMSException; <ide><path>spring-jms/src/test/java/org/springframework/jms/listener/adapter/MessagingMessageListenerAdapterTests.java <ide> import java.lang.reflect.Method; <ide> import java.util.ArrayList; <ide> import java.util.List; <add> <ide> import javax.jms.DeliveryMode; <ide> import javax.jms.Destination; <ide> import javax.jms.JMSException; <ide><path>spring-jms/src/test/java/org/springframework/jms/listener/adapter/ResponsiveMessageDelegate.java <ide> <ide> import java.io.Serializable; <ide> import java.util.Map; <add> <ide> import javax.jms.BytesMessage; <ide> import javax.jms.MapMessage; <ide> import javax.jms.ObjectMessage; <ide><path>spring-jms/src/test/java/org/springframework/jms/remoting/JmsInvokerTests.java <ide> import java.io.Serializable; <ide> import java.util.Arrays; <ide> import java.util.Enumeration; <add> <ide> import javax.jms.CompletionListener; <ide> import javax.jms.Destination; <ide> import javax.jms.JMSException; <ide><path>spring-jms/src/test/java/org/springframework/jms/support/JmsMessageHeaderAccessorTests.java <ide> package org.springframework.jms.support; <ide> <ide> import java.util.Map; <add> <ide> import javax.jms.Destination; <ide> import javax.jms.JMSException; <ide>
300
Mixed
Ruby
log a warning when running sqlite in production
ad6a62e4e68247411dba7e0700802d8d729c90ca
<ide><path>activerecord/CHANGELOG.md <add>* Log a warning message when running SQLite in production <add> <add> Using SQLite in production ENV is generally discouraged. SQLite is also the default adapter <add> in a new Rails application. <add> For the above reasons log a warning message when running SQLite in production. <add> <add> The warning can be disabled by setting `config.active_record.sqlite3_production_warning=false`. <add> <add> *Jacopo Beschi* <add> <ide> * Add option to disable joins for `has_one` associations. <ide> <ide> In a multiple database application, associations can't join across <ide><path>activerecord/lib/active_record/core.rb <ide> def self.configurations <ide> <ide> mattr_accessor :has_many_inversing, instance_accessor: false, default: false <ide> <add> mattr_accessor :sqlite3_production_warning, instance_accessor: false, default: true <add> <ide> class_attribute :default_connection_handler, instance_writer: false <ide> <ide> class_attribute :default_role, instance_writer: false <ide><path>activerecord/lib/active_record/railtie.rb <ide> class Railtie < Rails::Railtie # :nodoc: <ide> config.active_record.check_schema_cache_dump_version = true <ide> config.active_record.maintain_test_schema = true <ide> config.active_record.has_many_inversing = false <add> config.active_record.sqlite3_production_warning = true <ide> <ide> config.active_record.queues = ActiveSupport::InheritableOptions.new <ide> <ide> class Railtie < Rails::Railtie # :nodoc: <ide> self.connection_handlers = { writing_role => ActiveRecord::Base.default_connection_handler } <ide> end <ide> self.configurations = Rails.application.config.database_configuration <add> <ide> establish_connection <ide> end <ide> end <ide> <add> SQLITE3_PRODUCTION_WARN = "You are running SQLite in production, this is generally not recommended."\ <add> " You can disable this warning by setting \"config.active_record.sqlite3_production_warning=false\"." <add> initializer "active_record.sqlite3_production_warning" do <add> if config.active_record.sqlite3_production_warning && Rails.env.production? <add> ActiveSupport.on_load(:active_record_sqlite3adapter) do <add> Rails.logger.warn(SQLITE3_PRODUCTION_WARN) <add> end <add> end <add> end <add> <ide> # Expose database runtime to controller for logging. <ide> initializer "active_record.log_runtime" do <ide> require "active_record/railties/controller_runtime" <ide><path>railties/test/application/configuration_test.rb <ide> def self.delivered_email(email); email; end <ide> <ide> class ::MyOtherMailObserver < ::MyMailObserver; end <ide> <add>class MyLogRecorder < Logger <add> def initialize <add> @io = StringIO.new <add> super(@io) <add> end <add> <add> def recording <add> @io.string <add> end <add>end <add> <ide> module ApplicationTests <ide> class ConfigurationTest < ActiveSupport::TestCase <ide> include ActiveSupport::Testing::Isolation <ide> def switch_development_hosts_to(*hosts) <ide> def setup <ide> build_app <ide> suppress_default_config <add> suppress_sqlite3_warning <ide> end <ide> <ide> def teardown <ide> def restore_default_config <ide> FileUtils.mv("#{app_path}/config/__environments__", "#{app_path}/config/environments") <ide> end <ide> <add> def suppress_sqlite3_warning <add> add_to_config "config.active_record.sqlite3_production_warning = false" <add> end <add> <add> def restore_sqlite3_warning <add> remove_from_config ".*config.active_record.sqlite3_production_warning.*\n" <add> end <add> <ide> test "Rails.env does not set the RAILS_ENV environment variable which would leak out into rake tasks" do <ide> require "rails" <ide> <ide> class MyLogger < ::Logger <ide> assert_equal false, ActionDispatch::Request.return_only_media_type_on_content_type <ide> end <ide> <add> test "config.active_record.sqlite3_production_warning is on by default for new apps" do <add> restore_sqlite3_warning <add> <add> app "development" <add> <add> assert_equal true, ActiveRecord::Base.sqlite3_production_warning <add> end <add> <add> test "logs a warning when running SQLite3 in production" do <add> restore_sqlite3_warning <add> app_file "config/initializers/active_record.rb", <<~RUBY <add> ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") <add> RUBY <add> add_to_config "config.logger = MyLogRecorder.new" <add> <add> app "production" <add> <add> assert_match(/You are running SQLite in production, this is generally not recommended/, Rails.logger.recording) <add> end <add> <add> test "doesn't log a warning when running SQLite3 in production and sqlite3_production_warning=false" do <add> app_file "config/initializers/active_record.rb", <<~RUBY <add> ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") <add> RUBY <add> add_to_config "config.logger = MyLogRecorder.new" <add> <add> app "production" <add> <add> assert_no_match(/You are running SQLite in production, this is generally not recommended/, Rails.logger.recording) <add> end <add> <add> test "doesn't log a warning when running MySQL in production" do <add> restore_sqlite3_warning <add> original_configurations = ActiveRecord::Base.configurations <add> ActiveRecord::Base.configurations = { production: { db1: { adapter: "mysql2" } } } <add> app_file "config/initializers/active_record.rb", <<~RUBY <add> ActiveRecord::Base.establish_connection(adapter: "mysql2") <add> RUBY <add> add_to_config "config.logger = MyLogRecorder.new" <add> <add> app "production" <add> <add> assert_no_match(/You are running SQLite in production, this is generally not recommended/, Rails.logger.recording) <add> ensure <add> ActiveRecord::Base.configurations = original_configurations <add> end <add> <add> test "doesn't log a warning when running SQLite3 in development" do <add> restore_sqlite3_warning <add> app_file "config/initializers/active_record.rb", <<~RUBY <add> ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") <add> RUBY <add> add_to_config "config.logger = MyLogRecorder.new" <add> <add> app "development" <add> <add> assert_no_match(/You are running SQLite in production, this is generally not recommended/, Rails.logger.recording) <add> end <add> <ide> private <ide> def set_custom_config(contents, config_source = "custom".inspect) <ide> app_file "config/custom.yml", contents
4
Python
Python
allow float in schedule value. closes
7caafb4a6ce370a1045afad59ee7c08fec2aa8b2
<ide><path>celery/schedules.py <ide> def __ne__(self, other): <ide> <ide> def maybe_schedule(s, relative=False, app=None): <ide> if s is not None: <del> if isinstance(s, numbers.Integral): <add> if isinstance(s, numbers.Number): <ide> s = timedelta(seconds=s) <ide> if isinstance(s, timedelta): <ide> return schedule(s, relative, app=app)
1
Python
Python
remove interdependency from openai tokenizer
bf7eb0c9b3c804f5314397c8a5473b2f8b98ef96
<ide><path>src/transformers/models/openai/tokenization_openai.py <ide> import json <ide> import os <ide> import re <add>import unicodedata <ide> from typing import Optional, Tuple <ide> <del>from ...tokenization_utils import PreTrainedTokenizer <add>from ...tokenization_utils import PreTrainedTokenizer, _is_control, _is_punctuation, _is_whitespace <ide> from ...utils import logging <del>from ..bert.tokenization_bert import BasicTokenizer <ide> <ide> <ide> logger = logging.get_logger(__name__) <ide> } <ide> <ide> <add># Copied from transformers.models.bert.tokenization_bert.whitespace_tokenize <add>def whitespace_tokenize(text): <add> """Runs basic whitespace cleaning and splitting on a piece of text.""" <add> text = text.strip() <add> if not text: <add> return [] <add> tokens = text.split() <add> return tokens <add> <add> <add># Copied from transformers.models.bert.tokenization_bert.BasicTokenizer <add>class BasicTokenizer(object): <add> """ <add> Constructs a BasicTokenizer that will run basic tokenization (punctuation splitting, lower casing, etc.). <add> <add> Args: <add> do_lower_case (`bool`, *optional*, defaults to `True`): <add> Whether or not to lowercase the input when tokenizing. <add> never_split (`Iterable`, *optional*): <add> Collection of tokens which will never be split during tokenization. Only has an effect when <add> `do_basic_tokenize=True` <add> tokenize_chinese_chars (`bool`, *optional*, defaults to `True`): <add> Whether or not to tokenize Chinese characters. <add> <add> This should likely be deactivated for Japanese (see this <add> [issue](https://github.com/huggingface/transformers/issues/328)). <add> strip_accents (`bool`, *optional*): <add> Whether or not to strip all accents. If this option is not specified, then it will be determined by the <add> value for `lowercase` (as in the original BERT). <add> """ <add> <add> def __init__(self, do_lower_case=True, never_split=None, tokenize_chinese_chars=True, strip_accents=None): <add> if never_split is None: <add> never_split = [] <add> self.do_lower_case = do_lower_case <add> self.never_split = set(never_split) <add> self.tokenize_chinese_chars = tokenize_chinese_chars <add> self.strip_accents = strip_accents <add> <add> def tokenize(self, text, never_split=None): <add> """ <add> Basic Tokenization of a piece of text. Split on "white spaces" only, for sub-word tokenization, see <add> WordPieceTokenizer. <add> <add> Args: <add> never_split (`List[str]`, *optional*) <add> Kept for backward compatibility purposes. Now implemented directly at the base class level (see <add> [`PreTrainedTokenizer.tokenize`]) List of token not to split. <add> """ <add> # union() returns a new set by concatenating the two sets. <add> never_split = self.never_split.union(set(never_split)) if never_split else self.never_split <add> text = self._clean_text(text) <add> <add> # This was added on November 1st, 2018 for the multilingual and Chinese <add> # models. This is also applied to the English models now, but it doesn't <add> # matter since the English models were not trained on any Chinese data <add> # and generally don't have any Chinese data in them (there are Chinese <add> # characters in the vocabulary because Wikipedia does have some Chinese <add> # words in the English Wikipedia.). <add> if self.tokenize_chinese_chars: <add> text = self._tokenize_chinese_chars(text) <add> orig_tokens = whitespace_tokenize(text) <add> split_tokens = [] <add> for token in orig_tokens: <add> if token not in never_split: <add> if self.do_lower_case: <add> token = token.lower() <add> if self.strip_accents is not False: <add> token = self._run_strip_accents(token) <add> elif self.strip_accents: <add> token = self._run_strip_accents(token) <add> split_tokens.extend(self._run_split_on_punc(token, never_split)) <add> <add> output_tokens = whitespace_tokenize(" ".join(split_tokens)) <add> return output_tokens <add> <add> def _run_strip_accents(self, text): <add> """Strips accents from a piece of text.""" <add> text = unicodedata.normalize("NFD", text) <add> output = [] <add> for char in text: <add> cat = unicodedata.category(char) <add> if cat == "Mn": <add> continue <add> output.append(char) <add> return "".join(output) <add> <add> def _run_split_on_punc(self, text, never_split=None): <add> """Splits punctuation on a piece of text.""" <add> if never_split is not None and text in never_split: <add> return [text] <add> chars = list(text) <add> i = 0 <add> start_new_word = True <add> output = [] <add> while i < len(chars): <add> char = chars[i] <add> if _is_punctuation(char): <add> output.append([char]) <add> start_new_word = True <add> else: <add> if start_new_word: <add> output.append([]) <add> start_new_word = False <add> output[-1].append(char) <add> i += 1 <add> <add> return ["".join(x) for x in output] <add> <add> def _tokenize_chinese_chars(self, text): <add> """Adds whitespace around any CJK character.""" <add> output = [] <add> for char in text: <add> cp = ord(char) <add> if self._is_chinese_char(cp): <add> output.append(" ") <add> output.append(char) <add> output.append(" ") <add> else: <add> output.append(char) <add> return "".join(output) <add> <add> def _is_chinese_char(self, cp): <add> """Checks whether CP is the codepoint of a CJK character.""" <add> # This defines a "chinese character" as anything in the CJK Unicode block: <add> # https://en.wikipedia.org/wiki/CJK_Unified_Ideographs_(Unicode_block) <add> # <add> # Note that the CJK Unicode block is NOT all Japanese and Korean characters, <add> # despite its name. The modern Korean Hangul alphabet is a different block, <add> # as is Japanese Hiragana and Katakana. Those alphabets are used to write <add> # space-separated words, so they are not treated specially and handled <add> # like the all of the other languages. <add> if ( <add> (cp >= 0x4E00 and cp <= 0x9FFF) <add> or (cp >= 0x3400 and cp <= 0x4DBF) # <add> or (cp >= 0x20000 and cp <= 0x2A6DF) # <add> or (cp >= 0x2A700 and cp <= 0x2B73F) # <add> or (cp >= 0x2B740 and cp <= 0x2B81F) # <add> or (cp >= 0x2B820 and cp <= 0x2CEAF) # <add> or (cp >= 0xF900 and cp <= 0xFAFF) <add> or (cp >= 0x2F800 and cp <= 0x2FA1F) # <add> ): # <add> return True <add> <add> return False <add> <add> def _clean_text(self, text): <add> """Performs invalid character removal and whitespace cleanup on text.""" <add> output = [] <add> for char in text: <add> cp = ord(char) <add> if cp == 0 or cp == 0xFFFD or _is_control(char): <add> continue <add> if _is_whitespace(char): <add> output.append(" ") <add> else: <add> output.append(char) <add> return "".join(output) <add> <add> <ide> def get_pairs(word): <ide> """ <ide> Return set of symbol pairs in a word. word is represented as tuple of symbols (symbols being variable-length
1
PHP
PHP
use a subquery to delete child records
e60ae26c16e3ca6c3cf1ea741fa612031cb39ac1
<ide><path>src/ORM/Behavior/TreeBehavior.php <ide> public function beforeDelete(Event $event, EntityInterface $entity) <ide> $left = $entity->get($config['left']); <ide> $right = $entity->get($config['right']); <ide> $diff = $right - $left + 1; <add> $primaryKey = $this->_getPrimaryKey(); <ide> <ide> if ($diff > 2) { <ide> /* @var \Cake\Database\Expression\QueryExpression $expression */ <del> $expression = $this->_scope($this->_table->find()) <add> $finder = $this->_scope($this->_table->find()) <add> ->select([$primaryKey], true) <ide> ->where(function ($exp) use ($config, $left, $right) { <ide> return $exp <ide> ->gte($config['leftField'], $left + 1) <ide> ->lte($config['leftField'], $right - 1); <del> }) <del> ->clause('where'); <add> }); <ide> <del> $this->_table->deleteAll($expression); <add> $this->_table->deleteAll([$primaryKey . ' IN' => $finder]); <ide> } <ide> <ide> $this->_sync($diff, '-', "> {$right}"); <ide><path>tests/TestCase/ORM/Behavior/TreeBehaviorTest.php <ide> public function testDeleteSubTree() <ide> $this->assertMpttValues($expected, $this->table); <ide> } <ide> <add> /** <add> * Tests deleting a subtree in a scoped tree <add> * <add> * @return void <add> */ <add> public function testDeleteSubTreeScopedTree() <add> { <add> $table = TableRegistry::get('MenuLinkTrees'); <add> $table->addBehavior('Tree', ['scope' => ['menu' => 'main-menu']]); <add> $entity = $table->get(3); <add> $this->assertTrue($table->delete($entity)); <add> <add> $expected = [ <add> ' 1: 4 - 1:Link 1', <add> '_ 2: 3 - 2:Link 2', <add> ' 5: 8 - 6:Link 6', <add> '_ 6: 7 - 7:Link 7', <add> ' 9:10 - 8:Link 8', <add> ]; <add> $this->assertMpttValues($expected, $table); <add> <add> $table->behaviors()->get('Tree')->config('scope', ['menu' => 'categories']); <add> $expected = [ <add> ' 1:10 - 9:electronics', <add> '_ 2: 9 - 10:televisions', <add> '__ 3: 4 - 11:tube', <add> '__ 5: 8 - 12:lcd', <add> '___ 6: 7 - 13:plasma', <add> '11:20 - 14:portable', <add> '_12:15 - 15:mp3', <add> '__13:14 - 16:flash', <add> '_16:17 - 17:cd', <add> '_18:19 - 18:radios', <add> ]; <add> $this->assertMpttValues($expected, $table); <add> } <add> <ide> /** <ide> * Test deleting a root node <ide> *
2
Javascript
Javascript
fix outdated comment
5a8c55f078fabe23c1c47ad3421899b445a83567
<ide><path>lib/internal/bootstrap/node.js <ide> // many dependencies are invoked lazily. <ide> // <ide> // Scripts run before this file: <del>// - `lib/internal/bootstrap/context.js`: to setup the v8::Context with <add>// - `lib/internal/per_context/setup.js`: to setup the v8::Context with <ide> // Node.js-specific tweaks - this is also done in vm contexts. <ide> // - `lib/internal/bootstrap/primordials.js`: to save copies of JavaScript <ide> // builtins that won't be affected by user land monkey-patching for internal
1
Ruby
Ruby
use system taps
ac2aabf287f177b3113acb6f29964528f1cadefa
<ide><path>Library/Homebrew/test/cmd/cask_spec.rb <ide> describe "brew cask", :integration_test, :needs_macos, :needs_network do <ide> describe "list" do <ide> it "returns a list of installed Casks" do <del> setup_remote_tap("homebrew/cask") <add> setup_remote_tap "homebrew/cask" <ide> <ide> expect { brew "cask", "list" }.to be_a_success <ide> end <ide><path>Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb <ide> class #{Formulary.class_s(name)} < Formula <ide> <ide> def setup_remote_tap(name) <ide> Tap.fetch(name).tap do |tap| <del> tap.install(full_clone: false, quiet: true) unless tap.installed? <add> next if tap.installed? <add> full_name = Tap.fetch(name).full_name <add> # Check to see if the original Homebrew process has taps we can use. <add> system_tap_path = Pathname("#{ENV["HOMEBREW_LIBRARY"]}/Taps/#{full_name}") <add> if system_tap_path.exist? <add> system "git", "clone", "--shared", system_tap_path, tap.path <add> system "git", "-C", tap.path, "checkout", "master" <add> else <add> tap.install(full_clone: false, quiet: true) <add> end <ide> end <ide> end <ide>
2
PHP
PHP
add svg to image validation rule
960d499924dfd8ee4b3889498246a37a6600725c
<ide><path>src/Illuminate/Validation/Validator.php <ide> protected function validateActiveUrl($attribute, $value) <ide> */ <ide> protected function validateImage($attribute, $value) <ide> { <del> return $this->validateMimes($attribute, $value, array('jpeg', 'png', 'gif', 'bmp')); <add> return $this->validateMimes($attribute, $value, array('jpeg', 'png', 'gif', 'bmp', 'svg')); <ide> } <ide> <ide> /** <ide><path>tests/Validation/ValidationValidatorTest.php <ide> public function testValidateImage() <ide> $file5->expects($this->any())->method('guessExtension')->will($this->returnValue('png')); <ide> $v->setFiles(array('x' => $file5)); <ide> $this->assertTrue($v->passes()); <add> <add> $file6 = $this->getMock('Symfony\Component\HttpFoundation\File\UploadedFile', array('guessExtension'), $uploadedFile); <add> $file6->expects($this->any())->method('guessExtension')->will($this->returnValue('svg')); <add> $v->setFiles(array('x' => $file6)); <add> $this->assertTrue($v->passes()); <ide> } <ide> <ide>
2
Javascript
Javascript
add support for padding to treemap layout
62bcec0998b153b078b31fc0a013b6e1c60d45f7
<ide><path>d3.layout.js <ide> d3.layout.treemap = function() { <ide> var hierarchy = d3.layout.hierarchy(), <ide> round = Math.round, <ide> size = [1, 1], // width, height <add> padding = d3_layout_treemapPadding, // top, right, bottom, left <ide> sticky = false, <ide> stickies, <ide> ratio = 0.5 * (1 + Math.sqrt(5)); // golden ratio <ide> <del> // Recursively compute the node area based on value & scale. <del> function scale(node, k) { <del> var children = node.children, <del> value = node.value; <del> node.area = isNaN(value) || value < 0 ? 0 : value * k; <del> if (children) { <del> var i = -1, <del> n = children.length; <del> while (++i < n) scale(children[i], k); <add> // Compute the area for each child based on value & scale. <add> function scale(children, k) { <add> var i = -1, <add> n = children.length, <add> child, <add> value; <add> while (++i < n) { <add> value = (child = children[i]).value; <add> child.area = isNaN(value) || value < 0 ? 0 : value * k; <ide> } <ide> } <ide> <add> // Computes the rectangle for a particular node. <add> function nodeRect(node) { <add> var p = padding.call(this, node); <add> return { <add> x: node.x + p[3], <add> y: node.y + p[0], <add> dx: node.dx - p[1] - p[3], <add> dy: node.dy - p[0] - p[2] <add> }; <add> } <add> <ide> // Recursively arranges the specified node's children into squarified rows. <ide> function squarify(node) { <ide> if (!node.children) return; <del> var rect = {x: node.x, y: node.y, dx: node.dx, dy: node.dy}, <add> var rect = nodeRect(node), <ide> row = [], <ide> children = node.children.slice(), // copy-on-write <ide> child, <ide> best = Infinity, // the best row score so far <ide> score, // the current row score <ide> u = Math.min(rect.dx, rect.dy), // initial orientation <ide> n; <add> scale(children, rect.dx * rect.dy / node.value); <ide> row.area = 0; <ide> while ((n = children.length) > 0) { <ide> row.push(child = children[n - 1]); <ide> d3.layout.treemap = function() { <ide> // Preserves the existing layout! <ide> function stickify(node) { <ide> if (!node.children) return; <del> var rect = {x: node.x, y: node.y, dx: node.dx, dy: node.dy}, <add> var rect = nodeRect(node), <ide> children = node.children.slice(), // copy-on-write <ide> child, <ide> row = []; <add> scale(children, rect.dx * rect.dy / node.value); <ide> row.area = 0; <ide> while (child = children.pop()) { <ide> row.push(child); <ide> d3.layout.treemap = function() { <ide> <ide> function treemap(d) { <ide> var nodes = stickies || hierarchy(d), <del> root = nodes[0]; <del> root.x = 0; <del> root.y = 0; <del> root.dx = size[0]; <del> root.dy = size[1]; <add> root = nodes[0], <add> p = padding.call(this, root); <add> root.x = p[3]; <add> root.y = p[0]; <add> root.dx = size[0] - p[3] - p[1]; <add> root.dy = size[1] - p[0] - p[2]; <ide> if (stickies) hierarchy.revalue(root); <del> scale(root, size[0] * size[1] / root.value); <add> scale(nodes, root.dx * root.dy / root.value); <ide> (stickies ? stickify : squarify)(root); <ide> if (sticky) stickies = nodes; <ide> return nodes; <ide> d3.layout.treemap = function() { <ide> return treemap; <ide> }; <ide> <add> treemap.padding = function(x) { <add> if (!arguments.length) return padding; <add> padding = d3.functor(x); <add> return treemap; <add> }; <add> <ide> treemap.round = function(x) { <ide> if (!arguments.length) return round != Number; <ide> round = x ? Math.round : Number; <ide> d3.layout.treemap = function() { <ide> <ide> return d3_layout_hierarchyRebind(treemap, hierarchy); <ide> }; <add> <add>function d3_layout_treemapPadding(node) { <add> return [0, 0, 0, 0]; <add>} <ide> })(); <ide><path>d3.layout.min.js <del>(function(){function bh(a,b,c){return a._tree.ancestor.parent==b.parent?a._tree.ancestor:c}function bg(a,b,c){a=a._tree,b=b._tree;var d=c/(b.number-a.number);a.change+=d,b.change-=d,b.shift+=c,b.prelim+=c,b.mod+=c}function bf(a){var b=0,c=0,d=a.children,e=d.length,f;while(--e>=0)f=d[e]._tree,f.prelim+=b,f.mod+=b,b+=f.shift+(c+=f.change)}function be(a,b){function c(a,d){var e=a.children;if(e){var f,g=null,h=-1,i=e.length;while(++h<i)f=e[h],c(f,g),g=f}b(a,d)}c(a,null)}function bd(a,b){return a.depth-b.depth}function bc(a,b){return b.x-a.x}function bb(a,b){return a.x-b.x}function ba(a,b){var c=a.children;if(c){var d,e=c.length,f=-1;while(++f<e)b(d=ba(c[f],b),a)>0&&(a=d)}return a}function _(a){return a.children?a.children[a.children.length-1]:a._tree.thread}function $(a){return a.children?a.children[0]:a._tree.thread}function Z(a,b){return a.parent==b.parent?1:2}function Y(a){var b=a.children;return b?Y(b[b.length-1]):a}function X(a){var b=a.children;return b?X(b[0]):a}function W(a){return a.reduce(function(a,b){return a+b.x},0)/a.length}function V(a){return 1+d3.max(a,function(a){return a.y})}function U(a,b,c){var d=b.r+c.r,e=a.r+c.r,f=b.x-a.x,g=b.y-a.y,h=Math.sqrt(f*f+g*g),i=(e*e+h*h-d*d)/(2*e*h),j=Math.acos(i),k=i*e,l=Math.sin(j)*e;f/=h,g/=h,c.x=a.x+k*f+l*g,c.y=a.y+k*g-l*f}function T(a,b,c,d){var e=a.children;a.x=b+=d*a.x,a.y=c+=d*a.y,a.r*=d;if(e){var f=-1,g=e.length;while(++f<g)T(e[f],b,c,d)}}function S(a){var b=a.children;b?(b.forEach(S),a.r=P(b)):a.r=Math.sqrt(a.value)}function R(a){delete a._pack_next,delete a._pack_prev}function Q(a){a._pack_next=a._pack_prev=a}function P(a){function l(a){b=Math.min(a.x-a.r,b),c=Math.max(a.x+a.r,c),d=Math.min(a.y-a.r,d),e=Math.max(a.y+a.r,e)}var b=Infinity,c=-Infinity,d=Infinity,e=-Infinity,f=a.length,g,h,i,j,k;a.forEach(Q),g=a[0],g.x=-g.r,g.y=0,l(g);if(f>1){h=a[1],h.x=h.r,h.y=0,l(h);if(f>2){i=a[2],U(g,h,i),l(i),M(g,i),g._pack_prev=i,M(i,h),h=g._pack_next;for(var m=3;m<f;m++){U(g,h,i=a[m]);var n=0,o=1,p=1;for(j=h._pack_next;j!==h;j=j._pack_next,o++)if(O(j,i)){n=1;break}if(n==1)for(k=g._pack_prev;k!==j._pack_prev;k=k._pack_prev,p++)if(O(k,i)){p<o&&(n=-1,j=k);break}n==0?(M(g,i),h=i,l(i)):n>0?(N(g,j),h=j,m--):(N(j,h),g=j,m--)}}}var q=(b+c)/2,r=(d+e)/2,s=0;for(var m=0;m<f;m++){var t=a[m];t.x-=q,t.y-=r,s=Math.max(s,t.r+Math.sqrt(t.x*t.x+t.y*t.y))}a.forEach(R);return s}function O(a,b){var c=b.x-a.x,d=b.y-a.y,e=a.r+b.r;return e*e-c*c-d*d>.001}function N(a,b){a._pack_next=b,b._pack_prev=a}function M(a,b){var c=a._pack_next;a._pack_next=b,b._pack_prev=a,b._pack_next=c,c._pack_prev=b}function L(a,b){return a.value-b.value}function J(a){return d3.merge(a.map(function(a){return(a.children||[]).map(function(b){return{source:a,target:b}})}))}function I(a,b){return b.value-a.value}function H(a){return a.value}function G(a){return a.children}function F(a,b){a.sort=d3.rebind(a,b.sort),a.children=d3.rebind(a,b.children),a.links=J,a.value=d3.rebind(a,b.value),a.nodes=function(b){K=!0;return(a.nodes=a)(b)};return a}function E(a){return[d3.min(a),d3.max(a)]}function D(a,b){var c=-1,d=+a[0],e=(a[1]-d)/b,f=[];while(++c<=b)f[c]=e*c+d;return f}function C(a,b){return D(a,Math.ceil(Math.log(b.length)/Math.LN2+1))}function B(a,b){return a+b[1]}function A(a){return a.reduce(B,0)}function z(a){var b=1,c=0,d=a[0][1],e,f=a.length;for(;b<f;++b)(e=a[b][1])>d&&(c=b,d=e);return c}function w(a,b,c){a.y0=b,a.y=c}function v(a){return a.y}function u(a){return a.x}function t(a){return 1}function s(a){return 20}function r(a){var b=0,c=0;a.count=0;if(!a.leaf){var d=a.nodes,e=d.length,f=-1,g;while(++f<e){g=d[f];if(g==null)continue;r(g),a.count+=g.count,b+=g.count*g.cx,c+=g.count*g.cy}}a.point&&(a.leaf||(a.point.x+=Math.random()-.5,a.point.y+=Math.random()-.5),a.count++,b+=a.point.x,c+=a.point.y),a.cx=b/a.count,a.cy=c/a.count}function q(){d3.event.stopPropagation(),d3.event.preventDefault()}function p(){i&&(q(),i=!1)}function o(){!f||(g&&(i=!0,q()),d3.event.type==="mouseup"&&n(),f.fixed=!1,e=h=f=j=null)}function n(){if(!!f){var a=j.parentNode;if(!a){f.fixed=!1,h=f=j=null;return}var b=m(a);g=!0,f.px=b[0]-h[0],f.py=b[1]-h[1],q(),e.resume()}}function m(a){return d3.event.touches?d3.svg.touches(a)[0]:d3.svg.mouse(a)}function l(a){a!==f&&(a.fixed=!1)}function k(a){a.fixed=!0}function c(a,c){if(a===c)return a;var d=b(a),e=b(c),f=d.pop(),g=e.pop(),h=null;while(f===g)h=f,f=d.pop(),g=e.pop();return h}function b(a){var b=[],c=a.parent;while(c!=null)b.push(a),a=c,c=c.parent;b.push(a);return b}function a(a){var b=a.source,d=a.target,e=c(b,d),f=[b];while(b!==e)b=b.parent,f.push(b);var g=f.length;while(d!==e)f.splice(g,0,d),d=d.parent;return f}d3.layout={},d3.layout.bundle=function(){return function(b){var c=[],d=-1,e=b.length;while(++d<e)c.push(a(b[d]));return c}},d3.layout.chord=function(){function k(){b.sort(function(a,b){return i(a.target.value,b.target.value)})}function j(){var a={},j=[],l=d3.range(e),m=[],n,o,p,q,r;b=[],c=[],n=0,q=-1;while(++q<e){o=0,r=-1;while(++r<e)o+=d[q][r];j.push(o),m.push(d3.range(e)),n+=o}g&&l.sort(function(a,b){return g(j[a],j[b])}),h&&m.forEach(function(a,b){a.sort(function(a,c){return h(d[b][a],d[b][c])})}),n=(2*Math.PI-f*e)/n,o=0,q=-1;while(++q<e){p=o,r=-1;while(++r<e){var s=l[q],t=m[q][r],u=d[s][t];a[s+"-"+t]={index:s,subindex:t,startAngle:o,endAngle:o+=u*n,value:u}}c.push({index:s,startAngle:p,endAngle:o,value:(o-p)/n}),o+=f}q=-1;while(++q<e){r=q-1;while(++r<e){var v=a[q+"-"+r],w=a[r+"-"+q];(v.value||w.value)&&b.push(v.value<w.value?{source:w,target:v}:{source:v,target:w})}}i&&k()}var a={},b,c,d,e,f=0,g,h,i;a.matrix=function(f){if(!arguments.length)return d;e=(d=f)&&d.length,b=c=null;return a},a.padding=function(d){if(!arguments.length)return f;f=d,b=c=null;return a},a.sortGroups=function(d){if(!arguments.length)return g;g=d,b=c=null;return a},a.sortSubgroups=function(c){if(!arguments.length)return h;h=c,b=null;return a},a.sortChords=function(c){if(!arguments.length)return i;i=c,b&&k();return a},a.chords=function(){b||j();return b},a.groups=function(){c||j();return c};return a},d3.layout.force=function(){function G(b,c){var d=m(this.parentNode);(f=b).fixed=!0,g=!1,j=this,e=a,h=[d[0]-b.x,d[1]-b.y],q()}function F(){var a=A.length,e=B.length,f=d3.geom.quadtree(A),g,h,j,k,l,m,n;for(g=0;g<e;++g){h=B[g],j=h.source,k=h.target,m=k.x-j.x,n=k.y-j.y;if(l=m*m+n*n)l=d*D[g]*((l=Math.sqrt(l))-C[g])/l,m*=l,n*=l,k.x-=m,k.y-=n,j.x+=m,j.y+=n}var o=d*x;m=c[0]/2,n=c[1]/2,g=-1;while(++g<a)h=A[g],h.x+=(m-h.x)*o,h.y+=(n-h.y)*o;r(f);var p=d*w;g=-1;while(++g<a)f.visit(E(A[g],p));g=-1;while(++g<a)h=A[g],h.fixed?(h.x=h.px,h.y=h.py):(h.x-=(h.px-(h.px=h.x))*i,h.y-=(h.py-(h.py=h.y))*i);b.tick.dispatch({type:"tick",alpha:d});return(d*=.99)<.005}function E(a,b){return function(c,d,e,f,g){if(c.point!==a){var h=c.cx-a.x,i=c.cy-a.y,j=1/Math.sqrt(h*h+i*i);if((f-d)*j<y){var k=b*c.count*j*j;a.x+=h*k,a.y+=i*k;return!0}if(c.point&&isFinite(j)){var k=b*j*j;a.x+=h*k,a.y+=i*k}}}}var a={},b=d3.dispatch("tick"),c=[1,1],d,i=.9,u=s,v=t,w=-30,x=.1,y=.8,z,A=[],B=[],C,D;a.on=function(c,d){b[c].add(d);return a},a.nodes=function(b){if(!arguments.length)return A;A=b;return a},a.links=function(b){if(!arguments.length)return B;B=b;return a},a.size=function(b){if(!arguments.length)return c;c=b;return a},a.linkDistance=function(b){if(!arguments.length)return u;u=d3.functor(b);return a},a.distance=a.linkDistance,a.linkStrength=function(b){if(!arguments.length)return v;v=d3.functor(b);return a},a.friction=function(b){if(!arguments.length)return i;i=b;return a},a.charge=function(b){if(!arguments.length)return w;w=b;return a},a.gravity=function(b){if(!arguments.length)return x;x=b;return a},a.theta=function(b){if(!arguments.length)return y;y=b;return a},a.start=function(){function l(){if(!i){i=[];for(d=0;d<e;++d)i[d]=[];for(d=0;d<f;++d){var a=B[d];i[a.source.index].push(a.target),i[a.target.index].push(a.source)}}return i[b]}function k(a,c){var d=l(b),e=-1,f=d.length,g;while(++e<f)if(!isNaN(g=d[e][a]))return g;return Math.random()*c}var b,d,e=A.length,f=B.length,g=c[0],h=c[1],i,j;for(b=0;b<e;++b)(j=A[b]).index=b;C=[],D=[];for(b=0;b<f;++b)j=B[b],typeof j.source=="number"&&(j.source=A[j.source]),typeof j.target=="number"&&(j.target=A[j.target]),C[b]=u.call(this,j,b),D[b]=v.call(this,j,b);for(b=0;b<e;++b)j=A[b],isNaN(j.x)&&(j.x=k("x",g)),isNaN(j.y)&&(j.y=k("y",h)),isNaN(j.px)&&(j.px=j.x),isNaN(j.py)&&(j.py=j.y);return a.resume()},a.resume=function(){d=.1,d3.timer(F);return a},a.stop=function(){d=0;return a},a.drag=function(){this.on("mouseover.force",k).on("mouseout.force",l).on("mousedown.force",G).on("touchstart.force",G),d3.select(window).on("mousemove.force",n).on("touchmove.force",n).on("mouseup.force",o,!0).on("touchend.force",o,!0).on("click.force",p,!0);return a};return a};var e,f,g,h,i,j;d3.layout.partition=function(){function e(e,f){var g=a.call(this,e,f);c(g[0],0,b[0],b[1]/d(g[0]));return g}function d(a){var b=a.children,c=0;if(b){var e=-1,f=b.length;while(++e<f)c=Math.max(c,d(b[e]))}return 1+c}function c(a,b,d,e){var f=a.children;a.x=b,a.y=a.depth*e,a.dx=d,a.dy=e;if(f){var g=-1,h=f.length,i,j;d/=a.value;while(++g<h)c(i=f[g],b,j=i.value*d,e),b+=j}}var a=d3.layout.hierarchy(),b=[1,1];e.size=function(a){if(!arguments.length)return b;b=a;return e};return F(e,a)},d3.layout.pie=function(){function f(f,g){var h=+(typeof c=="function"?c.apply(this,arguments):c),i=(typeof e=="function"?e.apply(this,arguments):e)-c,j=d3.range(f.length);b!=null&&j.sort(function(a,c){return b(f[a],f[c])});var k=f.map(a);i/=k.reduce(function(a,b){return a+b},0);var l=j.map(function(a){return{data:f[a],value:d=k[a],startAngle:h,endAngle:h+=d*i}});return f.map(function(a,b){return l[j[b]]})}var a=Number,b=null,c=0,e=2*Math.PI;f.value=function(b){if(!arguments.length)return a;a=b;return f},f.sort=function(a){if(!arguments.length)return b;b=a;return f},f.startAngle=function(a){if(!arguments.length)return c;c=a;return f},f.endAngle=function(a){if(!arguments.length)return e;e=a;return f};return f},d3.layout.stack=function(){function g(h,i){var j=h.map(function(b,c){return a.call(g,b,c)}),k=j.map(function(a,b){return a.map(function(a,b){return[e.call(g,a,b),f.call(g,a,b)]})}),l=b.call(g,k,i);j=d3.permute(j,l),k=d3.permute(k,l);var m=c.call(g,k,i),n=j.length,o=j[0].length,p,q,r;for(q=0;q<o;++q){d.call(g,j[0][q],r=m[q],k[0][q][1]);for(p=1;p<n;++p)d.call(g,j[p][q],r+=k[p-1][q][1],k[p][q][1])}return h}var a=Object,b=x["default"],c=y.zero,d=w,e=u,f=v;g.values=function(b){if(!arguments.length)return a;a=b;return g},g.order=function(a){if(!arguments.length)return b;b=typeof a=="function"?a:x[a];return g},g.offset=function(a){if(!arguments.length)return c;c=typeof a=="function"?a:y[a];return g},g.x=function(a){if(!arguments.length)return e;e=a;return g},g.y=function(a){if(!arguments.length)return f;f=a;return g},g.out=function(a){if(!arguments.length)return d;d=a;return g};return g};var x={"inside-out":function(a){var b=a.length,c,d,e=a.map(z),f=a.map(A),g=d3.range(b).sort(function(a,b){return e[a]-e[b]}),h=0,i=0,j=[],k=[];for(c=0;c<b;++c)d=g[c],h<i?(h+=f[d],j.push(d)):(i+=f[d],k.push(d));return k.reverse().concat(j)},reverse:function(a){return d3.range(a.length).reverse()},"default":function(a){return d3.range(a.length)}},y={silhouette:function(a){var b=a.length,c=a[0].length,d=[],e=0,f,g,h,i=[];for(g=0;g<c;++g){for(f=0,h=0;f<b;f++)h+=a[f][g][1];h>e&&(e=h),d.push(h)}for(g=0;g<c;++g)i[g]=(e-d[g])/2;return i},wiggle:function(a){var b=a.length,c=a[0],d=c.length,e=0,f,g,h,i,j,k,l,m,n,o=[];o[0]=m=n=0;for(g=1;g<d;++g){for(f=0,i=0;f<b;++f)i+=a[f][g][1];for(f=0,j=0,l=c[g][0]-c[g-1][0];f<b;++f){for(h=0,k=(a[f][g][1]-a[f][g-1][1])/(2*l);h<f;++h)k+=(a[h][g][1]-a[h][g-1][1])/l;j+=k*a[f][g][1]}o[g]=m-=i?j/i*l:0,m<n&&(n=m)}for(g=0;g<d;++g)o[g]-=n;return o},expand:function(a){var b=a.length,c=a[0].length,d=1/b,e,f,g,h=[];for(f=0;f<c;++f){for(e=0,g=0;e<b;e++)g+=a[e][f][1];if(g)for(e=0;e<b;e++)a[e][f][1]/=g;else for(e=0;e<b;e++)a[e][f][1]=d}for(f=0;f<c;++f)h[f]=0;return h},zero:function(a){var b=-1,c=a[0].length,d=[];while(++b<c)d[b]=0;return d}};d3.layout.histogram=function(){function e(e,f){var g=[],h=e.map(b,this),i=c.call(this,h,f),j=d.call(this,i,h,f),k,f=-1,l=h.length,m=j.length-1,n=a?1/l:1,o;while(++f<m)k=g[f]=[],k.dx=j[f+1]-(k.x=j[f]),k.y=0;f=-1;while(++f<l)o=h[f],o>=i[0]&&o<=i[1]&&(k=g[d3.bisect(j,o,1,m)-1],k.y+=n,k.push(e[f]));return g}var a=!0,b=Number,c=E,d=C;e.value=function(a){if(!arguments.length)return b;b=a;return e},e.range=function(a){if(!arguments.length)return c;c=d3.functor(a);return e},e.bins=function(a){if(!arguments.length)return d;d=typeof a=="number"?function(b){return D(b,a)}:d3.functor(a);return e},e.frequency=function(b){if(!arguments.length)return a;a=!!b;return e};return e},d3.layout.hierarchy=function(){function g(a){var b=[];e(a,0,b);return b}function f(a,b){var d=a.children,e=0;if(d){var h=-1,i=d.length,j=b+1;while(++h<i)e+=f(d[h],j)}else c&&(e=c.call(g,K?a:a.data,b));c&&(a.value=e);return e}function e(f,h,i){var j=b.call(g,f,h),k=K?f:{data:f};k.depth=h,i.push(k);if(j){var l=-1,m=j.length,n=k.children=[],o=0,p=h+1;while(++l<m)d=e(j[l],p,i),d.parent=k,n.push(d),o+=d.value;a&&n.sort(a),c&&(k.value=o)}else c&&(k.value=c.call(g,f,h));return k}var a=I,b=G,c=H;g.sort=function(b){if(!arguments.length)return a;a=b;return g},g.children=function(a){if(!arguments.length)return b;b=a;return g},g.value=function(a){if(!arguments.length)return c;c=a;return g},g.revalue=function(a){f(a,0);return a};return g};var K=!1;d3.layout.pack=function(){function c(c,d){var e=a.call(this,c,d),f=e[0];f.x=0,f.y=0,S(f);var g=b[0],h=b[1],i=1/Math.max(2*f.r/g,2*f.r/h);T(f,g/2,h/2,i);return e}var a=d3.layout.hierarchy().sort(L),b=[1,1];c.size=function(a){if(!arguments.length)return b;b=a;return c};return F(c,a)},d3.layout.cluster=function(){function d(d,e){var f=a.call(this,d,e),g=f[0],h,i=0,j,k;be(g,function(a){a.children?(a.x=W(a.children),a.y=V(a.children)):(a.x=h?i+=b(a,h):0,a.y=0,h=a)});var l=X(g),m=Y(g),n=l.x-b(l,m)/2,o=m.x+b(m,l)/2;be(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=(1-a.y/g.y)*c[1]});return f}var a=d3.layout.hierarchy().sort(null).value(null),b=Z,c=[1,1];d.separation=function(a){if(!arguments.length)return b;b=a;return d},d.size=function(a){if(!arguments.length)return c;c=a;return d};return F(d,a)},d3.layout.tree=function(){function d(d,e){function j(a,c,d){if(c){var e=a,f=a,g=c,h=a.parent.children[0],i=e._tree.mod,j=f._tree.mod,k=g._tree.mod,l=h._tree.mod,m;while(g=_(g),e=$(e),g&&e)h=$(h),f=_(f),f._tree.ancestor=a,m=g._tree.prelim+k-e._tree.prelim-i+b(g,e),m>0&&(bg(bh(g,a,d),a,m),i+=m,j+=m),k+=g._tree.mod,i+=e._tree.mod,l+=h._tree.mod,j+=f._tree.mod;g&&!_(f)&&(f._tree.thread=g,f._tree.mod+=k-j),e&&!$(h)&&(h._tree.thread=e,h._tree.mod+=i-l,d=a)}return d}function i(a,b){a.x=a._tree.prelim+b;var c=a.children;if(c){var d=-1,e=c.length;b+=a._tree.mod;while(++d<e)i(c[d],b)}}function h(a,c){var d=a.children,e=a._tree;if(d){var f=d.length,g=d[0],i,k=g,l,m=-1;while(++m<f)l=d[m],h(l,i),k=j(l,i,k),i=l;bf(a);var n=.5*(g._tree.prelim+l._tree.prelim);c?(e.prelim=c._tree.prelim+b(a,c),e.mod=e.prelim-n):e.prelim=n}else c&&(e.prelim=c._tree.prelim+b(a,c))}var f=a.call(this,d,e),g=f[0];be(g,function(a,b){a._tree={ancestor:a,prelim:0,mod:0,change:0,shift:0,number:b?b._tree.number+1:0}}),h(g),i(g,-g._tree.prelim);var k=ba(g,bc),l=ba(g,bb),m=ba(g,bd),n=k.x-b(k,l)/2,o=l.x+b(l,k)/2,p=m.depth||1;be(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=a.depth/p*c[1],delete a._tree});return f}var a=d3.layout.hierarchy().sort(null).value(null),b=Z,c=[1,1];d.separation=function(a){if(!arguments.length)return b;b=a;return d},d.size=function(a){if(!arguments.length)return c;c=a;return d};return F(d,a)},d3.layout.treemap=function(){function l(b){var f=e||a(b),j=f[0];j.x=0,j.y=0,j.dx=c[0],j.dy=c[1],e&&a.revalue(j),g(j,c[0]*c[1]/j.value),(e?i:h)(j),d&&(e=f);return f}function k(a,c,d,e){var f=-1,g=a.length,h=d.x,i=d.y,j=c?b(a.area/c):0,k;if(c==d.dx){if(e||j>d.dy)j=d.dy;while(++f<g)k=a[f],k.x=h,k.y=i,k.dy=j,h+=k.dx=b(k.area/j);k.z=!0,k.dx+=d.x+d.dx-h,d.y+=j,d.dy-=j}else{if(e||j>d.dx)j=d.dx;while(++f<g)k=a[f],k.x=h,k.y=i,k.dx=j,i+=k.dy=b(k.area/j);k.z=!1,k.dy+=d.y+d.dy-i,d.x+=j,d.dx-=j}}function j(a,b){var c=a.area,d,e=0,g=Infinity,h=-1,i=a.length;while(++h<i)d=a[h].area,d<g&&(g=d),d>e&&(e=d);c*=c,b*=b;return g||e?Math.max(b*e*f/c,c/(b*g*f)):Infinity}function i(a){if(!!a.children){var b={x:a.x,y:a.y,dx:a.dx,dy:a.dy},c=a.children.slice(),d,e=[];e.area=0;while(d=c.pop())e.push(d),e.area+=d.area,d.z!=null&&(k(e,d.z?b.dx:b.dy,b,!c.length),e.length=e.area=0);a.children.forEach(i)}}function h(a){if(!!a.children){var b={x:a.x,y:a.y,dx:a.dx,dy:a.dy},c=[],d=a.children.slice(),e,f=Infinity,g,i=Math.min(b.dx,b.dy),l;c.area=0;while((l=d.length)>0)c.push(e=d[l-1]),c.area+=e.area,(g=j(c,i))<=f?(d.pop(),f=g):(c.area-=c.pop().area,k(c,i,b,!1),i=Math.min(b.dx,b.dy),c.length=c.area=0,f=Infinity);c.length&&(k(c,i,b,!0),c.length=c.area=0),a.children.forEach(h)}}function g(a,b){var c=a.children,d=a.value;a.area=isNaN(d)||d<0?0:d*b;if(c){var e=-1,f=c.length;while(++e<f)g(c[e],b)}}var a=d3.layout.hierarchy(),b=Math.round,c=[1,1],d=!1,e,f=.5*(1+Math.sqrt(5));l.size=function(a){if(!arguments.length)return c;c=a;return l},l.round=function(a){if(!arguments.length)return b!=Number;b=a?Math.round:Number;return l},l.sticky=function(a){if(!arguments.length)return d;d=a,e=null;return l},l.ratio=function(a){if(!arguments.length)return f;f=a;return l};return F(l,a)}})() <ide>\ No newline at end of file <add>(function(){function bi(a){return[0,0,0,0]}function bh(a,b,c){return a._tree.ancestor.parent==b.parent?a._tree.ancestor:c}function bg(a,b,c){a=a._tree,b=b._tree;var d=c/(b.number-a.number);a.change+=d,b.change-=d,b.shift+=c,b.prelim+=c,b.mod+=c}function bf(a){var b=0,c=0,d=a.children,e=d.length,f;while(--e>=0)f=d[e]._tree,f.prelim+=b,f.mod+=b,b+=f.shift+(c+=f.change)}function be(a,b){function c(a,d){var e=a.children;if(e){var f,g=null,h=-1,i=e.length;while(++h<i)f=e[h],c(f,g),g=f}b(a,d)}c(a,null)}function bd(a,b){return a.depth-b.depth}function bc(a,b){return b.x-a.x}function bb(a,b){return a.x-b.x}function ba(a,b){var c=a.children;if(c){var d,e=c.length,f=-1;while(++f<e)b(d=ba(c[f],b),a)>0&&(a=d)}return a}function _(a){return a.children?a.children[a.children.length-1]:a._tree.thread}function $(a){return a.children?a.children[0]:a._tree.thread}function Z(a,b){return a.parent==b.parent?1:2}function Y(a){var b=a.children;return b?Y(b[b.length-1]):a}function X(a){var b=a.children;return b?X(b[0]):a}function W(a){return a.reduce(function(a,b){return a+b.x},0)/a.length}function V(a){return 1+d3.max(a,function(a){return a.y})}function U(a,b,c){var d=b.r+c.r,e=a.r+c.r,f=b.x-a.x,g=b.y-a.y,h=Math.sqrt(f*f+g*g),i=(e*e+h*h-d*d)/(2*e*h),j=Math.acos(i),k=i*e,l=Math.sin(j)*e;f/=h,g/=h,c.x=a.x+k*f+l*g,c.y=a.y+k*g-l*f}function T(a,b,c,d){var e=a.children;a.x=b+=d*a.x,a.y=c+=d*a.y,a.r*=d;if(e){var f=-1,g=e.length;while(++f<g)T(e[f],b,c,d)}}function S(a){var b=a.children;b?(b.forEach(S),a.r=P(b)):a.r=Math.sqrt(a.value)}function R(a){delete a._pack_next,delete a._pack_prev}function Q(a){a._pack_next=a._pack_prev=a}function P(a){function l(a){b=Math.min(a.x-a.r,b),c=Math.max(a.x+a.r,c),d=Math.min(a.y-a.r,d),e=Math.max(a.y+a.r,e)}var b=Infinity,c=-Infinity,d=Infinity,e=-Infinity,f=a.length,g,h,i,j,k;a.forEach(Q),g=a[0],g.x=-g.r,g.y=0,l(g);if(f>1){h=a[1],h.x=h.r,h.y=0,l(h);if(f>2){i=a[2],U(g,h,i),l(i),M(g,i),g._pack_prev=i,M(i,h),h=g._pack_next;for(var m=3;m<f;m++){U(g,h,i=a[m]);var n=0,o=1,p=1;for(j=h._pack_next;j!==h;j=j._pack_next,o++)if(O(j,i)){n=1;break}if(n==1)for(k=g._pack_prev;k!==j._pack_prev;k=k._pack_prev,p++)if(O(k,i)){p<o&&(n=-1,j=k);break}n==0?(M(g,i),h=i,l(i)):n>0?(N(g,j),h=j,m--):(N(j,h),g=j,m--)}}}var q=(b+c)/2,r=(d+e)/2,s=0;for(var m=0;m<f;m++){var t=a[m];t.x-=q,t.y-=r,s=Math.max(s,t.r+Math.sqrt(t.x*t.x+t.y*t.y))}a.forEach(R);return s}function O(a,b){var c=b.x-a.x,d=b.y-a.y,e=a.r+b.r;return e*e-c*c-d*d>.001}function N(a,b){a._pack_next=b,b._pack_prev=a}function M(a,b){var c=a._pack_next;a._pack_next=b,b._pack_prev=a,b._pack_next=c,c._pack_prev=b}function L(a,b){return a.value-b.value}function J(a){return d3.merge(a.map(function(a){return(a.children||[]).map(function(b){return{source:a,target:b}})}))}function I(a,b){return b.value-a.value}function H(a){return a.value}function G(a){return a.children}function F(a,b){a.sort=d3.rebind(a,b.sort),a.children=d3.rebind(a,b.children),a.links=J,a.value=d3.rebind(a,b.value),a.nodes=function(b){K=!0;return(a.nodes=a)(b)};return a}function E(a){return[d3.min(a),d3.max(a)]}function D(a,b){var c=-1,d=+a[0],e=(a[1]-d)/b,f=[];while(++c<=b)f[c]=e*c+d;return f}function C(a,b){return D(a,Math.ceil(Math.log(b.length)/Math.LN2+1))}function B(a,b){return a+b[1]}function A(a){return a.reduce(B,0)}function z(a){var b=1,c=0,d=a[0][1],e,f=a.length;for(;b<f;++b)(e=a[b][1])>d&&(c=b,d=e);return c}function w(a,b,c){a.y0=b,a.y=c}function v(a){return a.y}function u(a){return a.x}function t(a){return 1}function s(a){return 20}function r(a){var b=0,c=0;a.count=0;if(!a.leaf){var d=a.nodes,e=d.length,f=-1,g;while(++f<e){g=d[f];if(g==null)continue;r(g),a.count+=g.count,b+=g.count*g.cx,c+=g.count*g.cy}}a.point&&(a.leaf||(a.point.x+=Math.random()-.5,a.point.y+=Math.random()-.5),a.count++,b+=a.point.x,c+=a.point.y),a.cx=b/a.count,a.cy=c/a.count}function q(){d3.event.stopPropagation(),d3.event.preventDefault()}function p(){i&&(q(),i=!1)}function o(){!f||(g&&(i=!0,q()),d3.event.type==="mouseup"&&n(),f.fixed=!1,e=h=f=j=null)}function n(){if(!!f){var a=j.parentNode;if(!a){f.fixed=!1,h=f=j=null;return}var b=m(a);g=!0,f.px=b[0]-h[0],f.py=b[1]-h[1],q(),e.resume()}}function m(a){return d3.event.touches?d3.svg.touches(a)[0]:d3.svg.mouse(a)}function l(a){a!==f&&(a.fixed=!1)}function k(a){a.fixed=!0}function c(a,c){if(a===c)return a;var d=b(a),e=b(c),f=d.pop(),g=e.pop(),h=null;while(f===g)h=f,f=d.pop(),g=e.pop();return h}function b(a){var b=[],c=a.parent;while(c!=null)b.push(a),a=c,c=c.parent;b.push(a);return b}function a(a){var b=a.source,d=a.target,e=c(b,d),f=[b];while(b!==e)b=b.parent,f.push(b);var g=f.length;while(d!==e)f.splice(g,0,d),d=d.parent;return f}d3.layout={},d3.layout.bundle=function(){return function(b){var c=[],d=-1,e=b.length;while(++d<e)c.push(a(b[d]));return c}},d3.layout.chord=function(){function k(){b.sort(function(a,b){return i(a.target.value,b.target.value)})}function j(){var a={},j=[],l=d3.range(e),m=[],n,o,p,q,r;b=[],c=[],n=0,q=-1;while(++q<e){o=0,r=-1;while(++r<e)o+=d[q][r];j.push(o),m.push(d3.range(e)),n+=o}g&&l.sort(function(a,b){return g(j[a],j[b])}),h&&m.forEach(function(a,b){a.sort(function(a,c){return h(d[b][a],d[b][c])})}),n=(2*Math.PI-f*e)/n,o=0,q=-1;while(++q<e){p=o,r=-1;while(++r<e){var s=l[q],t=m[q][r],u=d[s][t];a[s+"-"+t]={index:s,subindex:t,startAngle:o,endAngle:o+=u*n,value:u}}c.push({index:s,startAngle:p,endAngle:o,value:(o-p)/n}),o+=f}q=-1;while(++q<e){r=q-1;while(++r<e){var v=a[q+"-"+r],w=a[r+"-"+q];(v.value||w.value)&&b.push(v.value<w.value?{source:w,target:v}:{source:v,target:w})}}i&&k()}var a={},b,c,d,e,f=0,g,h,i;a.matrix=function(f){if(!arguments.length)return d;e=(d=f)&&d.length,b=c=null;return a},a.padding=function(d){if(!arguments.length)return f;f=d,b=c=null;return a},a.sortGroups=function(d){if(!arguments.length)return g;g=d,b=c=null;return a},a.sortSubgroups=function(c){if(!arguments.length)return h;h=c,b=null;return a},a.sortChords=function(c){if(!arguments.length)return i;i=c,b&&k();return a},a.chords=function(){b||j();return b},a.groups=function(){c||j();return c};return a},d3.layout.force=function(){function G(b,c){var d=m(this.parentNode);(f=b).fixed=!0,g=!1,j=this,e=a,h=[d[0]-b.x,d[1]-b.y],q()}function F(){var a=A.length,e=B.length,f=d3.geom.quadtree(A),g,h,j,k,l,m,n;for(g=0;g<e;++g){h=B[g],j=h.source,k=h.target,m=k.x-j.x,n=k.y-j.y;if(l=m*m+n*n)l=d*D[g]*((l=Math.sqrt(l))-C[g])/l,m*=l,n*=l,k.x-=m,k.y-=n,j.x+=m,j.y+=n}var o=d*x;m=c[0]/2,n=c[1]/2,g=-1;while(++g<a)h=A[g],h.x+=(m-h.x)*o,h.y+=(n-h.y)*o;r(f);var p=d*w;g=-1;while(++g<a)f.visit(E(A[g],p));g=-1;while(++g<a)h=A[g],h.fixed?(h.x=h.px,h.y=h.py):(h.x-=(h.px-(h.px=h.x))*i,h.y-=(h.py-(h.py=h.y))*i);b.tick.dispatch({type:"tick",alpha:d});return(d*=.99)<.005}function E(a,b){return function(c,d,e,f,g){if(c.point!==a){var h=c.cx-a.x,i=c.cy-a.y,j=1/Math.sqrt(h*h+i*i);if((f-d)*j<y){var k=b*c.count*j*j;a.x+=h*k,a.y+=i*k;return!0}if(c.point&&isFinite(j)){var k=b*j*j;a.x+=h*k,a.y+=i*k}}}}var a={},b=d3.dispatch("tick"),c=[1,1],d,i=.9,u=s,v=t,w=-30,x=.1,y=.8,z,A=[],B=[],C,D;a.on=function(c,d){b[c].add(d);return a},a.nodes=function(b){if(!arguments.length)return A;A=b;return a},a.links=function(b){if(!arguments.length)return B;B=b;return a},a.size=function(b){if(!arguments.length)return c;c=b;return a},a.linkDistance=function(b){if(!arguments.length)return u;u=d3.functor(b);return a},a.distance=a.linkDistance,a.linkStrength=function(b){if(!arguments.length)return v;v=d3.functor(b);return a},a.friction=function(b){if(!arguments.length)return i;i=b;return a},a.charge=function(b){if(!arguments.length)return w;w=b;return a},a.gravity=function(b){if(!arguments.length)return x;x=b;return a},a.theta=function(b){if(!arguments.length)return y;y=b;return a},a.start=function(){function l(){if(!i){i=[];for(d=0;d<e;++d)i[d]=[];for(d=0;d<f;++d){var a=B[d];i[a.source.index].push(a.target),i[a.target.index].push(a.source)}}return i[b]}function k(a,c){var d=l(b),e=-1,f=d.length,g;while(++e<f)if(!isNaN(g=d[e][a]))return g;return Math.random()*c}var b,d,e=A.length,f=B.length,g=c[0],h=c[1],i,j;for(b=0;b<e;++b)(j=A[b]).index=b;C=[],D=[];for(b=0;b<f;++b)j=B[b],typeof j.source=="number"&&(j.source=A[j.source]),typeof j.target=="number"&&(j.target=A[j.target]),C[b]=u.call(this,j,b),D[b]=v.call(this,j,b);for(b=0;b<e;++b)j=A[b],isNaN(j.x)&&(j.x=k("x",g)),isNaN(j.y)&&(j.y=k("y",h)),isNaN(j.px)&&(j.px=j.x),isNaN(j.py)&&(j.py=j.y);return a.resume()},a.resume=function(){d=.1,d3.timer(F);return a},a.stop=function(){d=0;return a},a.drag=function(){this.on("mouseover.force",k).on("mouseout.force",l).on("mousedown.force",G).on("touchstart.force",G),d3.select(window).on("mousemove.force",n).on("touchmove.force",n).on("mouseup.force",o,!0).on("touchend.force",o,!0).on("click.force",p,!0);return a};return a};var e,f,g,h,i,j;d3.layout.partition=function(){function e(e,f){var g=a.call(this,e,f);c(g[0],0,b[0],b[1]/d(g[0]));return g}function d(a){var b=a.children,c=0;if(b){var e=-1,f=b.length;while(++e<f)c=Math.max(c,d(b[e]))}return 1+c}function c(a,b,d,e){var f=a.children;a.x=b,a.y=a.depth*e,a.dx=d,a.dy=e;if(f){var g=-1,h=f.length,i,j;d/=a.value;while(++g<h)c(i=f[g],b,j=i.value*d,e),b+=j}}var a=d3.layout.hierarchy(),b=[1,1];e.size=function(a){if(!arguments.length)return b;b=a;return e};return F(e,a)},d3.layout.pie=function(){function f(f,g){var h=+(typeof c=="function"?c.apply(this,arguments):c),i=(typeof e=="function"?e.apply(this,arguments):e)-c,j=d3.range(f.length);b!=null&&j.sort(function(a,c){return b(f[a],f[c])});var k=f.map(a);i/=k.reduce(function(a,b){return a+b},0);var l=j.map(function(a){return{data:f[a],value:d=k[a],startAngle:h,endAngle:h+=d*i}});return f.map(function(a,b){return l[j[b]]})}var a=Number,b=null,c=0,e=2*Math.PI;f.value=function(b){if(!arguments.length)return a;a=b;return f},f.sort=function(a){if(!arguments.length)return b;b=a;return f},f.startAngle=function(a){if(!arguments.length)return c;c=a;return f},f.endAngle=function(a){if(!arguments.length)return e;e=a;return f};return f},d3.layout.stack=function(){function g(h,i){var j=h.map(function(b,c){return a.call(g,b,c)}),k=j.map(function(a,b){return a.map(function(a,b){return[e.call(g,a,b),f.call(g,a,b)]})}),l=b.call(g,k,i);j=d3.permute(j,l),k=d3.permute(k,l);var m=c.call(g,k,i),n=j.length,o=j[0].length,p,q,r;for(q=0;q<o;++q){d.call(g,j[0][q],r=m[q],k[0][q][1]);for(p=1;p<n;++p)d.call(g,j[p][q],r+=k[p-1][q][1],k[p][q][1])}return h}var a=Object,b=x["default"],c=y.zero,d=w,e=u,f=v;g.values=function(b){if(!arguments.length)return a;a=b;return g},g.order=function(a){if(!arguments.length)return b;b=typeof a=="function"?a:x[a];return g},g.offset=function(a){if(!arguments.length)return c;c=typeof a=="function"?a:y[a];return g},g.x=function(a){if(!arguments.length)return e;e=a;return g},g.y=function(a){if(!arguments.length)return f;f=a;return g},g.out=function(a){if(!arguments.length)return d;d=a;return g};return g};var x={"inside-out":function(a){var b=a.length,c,d,e=a.map(z),f=a.map(A),g=d3.range(b).sort(function(a,b){return e[a]-e[b]}),h=0,i=0,j=[],k=[];for(c=0;c<b;++c)d=g[c],h<i?(h+=f[d],j.push(d)):(i+=f[d],k.push(d));return k.reverse().concat(j)},reverse:function(a){return d3.range(a.length).reverse()},"default":function(a){return d3.range(a.length)}},y={silhouette:function(a){var b=a.length,c=a[0].length,d=[],e=0,f,g,h,i=[];for(g=0;g<c;++g){for(f=0,h=0;f<b;f++)h+=a[f][g][1];h>e&&(e=h),d.push(h)}for(g=0;g<c;++g)i[g]=(e-d[g])/2;return i},wiggle:function(a){var b=a.length,c=a[0],d=c.length,e=0,f,g,h,i,j,k,l,m,n,o=[];o[0]=m=n=0;for(g=1;g<d;++g){for(f=0,i=0;f<b;++f)i+=a[f][g][1];for(f=0,j=0,l=c[g][0]-c[g-1][0];f<b;++f){for(h=0,k=(a[f][g][1]-a[f][g-1][1])/(2*l);h<f;++h)k+=(a[h][g][1]-a[h][g-1][1])/l;j+=k*a[f][g][1]}o[g]=m-=i?j/i*l:0,m<n&&(n=m)}for(g=0;g<d;++g)o[g]-=n;return o},expand:function(a){var b=a.length,c=a[0].length,d=1/b,e,f,g,h=[];for(f=0;f<c;++f){for(e=0,g=0;e<b;e++)g+=a[e][f][1];if(g)for(e=0;e<b;e++)a[e][f][1]/=g;else for(e=0;e<b;e++)a[e][f][1]=d}for(f=0;f<c;++f)h[f]=0;return h},zero:function(a){var b=-1,c=a[0].length,d=[];while(++b<c)d[b]=0;return d}};d3.layout.histogram=function(){function e(e,f){var g=[],h=e.map(b,this),i=c.call(this,h,f),j=d.call(this,i,h,f),k,f=-1,l=h.length,m=j.length-1,n=a?1/l:1,o;while(++f<m)k=g[f]=[],k.dx=j[f+1]-(k.x=j[f]),k.y=0;f=-1;while(++f<l)o=h[f],o>=i[0]&&o<=i[1]&&(k=g[d3.bisect(j,o,1,m)-1],k.y+=n,k.push(e[f]));return g}var a=!0,b=Number,c=E,d=C;e.value=function(a){if(!arguments.length)return b;b=a;return e},e.range=function(a){if(!arguments.length)return c;c=d3.functor(a);return e},e.bins=function(a){if(!arguments.length)return d;d=typeof a=="number"?function(b){return D(b,a)}:d3.functor(a);return e},e.frequency=function(b){if(!arguments.length)return a;a=!!b;return e};return e},d3.layout.hierarchy=function(){function g(a){var b=[];e(a,0,b);return b}function f(a,b){var d=a.children,e=0;if(d){var h=-1,i=d.length,j=b+1;while(++h<i)e+=f(d[h],j)}else c&&(e=c.call(g,K?a:a.data,b));c&&(a.value=e);return e}function e(f,h,i){var j=b.call(g,f,h),k=K?f:{data:f};k.depth=h,i.push(k);if(j){var l=-1,m=j.length,n=k.children=[],o=0,p=h+1;while(++l<m)d=e(j[l],p,i),d.parent=k,n.push(d),o+=d.value;a&&n.sort(a),c&&(k.value=o)}else c&&(k.value=c.call(g,f,h));return k}var a=I,b=G,c=H;g.sort=function(b){if(!arguments.length)return a;a=b;return g},g.children=function(a){if(!arguments.length)return b;b=a;return g},g.value=function(a){if(!arguments.length)return c;c=a;return g},g.revalue=function(a){f(a,0);return a};return g};var K=!1;d3.layout.pack=function(){function c(c,d){var e=a.call(this,c,d),f=e[0];f.x=0,f.y=0,S(f);var g=b[0],h=b[1],i=1/Math.max(2*f.r/g,2*f.r/h);T(f,g/2,h/2,i);return e}var a=d3.layout.hierarchy().sort(L),b=[1,1];c.size=function(a){if(!arguments.length)return b;b=a;return c};return F(c,a)},d3.layout.cluster=function(){function d(d,e){var f=a.call(this,d,e),g=f[0],h,i=0,j,k;be(g,function(a){a.children?(a.x=W(a.children),a.y=V(a.children)):(a.x=h?i+=b(a,h):0,a.y=0,h=a)});var l=X(g),m=Y(g),n=l.x-b(l,m)/2,o=m.x+b(m,l)/2;be(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=(1-a.y/g.y)*c[1]});return f}var a=d3.layout.hierarchy().sort(null).value(null),b=Z,c=[1,1];d.separation=function(a){if(!arguments.length)return b;b=a;return d},d.size=function(a){if(!arguments.length)return c;c=a;return d};return F(d,a)},d3.layout.tree=function(){function d(d,e){function j(a,c,d){if(c){var e=a,f=a,g=c,h=a.parent.children[0],i=e._tree.mod,j=f._tree.mod,k=g._tree.mod,l=h._tree.mod,m;while(g=_(g),e=$(e),g&&e)h=$(h),f=_(f),f._tree.ancestor=a,m=g._tree.prelim+k-e._tree.prelim-i+b(g,e),m>0&&(bg(bh(g,a,d),a,m),i+=m,j+=m),k+=g._tree.mod,i+=e._tree.mod,l+=h._tree.mod,j+=f._tree.mod;g&&!_(f)&&(f._tree.thread=g,f._tree.mod+=k-j),e&&!$(h)&&(h._tree.thread=e,h._tree.mod+=i-l,d=a)}return d}function i(a,b){a.x=a._tree.prelim+b;var c=a.children;if(c){var d=-1,e=c.length;b+=a._tree.mod;while(++d<e)i(c[d],b)}}function h(a,c){var d=a.children,e=a._tree;if(d){var f=d.length,g=d[0],i,k=g,l,m=-1;while(++m<f)l=d[m],h(l,i),k=j(l,i,k),i=l;bf(a);var n=.5*(g._tree.prelim+l._tree.prelim);c?(e.prelim=c._tree.prelim+b(a,c),e.mod=e.prelim-n):e.prelim=n}else c&&(e.prelim=c._tree.prelim+b(a,c))}var f=a.call(this,d,e),g=f[0];be(g,function(a,b){a._tree={ancestor:a,prelim:0,mod:0,change:0,shift:0,number:b?b._tree.number+1:0}}),h(g),i(g,-g._tree.prelim);var k=ba(g,bc),l=ba(g,bb),m=ba(g,bd),n=k.x-b(k,l)/2,o=l.x+b(l,k)/2,p=m.depth||1;be(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=a.depth/p*c[1],delete a._tree});return f}var a=d3.layout.hierarchy().sort(null).value(null),b=Z,c=[1,1];d.separation=function(a){if(!arguments.length)return b;b=a;return d},d.size=function(a){if(!arguments.length)return c;c=a;return d};return F(d,a)},d3.layout.treemap=function(){function n(b){var g=f||a(b),i=g[0],l=d.call(this,i);i.x=l[3],i.y=l[0],i.dx=c[0]-l[3]-l[1],i.dy=c[1]-l[0]-l[2],f&&a.revalue(i),h(g,i.dx*i.dy/i.value),(f?k:j)(i),e&&(f=g);return g}function m(a,c,d,e){var f=-1,g=a.length,h=d.x,i=d.y,j=c?b(a.area/c):0,k;if(c==d.dx){if(e||j>d.dy)j=d.dy;while(++f<g)k=a[f],k.x=h,k.y=i,k.dy=j,h+=k.dx=b(k.area/j);k.z=!0,k.dx+=d.x+d.dx-h,d.y+=j,d.dy-=j}else{if(e||j>d.dx)j=d.dx;while(++f<g)k=a[f],k.x=h,k.y=i,k.dx=j,i+=k.dy=b(k.area/j);k.z=!1,k.dy+=d.y+d.dy-i,d.x+=j,d.dx-=j}}function l(a,b){var c=a.area,d,e=0,f=Infinity,h=-1,i=a.length;while(++h<i)d=a[h].area,d<f&&(f=d),d>e&&(e=d);c*=c,b*=b;return f||e?Math.max(b*e*g/c,c/(b*f*g)):Infinity}function k(a){if(!!a.children){var b=i(a),c=a.children.slice(),d,e=[];h(c,b.dx*b.dy/a.value),e.area=0;while(d=c.pop())e.push(d),e.area+=d.area,d.z!=null&&(m(e,d.z?b.dx:b.dy,b,!c.length),e.length=e.area=0);a.children.forEach(k)}}function j(a){if(!!a.children){var b=i(a),c=[],d=a.children.slice(),e,f=Infinity,g,k=Math.min(b.dx,b.dy),n;h(d,b.dx*b.dy/a.value),c.area=0;while((n=d.length)>0)c.push(e=d[n-1]),c.area+=e.area,(g=l(c,k))<=f?(d.pop(),f=g):(c.area-=c.pop().area,m(c,k,b,!1),k=Math.min(b.dx,b.dy),c.length=c.area=0,f=Infinity);c.length&&(m(c,k,b,!0),c.length=c.area=0),a.children.forEach(j)}}function i(a){var b=d.call(this,a);return{x:a.x+b[3],y:a.y+b[0],dx:a.dx-b[1]-b[3],dy:a.dy-b[0]-b[2]}}function h(a,b){var c=-1,d=a.length,e,f;while(++c<d)f=(e=a[c]).value,e.area=isNaN(f)||f<0?0:f*b}var a=d3.layout.hierarchy(),b=Math.round,c=[1,1],d=bi,e=!1,f,g=.5*(1+Math.sqrt(5));n.size=function(a){if(!arguments.length)return c;c=a;return n},n.padding=function(a){if(!arguments.length)return d;d=d3.functor(a);return n},n.round=function(a){if(!arguments.length)return b!=Number;b=a?Math.round:Number;return n},n.sticky=function(a){if(!arguments.length)return e;e=a,f=null;return n},n.ratio=function(a){if(!arguments.length)return g;g=a;return n};return F(n,a)}})() <ide>\ No newline at end of file <ide><path>examples/treemap/treemap.js <ide> var w = 960, <ide> var treemap = d3.layout.treemap() <ide> .size([w, h]) <ide> .sticky(true) <add> .padding([5, 5, 5, 5]) <ide> .value(function(d) { return d.size; }); <ide> <ide> var div = d3.select("#chart").append("div") <ide><path>src/layout/treemap.js <ide> d3.layout.treemap = function() { <ide> var hierarchy = d3.layout.hierarchy(), <ide> round = Math.round, <ide> size = [1, 1], // width, height <add> padding = d3_layout_treemapPadding, // top, right, bottom, left <ide> sticky = false, <ide> stickies, <ide> ratio = 0.5 * (1 + Math.sqrt(5)); // golden ratio <ide> <del> // Recursively compute the node area based on value & scale. <del> function scale(node, k) { <del> var children = node.children, <del> value = node.value; <del> node.area = isNaN(value) || value < 0 ? 0 : value * k; <del> if (children) { <del> var i = -1, <del> n = children.length; <del> while (++i < n) scale(children[i], k); <add> // Compute the area for each child based on value & scale. <add> function scale(children, k) { <add> var i = -1, <add> n = children.length, <add> child, <add> value; <add> while (++i < n) { <add> value = (child = children[i]).value; <add> child.area = isNaN(value) || value < 0 ? 0 : value * k; <ide> } <ide> } <ide> <add> // Computes the rectangle for a particular node. <add> function nodeRect(node) { <add> var p = padding.call(this, node); <add> return { <add> x: node.x + p[3], <add> y: node.y + p[0], <add> dx: node.dx - p[1] - p[3], <add> dy: node.dy - p[0] - p[2] <add> }; <add> } <add> <ide> // Recursively arranges the specified node's children into squarified rows. <ide> function squarify(node) { <ide> if (!node.children) return; <del> var rect = {x: node.x, y: node.y, dx: node.dx, dy: node.dy}, <add> var rect = nodeRect(node), <ide> row = [], <ide> children = node.children.slice(), // copy-on-write <ide> child, <ide> best = Infinity, // the best row score so far <ide> score, // the current row score <ide> u = Math.min(rect.dx, rect.dy), // initial orientation <ide> n; <add> scale(children, rect.dx * rect.dy / node.value); <ide> row.area = 0; <ide> while ((n = children.length) > 0) { <ide> row.push(child = children[n - 1]); <ide> d3.layout.treemap = function() { <ide> // Preserves the existing layout! <ide> function stickify(node) { <ide> if (!node.children) return; <del> var rect = {x: node.x, y: node.y, dx: node.dx, dy: node.dy}, <add> var rect = nodeRect(node), <ide> children = node.children.slice(), // copy-on-write <ide> child, <ide> row = []; <add> scale(children, rect.dx * rect.dy / node.value); <ide> row.area = 0; <ide> while (child = children.pop()) { <ide> row.push(child); <ide> d3.layout.treemap = function() { <ide> <ide> function treemap(d) { <ide> var nodes = stickies || hierarchy(d), <del> root = nodes[0]; <del> root.x = 0; <del> root.y = 0; <del> root.dx = size[0]; <del> root.dy = size[1]; <add> root = nodes[0], <add> p = padding.call(this, root); <add> root.x = p[3]; <add> root.y = p[0]; <add> root.dx = size[0] - p[3] - p[1]; <add> root.dy = size[1] - p[0] - p[2]; <ide> if (stickies) hierarchy.revalue(root); <del> scale(root, size[0] * size[1] / root.value); <add> scale(nodes, root.dx * root.dy / root.value); <ide> (stickies ? stickify : squarify)(root); <ide> if (sticky) stickies = nodes; <ide> return nodes; <ide> d3.layout.treemap = function() { <ide> return treemap; <ide> }; <ide> <add> treemap.padding = function(x) { <add> if (!arguments.length) return padding; <add> padding = d3.functor(x); <add> return treemap; <add> }; <add> <ide> treemap.round = function(x) { <ide> if (!arguments.length) return round != Number; <ide> round = x ? Math.round : Number; <ide> d3.layout.treemap = function() { <ide> <ide> return d3_layout_hierarchyRebind(treemap, hierarchy); <ide> }; <add> <add>function d3_layout_treemapPadding(node) { <add> return [0, 0, 0, 0]; <add>}
4
Python
Python
fix screenshot generation for dumb terminal
70065e656950a5948351164bb8f1c5454ed5b7f7
<ide><path>scripts/ci/pre_commit/pre_commit_breeze_cmd_line.py <ide> def print_help_for_all_commands(): <ide> env['RECORD_BREEZE_WIDTH'] = SCREENSHOT_WIDTH <ide> env['RECORD_BREEZE_TITLE'] = "Breeze commands" <ide> env['RECORD_BREEZE_OUTPUT_FILE'] = str(BREEZE_IMAGES_DIR / "output-commands.svg") <add> env['TERM'] = "xterm-256color" <ide> check_call(["breeze", "--help"], env=env) <ide> for command in get_command_list(): <ide> env = os.environ.copy() <ide> env['RECORD_BREEZE_WIDTH'] = SCREENSHOT_WIDTH <ide> env['RECORD_BREEZE_TITLE'] = f"Command: {command}" <ide> env['RECORD_BREEZE_OUTPUT_FILE'] = str(BREEZE_IMAGES_DIR / f"output-{command}.svg") <add> env['TERM'] = "xterm-256color" <ide> check_call(["breeze", command, "--help"], env=env) <ide> <ide>
1
Javascript
Javascript
fix a bug in circle-packing layout
f21d6b826bfdf74cfe43636e9755e66e0569759a
<ide><path>d3.layout.js <ide> function d3_layout_packIntersects(a, b) { <ide> var dx = b.x - a.x, <ide> dy = b.y - a.y, <ide> dr = a.r + b.r; <del> return (dr * dr - dx * dx - dy * dy) > .001; // within epsilon <add> return dr * dr - dx * dx - dy * dy > .001; // within epsilon <ide> } <ide> <ide> function d3_layout_packCircle(nodes) { <ide> function d3_layout_packCircle(nodes) { <ide> if (isect == 1) { <ide> for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) { <ide> if (d3_layout_packIntersects(k, c)) { <del> if (s2 < s1) { <del> isect = -1; <del> j = k; <del> } <ide> break; <ide> } <ide> } <ide> } <ide> <ide> // Update node chain. <del> if (isect == 0) { <add> if (isect) { <add> if (s1 < s2 || (s1 == s2 && b.r < a.r)) d3_layout_packSplice(a, b = j); <add> else d3_layout_packSplice(a = k, b); <add> i--; <add> } else { <ide> d3_layout_packInsert(a, c); <ide> b = c; <ide> bound(c); <del> } else if (isect > 0) { <del> d3_layout_packSplice(a, j); <del> b = j; <del> i--; <del> } else { // isect < 0 <del> d3_layout_packSplice(j, b); <del> a = j; <del> i--; <ide> } <ide> } <ide> } <ide><path>d3.layout.min.js <del>(function(){function a(a){var b=a.source,d=a.target,e=c(b,d),f=[b];while(b!==e)b=b.parent,f.push(b);var g=f.length;while(d!==e)f.splice(g,0,d),d=d.parent;return f}function b(a){var b=[],c=a.parent;while(c!=null)b.push(a),a=c,c=c.parent;return b.push(a),b}function c(a,c){if(a===c)return a;var d=b(a),e=b(c),f=d.pop(),g=e.pop(),h=null;while(f===g)h=f,f=d.pop(),g=e.pop();return h}function g(a){a.fixed|=2}function h(a){a!==f&&(a.fixed&=1)}function i(){j(),f.fixed&=1,e=f=null}function j(){f.px=d3.event.x,f.py=d3.event.y,e.resume()}function k(a,b,c){var d=0,e=0;a.charge=0;if(!a.leaf){var f=a.nodes,g=f.length,h=-1,i;while(++h<g){i=f[h];if(i==null)continue;k(i,b,c),a.charge+=i.charge,d+=i.charge*i.cx,e+=i.charge*i.cy}}if(a.point){a.leaf||(a.point.x+=Math.random()-.5,a.point.y+=Math.random()-.5);var j=b*c[a.point.index];a.charge+=a.pointCharge=j,d+=j*a.point.x,e+=j*a.point.y}a.cx=d/a.charge,a.cy=e/a.charge}function l(a){return 20}function m(a){return 1}function o(a){return a.x}function p(a){return a.y}function q(a,b,c){a.y0=b,a.y=c}function t(a){var b=1,c=0,d=a[0][1],e,f=a.length;for(;b<f;++b)(e=a[b][1])>d&&(c=b,d=e);return c}function u(a){return a.reduce(v,0)}function v(a,b){return a+b[1]}function w(a,b){return x(a,Math.ceil(Math.log(b.length)/Math.LN2+1))}function x(a,b){var c=-1,d=+a[0],e=(a[1]-d)/b,f=[];while(++c<=b)f[c]=e*c+d;return f}function y(a){return[d3.min(a),d3.max(a)]}function z(a,b){return d3.rebind(a,b,"sort","children","value"),a.links=D,a.nodes=function(b){return E=!0,(a.nodes=a)(b)},a}function A(a){return a.children}function B(a){return a.value}function C(a,b){return b.value-a.value}function D(a){return d3.merge(a.map(function(a){return(a.children||[]).map(function(b){return{source:a,target:b}})}))}function F(a,b){return a.value-b.value}function G(a,b){var c=a._pack_next;a._pack_next=b,b._pack_prev=a,b._pack_next=c,c._pack_prev=b}function H(a,b){a._pack_next=b,b._pack_prev=a}function I(a,b){var c=b.x-a.x,d=b.y-a.y,e=a.r+b.r;return e*e-c*c-d*d>.001}function J(a){function l(a){b=Math.min(a.x-a.r,b),c=Math.max(a.x+a.r,c),d=Math.min(a.y-a.r,d),e=Math.max(a.y+a.r,e)}var b=Infinity,c=-Infinity,d=Infinity,e=-Infinity,f=a.length,g,h,i,j,k;a.forEach(K),g=a[0],g.x=-g.r,g.y=0,l(g);if(f>1){h=a[1],h.x=h.r,h.y=0,l(h);if(f>2){i=a[2],O(g,h,i),l(i),G(g,i),g._pack_prev=i,G(i,h),h=g._pack_next;for(var m=3;m<f;m++){O(g,h,i=a[m]);var n=0,o=1,p=1;for(j=h._pack_next;j!==h;j=j._pack_next,o++)if(I(j,i)){n=1;break}if(n==1)for(k=g._pack_prev;k!==j._pack_prev;k=k._pack_prev,p++)if(I(k,i)){p<o&&(n=-1,j=k);break}n==0?(G(g,i),h=i,l(i)):n>0?(H(g,j),h=j,m--):(H(j,h),g=j,m--)}}}var q=(b+c)/2,r=(d+e)/2,s=0;for(var m=0;m<f;m++){var t=a[m];t.x-=q,t.y-=r,s=Math.max(s,t.r+Math.sqrt(t.x*t.x+t.y*t.y))}return a.forEach(L),s}function K(a){a._pack_next=a._pack_prev=a}function L(a){delete a._pack_next,delete a._pack_prev}function M(a){var b=a.children;b&&b.length?(b.forEach(M),a.r=J(b)):a.r=Math.sqrt(a.value)}function N(a,b,c,d){var e=a.children;a.x=b+=d*a.x,a.y=c+=d*a.y,a.r*=d;if(e){var f=-1,g=e.length;while(++f<g)N(e[f],b,c,d)}}function O(a,b,c){var d=a.r+c.r,e=b.x-a.x,f=b.y-a.y;if(d&&(e||f)){var g=b.r+c.r,h=Math.sqrt(e*e+f*f),i=Math.max(-1,Math.min(1,(d*d+h*h-g*g)/(2*d*h))),j=Math.acos(i),k=i*(d/=h),l=Math.sin(j)*d;c.x=a.x+k*e+l*f,c.y=a.y+k*f-l*e}else c.x=a.x+d,c.y=a.y}function P(a){return 1+d3.max(a,function(a){return a.y})}function Q(a){return a.reduce(function(a,b){return a+b.x},0)/a.length}function R(a){var b=a.children;return b&&b.length?R(b[0]):a}function S(a){var b=a.children,c;return b&&(c=b.length)?S(b[c-1]):a}function T(a,b){return a.parent==b.parent?1:2}function U(a){var b=a.children;return b&&b.length?b[0]:a._tree.thread}function V(a){var b=a.children,c;return b&&(c=b.length)?b[c-1]:a._tree.thread}function W(a,b){var c=a.children;if(c&&(e=c.length)){var d,e,f=-1;while(++f<e)b(d=W(c[f],b),a)>0&&(a=d)}return a}function X(a,b){return a.x-b.x}function Y(a,b){return b.x-a.x}function Z(a,b){return a.depth-b.depth}function $(a,b){function c(a,d){var e=a.children;if(e&&(i=e.length)){var f,g=null,h=-1,i;while(++h<i)f=e[h],c(f,g),g=f}b(a,d)}c(a,null)}function _(a){var b=0,c=0,d=a.children,e=d.length,f;while(--e>=0)f=d[e]._tree,f.prelim+=b,f.mod+=b,b+=f.shift+(c+=f.change)}function ba(a,b,c){a=a._tree,b=b._tree;var d=c/(b.number-a.number);a.change+=d,b.change-=d,b.shift+=c,b.prelim+=c,b.mod+=c}function bb(a,b,c){return a._tree.ancestor.parent==b.parent?a._tree.ancestor:c}function bc(a){return{x:a.x,y:a.y,dx:a.dx,dy:a.dy}}function bd(a,b){var c=a.x+b[3],d=a.y+b[0],e=a.dx-b[1]-b[3],f=a.dy-b[0]-b[2];return e<0&&(c+=e/2,e=0),f<0&&(d+=f/2,f=0),{x:c,y:d,dx:e,dy:f}}d3.layout={},d3.layout.bundle=function(){return function(b){var c=[],d=-1,e=b.length;while(++d<e)c.push(a(b[d]));return c}},d3.layout.chord=function(){function j(){var a={},j=[],l=d3.range(e),m=[],n,o,p,q,r;b=[],c=[],n=0,q=-1;while(++q<e){o=0,r=-1;while(++r<e)o+=d[q][r];j.push(o),m.push(d3.range(e)),n+=o}g&&l.sort(function(a,b){return g(j[a],j[b])}),h&&m.forEach(function(a,b){a.sort(function(a,c){return h(d[b][a],d[b][c])})}),n=(2*Math.PI-f*e)/n,o=0,q=-1;while(++q<e){p=o,r=-1;while(++r<e){var s=l[q],t=m[s][r],u=d[s][t],v=o,w=o+=u*n;a[s+"-"+t]={index:s,subindex:t,startAngle:v,endAngle:w,value:u}}c.push({index:s,startAngle:p,endAngle:o,value:(o-p)/n}),o+=f}q=-1;while(++q<e){r=q-1;while(++r<e){var x=a[q+"-"+r],y=a[r+"-"+q];(x.value||y.value)&&b.push(x.value<y.value?{source:y,target:x}:{source:x,target:y})}}i&&k()}function k(){b.sort(function(a,b){return i((a.source.value+a.target.value)/2,(b.source.value+b.target.value)/2)})}var a={},b,c,d,e,f=0,g,h,i;return a.matrix=function(f){return arguments.length?(e=(d=f)&&d.length,b=c=null,a):d},a.padding=function(d){return arguments.length?(f=d,b=c=null,a):f},a.sortGroups=function(d){return arguments.length?(g=d,b=c=null,a):g},a.sortSubgroups=function(c){return arguments.length?(h=c,b=null,a):h},a.sortChords=function(c){return arguments.length?(i=c,b&&k(),a):i},a.chords=function(){return b||j(),b},a.groups=function(){return c||j(),c},a},d3.layout.force=function(){function A(a){return function(b,c,d,e,f){if(b.point!==a){var g=b.cx-a.x,h=b.cy-a.y,i=1/Math.sqrt(g*g+h*h);if((e-c)*i<t){var j=b.charge*i*i;return a.px-=g*j,a.py-=h*j,!0}if(b.point&&isFinite(i)){var j=b.pointCharge*i*i;a.px-=g*j,a.py-=h*j}}return!b.charge}}function B(){var a=v.length,d=w.length,e,f,g,h,i,j,l,m,p;for(f=0;f<d;++f){g=w[f],h=g.source,i=g.target,m=i.x-h.x,p=i.y-h.y;if(j=m*m+p*p)j=n*y[f]*((j=Math.sqrt(j))-x[f])/j,m*=j,p*=j,i.x-=m*(l=h.weight/(i.weight+h.weight)),i.y-=p*l,h.x+=m*(l=1-l),h.y+=p*l}if(l=n*s){m=c[0]/2,p=c[1]/2,f=-1;if(l)while(++f<a)g=v[f],g.x+=(m-g.x)*l,g.y+=(p-g.y)*l}if(r){k(e=d3.geom.quadtree(v),n,z),f=-1;while(++f<a)(g=v[f]).fixed||e.visit(A(g))}f=-1;while(++f<a)g=v[f],g.fixed?(g.x=g.px,g.y=g.py):(g.x-=(g.px-(g.px=g.x))*o,g.y-=(g.py-(g.py=g.y))*o);return b.tick({type:"tick",alpha:n}),(n*=.99)<.005}function C(b){g(f=b),e=a}var a={},b=d3.dispatch("tick"),c=[1,1],d,n,o=.9,p=l,q=m,r=-30,s=.1,t=.8,u,v=[],w=[],x,y,z;return a.nodes=function(b){return arguments.length?(v=b,a):v},a.links=function(b){return arguments.length?(w=b,a):w},a.size=function(b){return arguments.length?(c=b,a):c},a.linkDistance=function(b){return arguments.length?(p=d3.functor(b),a):p},a.distance=a.linkDistance,a.linkStrength=function(b){return arguments.length?(q=d3.functor(b),a):q},a.friction=function(b){return arguments.length?(o=b,a):o},a.charge=function(b){return arguments.length?(r=typeof b=="function"?b:+b,a):r},a.gravity=function(b){return arguments.length?(s=b,a):s},a.theta=function(b){return arguments.length?(t=b,a):t},a.start=function(){function k(a,c){var d=l(b),e=-1,f=d.length,g;while(++e<f)if(!isNaN(g=d[e][a]))return g;return Math.random()*c}function l(){if(!i){i=[];for(d=0;d<e;++d)i[d]=[];for(d=0;d<f;++d){var a=w[d];i[a.source.index].push(a.target),i[a.target.index].push(a.source)}}return i[b]}var b,d,e=v.length,f=w.length,g=c[0],h=c[1],i,j;for(b=0;b<e;++b)(j=v[b]).index=b,j.weight=0;x=[],y=[];for(b=0;b<f;++b)j=w[b],typeof j.source=="number"&&(j.source=v[j.source]),typeof j.target=="number"&&(j.target=v[j.target]),x[b]=p.call(this,j,b),y[b]=q.call(this,j,b),++j.source.weight,++j.target.weight;for(b=0;b<e;++b)j=v[b],isNaN(j.x)&&(j.x=k("x",g)),isNaN(j.y)&&(j.y=k("y",h)),isNaN(j.px)&&(j.px=j.x),isNaN(j.py)&&(j.py=j.y);z=[];if(typeof r=="function")for(b=0;b<e;++b)z[b]=+r.call(this,v[b],b);else for(b=0;b<e;++b)z[b]=r;return a.resume()},a.resume=function(){return n=.1,d3.timer(B),a},a.stop=function(){return n=0,a},a.drag=function(){d||(d=d3.behavior.drag().origin(Object).on("dragstart",C).on("drag",j).on("dragend",i)),this.on("mouseover.force",g).on("mouseout.force",h).call(d)},d3.rebind(a,b,"on")};var e,f;d3.layout.partition=function(){function c(a,b,d,e){var f=a.children;a.x=b,a.y=a.depth*e,a.dx=d,a.dy=e;if(f&&(h=f.length)){var g=-1,h,i,j;d=a.value?d/a.value:0;while(++g<h)c(i=f[g],b,j=i.value*d,e),b+=j}}function d(a){var b=a.children,c=0;if(b&&(f=b.length)){var e=-1,f;while(++e<f)c=Math.max(c,d(b[e]))}return 1+c}function e(e,f){var g=a.call(this,e,f);return c(g[0],0,b[0],b[1]/d(g[0])),g}var a=d3.layout.hierarchy(),b=[1,1];return e.size=function(a){return arguments.length?(b=a,e):b},z(e,a)},d3.layout.pie=function(){function f(g,h){var i=g.map(function(b,c){return+a.call(f,b,c)}),j=+(typeof c=="function"?c.apply(this,arguments):c),k=((typeof e=="function"?e.apply(this,arguments):e)-c)/d3.sum(i),l=d3.range(g.length);b!=null&&l.sort(b===n?function(a,b){return i[b]-i[a]}:function(a,c){return b(g[a],g[c])});var m=[];return l.forEach(function(a){m[a]={data:g[a],value:d=i[a],startAngle:j,endAngle:j+=d*k}}),m}var a=Number,b=n,c=0,e=2*Math.PI;return f.value=function(b){return arguments.length?(a=b,f):a},f.sort=function(a){return arguments.length?(b=a,f):b},f.startAngle=function(a){return arguments.length?(c=a,f):c},f.endAngle=function(a){return arguments.length?(e=a,f):e},f};var n={};d3.layout.stack=function(){function g(h,i){var j=h.map(function(b,c){return a.call(g,b,c)}),k=j.map(function(a,b){return a.map(function(a,b){return[e.call(g,a,b),f.call(g,a,b)]})}),l=b.call(g,k,i);j=d3.permute(j,l),k=d3.permute(k,l);var m=c.call(g,k,i),n=j.length,o=j[0].length,p,q,r;for(q=0;q<o;++q){d.call(g,j[0][q],r=m[q],k[0][q][1]);for(p=1;p<n;++p)d.call(g,j[p][q],r+=k[p-1][q][1],k[p][q][1])}return h}var a=Object,b=r["default"],c=s.zero,d=q,e=o,f=p;return g.values=function(b){return arguments.length?(a=b,g):a},g.order=function(a){return arguments.length?(b=typeof a=="function"?a:r[a],g):b},g.offset=function(a){return arguments.length?(c=typeof a=="function"?a:s[a],g):c},g.x=function(a){return arguments.length?(e=a,g):e},g.y=function(a){return arguments.length?(f=a,g):f},g.out=function(a){return arguments.length?(d=a,g):d},g};var r={"inside-out":function(a){var b=a.length,c,d,e=a.map(t),f=a.map(u),g=d3.range(b).sort(function(a,b){return e[a]-e[b]}),h=0,i=0,j=[],k=[];for(c=0;c<b;++c)d=g[c],h<i?(h+=f[d],j.push(d)):(i+=f[d],k.push(d));return k.reverse().concat(j)},reverse:function(a){return d3.range(a.length).reverse()},"default":function(a){return d3.range(a.length)}},s={silhouette:function(a){var b=a.length,c=a[0].length,d=[],e=0,f,g,h,i=[];for(g=0;g<c;++g){for(f=0,h=0;f<b;f++)h+=a[f][g][1];h>e&&(e=h),d.push(h)}for(g=0;g<c;++g)i[g]=(e-d[g])/2;return i},wiggle:function(a){var b=a.length,c=a[0],d=c.length,e=0,f,g,h,i,j,k,l,m,n,o=[];o[0]=m=n=0;for(g=1;g<d;++g){for(f=0,i=0;f<b;++f)i+=a[f][g][1];for(f=0,j=0,l=c[g][0]-c[g-1][0];f<b;++f){for(h=0,k=(a[f][g][1]-a[f][g-1][1])/(2*l);h<f;++h)k+=(a[h][g][1]-a[h][g-1][1])/l;j+=k*a[f][g][1]}o[g]=m-=i?j/i*l:0,m<n&&(n=m)}for(g=0;g<d;++g)o[g]-=n;return o},expand:function(a){var b=a.length,c=a[0].length,d=1/b,e,f,g,h=[];for(f=0;f<c;++f){for(e=0,g=0;e<b;e++)g+=a[e][f][1];if(g)for(e=0;e<b;e++)a[e][f][1]/=g;else for(e=0;e<b;e++)a[e][f][1]=d}for(f=0;f<c;++f)h[f]=0;return h},zero:function(a){var b=-1,c=a[0].length,d=[];while(++b<c)d[b]=0;return d}};d3.layout.histogram=function(){function e(e,f){var g=[],h=e.map(b,this),i=c.call(this,h,f),j=d.call(this,i,h,f),k,f=-1,l=h.length,m=j.length-1,n=a?1:1/l,o;while(++f<m)k=g[f]=[],k.dx=j[f+1]-(k.x=j[f]),k.y=0;f=-1;while(++f<l)o=h[f],o>=i[0]&&o<=i[1]&&(k=g[d3.bisect(j,o,1,m)-1],k.y+=n,k.push(e[f]));return g}var a=!0,b=Number,c=y,d=w;return e.value=function(a){return arguments.length?(b=a,e):b},e.range=function(a){return arguments.length?(c=d3.functor(a),e):c},e.bins=function(a){return arguments.length?(d=typeof a=="number"?function(b){return x(b,a)}:d3.functor(a),e):d},e.frequency=function(b){return arguments.length?(a=!!b,e):a},e},d3.layout.hierarchy=function(){function e(f,h,i){var j=b.call(g,f,h),k=E?f:{data:f};k.depth=h,i.push(k);if(j&&(m=j.length)){var l=-1,m,n=k.children=[],o=0,p=h+1;while(++l<m)d=e(j[l],p,i),d.parent=k,n.push(d),o+=d.value;a&&n.sort(a),c&&(k.value=o)}else c&&(k.value=+c.call(g,f,h)||0);return k}function f(a,b){var d=a.children,e=0;if(d&&(i=d.length)){var h=-1,i,j=b+1;while(++h<i)e+=f(d[h],j)}else c&&(e=+c.call(g,E?a:a.data,b)||0);return c&&(a.value=e),e}function g(a){var b=[];return e(a,0,b),b}var a=C,b=A,c=B;return g.sort=function(b){return arguments.length?(a=b,g):a},g.children=function(a){return arguments.length?(b=a,g):b},g.value=function(a){return arguments.length?(c=a,g):c},g.revalue=function(a){return f(a,0),a},g};var E=!1;d3.layout.pack=function(){function c(c,d){var e=a.call(this,c,d),f=e[0];f.x=0,f.y=0,M(f);var g=b[0],h=b[1],i=1/Math.max(2*f.r/g,2*f.r/h);return N(f,g/2,h/2,i),e}var a=d3.layout.hierarchy().sort(F),b=[1,1];return c.size=function(a){return arguments.length?(b=a,c):b},z(c,a)},d3.layout.cluster=function(){function d(d,e){var f=a.call(this,d,e),g=f[0],h,i=0,j,k;$(g,function(a){var c=a.children;c&&c.length?(a.x=Q(c),a.y=P(c)):(a.x=h?i+=b(a,h):0,a.y=0,h=a)});var l=R(g),m=S(g),n=l.x-b(l,m)/2,o=m.x+b(m,l)/2;return $(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=(1-(g.y?a.y/g.y:1))*c[1]}),f}var a=d3.layout.hierarchy().sort(null).value(null),b=T,c=[1,1];return d.separation=function(a){return arguments.length?(b=a,d):b},d.size=function(a){return arguments.length?(c=a,d):c},z(d,a)},d3.layout.tree=function(){function d(d,e){function h(a,c){var d=a.children,e=a._tree;if(d&&(f=d.length)){var f,g=d[0],i,k=g,l,m=-1;while(++m<f)l=d[m],h(l,i),k=j(l,i,k),i=l;_(a);var n=.5*(g._tree.prelim+l._tree.prelim);c?(e.prelim=c._tree.prelim+b(a,c),e.mod=e.prelim-n):e.prelim=n}else c&&(e.prelim=c._tree.prelim+b(a,c))}function i(a,b){a.x=a._tree.prelim+b;var c=a.children;if(c&&(e=c.length)){var d=-1,e;b+=a._tree.mod;while(++d<e)i(c[d],b)}}function j(a,c,d){if(c){var e=a,f=a,g=c,h=a.parent.children[0],i=e._tree.mod,j=f._tree.mod,k=g._tree.mod,l=h._tree.mod,m;while(g=V(g),e=U(e),g&&e)h=U(h),f=V(f),f._tree.ancestor=a,m=g._tree.prelim+k-e._tree.prelim-i+b(g,e),m>0&&(ba(bb(g,a,d),a,m),i+=m,j+=m),k+=g._tree.mod,i+=e._tree.mod,l+=h._tree.mod,j+=f._tree.mod;g&&!V(f)&&(f._tree.thread=g,f._tree.mod+=k-j),e&&!U(h)&&(h._tree.thread=e,h._tree.mod+=i-l,d=a)}return d}var f=a.call(this,d,e),g=f[0];$(g,function(a,b){a._tree={ancestor:a,prelim:0,mod:0,change:0,shift:0,number:b?b._tree.number+1:0}}),h(g),i(g,-g._tree.prelim);var k=W(g,Y),l=W(g,X),m=W(g,Z),n=k.x-b(k,l)/2,o=l.x+b(l,k)/2,p=m.depth||1;return $(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=a.depth/p*c[1],delete a._tree}),f}var a=d3.layout.hierarchy().sort(null).value(null),b=T,c=[1,1];return d.separation=function(a){return arguments.length?(b=a,d):b},d.size=function(a){return arguments.length?(c=a,d):c},z(d,a)},d3.layout.treemap=function(){function i(a,b){var c=-1,d=a.length,e,f;while(++c<d)f=(e=a[c]).value*(b<0?0:b),e.area=isNaN(f)||f<=0?0:f}function j(a){var b=a.children;if(b&&b.length){var c=e(a),d=[],f=b.slice(),g,h=Infinity,k,n=Math.min(c.dx,c.dy),o;i(f,c.dx*c.dy/a.value),d.area=0;while((o=f.length)>0)d.push(g=f[o-1]),d.area+=g.area,(k=l(d,n))<=h?(f.pop(),h=k):(d.area-=d.pop().area,m(d,n,c,!1),n=Math.min(c.dx,c.dy),d.length=d.area=0,h=Infinity);d.length&&(m(d,n,c,!0),d.length=d.area=0),b.forEach(j)}}function k(a){var b=a.children;if(b&&b.length){var c=e(a),d=b.slice(),f,g=[];i(d,c.dx*c.dy/a.value),g.area=0;while(f=d.pop())g.push(f),g.area+=f.area,f.z!=null&&(m(g,f.z?c.dx:c.dy,c,!d.length),g.length=g.area=0);b.forEach(k)}}function l(a,b){var c=a.area,d,e=0,f=Infinity,g=-1,i=a.length;while(++g<i){if(!(d=a[g].area))continue;d<f&&(f=d),d>e&&(e=d)}return c*=c,b*=b,c?Math.max(b*e*h/c,c/(b*f*h)):Infinity}function m(a,c,d,e){var f=-1,g=a.length,h=d.x,i=d.y,j=c?b(a.area/c):0,k;if(c==d.dx){if(e||j>d.dy)j=j?d.dy:0;while(++f<g)k=a[f],k.x=h,k.y=i,k.dy=j,h+=k.dx=j?b(k.area/j):0;k.z=!0,k.dx+=d.x+d.dx-h,d.y+=j,d.dy-=j}else{if(e||j>d.dx)j=j?d.dx:0;while(++f<g)k=a[f],k.x=h,k.y=i,k.dx=j,i+=k.dy=j?b(k.area/j):0;k.z=!1,k.dy+=d.y+d.dy-i,d.x+=j,d.dx-=j}}function n(b){var d=g||a(b),e=d[0];return e.x=0,e.y=0,e.dx=c[0],e.dy=c[1],g&&a.revalue(e),i([e],e.dx*e.dy/e.value),(g?k:j)(e),f&&(g=d),d}var a=d3.layout.hierarchy(),b=Math.round,c=[1,1],d=null,e=bc,f=!1,g,h=.5*(1+Math.sqrt(5));return n.size=function(a){return arguments.length?(c=a,n):c},n.padding=function(a){function b(b){var c=a.call(n,b,b.depth);return c==null?bc(b):bd(b,typeof c=="number"?[c,c,c,c]:c)}function c(b){return bd(b,a)}if(!arguments.length)return d;var f;return e=(d=a)==null?bc:(f=typeof a)==="function"?b:f==="number"?(a=[a,a,a,a],c):c,n},n.round=function(a){return arguments.length?(b=a?Math.round:Number,n):b!=Number},n.sticky=function(a){return arguments.length?(f=a,g=null,n):f},n.ratio=function(a){return arguments.length?(h=a,n):h},z(n,a)}})(); <ide>\ No newline at end of file <add>(function(){function a(a){var b=a.source,d=a.target,e=c(b,d),f=[b];while(b!==e)b=b.parent,f.push(b);var g=f.length;while(d!==e)f.splice(g,0,d),d=d.parent;return f}function b(a){var b=[],c=a.parent;while(c!=null)b.push(a),a=c,c=c.parent;return b.push(a),b}function c(a,c){if(a===c)return a;var d=b(a),e=b(c),f=d.pop(),g=e.pop(),h=null;while(f===g)h=f,f=d.pop(),g=e.pop();return h}function g(a){a.fixed|=2}function h(a){a!==f&&(a.fixed&=1)}function i(){j(),f.fixed&=1,e=f=null}function j(){f.px=d3.event.x,f.py=d3.event.y,e.resume()}function k(a,b,c){var d=0,e=0;a.charge=0;if(!a.leaf){var f=a.nodes,g=f.length,h=-1,i;while(++h<g){i=f[h];if(i==null)continue;k(i,b,c),a.charge+=i.charge,d+=i.charge*i.cx,e+=i.charge*i.cy}}if(a.point){a.leaf||(a.point.x+=Math.random()-.5,a.point.y+=Math.random()-.5);var j=b*c[a.point.index];a.charge+=a.pointCharge=j,d+=j*a.point.x,e+=j*a.point.y}a.cx=d/a.charge,a.cy=e/a.charge}function l(a){return 20}function m(a){return 1}function o(a){return a.x}function p(a){return a.y}function q(a,b,c){a.y0=b,a.y=c}function t(a){var b=1,c=0,d=a[0][1],e,f=a.length;for(;b<f;++b)(e=a[b][1])>d&&(c=b,d=e);return c}function u(a){return a.reduce(v,0)}function v(a,b){return a+b[1]}function w(a,b){return x(a,Math.ceil(Math.log(b.length)/Math.LN2+1))}function x(a,b){var c=-1,d=+a[0],e=(a[1]-d)/b,f=[];while(++c<=b)f[c]=e*c+d;return f}function y(a){return[d3.min(a),d3.max(a)]}function z(a,b){return d3.rebind(a,b,"sort","children","value"),a.links=D,a.nodes=function(b){return E=!0,(a.nodes=a)(b)},a}function A(a){return a.children}function B(a){return a.value}function C(a,b){return b.value-a.value}function D(a){return d3.merge(a.map(function(a){return(a.children||[]).map(function(b){return{source:a,target:b}})}))}function F(a,b){return a.value-b.value}function G(a,b){var c=a._pack_next;a._pack_next=b,b._pack_prev=a,b._pack_next=c,c._pack_prev=b}function H(a,b){a._pack_next=b,b._pack_prev=a}function I(a,b){var c=b.x-a.x,d=b.y-a.y,e=a.r+b.r;return e*e-c*c-d*d>.001}function J(a){function l(a){b=Math.min(a.x-a.r,b),c=Math.max(a.x+a.r,c),d=Math.min(a.y-a.r,d),e=Math.max(a.y+a.r,e)}var b=Infinity,c=-Infinity,d=Infinity,e=-Infinity,f=a.length,g,h,i,j,k;a.forEach(K),g=a[0],g.x=-g.r,g.y=0,l(g);if(f>1){h=a[1],h.x=h.r,h.y=0,l(h);if(f>2){i=a[2],O(g,h,i),l(i),G(g,i),g._pack_prev=i,G(i,h),h=g._pack_next;for(var m=3;m<f;m++){O(g,h,i=a[m]);var n=0,o=1,p=1;for(j=h._pack_next;j!==h;j=j._pack_next,o++)if(I(j,i)){n=1;break}if(n==1)for(k=g._pack_prev;k!==j._pack_prev;k=k._pack_prev,p++)if(I(k,i))break;n?(o<p||o==p&&h.r<g.r?H(g,h=j):H(g=k,h),m--):(G(g,i),h=i,l(i))}}}var q=(b+c)/2,r=(d+e)/2,s=0;for(var m=0;m<f;m++){var t=a[m];t.x-=q,t.y-=r,s=Math.max(s,t.r+Math.sqrt(t.x*t.x+t.y*t.y))}return a.forEach(L),s}function K(a){a._pack_next=a._pack_prev=a}function L(a){delete a._pack_next,delete a._pack_prev}function M(a){var b=a.children;b&&b.length?(b.forEach(M),a.r=J(b)):a.r=Math.sqrt(a.value)}function N(a,b,c,d){var e=a.children;a.x=b+=d*a.x,a.y=c+=d*a.y,a.r*=d;if(e){var f=-1,g=e.length;while(++f<g)N(e[f],b,c,d)}}function O(a,b,c){var d=a.r+c.r,e=b.x-a.x,f=b.y-a.y;if(d&&(e||f)){var g=b.r+c.r,h=Math.sqrt(e*e+f*f),i=Math.max(-1,Math.min(1,(d*d+h*h-g*g)/(2*d*h))),j=Math.acos(i),k=i*(d/=h),l=Math.sin(j)*d;c.x=a.x+k*e+l*f,c.y=a.y+k*f-l*e}else c.x=a.x+d,c.y=a.y}function P(a){return 1+d3.max(a,function(a){return a.y})}function Q(a){return a.reduce(function(a,b){return a+b.x},0)/a.length}function R(a){var b=a.children;return b&&b.length?R(b[0]):a}function S(a){var b=a.children,c;return b&&(c=b.length)?S(b[c-1]):a}function T(a,b){return a.parent==b.parent?1:2}function U(a){var b=a.children;return b&&b.length?b[0]:a._tree.thread}function V(a){var b=a.children,c;return b&&(c=b.length)?b[c-1]:a._tree.thread}function W(a,b){var c=a.children;if(c&&(e=c.length)){var d,e,f=-1;while(++f<e)b(d=W(c[f],b),a)>0&&(a=d)}return a}function X(a,b){return a.x-b.x}function Y(a,b){return b.x-a.x}function Z(a,b){return a.depth-b.depth}function $(a,b){function c(a,d){var e=a.children;if(e&&(i=e.length)){var f,g=null,h=-1,i;while(++h<i)f=e[h],c(f,g),g=f}b(a,d)}c(a,null)}function _(a){var b=0,c=0,d=a.children,e=d.length,f;while(--e>=0)f=d[e]._tree,f.prelim+=b,f.mod+=b,b+=f.shift+(c+=f.change)}function ba(a,b,c){a=a._tree,b=b._tree;var d=c/(b.number-a.number);a.change+=d,b.change-=d,b.shift+=c,b.prelim+=c,b.mod+=c}function bb(a,b,c){return a._tree.ancestor.parent==b.parent?a._tree.ancestor:c}function bc(a){return{x:a.x,y:a.y,dx:a.dx,dy:a.dy}}function bd(a,b){var c=a.x+b[3],d=a.y+b[0],e=a.dx-b[1]-b[3],f=a.dy-b[0]-b[2];return e<0&&(c+=e/2,e=0),f<0&&(d+=f/2,f=0),{x:c,y:d,dx:e,dy:f}}d3.layout={},d3.layout.bundle=function(){return function(b){var c=[],d=-1,e=b.length;while(++d<e)c.push(a(b[d]));return c}},d3.layout.chord=function(){function j(){var a={},j=[],l=d3.range(e),m=[],n,o,p,q,r;b=[],c=[],n=0,q=-1;while(++q<e){o=0,r=-1;while(++r<e)o+=d[q][r];j.push(o),m.push(d3.range(e)),n+=o}g&&l.sort(function(a,b){return g(j[a],j[b])}),h&&m.forEach(function(a,b){a.sort(function(a,c){return h(d[b][a],d[b][c])})}),n=(2*Math.PI-f*e)/n,o=0,q=-1;while(++q<e){p=o,r=-1;while(++r<e){var s=l[q],t=m[s][r],u=d[s][t],v=o,w=o+=u*n;a[s+"-"+t]={index:s,subindex:t,startAngle:v,endAngle:w,value:u}}c.push({index:s,startAngle:p,endAngle:o,value:(o-p)/n}),o+=f}q=-1;while(++q<e){r=q-1;while(++r<e){var x=a[q+"-"+r],y=a[r+"-"+q];(x.value||y.value)&&b.push(x.value<y.value?{source:y,target:x}:{source:x,target:y})}}i&&k()}function k(){b.sort(function(a,b){return i((a.source.value+a.target.value)/2,(b.source.value+b.target.value)/2)})}var a={},b,c,d,e,f=0,g,h,i;return a.matrix=function(f){return arguments.length?(e=(d=f)&&d.length,b=c=null,a):d},a.padding=function(d){return arguments.length?(f=d,b=c=null,a):f},a.sortGroups=function(d){return arguments.length?(g=d,b=c=null,a):g},a.sortSubgroups=function(c){return arguments.length?(h=c,b=null,a):h},a.sortChords=function(c){return arguments.length?(i=c,b&&k(),a):i},a.chords=function(){return b||j(),b},a.groups=function(){return c||j(),c},a},d3.layout.force=function(){function A(a){return function(b,c,d,e,f){if(b.point!==a){var g=b.cx-a.x,h=b.cy-a.y,i=1/Math.sqrt(g*g+h*h);if((e-c)*i<t){var j=b.charge*i*i;return a.px-=g*j,a.py-=h*j,!0}if(b.point&&isFinite(i)){var j=b.pointCharge*i*i;a.px-=g*j,a.py-=h*j}}return!b.charge}}function B(){var a=v.length,d=w.length,e,f,g,h,i,j,l,m,p;for(f=0;f<d;++f){g=w[f],h=g.source,i=g.target,m=i.x-h.x,p=i.y-h.y;if(j=m*m+p*p)j=n*y[f]*((j=Math.sqrt(j))-x[f])/j,m*=j,p*=j,i.x-=m*(l=h.weight/(i.weight+h.weight)),i.y-=p*l,h.x+=m*(l=1-l),h.y+=p*l}if(l=n*s){m=c[0]/2,p=c[1]/2,f=-1;if(l)while(++f<a)g=v[f],g.x+=(m-g.x)*l,g.y+=(p-g.y)*l}if(r){k(e=d3.geom.quadtree(v),n,z),f=-1;while(++f<a)(g=v[f]).fixed||e.visit(A(g))}f=-1;while(++f<a)g=v[f],g.fixed?(g.x=g.px,g.y=g.py):(g.x-=(g.px-(g.px=g.x))*o,g.y-=(g.py-(g.py=g.y))*o);return b.tick({type:"tick",alpha:n}),(n*=.99)<.005}function C(b){g(f=b),e=a}var a={},b=d3.dispatch("tick"),c=[1,1],d,n,o=.9,p=l,q=m,r=-30,s=.1,t=.8,u,v=[],w=[],x,y,z;return a.nodes=function(b){return arguments.length?(v=b,a):v},a.links=function(b){return arguments.length?(w=b,a):w},a.size=function(b){return arguments.length?(c=b,a):c},a.linkDistance=function(b){return arguments.length?(p=d3.functor(b),a):p},a.distance=a.linkDistance,a.linkStrength=function(b){return arguments.length?(q=d3.functor(b),a):q},a.friction=function(b){return arguments.length?(o=b,a):o},a.charge=function(b){return arguments.length?(r=typeof b=="function"?b:+b,a):r},a.gravity=function(b){return arguments.length?(s=b,a):s},a.theta=function(b){return arguments.length?(t=b,a):t},a.start=function(){function k(a,c){var d=l(b),e=-1,f=d.length,g;while(++e<f)if(!isNaN(g=d[e][a]))return g;return Math.random()*c}function l(){if(!i){i=[];for(d=0;d<e;++d)i[d]=[];for(d=0;d<f;++d){var a=w[d];i[a.source.index].push(a.target),i[a.target.index].push(a.source)}}return i[b]}var b,d,e=v.length,f=w.length,g=c[0],h=c[1],i,j;for(b=0;b<e;++b)(j=v[b]).index=b,j.weight=0;x=[],y=[];for(b=0;b<f;++b)j=w[b],typeof j.source=="number"&&(j.source=v[j.source]),typeof j.target=="number"&&(j.target=v[j.target]),x[b]=p.call(this,j,b),y[b]=q.call(this,j,b),++j.source.weight,++j.target.weight;for(b=0;b<e;++b)j=v[b],isNaN(j.x)&&(j.x=k("x",g)),isNaN(j.y)&&(j.y=k("y",h)),isNaN(j.px)&&(j.px=j.x),isNaN(j.py)&&(j.py=j.y);z=[];if(typeof r=="function")for(b=0;b<e;++b)z[b]=+r.call(this,v[b],b);else for(b=0;b<e;++b)z[b]=r;return a.resume()},a.resume=function(){return n=.1,d3.timer(B),a},a.stop=function(){return n=0,a},a.drag=function(){d||(d=d3.behavior.drag().origin(Object).on("dragstart",C).on("drag",j).on("dragend",i)),this.on("mouseover.force",g).on("mouseout.force",h).call(d)},d3.rebind(a,b,"on")};var e,f;d3.layout.partition=function(){function c(a,b,d,e){var f=a.children;a.x=b,a.y=a.depth*e,a.dx=d,a.dy=e;if(f&&(h=f.length)){var g=-1,h,i,j;d=a.value?d/a.value:0;while(++g<h)c(i=f[g],b,j=i.value*d,e),b+=j}}function d(a){var b=a.children,c=0;if(b&&(f=b.length)){var e=-1,f;while(++e<f)c=Math.max(c,d(b[e]))}return 1+c}function e(e,f){var g=a.call(this,e,f);return c(g[0],0,b[0],b[1]/d(g[0])),g}var a=d3.layout.hierarchy(),b=[1,1];return e.size=function(a){return arguments.length?(b=a,e):b},z(e,a)},d3.layout.pie=function(){function f(g,h){var i=g.map(function(b,c){return+a.call(f,b,c)}),j=+(typeof c=="function"?c.apply(this,arguments):c),k=((typeof e=="function"?e.apply(this,arguments):e)-c)/d3.sum(i),l=d3.range(g.length);b!=null&&l.sort(b===n?function(a,b){return i[b]-i[a]}:function(a,c){return b(g[a],g[c])});var m=[];return l.forEach(function(a){m[a]={data:g[a],value:d=i[a],startAngle:j,endAngle:j+=d*k}}),m}var a=Number,b=n,c=0,e=2*Math.PI;return f.value=function(b){return arguments.length?(a=b,f):a},f.sort=function(a){return arguments.length?(b=a,f):b},f.startAngle=function(a){return arguments.length?(c=a,f):c},f.endAngle=function(a){return arguments.length?(e=a,f):e},f};var n={};d3.layout.stack=function(){function g(h,i){var j=h.map(function(b,c){return a.call(g,b,c)}),k=j.map(function(a,b){return a.map(function(a,b){return[e.call(g,a,b),f.call(g,a,b)]})}),l=b.call(g,k,i);j=d3.permute(j,l),k=d3.permute(k,l);var m=c.call(g,k,i),n=j.length,o=j[0].length,p,q,r;for(q=0;q<o;++q){d.call(g,j[0][q],r=m[q],k[0][q][1]);for(p=1;p<n;++p)d.call(g,j[p][q],r+=k[p-1][q][1],k[p][q][1])}return h}var a=Object,b=r["default"],c=s.zero,d=q,e=o,f=p;return g.values=function(b){return arguments.length?(a=b,g):a},g.order=function(a){return arguments.length?(b=typeof a=="function"?a:r[a],g):b},g.offset=function(a){return arguments.length?(c=typeof a=="function"?a:s[a],g):c},g.x=function(a){return arguments.length?(e=a,g):e},g.y=function(a){return arguments.length?(f=a,g):f},g.out=function(a){return arguments.length?(d=a,g):d},g};var r={"inside-out":function(a){var b=a.length,c,d,e=a.map(t),f=a.map(u),g=d3.range(b).sort(function(a,b){return e[a]-e[b]}),h=0,i=0,j=[],k=[];for(c=0;c<b;++c)d=g[c],h<i?(h+=f[d],j.push(d)):(i+=f[d],k.push(d));return k.reverse().concat(j)},reverse:function(a){return d3.range(a.length).reverse()},"default":function(a){return d3.range(a.length)}},s={silhouette:function(a){var b=a.length,c=a[0].length,d=[],e=0,f,g,h,i=[];for(g=0;g<c;++g){for(f=0,h=0;f<b;f++)h+=a[f][g][1];h>e&&(e=h),d.push(h)}for(g=0;g<c;++g)i[g]=(e-d[g])/2;return i},wiggle:function(a){var b=a.length,c=a[0],d=c.length,e=0,f,g,h,i,j,k,l,m,n,o=[];o[0]=m=n=0;for(g=1;g<d;++g){for(f=0,i=0;f<b;++f)i+=a[f][g][1];for(f=0,j=0,l=c[g][0]-c[g-1][0];f<b;++f){for(h=0,k=(a[f][g][1]-a[f][g-1][1])/(2*l);h<f;++h)k+=(a[h][g][1]-a[h][g-1][1])/l;j+=k*a[f][g][1]}o[g]=m-=i?j/i*l:0,m<n&&(n=m)}for(g=0;g<d;++g)o[g]-=n;return o},expand:function(a){var b=a.length,c=a[0].length,d=1/b,e,f,g,h=[];for(f=0;f<c;++f){for(e=0,g=0;e<b;e++)g+=a[e][f][1];if(g)for(e=0;e<b;e++)a[e][f][1]/=g;else for(e=0;e<b;e++)a[e][f][1]=d}for(f=0;f<c;++f)h[f]=0;return h},zero:function(a){var b=-1,c=a[0].length,d=[];while(++b<c)d[b]=0;return d}};d3.layout.histogram=function(){function e(e,f){var g=[],h=e.map(b,this),i=c.call(this,h,f),j=d.call(this,i,h,f),k,f=-1,l=h.length,m=j.length-1,n=a?1:1/l,o;while(++f<m)k=g[f]=[],k.dx=j[f+1]-(k.x=j[f]),k.y=0;f=-1;while(++f<l)o=h[f],o>=i[0]&&o<=i[1]&&(k=g[d3.bisect(j,o,1,m)-1],k.y+=n,k.push(e[f]));return g}var a=!0,b=Number,c=y,d=w;return e.value=function(a){return arguments.length?(b=a,e):b},e.range=function(a){return arguments.length?(c=d3.functor(a),e):c},e.bins=function(a){return arguments.length?(d=typeof a=="number"?function(b){return x(b,a)}:d3.functor(a),e):d},e.frequency=function(b){return arguments.length?(a=!!b,e):a},e},d3.layout.hierarchy=function(){function e(f,h,i){var j=b.call(g,f,h),k=E?f:{data:f};k.depth=h,i.push(k);if(j&&(m=j.length)){var l=-1,m,n=k.children=[],o=0,p=h+1;while(++l<m)d=e(j[l],p,i),d.parent=k,n.push(d),o+=d.value;a&&n.sort(a),c&&(k.value=o)}else c&&(k.value=+c.call(g,f,h)||0);return k}function f(a,b){var d=a.children,e=0;if(d&&(i=d.length)){var h=-1,i,j=b+1;while(++h<i)e+=f(d[h],j)}else c&&(e=+c.call(g,E?a:a.data,b)||0);return c&&(a.value=e),e}function g(a){var b=[];return e(a,0,b),b}var a=C,b=A,c=B;return g.sort=function(b){return arguments.length?(a=b,g):a},g.children=function(a){return arguments.length?(b=a,g):b},g.value=function(a){return arguments.length?(c=a,g):c},g.revalue=function(a){return f(a,0),a},g};var E=!1;d3.layout.pack=function(){function c(c,d){var e=a.call(this,c,d),f=e[0];f.x=0,f.y=0,M(f);var g=b[0],h=b[1],i=1/Math.max(2*f.r/g,2*f.r/h);return N(f,g/2,h/2,i),e}var a=d3.layout.hierarchy().sort(F),b=[1,1];return c.size=function(a){return arguments.length?(b=a,c):b},z(c,a)},d3.layout.cluster=function(){function d(d,e){var f=a.call(this,d,e),g=f[0],h,i=0,j,k;$(g,function(a){var c=a.children;c&&c.length?(a.x=Q(c),a.y=P(c)):(a.x=h?i+=b(a,h):0,a.y=0,h=a)});var l=R(g),m=S(g),n=l.x-b(l,m)/2,o=m.x+b(m,l)/2;return $(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=(1-(g.y?a.y/g.y:1))*c[1]}),f}var a=d3.layout.hierarchy().sort(null).value(null),b=T,c=[1,1];return d.separation=function(a){return arguments.length?(b=a,d):b},d.size=function(a){return arguments.length?(c=a,d):c},z(d,a)},d3.layout.tree=function(){function d(d,e){function h(a,c){var d=a.children,e=a._tree;if(d&&(f=d.length)){var f,g=d[0],i,k=g,l,m=-1;while(++m<f)l=d[m],h(l,i),k=j(l,i,k),i=l;_(a);var n=.5*(g._tree.prelim+l._tree.prelim);c?(e.prelim=c._tree.prelim+b(a,c),e.mod=e.prelim-n):e.prelim=n}else c&&(e.prelim=c._tree.prelim+b(a,c))}function i(a,b){a.x=a._tree.prelim+b;var c=a.children;if(c&&(e=c.length)){var d=-1,e;b+=a._tree.mod;while(++d<e)i(c[d],b)}}function j(a,c,d){if(c){var e=a,f=a,g=c,h=a.parent.children[0],i=e._tree.mod,j=f._tree.mod,k=g._tree.mod,l=h._tree.mod,m;while(g=V(g),e=U(e),g&&e)h=U(h),f=V(f),f._tree.ancestor=a,m=g._tree.prelim+k-e._tree.prelim-i+b(g,e),m>0&&(ba(bb(g,a,d),a,m),i+=m,j+=m),k+=g._tree.mod,i+=e._tree.mod,l+=h._tree.mod,j+=f._tree.mod;g&&!V(f)&&(f._tree.thread=g,f._tree.mod+=k-j),e&&!U(h)&&(h._tree.thread=e,h._tree.mod+=i-l,d=a)}return d}var f=a.call(this,d,e),g=f[0];$(g,function(a,b){a._tree={ancestor:a,prelim:0,mod:0,change:0,shift:0,number:b?b._tree.number+1:0}}),h(g),i(g,-g._tree.prelim);var k=W(g,Y),l=W(g,X),m=W(g,Z),n=k.x-b(k,l)/2,o=l.x+b(l,k)/2,p=m.depth||1;return $(g,function(a){a.x=(a.x-n)/(o-n)*c[0],a.y=a.depth/p*c[1],delete a._tree}),f}var a=d3.layout.hierarchy().sort(null).value(null),b=T,c=[1,1];return d.separation=function(a){return arguments.length?(b=a,d):b},d.size=function(a){return arguments.length?(c=a,d):c},z(d,a)},d3.layout.treemap=function(){function i(a,b){var c=-1,d=a.length,e,f;while(++c<d)f=(e=a[c]).value*(b<0?0:b),e.area=isNaN(f)||f<=0?0:f}function j(a){var b=a.children;if(b&&b.length){var c=e(a),d=[],f=b.slice(),g,h=Infinity,k,n=Math.min(c.dx,c.dy),o;i(f,c.dx*c.dy/a.value),d.area=0;while((o=f.length)>0)d.push(g=f[o-1]),d.area+=g.area,(k=l(d,n))<=h?(f.pop(),h=k):(d.area-=d.pop().area,m(d,n,c,!1),n=Math.min(c.dx,c.dy),d.length=d.area=0,h=Infinity);d.length&&(m(d,n,c,!0),d.length=d.area=0),b.forEach(j)}}function k(a){var b=a.children;if(b&&b.length){var c=e(a),d=b.slice(),f,g=[];i(d,c.dx*c.dy/a.value),g.area=0;while(f=d.pop())g.push(f),g.area+=f.area,f.z!=null&&(m(g,f.z?c.dx:c.dy,c,!d.length),g.length=g.area=0);b.forEach(k)}}function l(a,b){var c=a.area,d,e=0,f=Infinity,g=-1,i=a.length;while(++g<i){if(!(d=a[g].area))continue;d<f&&(f=d),d>e&&(e=d)}return c*=c,b*=b,c?Math.max(b*e*h/c,c/(b*f*h)):Infinity}function m(a,c,d,e){var f=-1,g=a.length,h=d.x,i=d.y,j=c?b(a.area/c):0,k;if(c==d.dx){if(e||j>d.dy)j=j?d.dy:0;while(++f<g)k=a[f],k.x=h,k.y=i,k.dy=j,h+=k.dx=j?b(k.area/j):0;k.z=!0,k.dx+=d.x+d.dx-h,d.y+=j,d.dy-=j}else{if(e||j>d.dx)j=j?d.dx:0;while(++f<g)k=a[f],k.x=h,k.y=i,k.dx=j,i+=k.dy=j?b(k.area/j):0;k.z=!1,k.dy+=d.y+d.dy-i,d.x+=j,d.dx-=j}}function n(b){var d=g||a(b),e=d[0];return e.x=0,e.y=0,e.dx=c[0],e.dy=c[1],g&&a.revalue(e),i([e],e.dx*e.dy/e.value),(g?k:j)(e),f&&(g=d),d}var a=d3.layout.hierarchy(),b=Math.round,c=[1,1],d=null,e=bc,f=!1,g,h=.5*(1+Math.sqrt(5));return n.size=function(a){return arguments.length?(c=a,n):c},n.padding=function(a){function b(b){var c=a.call(n,b,b.depth);return c==null?bc(b):bd(b,typeof c=="number"?[c,c,c,c]:c)}function c(b){return bd(b,a)}if(!arguments.length)return d;var f;return e=(d=a)==null?bc:(f=typeof a)==="function"?b:f==="number"?(a=[a,a,a,a],c):c,n},n.round=function(a){return arguments.length?(b=a?Math.round:Number,n):b!=Number},n.sticky=function(a){return arguments.length?(f=a,g=null,n):f},n.ratio=function(a){return arguments.length?(h=a,n):h},z(n,a)}})(); <ide>\ No newline at end of file <ide><path>src/layout/pack.js <ide> function d3_layout_packIntersects(a, b) { <ide> var dx = b.x - a.x, <ide> dy = b.y - a.y, <ide> dr = a.r + b.r; <del> return (dr * dr - dx * dx - dy * dy) > .001; // within epsilon <add> return dr * dr - dx * dx - dy * dy > .001; // within epsilon <ide> } <ide> <ide> function d3_layout_packCircle(nodes) { <ide> function d3_layout_packCircle(nodes) { <ide> if (isect == 1) { <ide> for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) { <ide> if (d3_layout_packIntersects(k, c)) { <del> if (s2 < s1) { <del> isect = -1; <del> j = k; <del> } <ide> break; <ide> } <ide> } <ide> } <ide> <ide> // Update node chain. <del> if (isect == 0) { <add> if (isect) { <add> if (s1 < s2 || (s1 == s2 && b.r < a.r)) d3_layout_packSplice(a, b = j); <add> else d3_layout_packSplice(a = k, b); <add> i--; <add> } else { <ide> d3_layout_packInsert(a, c); <ide> b = c; <ide> bound(c); <del> } else if (isect > 0) { <del> d3_layout_packSplice(a, j); <del> b = j; <del> i--; <del> } else { // isect < 0 <del> d3_layout_packSplice(j, b); <del> a = j; <del> i--; <ide> } <ide> } <ide> } <ide><path>test/layout/pack-test.js <ide> suite.addBatch({ <ide> {value: 1, depth: 1, x: 0.5, y: 0.5, r: 0.5} <ide> ]); <ide> }, <add> "can handle small nodes": function() { <add> assert.deepEqual(d3.layout.pack().sort(null).nodes({children: [ <add> {value: .01}, <add> {value: 2}, <add> {value: 2}, <add> {value: 1} <add> ]}).map(layout), [ <add> {y: 0.5, x: 0.5, value: 5.01, r: 0.5, depth: 0}, <add> {y: 0.5084543199854831, x: 0.4682608366855136, value: 0.01, r: 0.016411496513964046, depth: 1}, <add> {y: 0.5084543199854831, x: 0.7167659426883449, value: 2, r: 0.23209360948886723, depth: 1}, <add> {y: 0.34256315498862167, x: 0.2832340573116551, value: 2, r: 0.23209360948886723, depth: 1}, <add> {y: 0.7254154893606051, x: 0.3852405506102519, value: 1, r: 0.16411496513964044, depth: 1} <add> ]); <add> assert.deepEqual(d3.layout.pack().sort(null).nodes({children: [ <add> {value: 2}, <add> {value: 2}, <add> {value: 1}, <add> {value: .01} <add> ]}).map(layout), [ <add> {y: 0.5, x: 0.5, value: 5.01, r: 0.5, depth: 0}, <add> {y: 0.6274712284943809, x: 0.26624891409386664, value: 2, r: 0.23375108590613333, depth: 1}, <add> {y: 0.6274712284943809, x: 0.7337510859061334, value: 2, r: 0.23375108590613333, depth: 1}, <add> {y: 0.30406466355343187, x: 0.5, value: 1, r: 0.1652869779539461, depth: 1}, <add> {y: 0.3878967195987758, x: 0.3386645534068855, value: 0.01, r: 0.01652869779539461, depth: 1} <add> ]); <add> }, <ide> "can handle residual floating point error": function(pack) { <ide> var result = pack.nodes({children: [ <ide> {value: 0.005348322447389364},
4
Ruby
Ruby
fix undefined method
12070b4c0fd0f41151c10ad2322168e7aa30fa9e
<ide><path>Library/Homebrew/upgrade.rb <ide> def check_installed_dependents(args:) <ide> oh1 "Checking for dependents of upgraded formulae..." unless args.dry_run? <ide> broken_dependents = CacheStoreDatabase.use(:linkage) do |db| <ide> installed_formulae.flat_map(&:runtime_installed_formula_dependents) <add> .uniq <ide> .select do |f| <ide> keg = f.opt_or_installed_prefix_keg <ide> next unless keg <ide> def check_installed_dependents(args:) <ide> return if args.dry_run? <ide> <ide> reinstallable_broken_dependents.each do |f| <del> reinstall_formula(f, build_from_source: true, args: args) <add> Homebrew.reinstall_formula(f, build_from_source: true, args: args) <ide> rescue FormulaInstallationAlreadyAttemptedError <ide> # We already attempted to reinstall f as part of the dependency tree of <ide> # another formula. In that case, don't generate an error, just move on.
1
Ruby
Ruby
fix typo in test method names. [ci skip]
b4b5af0342cdb5917d9342cd4da245f19c3b4025
<ide><path>activerecord/test/cases/tasks/database_tasks_test.rb <ide> def test_warning_for_remote_databases <ide> ActiveRecord::Tasks::DatabaseTasks.drop_all <ide> end <ide> <del> def test_creates_configurations_with_local_ip <add> def test_drops_configurations_with_local_ip <ide> @configurations[:development].merge!('host' => '127.0.0.1') <ide> <ide> ActiveRecord::Tasks::DatabaseTasks.expects(:drop) <ide> <ide> ActiveRecord::Tasks::DatabaseTasks.drop_all <ide> end <ide> <del> def test_creates_configurations_with_local_host <add> def test_drops_configurations_with_local_host <ide> @configurations[:development].merge!('host' => 'localhost') <ide> <ide> ActiveRecord::Tasks::DatabaseTasks.expects(:drop) <ide> <ide> ActiveRecord::Tasks::DatabaseTasks.drop_all <ide> end <ide> <del> def test_creates_configurations_with_blank_hosts <add> def test_drops_configurations_with_blank_hosts <ide> @configurations[:development].merge!('host' => nil) <ide> <ide> ActiveRecord::Tasks::DatabaseTasks.expects(:drop) <ide> def setup <ide> ActiveRecord::Base.stubs(:configurations).returns(@configurations) <ide> end <ide> <del> def test_creates_current_environment_database <add> def test_drops_current_environment_database <ide> ActiveRecord::Tasks::DatabaseTasks.expects(:drop). <ide> with('database' => 'prod-db') <ide>
1
Python
Python
fix stateful metrics when passing dict to compile
adc321b4d7a4e22f6bdb00b404dfe5e23d4887aa
<ide><path>keras/engine/training.py <ide> def compile(self, optimizer, loss=None, metrics=None, loss_weights=None, <ide> nested_weighted_metrics = _collect_metrics(weighted_metrics, self.output_names) <ide> self.metrics_updates = [] <ide> self.stateful_metric_names = [] <add> self.stateful_metric_functions = [] <ide> with K.name_scope('metrics'): <ide> for i in range(len(self.outputs)): <ide> if i in skip_target_indices: <ide> def handle_metrics(metrics, weights=None): <ide> # stateful metrics (i.e. metrics layers). <ide> if isinstance(metric_fn, Layer) and metric_fn.stateful: <ide> self.stateful_metric_names.append(metric_name) <add> self.stateful_metric_functions.append(metric_fn) <ide> self.metrics_updates += metric_fn.updates <ide> <ide> handle_metrics(output_metrics) <ide> def _fit_loop(self, f, ins, out_labels=None, batch_size=None, <ide> <ide> for epoch in range(initial_epoch, epochs): <ide> # Reset stateful metrics <del> for m in self.metrics: <del> if isinstance(m, Layer) and m.stateful: <del> m.reset_states() <add> for m in self.stateful_metric_functions: <add> m.reset_states() <ide> callbacks.on_epoch_begin(epoch) <ide> epoch_logs = {} <ide> if steps_per_epoch is not None: <ide> def _test_loop(self, f, ins, batch_size=None, verbose=0, steps=None): <ide> """ <ide> <ide> if hasattr(self, 'metrics'): <del> for m in self.metrics: <del> if isinstance(m, Layer) and m.stateful: <del> m.reset_states() <add> for m in self.stateful_metric_functions: <add> m.reset_states() <ide> stateful_metric_indices = [ <ide> i for i, name in enumerate(self.metrics_names) <ide> if str(name) in self.stateful_metric_names] <ide> def generate_arrays_from_file(path): <ide> # Construct epoch logs. <ide> epoch_logs = {} <ide> while epoch < epochs: <del> for m in self.metrics: <del> if isinstance(m, Layer) and m.stateful: <del> m.reset_states() <add> for m in self.stateful_metric_functions: <add> m.reset_states() <ide> callbacks.on_epoch_begin(epoch) <ide> steps_done = 0 <ide> batch_index = 0 <ide> def evaluate_generator(self, generator, steps=None, <ide> <ide> stateful_metric_indices = [] <ide> if hasattr(self, 'metrics'): <del> for i, m in enumerate(self.metrics): <del> if isinstance(m, Layer) and m.stateful: <del> m.reset_states() <add> for m in self.stateful_metric_functions: <add> m.reset_states() <ide> stateful_metric_indices = [ <ide> i for i, name in enumerate(self.metrics_names) <ide> if str(name) in self.stateful_metric_names] <ide><path>tests/keras/metrics_test.py <ide> def test_sparse_top_k_categorical_accuracy(): <ide> <ide> <ide> @keras_test <del>def test_stateful_metrics(): <add>@pytest.mark.parametrize('metrics_mode', ['list', 'dict']) <add>def test_stateful_metrics(metrics_mode): <ide> np.random.seed(1334) <ide> <ide> class BinaryTruePositives(keras.layers.Layer): <ide> def __call__(self, y_true, y_pred): <ide> <ide> # Test on simple model <ide> inputs = keras.Input(shape=(2,)) <del> outputs = keras.layers.Dense(1, activation='sigmoid')(inputs) <add> outputs = keras.layers.Dense(1, activation='sigmoid', name='out')(inputs) <ide> model = keras.Model(inputs, outputs) <del> model.compile(optimizer='sgd', <del> loss='binary_crossentropy', <del> metrics=['acc', metric_fn]) <add> <add> if metrics_mode == 'list': <add> model.compile(optimizer='sgd', <add> loss='binary_crossentropy', <add> metrics=['acc', metric_fn]) <add> elif metrics_mode == 'dict': <add> model.compile(optimizer='sgd', <add> loss='binary_crossentropy', <add> metrics={'out': ['acc', metric_fn]}) <ide> <ide> samples = 1000 <ide> x = np.random.random((samples, 2))
2
Text
Text
add section on remote coding jobs and job boards
491b2e7c9c2f12583198f1b6d7df5acc83b939fd
<ide><path>guide/english/miscellaneous/getting-a-coding-job/index.md <ide> I've found <a href='https://github.com/cassidoo/getting-a-gig' target='_blank' r <ide> ## Pro tip: <ide> <ide> Like in any other industry or field, the hardest part is actually getting started. Do not worry too much and take action instead - the results will be mesmerizing. <add> <add>## Remote Coding Jobs <add> <add>Of those hundreds of thousands of coding jobs out there, there is a growing number that are remote. In fact, there are quite a bit of remote coding jobs out there. Remote offers companies the opportunity to find the best fit for their position without being geographically limited. Similarly remote jobs opens up opportunities for you that may not be available locally or even in the same timezone. <add> <add>### Here are a few remote job boards with coding positions: <add> <add>- [We Work Remotely](https://weworkremotely.com/) <add>- [RemoteOK](https://remoteok.io/) <add>- [Remotive](https://remotive.io/find-a-remote-job/)
1
PHP
PHP
add extra functions to user
f138f0f4fce63fdb371064a66a4c92226a8b1ace
<ide><path>app/models/User.php <ide> public function getAuthPassword() <ide> return $this->password; <ide> } <ide> <add> /** <add> * Get the token value for the "remember me" session. <add> * <add> * @return string <add> */ <add> public function getRememberToken() <add> { <add> return $this->remember_token; <add> } <add> <add> /** <add> * Set the token value for the "remember me" session. <add> * <add> * @param string $value <add> * @return void <add> */ <add> public function setRememberToken($value) <add> { <add> $this->remember_token = $value; <add> } <add> <add> /** <add> * Get the column name for the "remember me" token. <add> * <add> * @return string <add> */ <add> public function getRememberTokenName() <add> { <add> return 'remember_token'; <add> } <add> <ide> /** <ide> * Get the e-mail address where password reminders are sent. <ide> *
1
PHP
PHP
fix invalid sql on paginated results
4489522d1564a5b2cc58ff4d8f240f55fda2390a
<ide><path>src/ORM/EagerLoader.php <ide> protected function _groupKeys($statement, $collectKeys) <ide> <ide> return $keys; <ide> } <add> <add> /** <add> * Clone hook implementation <add> * <add> * Clone the _matching eager loader as well. <add> * <add> * @return void <add> */ <add> public function __clone() <add> { <add> if ($this->_matching) { <add> $this->_matching = clone $this->_matching; <add> } <add> } <ide> } <ide><path>src/ORM/Query.php <ide> public function cleanCopy() <ide> $clone->formatResults(null, true); <ide> $clone->setSelectTypeMap(new TypeMap()); <ide> $clone->decorateResults(null, true); <add> $clone->setEagerLoader(clone $this->getEagerLoader()); <ide> <ide> return $clone; <ide> } <ide><path>tests/TestCase/ORM/QueryRegressionTest.php <ide> public function testEagerLoadingBelongsToManyList() <ide> $table->find()->contain('Tags')->toArray(); <ide> } <ide> <add> /** <add> * Tests that eagerloading and hydration works for associations that have <add> * different aliases in the association and targetTable <add> * <add> * @return void <add> */ <add> public function testEagerLoadingNestedMatchingCalls() <add> { <add> $this->loadFixtures('Articles', 'Authors', 'Tags', 'ArticlesTags', 'AuthorsTags'); <add> $articles = TableRegistry::get('Articles'); <add> $articles->belongsToMany('Tags', [ <add> 'foreignKey' => 'article_id', <add> 'targetForeignKey' => 'tag_id', <add> 'joinTable' => 'articles_tags' <add> ]); <add> $tags = TableRegistry::get('Tags'); <add> $tags->belongsToMany('Authors', [ <add> 'foreignKey' => 'tag_id', <add> 'targetForeignKey' => 'author_id', <add> 'joinTable' => 'authors_tags' <add> ]); <add> <add> $query = $articles->find() <add> ->matching('Tags', function ($q) { <add> return $q->matching('Authors', function ($q) { <add> return $q->where(['Authors.name' => 'larry']); <add> }); <add> }); <add> $this->assertEquals(3, $query->count()); <add> <add> $result = $query->first(); <add> $this->assertInstanceOf(EntityInterface::class, $result); <add> $this->assertInstanceOf(EntityInterface::class, $result->_matchingData['Tags']); <add> $this->assertInstanceOf(EntityInterface::class, $result->_matchingData['Authors']); <add> } <add> <ide> /** <ide> * Tests that duplicate aliases in contain() can be used, even when they would <ide> * naturally be attached to the query instead of eagerly loaded. What should <ide><path>tests/TestCase/ORM/QueryTest.php <ide> public function testCleanCopy() <ide> $query->offset(10) <ide> ->limit(1) <ide> ->order(['Articles.id' => 'DESC']) <del> ->contain(['Comments']); <add> ->contain(['Comments']) <add> ->matching('Comments'); <ide> $copy = $query->cleanCopy(); <ide> <ide> $this->assertNotSame($copy, $query); <del> $this->assertNotSame($copy->eagerLoader(), $query->eagerLoader()); <del> $this->assertNotEmpty($copy->eagerLoader()->contain()); <add> $copyLoader = $copy->getEagerLoader(); <add> $loader = $query->getEagerLoader(); <add> $this->assertEquals($copyLoader, $loader, 'should be equal'); <add> $this->assertNotSame($copyLoader, $loader, 'should be clones'); <add> $this->assertNotSame( <add> $this->readAttribute($copyLoader, '_matching'), <add> $this->readAttribute($loader, '_matching'), <add> 'should be clones' <add> ); <ide> $this->assertNull($copy->clause('offset')); <ide> $this->assertNull($copy->clause('limit')); <ide> $this->assertNull($copy->clause('order'));
4
Text
Text
add petkaantonov as collaborator
3c8ae2d93492c8fff6a5085642a94e577b3e9995
<ide><path>README.md <ide> information about the governance of the io.js project, see <ide> * **Julian Duque** ([@julianduque](https://github.com/julianduque)) &lt;julianduquej@gmail.com&gt; <ide> * **Johan Bergström** ([@jbergstroem](https://github.com/jbergstroem)) &lt;bugs@bergstroem.nu&gt; <ide> * **Roman Reiss** ([@silverwind](https://github.com/silverwind)) &lt;me@silverwind.io&gt; <add>* **Petka Antonov** ([@petkaantonov](https://github.com/petkaanotnov)) &lt;petka_antonov@hotmail.com&gt; <ide> <ide> Collaborators follow the [COLLABORATOR_GUIDE.md](./COLLABORATOR_GUIDE.md) in <ide> maintaining the io.js project.
1
Text
Text
minimize line length
25242fe4e9649ecc5033510c408e6db5b6fe8bcc
<ide><path>docs/FAQ.md <ide> will use a bottled version of $FORMULA, but <ide> `brew install $FORMULA --enable-bar` will trigger a source build. <ide> * The `--build-from-source` option is invoked. <ide> * The environment variable `HOMEBREW_BUILD_FROM_SOURCE` is set. <del>* The machine is not running a supported version of macOS as all bottled builds are generated only for supported macOS versions. <add>* The machine is not running a supported version of macOS as all <add>bottled builds are generated only for supported macOS versions. <ide> * Homebrew is installed to a prefix other than the standard <ide> `/usr/local` (although some bottles support this) <ide>
1
Ruby
Ruby
test the verb method on the route, specifically
23cfdd4b71e4284e3efb29a37b2260e2ec77ddc9
<ide><path>actionpack/test/controller/resources_test.rb <ide> def test_restful_routes_dont_generate_duplicates <ide> routes.each do |route| <ide> routes.each do |r| <ide> next if route == r # skip the comparison instance <del> assert_not_equal [route.conditions, route.path.spec.to_s], [r.conditions, r.path.spec.to_s] <add> assert_not_equal [route.conditions, route.path.spec.to_s, route.verb], [r.conditions, r.path.spec.to_s, r.verb] <ide> end <ide> end <ide> end
1
Go
Go
ignore vfs from warning
f88066fd43454be005ec303977ee45561f3436e6
<ide><path>daemon/graphdriver/driver.go <ide> func New(root string, options []string) (driver Driver, err error) { <ide> func checkPriorDriver(name, root string) { <ide> priorDrivers := []string{} <ide> for prior := range drivers { <del> if prior != name { <add> if prior != name && prior != "vfs" { <ide> if _, err := os.Stat(path.Join(root, prior)); err == nil { <ide> priorDrivers = append(priorDrivers, prior) <ide> }
1
Ruby
Ruby
add dirty methods for store accessors
61a39ffcc6614d4369f524b5687309d9f12f279f
<ide><path>activerecord/lib/active_record/store.rb <ide> module ActiveRecord <ide> # of the model. This is very helpful for easily exposing store keys to a form or elsewhere that's <ide> # already built around just accessing attributes on the model. <ide> # <add> # Every accessor comes with dirty tracking methods (+key_changed?+, +key_was+ and +key_change+). <add> # <add> # NOTE: There is no +key_will_change!+ method for accessors, use +store_will_change!+ instead. <add> # <ide> # Make sure that you declare the database column used for the serialized store as a text, so there's <ide> # plenty of room. <ide> # <ide> module ActiveRecord <ide> # u.settings[:country] # => 'Denmark' <ide> # u.settings['country'] # => 'Denmark' <ide> # <add> # # Dirty tracking <add> # u.color = 'green' <add> # u.color_changed? # => true <add> # u.color_was # => 'black' <add> # u.color_change # => ['black', 'red'] <add> # <ide> # # Add additional accessors to an existing store through store_accessor <ide> # class SuperUser < User <ide> # store_accessor :settings, :privileges, :servants <ide> def store_accessor(store_attribute, *keys, prefix: nil, suffix: nil) <ide> define_method(accessor_key) do <ide> read_store_attribute(store_attribute, key) <ide> end <add> <add> define_method("#{accessor_key}_changed?") do <add> return false unless attribute_changed?(store_attribute) <add> prev_store, new_store = changes[store_attribute] <add> prev_store&.dig(key) != new_store&.dig(key) <add> end <add> <add> define_method("#{accessor_key}_change") do <add> return unless attribute_changed?(store_attribute) <add> prev_store, new_store = changes[store_attribute] <add> [prev_store&.dig(key), new_store&.dig(key)] <add> end <add> <add> define_method("#{accessor_key}_was") do <add> return unless attribute_changed?(store_attribute) <add> prev_store, _new_store = changes[store_attribute] <add> prev_store&.dig(key) <add> end <ide> end <ide> end <ide> <ide><path>activerecord/test/cases/adapters/postgresql/hstore_test.rb <ide> def test_yaml_round_trip_with_store_accessors <ide> assert_equal "GMT", y.timezone <ide> end <ide> <add> def test_changes_with_store_accessors <add> x = Hstore.new(language: "de") <add> assert x.language_changed? <add> assert_nil x.language_was <add> assert_equal [nil, "de"], x.language_change <add> x.save! <add> <add> assert_not x.language_changed? <add> x.reload <add> <add> x.settings = nil <add> assert x.language_changed? <add> assert_equal "de", x.language_was <add> assert_equal ["de", nil], x.language_change <add> end <add> <ide> def test_changes_in_place <ide> hstore = Hstore.create!(settings: { "one" => "two" }) <ide> hstore.settings["three"] = "four" <ide><path>activerecord/test/cases/store_test.rb <ide> class StoreTest < ActiveRecord::TestCase <ide> assert_not_predicate @john, :settings_changed? <ide> end <ide> <add> test "updating the store will mark accessor as changed" do <add> @john.color = "red" <add> assert @john.color_changed? <add> end <add> <add> test "new record and no accessors changes" do <add> user = Admin::User.new <add> assert_not user.color_changed? <add> assert_nil user.color_was <add> assert_nil user.color_change <add> <add> user.color = "red" <add> assert user.color_changed? <add> assert_nil user.color_was <add> assert_equal "red", user.color_change[1] <add> end <add> <add> test "updating the store won't mark accessor as changed if the whole store was updated" do <add> @john.settings = { color: @john.color, some: "thing" } <add> assert @john.settings_changed? <add> assert_not @john.color_changed? <add> end <add> <add> test "updating the store populates the accessor changed array correctly" do <add> @john.color = "red" <add> assert_equal "black", @john.color_was <add> assert_equal "black", @john.color_change[0] <add> assert_equal "red", @john.color_change[1] <add> end <add> <add> test "updating the store won't mark accessor as changed if the value isn't changed" do <add> @john.color = @john.color <add> assert_not @john.color_changed? <add> end <add> <add> test "nullifying the store mark accessor as changed" do <add> color = @john.color <add> @john.settings = nil <add> assert @john.color_changed? <add> assert_equal color, @john.color_was <add> assert_equal [color, nil], @john.color_change <add> end <add> <add> test "dirty methods for suffixed accessors" do <add> @john.configs[:two_factor_auth] = true <add> assert @john.two_factor_auth_configs_changed? <add> assert_nil @john.two_factor_auth_configs_was <add> assert_equal [nil, true], @john.two_factor_auth_configs_change <add> end <add> <add> test "dirty methods for prefixed accessors" do <add> @john.spouse[:name] = "Lena" <add> assert @john.partner_name_changed? <add> assert_equal "Dallas", @john.partner_name_was <add> assert_equal ["Dallas", "Lena"], @john.partner_name_change <add> end <add> <ide> test "object initialization with not nullable column" do <ide> assert_equal true, @john.remember_login <ide> end
3
Go
Go
camelize some snake_case variable names
a6da7f138c0b260d560c63e234c87db0f5c72bb1
<ide><path>auth/auth.go <ide> func LoadConfig(rootPath string) (*AuthConfig, error) { <ide> return nil, err <ide> } <ide> arr := strings.Split(string(b), "\n") <del> orig_auth := strings.Split(arr[0], " = ") <del> orig_email := strings.Split(arr[1], " = ") <del> authConfig, err := DecodeAuth(orig_auth[1]) <add> origAuth := strings.Split(arr[0], " = ") <add> origEmail := strings.Split(arr[1], " = ") <add> authConfig, err := DecodeAuth(origAuth[1]) <ide> if err != nil { <ide> return nil, err <ide> } <del> authConfig.Email = orig_email[1] <add> authConfig.Email = origEmail[1] <ide> authConfig.rootPath = rootPath <ide> return authConfig, nil <ide> } <ide><path>commands.go <ide> func (srv *Server) CmdImages(stdin io.ReadCloser, stdout io.Writer, args ...stri <ide> cmd := rcli.Subcmd(stdout, "images", "[OPTIONS] [NAME]", "List images") <ide> //limit := cmd.Int("l", 0, "Only show the N most recent versions of each image") <ide> quiet := cmd.Bool("q", false, "only show numeric IDs") <del> fl_a := cmd.Bool("a", false, "show all images") <add> flAll := cmd.Bool("a", false, "show all images") <ide> if err := cmd.Parse(args); err != nil { <ide> return nil <ide> } <ide> func (srv *Server) CmdImages(stdin io.ReadCloser, stdout io.Writer, args ...stri <ide> } <ide> var allImages map[string]*Image <ide> var err error <del> if *fl_a { <add> if *flAll { <ide> allImages, err = srv.runtime.graph.Map() <ide> } else { <ide> allImages, err = srv.runtime.graph.Heads() <ide> func (srv *Server) CmdPs(stdin io.ReadCloser, stdout io.Writer, args ...string) <ide> cmd := rcli.Subcmd(stdout, <ide> "ps", "[OPTIONS]", "List containers") <ide> quiet := cmd.Bool("q", false, "Only display numeric IDs") <del> fl_all := cmd.Bool("a", false, "Show all containers. Only running containers are shown by default.") <del> fl_full := cmd.Bool("notrunc", false, "Don't truncate output") <add> flAll := cmd.Bool("a", false, "Show all containers. Only running containers are shown by default.") <add> flFull := cmd.Bool("notrunc", false, "Don't truncate output") <ide> if err := cmd.Parse(args); err != nil { <ide> return nil <ide> } <ide> func (srv *Server) CmdPs(stdin io.ReadCloser, stdout io.Writer, args ...string) <ide> fmt.Fprintf(w, "ID\tIMAGE\tCOMMAND\tCREATED\tSTATUS\tCOMMENT\n") <ide> } <ide> for _, container := range srv.runtime.List() { <del> if !container.State.Running && !*fl_all { <add> if !container.State.Running && !*flAll { <ide> continue <ide> } <ide> if !*quiet { <ide> command := fmt.Sprintf("%s %s", container.Path, strings.Join(container.Args, " ")) <del> if !*fl_full { <add> if !*flFull { <ide> command = Trunc(command, 20) <ide> } <ide> for idx, field := range []string{ <ide> func (srv *Server) CmdCommit(stdin io.ReadCloser, stdout io.Writer, args ...stri <ide> cmd := rcli.Subcmd(stdout, <ide> "commit", "[OPTIONS] CONTAINER [REPOSITORY [TAG]]", <ide> "Create a new image from a container's changes") <del> fl_comment := cmd.String("m", "", "Commit message") <add> flComment := cmd.String("m", "", "Commit message") <ide> if err := cmd.Parse(args); err != nil { <ide> return nil <ide> } <ide> func (srv *Server) CmdCommit(stdin io.ReadCloser, stdout io.Writer, args ...stri <ide> cmd.Usage() <ide> return nil <ide> } <del> img, err := srv.runtime.Commit(containerName, repository, tag, *fl_comment) <add> img, err := srv.runtime.Commit(containerName, repository, tag, *flComment) <ide> if err != nil { <ide> return err <ide> } <ide> func (srv *Server) CmdLogs(stdin io.ReadCloser, stdout io.Writer, args ...string <ide> } <ide> name := cmd.Arg(0) <ide> if container := srv.runtime.Get(name); container != nil { <del> log_stdout, err := container.ReadLog("stdout") <add> logStdout, err := container.ReadLog("stdout") <ide> if err != nil { <ide> return err <ide> } <del> log_stderr, err := container.ReadLog("stderr") <add> logStderr, err := container.ReadLog("stderr") <ide> if err != nil { <ide> return err <ide> } <ide> // FIXME: Interpolate stdout and stderr instead of concatenating them <ide> // FIXME: Differentiate stdout and stderr in the remote protocol <del> if _, err := io.Copy(stdout, log_stdout); err != nil { <add> if _, err := io.Copy(stdout, logStdout); err != nil { <ide> return err <ide> } <del> if _, err := io.Copy(stdout, log_stderr); err != nil { <add> if _, err := io.Copy(stdout, logStderr); err != nil { <ide> return err <ide> } <ide> return nil <ide> func (srv *Server) CmdLogs(stdin io.ReadCloser, stdout io.Writer, args ...string <ide> <ide> func (srv *Server) CmdAttach(stdin io.ReadCloser, stdout io.Writer, args ...string) error { <ide> cmd := rcli.Subcmd(stdout, "attach", "[OPTIONS]", "Attach to a running container") <del> fl_i := cmd.Bool("i", false, "Attach to stdin") <del> fl_o := cmd.Bool("o", true, "Attach to stdout") <del> fl_e := cmd.Bool("e", true, "Attach to stderr") <add> flStdin := cmd.Bool("i", false, "Attach to stdin") <add> flStdout := cmd.Bool("o", true, "Attach to stdout") <add> flStderr := cmd.Bool("e", true, "Attach to stderr") <ide> if err := cmd.Parse(args); err != nil { <ide> return nil <ide> } <ide> func (srv *Server) CmdAttach(stdin io.ReadCloser, stdout io.Writer, args ...stri <ide> return errors.New("No such container: " + name) <ide> } <ide> var wg sync.WaitGroup <del> if *fl_i { <del> c_stdin, err := container.StdinPipe() <add> if *flStdin { <add> cStdin, err := container.StdinPipe() <ide> if err != nil { <ide> return err <ide> } <ide> wg.Add(1) <del> go func() { io.Copy(c_stdin, stdin); wg.Add(-1) }() <add> go func() { io.Copy(cStdin, stdin); wg.Add(-1) }() <ide> } <del> if *fl_o { <del> c_stdout, err := container.StdoutPipe() <add> if *flStdout { <add> cStdout, err := container.StdoutPipe() <ide> if err != nil { <ide> return err <ide> } <ide> wg.Add(1) <del> go func() { io.Copy(stdout, c_stdout); wg.Add(-1) }() <add> go func() { io.Copy(stdout, cStdout); wg.Add(-1) }() <ide> } <del> if *fl_e { <del> c_stderr, err := container.StderrPipe() <add> if *flStderr { <add> cStderr, err := container.StderrPipe() <ide> if err != nil { <ide> return err <ide> } <ide> wg.Add(1) <del> go func() { io.Copy(stdout, c_stderr); wg.Add(-1) }() <add> go func() { io.Copy(stdout, cStderr); wg.Add(-1) }() <ide> } <ide> wg.Wait() <ide> return nil <ide> func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string) <ide> } <ide> } <ide> if config.OpenStdin { <del> cmd_stdin, err := container.StdinPipe() <add> cmdStdin, err := container.StdinPipe() <ide> if err != nil { <ide> return err <ide> } <ide> if !config.Detach { <ide> Go(func() error { <del> _, err := io.Copy(cmd_stdin, stdin) <del> cmd_stdin.Close() <add> _, err := io.Copy(cmdStdin, stdin) <add> cmdStdin.Close() <ide> return err <ide> }) <ide> } <ide> } <ide> // Run the container <ide> if !config.Detach { <del> cmd_stderr, err := container.StderrPipe() <add> cmdStderr, err := container.StderrPipe() <ide> if err != nil { <ide> return err <ide> } <del> cmd_stdout, err := container.StdoutPipe() <add> cmdStdout, err := container.StdoutPipe() <ide> if err != nil { <ide> return err <ide> } <ide> if err := container.Start(); err != nil { <ide> return err <ide> } <del> sending_stdout := Go(func() error { <del> _, err := io.Copy(stdout, cmd_stdout) <add> sendingStdout := Go(func() error { <add> _, err := io.Copy(stdout, cmdStdout) <ide> return err <ide> }) <del> sending_stderr := Go(func() error { <del> _, err := io.Copy(stdout, cmd_stderr) <add> sendingStderr := Go(func() error { <add> _, err := io.Copy(stdout, cmdStderr) <ide> return err <ide> }) <del> err_sending_stdout := <-sending_stdout <del> err_sending_stderr := <-sending_stderr <del> if err_sending_stdout != nil { <del> return err_sending_stdout <add> errSendingStdout := <-sendingStdout <add> errSendingStderr := <-sendingStderr <add> if errSendingStdout != nil { <add> return errSendingStdout <ide> } <del> if err_sending_stderr != nil { <del> return err_sending_stderr <add> if errSendingStderr != nil { <add> return errSendingStderr <ide> } <ide> container.Wait() <ide> } else { <ide><path>container.go <ide> func ParseRun(args []string, stdout io.Writer) (*Config, error) { <ide> cmd.SetOutput(ioutil.Discard) <ide> } <ide> <del> fl_user := cmd.String("u", "", "Username or UID") <del> fl_detach := cmd.Bool("d", false, "Detached mode: leave the container running in the background") <del> fl_stdin := cmd.Bool("i", false, "Keep stdin open even if not attached") <del> fl_tty := cmd.Bool("t", false, "Allocate a pseudo-tty") <del> fl_memory := cmd.Int64("m", 0, "Memory limit (in bytes)") <del> var fl_ports ports <del> <del> cmd.Var(&fl_ports, "p", "Map a network port to the container") <del> var fl_env ListOpts <del> cmd.Var(&fl_env, "e", "Set environment variables") <add> flUser := cmd.String("u", "", "Username or UID") <add> flDetach := cmd.Bool("d", false, "Detached mode: leave the container running in the background") <add> flStdin := cmd.Bool("i", false, "Keep stdin open even if not attached") <add> flTty := cmd.Bool("t", false, "Allocate a pseudo-tty") <add> flMemory := cmd.Int64("m", 0, "Memory limit (in bytes)") <add> var flPorts ports <add> <add> cmd.Var(&flPorts, "p", "Map a network port to the container") <add> var flEnv ListOpts <add> cmd.Var(&flEnv, "e", "Set environment variables") <ide> if err := cmd.Parse(args); err != nil { <ide> return nil, err <ide> } <ide> func ParseRun(args []string, stdout io.Writer) (*Config, error) { <ide> runCmd = parsedArgs[1:] <ide> } <ide> config := &Config{ <del> Ports: fl_ports, <del> User: *fl_user, <del> Tty: *fl_tty, <del> OpenStdin: *fl_stdin, <del> Memory: *fl_memory, <del> Detach: *fl_detach, <del> Env: fl_env, <add> Ports: flPorts, <add> User: *flUser, <add> Tty: *flTty, <add> OpenStdin: *flStdin, <add> Memory: *flMemory, <add> Detach: *flDetach, <add> Env: flEnv, <ide> Cmd: runCmd, <ide> Image: image, <ide> } <ide> func (container *Container) generateLXCConfig() error { <ide> } <ide> <ide> func (container *Container) startPty() error { <del> stdout_master, stdout_slave, err := pty.Open() <add> stdoutMaster, stdoutSlave, err := pty.Open() <ide> if err != nil { <ide> return err <ide> } <del> container.cmd.Stdout = stdout_slave <add> container.cmd.Stdout = stdoutSlave <ide> <del> stderr_master, stderr_slave, err := pty.Open() <add> stderrMaster, stderrSlave, err := pty.Open() <ide> if err != nil { <ide> return err <ide> } <del> container.cmd.Stderr = stderr_slave <add> container.cmd.Stderr = stderrSlave <ide> <ide> // Copy the PTYs to our broadcasters <ide> go func() { <ide> defer container.stdout.Close() <del> io.Copy(container.stdout, stdout_master) <add> io.Copy(container.stdout, stdoutMaster) <ide> }() <ide> <ide> go func() { <ide> defer container.stderr.Close() <del> io.Copy(container.stderr, stderr_master) <add> io.Copy(container.stderr, stderrMaster) <ide> }() <ide> <ide> // stdin <del> var stdin_slave io.ReadCloser <add> var stdinSlave io.ReadCloser <ide> if container.Config.OpenStdin { <del> stdin_master, stdin_slave, err := pty.Open() <add> stdinMaster, stdinSlave, err := pty.Open() <ide> if err != nil { <ide> return err <ide> } <del> container.cmd.Stdin = stdin_slave <add> container.cmd.Stdin = stdinSlave <ide> // FIXME: The following appears to be broken. <ide> // "cannot set terminal process group (-1): Inappropriate ioctl for device" <ide> // container.cmd.SysProcAttr = &syscall.SysProcAttr{Setctty: true, Setsid: true} <ide> go func() { <ide> defer container.stdin.Close() <del> io.Copy(stdin_master, container.stdin) <add> io.Copy(stdinMaster, container.stdin) <ide> }() <ide> } <ide> if err := container.cmd.Start(); err != nil { <ide> return err <ide> } <del> stdout_slave.Close() <del> stderr_slave.Close() <del> if stdin_slave != nil { <del> stdin_slave.Close() <add> stdoutSlave.Close() <add> stderrSlave.Close() <add> if stdinSlave != nil { <add> stdinSlave.Close() <ide> } <ide> return nil <ide> } <ide><path>docker/docker.go <ide> func main() { <ide> return <ide> } <ide> // FIXME: Switch d and D ? (to be more sshd like) <del> fl_daemon := flag.Bool("d", false, "Daemon mode") <del> fl_debug := flag.Bool("D", false, "Debug mode") <add> flDaemon := flag.Bool("d", false, "Daemon mode") <add> flDebug := flag.Bool("D", false, "Debug mode") <ide> flag.Parse() <del> rcli.DEBUG_FLAG = *fl_debug <del> if *fl_daemon { <add> rcli.DEBUG_FLAG = *flDebug <add> if *flDaemon { <ide> if flag.NArg() != 0 { <ide> flag.Usage() <ide> return <ide> func runCommand(args []string) error { <ide> // closing the connection. <ide> // See http://code.google.com/p/go/issues/detail?id=3345 <ide> if conn, err := rcli.Call("tcp", "127.0.0.1:4242", args...); err == nil { <del> receive_stdout := docker.Go(func() error { <add> receiveStdout := docker.Go(func() error { <ide> _, err := io.Copy(os.Stdout, conn) <ide> return err <ide> }) <del> send_stdin := docker.Go(func() error { <add> sendStdin := docker.Go(func() error { <ide> _, err := io.Copy(conn, os.Stdin) <ide> if err := conn.CloseWrite(); err != nil { <ide> log.Printf("Couldn't send EOF: " + err.Error()) <ide> } <ide> return err <ide> }) <del> if err := <-receive_stdout; err != nil { <add> if err := <-receiveStdout; err != nil { <ide> return err <ide> } <ide> if !term.IsTerminal(0) { <del> if err := <-send_stdin; err != nil { <add> if err := <-sendStdin; err != nil { <ide> return err <ide> } <ide> } <ide><path>runtime.go <ide> func NewRuntime() (*Runtime, error) { <ide> } <ide> <ide> func NewRuntimeFromDirectory(root string) (*Runtime, error) { <del> runtime_repo := path.Join(root, "containers") <add> runtimeRepo := path.Join(root, "containers") <ide> <del> if err := os.MkdirAll(runtime_repo, 0700); err != nil && !os.IsExist(err) { <add> if err := os.MkdirAll(runtimeRepo, 0700); err != nil && !os.IsExist(err) { <ide> return nil, err <ide> } <ide> <ide> func NewRuntimeFromDirectory(root string) (*Runtime, error) { <ide> <ide> runtime := &Runtime{ <ide> root: root, <del> repository: runtime_repo, <add> repository: runtimeRepo, <ide> containers: list.New(), <ide> networkManager: netManager, <ide> graph: g, <ide><path>utils.go <ide> func Debugf(format string, a ...interface{}) { <ide> <ide> // Reader with progress bar <ide> type progressReader struct { <del> reader io.ReadCloser // Stream to read from <del> output io.Writer // Where to send progress bar to <del> read_total int // Expected stream length (bytes) <del> read_progress int // How much has been read so far (bytes) <del> last_update int // How many bytes read at least update <add> reader io.ReadCloser // Stream to read from <add> output io.Writer // Where to send progress bar to <add> readTotal int // Expected stream length (bytes) <add> readProgress int // How much has been read so far (bytes) <add> lastUpdate int // How many bytes read at least update <ide> } <ide> <ide> func (r *progressReader) Read(p []byte) (n int, err error) { <ide> read, err := io.ReadCloser(r.reader).Read(p) <del> r.read_progress += read <add> r.readProgress += read <ide> <ide> // Only update progress for every 1% read <del> update_every := int(0.01 * float64(r.read_total)) <del> if r.read_progress-r.last_update > update_every || r.read_progress == r.read_total { <add> updateEvery := int(0.01 * float64(r.readTotal)) <add> if r.readProgress-r.lastUpdate > updateEvery || r.readProgress == r.readTotal { <ide> fmt.Fprintf(r.output, "%d/%d (%.0f%%)\r", <del> r.read_progress, <del> r.read_total, <del> float64(r.read_progress)/float64(r.read_total)*100) <del> r.last_update = r.read_progress <add> r.readProgress, <add> r.readTotal, <add> float64(r.readProgress)/float64(r.readTotal)*100) <add> r.lastUpdate = r.readProgress <ide> } <ide> // Send newline when complete <ide> if err == io.EOF {
6
Javascript
Javascript
fix path to results.json
cdfb06e38b311f8869241bfd1623aeece80e18d0
<ide><path>dangerfile.js <ide> function git(args) { <ide> <ide> for (let i = 0; i < baseArtifactsInfo.length; i++) { <ide> const info = baseArtifactsInfo[i]; <del> if (info.path === 'home/circleci/project/scripts/results.json') { <add> if (info.path === 'home/circleci/project/scripts/rollup/results.json') { <ide> resultsResponse = await fetch(info.url); <add> break; <ide> } <ide> } <ide> } catch (error) {
1
Javascript
Javascript
remove unnecessary parameter for assertcrypto()
69674f4d3eb171024d2d6a3c5180f6ba1def6801
<ide><path>lib/_tls_legacy.js <ide> 'use strict'; <ide> <del>require('internal/util').assertCrypto(exports); <add>require('internal/util').assertCrypto(); <ide> <ide> const assert = require('assert'); <ide> const EventEmitter = require('events'); <ide><path>lib/_tls_wrap.js <ide> 'use strict'; <ide> <del>require('internal/util').assertCrypto(exports); <add>require('internal/util').assertCrypto(); <ide> <ide> const assert = require('assert'); <ide> const crypto = require('crypto'); <ide><path>lib/crypto.js <ide> 'use strict'; <ide> <ide> const internalUtil = require('internal/util'); <del>internalUtil.assertCrypto(exports); <add>internalUtil.assertCrypto(); <ide> <ide> exports.DEFAULT_ENCODING = 'buffer'; <ide> <ide><path>lib/https.js <ide> 'use strict'; <ide> <del>require('internal/util').assertCrypto(exports); <add>require('internal/util').assertCrypto(); <ide> <ide> const tls = require('tls'); <ide> const url = require('url'); <ide><path>lib/internal/util.js <ide> exports.objectToString = function objectToString(o) { <ide> }; <ide> <ide> const noCrypto = !process.versions.openssl; <del>exports.assertCrypto = function(exports) { <add>exports.assertCrypto = function() { <ide> if (noCrypto) <ide> throw new Error('Node.js is not compiled with openssl crypto support'); <ide> }; <ide><path>lib/tls.js <ide> 'use strict'; <ide> <ide> const internalUtil = require('internal/util'); <del>internalUtil.assertCrypto(exports); <add>internalUtil.assertCrypto(); <ide> <ide> const net = require('net'); <ide> const url = require('url');
6
PHP
PHP
fix namesapce in test
c9101668667c517bc1bdc5324283d4d4a3b159fa
<ide><path>tests/Testing/Console/RouteListCommandTest.php <ide> <?php <ide> <del>namespace Illuminate\Tests\Testing; <add>namespace Illuminate\Tests\Testing\Console; <ide> <ide> use Illuminate\Contracts\Routing\Registrar; <ide> use Illuminate\Foundation\Auth\User; <ide> public function testDisplayRoutesForCli() <ide> ->assertSuccessful() <ide> ->expectsOutput('') <ide> ->expectsOutput(' GET|HEAD closure ............................................... ') <del> ->expectsOutput(' POST controller-invokable Illuminate\Tests\Testing\FooContr…') <del> ->expectsOutput(' GET|HEAD controller-method/{user} Illuminate\Tests\Testing\FooC…') <add> ->expectsOutput(' POST controller-invokable Illuminate\Tests\Testing\Console\…') <add> ->expectsOutput(' GET|HEAD controller-method/{user} Illuminate\Tests\Testing\Cons…') <ide> ->expectsOutput(' GET|HEAD {account}.example.com/user/{id} ............. user.show') <ide> ->expectsOutput(''); <ide> } <ide> public function testDisplayRoutesForCliInVerboseMode() <ide> ->assertSuccessful() <ide> ->expectsOutput('') <ide> ->expectsOutput(' GET|HEAD closure ............................................... ') <del> ->expectsOutput(' POST controller-invokable Illuminate\\Tests\\Testing\\FooController') <del> ->expectsOutput(' GET|HEAD controller-method/{user} Illuminate\\Tests\\Testing\\FooController@show') <add> ->expectsOutput(' POST controller-invokable Illuminate\\Tests\\Testing\\Console\\FooController') <add> ->expectsOutput(' GET|HEAD controller-method/{user} Illuminate\\Tests\\Testing\\Console\\FooController@show') <ide> ->expectsOutput(' GET|HEAD {account}.example.com/user/{id} ............. user.show') <ide> ->expectsOutput(' ⇂ web') <ide> ->expectsOutput('');
1
Ruby
Ruby
add option to downgrade from llvm to gcc
14b3ea887a06a296d3c3c2cb48d7f06d302a94e5
<ide><path>Library/Homebrew/brewkit.rb <ide> def gcc_4_0_1 <ide> self['CC']='gcc-4.0' <ide> self['CXX']='g++-4.0' <ide> remove_from_cflags '-march=core2' <add> self.O3 <ide> end <ide> remove_from_cflags '-msse4.1' <ide> remove_from_cflags '-msse4.2' <ide> def O3 <ide> remove_from_cflags '-O4' <ide> append_to_cflags '-O3' <ide> end <add> def gcc_4_2 <add> # Sometimes you want to downgrade from LLVM to GCC 4.2 <add> self['CC']="gcc-4.2" <add> self['CXX']="g++-4.2" <add> self.O3 <add> end <ide> def osx_10_4 <ide> self['MACOSX_DEPLOYMENT_TARGET']=nil <ide> remove_from_cflags(/ ?-mmacosx-version-min=10\.\d/) <ide><path>Library/Homebrew/unittest.rb <ide> def self.fixture_data <ide> end <ide> @fixture_data <ide> end <add> <add> def test_ENV_options <add> ENV.gcc_4_0_1 <add> ENV.gcc_4_2 <add> ENV.O3 <add> ENV.minimal_optimization <add> ENV.no_optimization <add> ENV.libxml2 <add> ENV.x11 <add> ENV.enable_warnings <add> assert !ENV.cc.empty? <add> assert !ENV.cxx.empty? <add> end <ide> end <ide> <ide> __END__
2
Python
Python
update deprecation message
263369c559bf8e7f78390eacb07aafab2cec4a4a
<ide><path>numpy/lib/type_check.py <ide> def asscalar(a): <ide> """ <ide> <ide> # 2018-10-10, 1.16 <del> warnings.warn('np.asscalar(a) will be removed in v1.18 of numpy, use ' <add> warnings.warn('np.asscalar(a) is deprecated since NumPy v1.16, use ' <ide> 'a.item() instead', DeprecationWarning, stacklevel=1) <ide> return a.item() <ide>
1
Text
Text
match docs to actual port range used in code
d6f4b2ebb40ac79c3ba21e7196bba3b83124cf16
<ide><path>docs/sources/articles/networking.md <ide> page. There are two approaches. <ide> First, you can supply `-P` or `--publish-all=true|false` to `docker run` <ide> which is a blanket operation that identifies every port with an `EXPOSE` <ide> line in the image's `Dockerfile` and maps it to a host port somewhere in <del>the range 49000–49900. This tends to be a bit inconvenient, since you <add>the range 49153–65535. This tends to be a bit inconvenient, since you <ide> then have to run other `docker` sub-commands to learn which external <ide> port a given service was mapped to. <ide> <ide> More convenient is the `-p SPEC` or `--publish=SPEC` option which lets <ide> you be explicit about exactly which external port on the Docker server — <del>which can be any port at all, not just those in the 49000–49900 block — <add>which can be any port at all, not just those in the 49153-65535 block — <ide> you want mapped to which port in the container. <ide> <ide> Either way, you should be able to peek at what Docker has accomplished <ide><path>docs/sources/userguide/dockerlinks.md <ide> container that ran a Python Flask application: <ide> > information on Docker networking [here](/articles/networking/). <ide> <ide> When that container was created, the `-P` flag was used to automatically map any <del>network ports inside it to a random high port from the range 49000 <del>to 49900 on our Docker host. Next, when `docker ps` was run, you saw that <add>network ports inside it to a random high port from the range 49153 <add>to 65535 on our Docker host. Next, when `docker ps` was run, you saw that <ide> port 5000 in the container was bound to port 49155 on the host. <ide> <ide> $ sudo docker ps nostalgic_morse <ide><path>docs/sources/userguide/usingdocker.md <ide> port) on port 49155. <ide> <ide> Network port bindings are very configurable in Docker. In our last <ide> example the `-P` flag is a shortcut for `-p 5000` that maps port 5000 <del>inside the container to a high port (from the range 49000 to 49900) on <add>inside the container to a high port (from the range 49153 to 65535) on <ide> the local Docker host. We can also bind Docker containers to specific <ide> ports using the `-p` flag, for example: <ide>
3
Text
Text
fix newstate highlighting
80ab0df0bbdc025d2f68ba946ce2eb1263aa91a2
<ide><path>docs/basics/Reducers.md <ide> You'll often find that you need to store some data, as well as some UI state, in <ide> Now that we've decided what our state object looks like, we're ready to write a reducer for it. The reducer is a pure function that takes the previous state and an action, and returns the next state. <ide> <ide> ``` <del>(previousState, action) => newState <add>(previousState, action) => nextState <ide> ``` <ide> <ide> It's called a reducer because it's the type of function you would pass to [`Array.prototype.reduce(reducer, ?initialValue)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce). It's very important that the reducer stays pure. Things you should **never** do inside a reducer:
1
Text
Text
learn more about inflections[ci skip]
01aeee8a918a456524036175287a3afe0c3d009b
<ide><path>guides/source/active_support_core_extensions.md <ide> The method `pluralize` returns the plural of its receiver: <ide> "equipment".pluralize # => "equipment" <ide> ``` <ide> <del>As the previous example shows, Active Support knows some irregular plurals and uncountable nouns. Built-in rules can be extended in `config/initializers/inflections.rb`. That file is generated by the `rails` command and has instructions in comments. <add>As the previous example shows, Active Support knows some irregular plurals and uncountable nouns. Built-in rules can be extended in `config/initializers/inflections.rb`. This file is generated by default, by the `rails new` command and has instructions in comments. <ide> <ide> `pluralize` can also take an optional `count` parameter. If `count == 1` the singular form will be returned. For any other value of `count` the plural form will be returned: <ide>
1
Python
Python
remove unused guesswordsize function
0c8f13df8faa46714707581d97b237c0c4e6b157
<ide><path>tools/utils.py <ide> def GuessArchitecture(): <ide> return None <ide> <ide> <del>def GuessWordsize(): <del> if '64' in platform.machine(): <del> return '64' <del> else: <del> return '32' <del> <del> <ide> def IsWindows(): <ide> return GuessOS() == 'win32'
1
Text
Text
add a guide article for the elm architecture
6f4e23bf5557c093cb91f6c5feed7f005c014a84
<ide><path>client/src/pages/guide/english/elm/architecture/index.md <add>--- <add>title: Architecture <add>--- <add> <add>## Architecture <add> <add>The Elm architecture was the inspiration of the state-of-the-practice architecture in many web applications developed nowadays. It's based on some principles that are inherent to Elm itself, like immutability. The Elm architecture is sometimes referred to as MVU (Model-View-Update). You can read more about the Elm architecture in the [official language guide](https://guide.elm-lang.org/architecture/). Let's explore each of the elements in this definition: <add> <add>### Model <add> <add>The Model represents the **whole** state of the application, centralized as a single immutable piece of data. In the TodoMVC sample app, you would find in the Model not only the list of todos, but also the current state of the todo creation form and the view-filtering options. <add> <add>### View <add> <add>The View represents the user interface presented in the web browser. In Elm applications, there is a very important aspect of the View: it is a pure function that receives the Model as input. <add> <add>If you look at the type for the Elm elements in a web application, `Html.Html`, you'll notice it is a parameterized type (you'll usually see something like `Html a` or `Html Msg`). The type parameter here is used to tell the Elm compiler the return type of the event handlers for the elements, if any. We usually call this type Message, and Messages returned from event handlers are dispatched to the Update function much like Redux actions. <add> <add>### Update <add> <add>The Update part is another pure function. It receives the current Model and a dispatched Message, returning a new Model as a result. In more complex applications, the Update function can also return Commands, which represent side effects that may later result in more Messages being dispatched. <add> <add>### How all of this fits together <add> <add>The three elements mentioned above interact in a predictable way during all of the application's life cycle. The initialization of an Elm application receives as one of its arguments the initial state, which is a value of the Model type. Based on that, the first View render is computed and presented in the web browser. Whenever some user interaction or another side effect results in the dispatch of a Message, the Update function is called. If the resulting Model is different from the previous, the View function is called again. <ide><path>client/src/pages/guide/english/elm/index.md <ide> title: Elm <ide> --- <ide> ## Elm <ide> <del>Elm is a domain-specific, purely functional programming language that compiles into Javascript. This programming language is statically typed, and was developed with an emphasis on usability, performance, and robustness. Elm was built by Evan Czaplicki in 2012, and was influenced by Haskell, Standard ML, and OCaml among others. It also helped to inspire the popular state management tool, Redux. <ide>\ No newline at end of file <add>Elm is a domain-specific, purely functional programming language that compiles into Javascript. This programming language is statically typed, and was developed with an emphasis on usability, performance, and robustness. Elm was built by Evan Czaplicki in 2012, and was influenced by Haskell, Standard ML, and OCaml among others. It also helped to inspire the popular state management tool, Redux. <add> <add>Elm presents itself as a very opinionated solution to building web applications. This is clearly noticeable as it basically forces you to follow its prescribed [architecture](architecture). This is not a bad thing per se, and a significant upside of having to follow "the Elm way" is that it's a very consistent language: as you understand it more deeply, you become able to get productive when contributing to an Elm-based project very quickly.
2
Ruby
Ruby
eliminate some conditionals
bff89a2022aedec60929f6d6744eefc84a5c102a
<ide><path>activerecord/lib/active_record/relation/merger.rb <ide> def merged_wheres <ide> # Remove equalities from the existing relation with a LHS which is <ide> # present in the relation being merged in. <ide> def reject_overwrites(lhs_wheres, rhs_wheres) <del> seen = Set.new <del> rhs_wheres.each do |w| <del> seen << w.left if w.respond_to?(:operator) && w.operator == :== <add> nodes = rhs_wheres.find_all do |w| <add> w.respond_to?(:operator) && w.operator == :== <ide> end <add> seen = Set.new(nodes) { |node| node.left } <ide> <ide> lhs_wheres.reject do |w| <ide> w.respond_to?(:operator) && w.operator == :== && seen.include?(w.left)
1
Python
Python
fix adam import
13336a61970ebd37d31bfb8da1e4db7db951410a
<ide><path>spacy/_ml.py <ide> from thinc.neural.ops import NumpyOps, CupyOps <ide> from thinc.neural.util import get_array_module, copy_array <ide> from thinc.neural._lsuv import svd_orthonormal <add>from thinc.neural.optimizers import Adam <ide> <ide> from thinc import describe <ide> from thinc.describe import Dimension, Synapses, Biases, Gradient <ide> from thinc.neural._classes.affine import _set_dimensions_if_needed <ide> import thinc.extra.load_nlp <del>from thinc.neural._lsuv import svd_orthonormal <ide> <ide> from .attrs import ID, ORTH, LOWER, NORM, PREFIX, SUFFIX, SHAPE <ide> from . import util <ide> def create_default_optimizer(ops, **cfg): <ide> optimizer = Adam(ops, learn_rate, L2=L2, beta1=beta1, <ide> beta2=beta2, eps=eps) <ide> optimizer.max_grad_norm = max_grad_norm <del> optimizer.device = device <add> optimizer.device = ops.device <ide> return optimizer <ide> <ide> @layerize
1
Go
Go
remove usage of listenbuffer package
ca5795cef810c85f101eb0aa3efe3ec8d756490b
<ide><path>api/server/server.go <ide> type Config struct { <ide> // Server contains instance details for the server <ide> type Server struct { <ide> cfg *Config <del> start chan struct{} <ide> servers []*HTTPServer <ide> routers []router.Router <ide> } <ide> type Addr struct { <ide> // It allocates resources which will be needed for ServeAPI(ports, unix-sockets). <ide> func New(cfg *Config) (*Server, error) { <ide> s := &Server{ <del> cfg: cfg, <del> start: make(chan struct{}), <add> cfg: cfg, <ide> } <ide> for _, addr := range cfg.Addrs { <ide> srv, err := s.newServer(addr.Proto, addr.Addr) <ide> func (s *Server) initTCPSocket(addr string) (l net.Listener, err error) { <ide> if s.cfg.TLSConfig == nil || s.cfg.TLSConfig.ClientAuth != tls.RequireAndVerifyClientCert { <ide> logrus.Warn("/!\\ DON'T BIND ON ANY IP ADDRESS WITHOUT setting -tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING /!\\") <ide> } <del> if l, err = sockets.NewTCPSocket(addr, s.cfg.TLSConfig, s.start); err != nil { <add> if l, err = sockets.NewTCPSocket(addr, s.cfg.TLSConfig); err != nil { <ide> return nil, err <ide> } <ide> if err := allocateDaemonPort(addr); err != nil { <ide> func (s *Server) CreateMux() *mux.Router { <ide> <ide> return m <ide> } <del> <del>// AcceptConnections allows clients to connect to the API server. <del>// Referenced Daemon is notified about this server, and waits for the <del>// daemon acknowledgement before the incoming connections are accepted. <del>func (s *Server) AcceptConnections() { <del> // close the lock so the listeners start accepting connections <del> select { <del> case <-s.start: <del> default: <del> close(s.start) <del> } <del>} <ide><path>api/server/server_unix.go <ide> func (s *Server) newServer(proto, addr string) ([]*HTTPServer, error) { <ide> } <ide> ls = append(ls, l) <ide> case "unix": <del> l, err := sockets.NewUnixSocket(addr, s.cfg.SocketGroup, s.start) <add> l, err := sockets.NewUnixSocket(addr, s.cfg.SocketGroup) <ide> if err != nil { <ide> return nil, err <ide> } <ide><path>docker/daemon.go <ide> func (cli *DaemonCli) CmdDaemon(args ...string) error { <ide> } <ide> }) <ide> <del> // after the daemon is done setting up we can tell the api to start <del> // accepting connections with specified daemon <add> // after the daemon is done setting up we can notify systemd api <ide> notifySystem() <del> api.AcceptConnections() <ide> <ide> // Daemon is fully initialized and handling API traffic <ide> // Wait for serve API to complete <ide><path>pkg/sockets/tcp_socket.go <ide> import ( <ide> "net" <ide> "net/http" <ide> "time" <del> <del> "github.com/docker/docker/pkg/listenbuffer" <ide> ) <ide> <ide> // NewTCPSocket creates a TCP socket listener with the specified address and <ide> // and the specified tls configuration. If TLSConfig is set, will encapsulate the <ide> // TCP listener inside a TLS one. <del>// The channel passed is used to activate the listenbuffer when the caller is ready <del>// to accept connections. <del>func NewTCPSocket(addr string, tlsConfig *tls.Config, activate <-chan struct{}) (net.Listener, error) { <del> l, err := listenbuffer.NewListenBuffer("tcp", addr, activate) <add>func NewTCPSocket(addr string, tlsConfig *tls.Config) (net.Listener, error) { <add> l, err := net.Listen("tcp", addr) <ide> if err != nil { <ide> return nil, err <ide> } <ide><path>pkg/sockets/unix_socket.go <ide> import ( <ide> "syscall" <ide> <ide> "github.com/Sirupsen/logrus" <del> "github.com/docker/docker/pkg/listenbuffer" <ide> "github.com/opencontainers/runc/libcontainer/user" <ide> ) <ide> <ide> // NewUnixSocket creates a unix socket with the specified path and group. <del>// The channel passed is used to activate the listenbuffer when the caller is ready <del>// to accept connections. <del>func NewUnixSocket(path, group string, activate <-chan struct{}) (net.Listener, error) { <add>func NewUnixSocket(path, group string) (net.Listener, error) { <ide> if err := syscall.Unlink(path); err != nil && !os.IsNotExist(err) { <ide> return nil, err <ide> } <ide> mask := syscall.Umask(0777) <ide> defer syscall.Umask(mask) <del> l, err := listenbuffer.NewListenBuffer("unix", path, activate) <add> l, err := net.Listen("unix", path) <ide> if err != nil { <ide> return nil, err <ide> }
5
PHP
PHP
add a success notification to password remind
d7bed9ed1560d52dbe947482ee9a9859cfc51843
<ide><path>src/Illuminate/Auth/Reminders/PasswordBroker.php <ide> public function remind(array $credentials, Closure $callback = null) <ide> <ide> $this->sendReminder($user, $token, $callback); <ide> <del> return $this->redirect->refresh(); <add> return $this->redirect->refresh()->with('success', true); <ide> } <ide> <ide> /**
1
Ruby
Ruby
remove libpng and freetype blacklist
f15bef5831f6b57090a012974129a49bffb9a1a7
<ide><path>Library/Homebrew/blacklist.rb <ide> def blacklisted? name <ide> However not all build scripts look for these hard enough, so you may need <ide> to call ENV.libxml2 in your formula's install function. <ide> EOS <del> when 'freetype', 'libpng' then <<-EOS.undent <del> Apple distributed #{name} with OS X until 10.8. It is also distributed <del> as part of XQuartz. You can find the XQuartz installer here: <del> http://xquartz.macosforge.org <del> EOS <ide> when 'wxwidgets' then <<-EOS.undent <ide> An old version of wxWidgets can be found in /usr/X11/lib. However, Homebrew <ide> does provide a newer version:
1
PHP
PHP
simplify usage of parsedsn
953b72c9c3c8151e4a923dd048007adafbac0c3f
<ide><path>src/Cache/Cache.php <ide> */ <ide> class Cache { <ide> <del> use StaticConfigTrait { <del> parseDsn as protected _parseDsn; <del> } <add> use StaticConfigTrait; <ide> <ide> /** <ide> * Flag for tracking whether or not caching is enabled. <ide> public static function remember($key, $callable, $config = 'default') { <ide> return $results; <ide> } <ide> <del>/** <del> * Parses a DSN into a valid connection configuration <del> * <del> * This method allows setting a DSN using PEAR::DB formatting, with added support for drivers <del> * in the SQLAlchemy format. The following is an example of its usage: <del> * <del> * {{{ <del> * $dsn = 'File:///'; <del> * $config = Cache::parseDsn($dsn); <del> * <del> * $dsn = 'File://?prefix=myapp_cake_core_&serialize=true&duration=+2 minutes&path=/tmp/persistent/'; <del> * $config = Cache::parseDsn($dsn); <del> * }} <del> * <del> * If an array is given, the parsed DSN will be merged into this array. Note that querystring <del> * arguments are also parsed and set as values in the returned configuration. <del> * <del> * @param array $config An array with a `url` key mapping to a string DSN <del> * @return mixed null when adding configuration and an array of configuration data when reading. <del> */ <del> public static function parseDsn($config = null) { <del> $config = static::_parseDsn($config); <del> <del> if (isset($config['scheme'])) { <del> $config['className'] = $config['scheme']; <del> } <del> <del> unset($config['scheme']); <del> return $config; <del> } <del> <ide> } <ide><path>src/Core/StaticConfigTrait.php <ide> public static function configured() { <ide> /** <ide> * Parses a DSN into a valid connection configuration <ide> * <del> * This method allows setting a DSN using PEAR::DB formatting, with added support for drivers <del> * in the SQLAlchemy format. The following is an example of its usage: <add> * This method allows setting a DSN using formatting similar to that used by PEAR::DB. <add> * The following is an example of its usage: <ide> * <ide> * {{{ <del> * $dsn = 'mysql+Cake\Database\Driver\Mysql://user:password@localhost:3306/database_name'; <del> * $config = ConnectionManager::parseDsn($dsn); <add> * $dsn = 'Cake\Database\Driver\Mysql://localhost/database?className=Cake\Database\Connection'; <add> * $config = ConnectionManager::parseDsn($dsn); <add> * <add> * $dsn = 'Cake\Database\Driver\Mysql://localhost:3306/database?className=Cake\Database\Connection'; <add> * $config = ConnectionManager::parseDsn($dsn); <add> * <add> * $dsn = 'Cake\Database\Connection://localhost:3306/database?driver=Cake\Database\Driver\Mysql'; <add> * $config = ConnectionManager::parseDsn($dsn); <add> * <add> * $dsn = 'Cake\Log\Engine\FileLog://?types=notice,info,debug&file=debug&path=LOGS'; <add> * $config = Log::parseDsn($dsn); <add> * <add> * $dsn = 'Mail://user:secret@localhost:25?timeout=30&client=null&tls=null'; <add> * $config = Email::parseDsn($dsn); <add> * <add> * $dsn = 'File:///'; <add> * $config = Cache::parseDsn($dsn); <add> * <add> * $dsn = 'File://?prefix=myapp_cake_core_&serialize=true&duration=+2 minutes&path=/tmp/persistent/'; <add> * $config = Cache::parseDsn($dsn); <add> * <ide> * }} <ide> * <del> * If an array is given, the parsed DSN will be merged into this array. Note that querystring <del> * arguments are also parsed and set as values in the returned configuration. <add> * For all classes, the value of `scheme` is set as the value of both the `className` and `driver` <add> * unless they have been otherwise specified. <add> * <add> * Note that querystring arguments are also parsed and set as values in the returned configuration. <ide> * <ide> * @param array $config An array with a `url` key mapping to a string DSN <ide> * @return mixed null when adding configuration and an array of configuration data when reading. <ide> public static function parseDsn($config = null) { <ide> $dsn = $config['url']; <ide> unset($config['url']); <ide> <del> if (preg_match("/^([\w]+)\+([\w\\\]+)/", $dsn, $matches)) { <del> $scheme = $matches[1]; <del> $driver = $matches[2]; <del> $dsn = preg_replace("/^([\w]+)\+([\w\\\]+)/", $scheme, $dsn); <del> } elseif (preg_match("/^([\w\\\]+)/", $dsn, $matches)) { <del> $scheme = explode('\\', $matches[1]); <add> if (preg_match('/^([\w\\]+)/', $dsn, $matches)) { <add> $scheme = explode('\\', $matches[2]); <ide> $scheme = array_pop($scheme); <del> $driver = $matches[1]; <del> $dsn = preg_replace("/^([\w\\\]+)/", $scheme, $dsn); <add> $driver = $matches[2]; <add> $dsn = preg_replace('/^([\w\\]+)/', $scheme, $dsn); <ide> } <ide> <ide> $parsed = parse_url($dsn); <ide> public static function parseDsn($config = null) { <ide> <ide> parse_str($query, $queryArgs); <ide> <del> if ($driver !== null) { <del> $queryArgs['driver'] = $driver; <del> } <del> <ide> if (isset($parsed['user'])) { <ide> $parsed['username'] = $parsed['user']; <ide> } <del> <ide> if (isset($parsed['pass'])) { <ide> $parsed['password'] = $parsed['pass']; <ide> } <ide> <ide> unset($config['user'], $config['pass']); <ide> $config = array_merge($queryArgs, $parsed, $config); <ide> <add> if ($driver !== null) { <add> if (!isset($config['driver'])) { <add> $config['driver'] = $driver; <add> } <add> <add> if (!isset($config['className'])) { <add> $config['className'] = $driver; <add> } <add> } <add> <ide> foreach ($config as $key => $value) { <ide> if ($value === 'true') { <ide> $config[$key] = true; <ide><path>src/Datasource/ConnectionManager.php <ide> public static function config($key, $config = null) { <ide> /** <ide> * Parses a DSN into a valid connection configuration <ide> * <del> * This method allows setting a DSN using PEAR::DB formatting, with added support for drivers <del> * in the SQLAlchemy format. The following is an example of its usage: <add> * This method allows setting a DSN using formatting similar to that used by PEAR::DB. <add> * The following is an example of its usage: <ide> * <ide> * {{{ <del> * $dsn = 'mysql+Cake\Database\Driver\Mysql://user:password@localhost:3306/database_name'; <del> * $config = ConnectionManager::parseDsn($dsn); <add> * $dsn = 'Cake\Database\Driver\Mysql://localhost/database?className=Cake\Database\Connection'; <add> * $config = ConnectionManager::parseDsn($dsn); <add> * <add> * $dsn = 'Cake\Database\Driver\Mysql://localhost:3306/database?className=Cake\Database\Connection'; <add> * $config = ConnectionManager::parseDsn($dsn); <add> * <add> * $dsn = 'Cake\Database\Connection://localhost:3306/database?driver=Cake\Database\Driver\Mysql'; <add> * $config = ConnectionManager::parseDsn($dsn); <ide> * }} <ide> * <del> * If an array is given, the parsed DSN will be merged into this array. Note that querystring <del> * arguments are also parsed and set as values in the returned configuration. <add> * For all classes, the value of `scheme` is set as the value of both the `className` and `driver` <add> * unless they have been otherwise specified. <add> * <add> * Note that querystring arguments are also parsed and set as values in the returned configuration. <ide> * <ide> * @param array $config An array with a `url` key mapping to a string DSN <ide> * @return mixed null when adding configuration and an array of configuration data when reading. <ide><path>src/Log/Log.php <ide> class Log { <ide> <ide> use StaticConfigTrait { <ide> config as protected _config; <del> parseDsn as protected _parseDsn; <ide> } <ide> <ide> /** <ide> public static function config($key, $config = null) { <ide> static::$_dirtyConfig = true; <ide> } <ide> <del>/** <del> * Parses a DSN into a valid connection configuration <del> * <del> * This method allows setting a DSN using PEAR::DB formatting, with added support for drivers <del> * in the SQLAlchemy format. The following is an example of its usage: <del> * <del> * {{{ <del> * $dsn = 'Cake\Log\Engine\FileLog://?types=notice,info,debug&file=debug&path=LOGS'; <del> * $config = Log::parseDsn($dsn); <del> * }} <del> * <del> * If an array is given, the parsed DSN will be merged into this array. Note that querystring <del> * arguments are also parsed and set as values in the returned configuration. <del> * <del> * @param array $config An array with a `url` key mapping to a string DSN <del> * @return mixed null when adding configuration and an array of configuration data when reading. <del> */ <del> public static function parseDsn($config = null) { <del> $config = static::_parseDsn($config); <del> <del> if (isset($config['driver'])) { <del> $config['className'] = $config['driver']; <del> } <del> <del> unset($config['driver']); <del> return $config; <del> } <del> <ide> /** <ide> * Get a logging engine. <ide> * <ide><path>src/Network/Email/Email.php <ide> */ <ide> class Email { <ide> <del> use StaticConfigTrait { <del> parseDsn as protected _parseDsn; <del> } <add> use StaticConfigTrait; <ide> <ide> /** <ide> * Default X-Mailer <ide> public static function dropTransport($key) { <ide> unset(static::$_transportConfig[$key]); <ide> } <ide> <del>/** <del> * Parses a DSN into a valid connection configuration <del> * <del> * This method allows setting a DSN using PEAR::DB formatting, with added support for drivers <del> * in the SQLAlchemy format. The following is an example of its usage: <del> * <del> * {{{ <del> * $dsn = 'mail://user:secret@localhost:25?timeout=30&client=null&tls=null'; <del> * $config = Email::parseDsn($dsn); <del> * }} <del> * <del> * If an array is given, the parsed DSN will be merged into this array. Note that querystring <del> * arguments are also parsed and set as values in the returned configuration. <del> * <del> * @param array $config An array with a `url` key mapping to a string DSN <del> * @return mixed null when adding configuration and an array of configuration data when reading. <del> */ <del> public static function parseDsn($config = null) { <del> $config = static::_parseDsn($config); <del> <del> if (isset($config['scheme'])) { <del> $config['className'] = $config['scheme']; <del> } <del> <del> unset($config['scheme']); <del> return $config; <del> } <del> <ide> /** <ide> * Get/Set the configuration profile to use for this instance. <ide> *
5
Javascript
Javascript
avoid jqlite/jquery for upward dom traversal
c966876e571133184db0c0fdce4d9501589a7322
<ide><path>src/ngAnimate/animateQueue.js <ide> var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) { <ide> parentElement = parentHost; <ide> } <ide> <del> while (parentElement && parentElement.length) { <add> parentElement = getDomNode(parentElement); <add> <add> while (parentElement) { <ide> if (!rootElementDetected) { <ide> // angular doesn't want to attempt to animate elements outside of the application <ide> // therefore we need to ensure that the rootElement is an ancestor of the current element <ide> rootElementDetected = isMatchingElement(parentElement, $rootElement); <ide> } <ide> <del> var parentNode = parentElement[0]; <del> if (parentNode.nodeType !== ELEMENT_NODE) { <add> if (parentElement.nodeType !== ELEMENT_NODE) { <ide> // no point in inspecting the #document element <ide> break; <ide> } <ide> <del> var details = activeAnimationsLookup.get(parentNode) || {}; <add> var details = activeAnimationsLookup.get(parentElement) || {}; <ide> // either an enter, leave or move animation will commence <ide> // therefore we can't allow any animations to take place <ide> // but if a parent animation is class-based then that's ok <ide> if (!parentAnimationDetected) { <del> var parentElementDisabled = disabledElementsLookup.get(parentNode); <add> var parentElementDisabled = disabledElementsLookup.get(parentElement); <ide> <ide> if (parentElementDisabled === true && elementDisabled !== false) { <ide> // disable animations if the user hasn't explicitly enabled animations on the <ide> var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) { <ide> } <ide> <ide> if (isUndefined(animateChildren) || animateChildren === true) { <del> var value = jqLite.data(parentElement[0], NG_ANIMATE_CHILDREN_DATA); <add> var value = jqLite.data(parentElement, NG_ANIMATE_CHILDREN_DATA); <ide> if (isDefined(value)) { <ide> animateChildren = value; <ide> } <ide> var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) { <ide> <ide> if (!rootElementDetected) { <ide> // If no rootElement is detected, check if the parentElement is pinned to another element <del> parentHost = jqLite.data(parentElement[0], NG_ANIMATE_PIN_DATA); <add> parentHost = jqLite.data(parentElement, NG_ANIMATE_PIN_DATA); <ide> if (parentHost) { <ide> // The pin target element becomes the next parent element <del> parentElement = parentHost; <add> parentElement = getDomNode(parentHost); <ide> continue; <ide> } <ide> } <ide> <del> parentElement = parentElement.parent(); <add> parentElement = parentElement.parentNode; <ide> } <ide> <ide> var allowAnimation = (!parentAnimationDetected || animateChildren) && elementDisabled !== true;
1
Text
Text
add myles borins to release team
c22fe92c672e2d0e7cd04ff2c91df63764df7513
<ide><path>README.md <ide> Releases of Node.js and io.js will be signed with one of the following GPG keys: <ide> * **Jeremiah Senkpiel** &lt;fishrock@keybase.io&gt; `FD3A5288F042B6850C66B31F09FE44734EB7990E` <ide> * **James M Snell** &lt;jasnell@keybase.io&gt; `71DCFD284A79C3B38668286BC97EC7A07EDE3FC1` <ide> * **Rod Vagg** &lt;rod@vagg.org&gt; `DD8F2338BAE7501E3DD5AC78C273792F7D83545D` <add>* **Myles Borins** &lt;thealphanerd@keybase.io&gt; `792807C150954BF0299B289A38CE40DEEE898E15` <ide> <ide> The full set of trusted release keys can be imported by running: <ide> <ide> gpg --keyserver pool.sks-keyservers.net --recv-keys 0034A06D9D9B0064CE8ADF6BF174 <ide> gpg --keyserver pool.sks-keyservers.net --recv-keys FD3A5288F042B6850C66B31F09FE44734EB7990E <ide> gpg --keyserver pool.sks-keyservers.net --recv-keys 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 <ide> gpg --keyserver pool.sks-keyservers.net --recv-keys DD8F2338BAE7501E3DD5AC78C273792F7D83545D <add>gpg --keyserver pool.sks-keyservers.net --recv-keys 792807C150954BF0299B289A38CE40DEEE898E15 <ide> ``` <ide> <ide> See the section above on [Verifying Binaries](#verifying-binaries) for
1
Javascript
Javascript
fix controller specific animations
d8ecf8bae5cb88f94c9efad26a91a916a3192fa1
<ide><path>src/core/core.config.js <ide> export default class Config { <ide> */ <ide> datasetScopeKeys(datasetType) { <ide> return cachedKeys(datasetType, <del> () => [`datasets.${datasetType}`, `controllers.${datasetType}.datasets`, '']); <add> () => [ <add> `datasets.${datasetType}`, <add> `controllers.${datasetType}`, <add> `controllers.${datasetType}.datasets`, <add> '' <add> ]); <ide> } <ide> <ide> /** <ide> export default class Config { <ide> return cachedKeys(`${datasetType}.animation`, <ide> () => [ <ide> `datasets.${datasetType}.animation`, <add> `controllers.${datasetType}.animation`, <ide> `controllers.${datasetType}.datasets.animation`, <ide> 'animation' <ide> ]);
1
Javascript
Javascript
add night mode to learn
2312d5e82e96475d39bdf720972f715dc6d3516b
<ide><path>packages/learn/src/layouts/index.js <ide> import ga from '../analytics'; <ide> <ide> import Header from '../components/Header'; <ide> import DonationModal from '../components/Donation'; <del>import { fetchUser } from '../redux/app'; <add>import { fetchUser, userSelector } from '../redux/app'; <ide> <ide> import 'prismjs/themes/prism.css'; <ide> import 'react-reflex/styles.css'; <ide> import './global.css'; <ide> import './layout.css'; <add>import { createSelector } from 'reselect'; <ide> <ide> const metaKeywords = [ <ide> 'javascript', <ide> const metaKeywords = [ <ide> 'programming' <ide> ]; <ide> <del>const mapStateToProps = () => ({}); <add>const mapStateToProps = createSelector( <add> userSelector, <add> ({ theme = 'default' }) => ({ theme }) <add>); <ide> const mapDispatchToProps = dispatch => <ide> bindActionCreators({ fetchUser }, dispatch); <ide> <ide> const propTypes = { <ide> children: PropTypes.func, <del> fetchUser: PropTypes.func.isRequired <add> fetchUser: PropTypes.func.isRequired, <add> theme: PropTypes.string <ide> }; <ide> <ide> class Layout extends PureComponent { <ide> class Layout extends PureComponent { <ide> } <ide> } <ide> render() { <del> const { children } = this.props; <add> const { children, theme } = this.props; <ide> return ( <ide> <Fragment> <ide> <Helmet <ide> class Layout extends PureComponent { <ide> ]} <ide> /> <ide> <Header /> <del> <div className='app-wrapper'> <add> <div className={'app-wrapper ' + theme}> <ide> <main>{children()}</main> <ide> </div> <ide> <DonationModal />
1
Ruby
Ruby
warn developers when uninstalling a dependency
3c310b2e3dd7805b04f48507c65c2c0a856c2aa2
<ide><path>Library/Homebrew/cmd/uninstall.rb <ide> def uninstall <ide> ARGV.kegs.group_by(&:rack) <ide> end <ide> <del> if should_check_for_dependents? <del> all_kegs = kegs_by_rack.values.flatten(1) <del> return if check_for_dependents all_kegs <del> end <add> handle_unsatisfied_dependents(kegs_by_rack) <add> return if Homebrew.failed? <ide> <ide> kegs_by_rack.each do |rack, kegs| <ide> if ARGV.force? <ide> def uninstall <ide> end <ide> end <ide> <del> def should_check_for_dependents? <del> # --ignore-dependencies, to be consistent with install <del> return false if ARGV.include?("--ignore-dependencies") <del> return false if ARGV.homebrew_developer? <del> true <add> def handle_unsatisfied_dependents(kegs_by_rack) <add> return if ARGV.include?("--ignore-dependencies") <add> <add> all_kegs = kegs_by_rack.values.flatten(1) <add> check_for_dependents all_kegs <ide> end <ide> <ide> def check_for_dependents(kegs) <ide> return false unless result = Keg.find_some_installed_dependents(kegs) <ide> <del> requireds, dependents = result <add> if ARGV.homebrew_developer? <add> dependents_output_for_developers(*result) <add> else <add> dependents_output_for_nondevelopers(*result) <add> end <add> <add> true <add> end <ide> <add> def dependents_output_for_developers(requireds, dependents) <add> msg = requireds.join(", ") <add> msg << (requireds.count == 1 ? " is" : " are") <add> msg << " required by #{dependents.join(", ")}, which " <add> msg << (dependents.count == 1 ? "is" : "are") <add> msg << " currently installed." <add> msg << "\nYou can silence this warning with " <add> msg << "`brew uninstall --ignore-dependencies " <add> msg << "#{requireds.map(&:name).join(" ")}`." <add> opoo msg <add> end <add> <add> def dependents_output_for_nondevelopers(requireds, dependents) <ide> msg = "Refusing to uninstall #{requireds.join(", ")} because " <ide> msg << (requireds.count == 1 ? "it is" : "they are") <ide> msg << " required by #{dependents.join(", ")}, which " <ide> msg << (dependents.count == 1 ? "is" : "are") <ide> msg << " currently installed." <add> msg << "\nYou can override this and force removal with " <add> msg << "`brew uninstall --ignore-dependencies " <add> msg << "#{requireds.map(&:name).join(" ")}`." <ide> ofail msg <del> print "You can override this and force removal with " <del> puts "`brew uninstall --ignore-dependencies #{requireds.map(&:name).join(" ")}`." <del> <del> true <ide> end <ide> <ide> def rm_pin(rack) <ide><path>Library/Homebrew/test/test_uninstall.rb <ide> require "cmd/uninstall" <ide> <ide> class UninstallTests < Homebrew::TestCase <add> def setup <add> @dependency = formula("dependency") { url "f-1" } <add> @dependent = formula("dependent") do <add> url "f-1" <add> depends_on "dependency" <add> end <add> <add> [@dependency, @dependent].each { |f| f.installed_prefix.mkpath } <add> <add> tab = Tab.empty <add> tab.tabfile = @dependent.installed_prefix/Tab::FILENAME <add> tab.runtime_dependencies = [ <add> { "full_name" => "dependency", "version" => "1" }, <add> ] <add> tab.write <add> <add> stub_formula_loader @dependency <add> stub_formula_loader @dependent <add> end <add> <add> def teardown <add> Homebrew.failed = false <add> [@dependency, @dependent].each { |f| f.rack.rmtree } <add> end <add> <add> def handle_unsatisfied_dependents <add> capture_stderr do <add> opts = { @dependency.rack => [Keg.new(@dependency.installed_prefix)] } <add> Homebrew.handle_unsatisfied_dependents(opts) <add> end <add> end <add> <ide> def test_check_for_testball_f2s_when_developer <del> refute_predicate Homebrew, :should_check_for_dependents? <add> assert_match "Warning", handle_unsatisfied_dependents <add> refute_predicate Homebrew, :failed? <ide> end <ide> <ide> def test_check_for_dependents_when_not_developer <ide> run_as_not_developer do <del> assert_predicate Homebrew, :should_check_for_dependents? <add> assert_match "Error", handle_unsatisfied_dependents <add> assert_predicate Homebrew, :failed? <ide> end <ide> end <ide> <ide> def test_check_for_dependents_when_ignore_dependencies <ide> ARGV << "--ignore-dependencies" <ide> run_as_not_developer do <del> refute_predicate Homebrew, :should_check_for_dependents? <add> assert_empty handle_unsatisfied_dependents <add> refute_predicate Homebrew, :failed? <ide> end <ide> ensure <ide> ARGV.delete("--ignore-dependencies") <ide><path>Library/Homebrew/test/test_utils.rb <ide> def test_gzip <ide> end <ide> end <ide> <add> def test_capture_stderr <add> assert_equal "test\n", capture_stderr { $stderr.puts "test" } <add> end <add> <ide> def test_shell_profile <ide> ENV["SHELL"] = "/bin/sh" <ide> assert_equal "~/.bash_profile", Utils::Shell.shell_profile <ide><path>Library/Homebrew/utils.rb <ide> def ignore_interrupts(opt = nil) <ide> trap("INT", std_trap) <ide> end <ide> <add>def capture_stderr <add> old, $stderr = $stderr, StringIO.new <add> yield <add> $stderr.string <add>ensure <add> $stderr = old <add>end <add> <ide> def nostdout <ide> if ARGV.verbose? <ide> yield
4
Java
Java
add more tracing to startup
45636ed7f4bb584f650cd1a3c4d6c6463bcab633
<ide><path>ReactAndroid/src/main/java/com/facebook/react/XReactInstanceManagerImpl.java <ide> import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_PACKAGES_START; <ide> import static com.facebook.react.bridge.ReactMarkerConstants.RUN_JS_BUNDLE_END; <ide> import static com.facebook.react.bridge.ReactMarkerConstants.RUN_JS_BUNDLE_START; <add>import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE; <ide> <ide> /** <ide> * This class is managing instances of {@link CatalystInstance}. It expose a way to configure <ide> public void detachRootView(ReactRootView rootView) { <ide> @Override <ide> public List<ViewManager> createAllViewManagers( <ide> ReactApplicationContext catalystApplicationContext) { <del> Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "createAllViewManagers"); <add> Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createAllViewManagers"); <ide> try { <ide> List<ViewManager> allViewManagers = new ArrayList<>(); <ide> for (ReactPackage reactPackage : mPackages) { <ide> allViewManagers.addAll(reactPackage.createViewManagers(catalystApplicationContext)); <ide> } <ide> return allViewManagers; <ide> } finally { <del> Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); <add> Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); <ide> } <ide> } <ide> <ide> private void recreateReactContextInBackground( <ide> } <ide> <ide> private void setupReactContext(ReactApplicationContext reactContext) { <add> Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "setupReactContext"); <ide> UiThreadUtil.assertOnUiThread(); <ide> Assertions.assertCondition(mCurrentReactContext == null); <ide> mCurrentReactContext = Assertions.assertNotNull(reactContext); <ide> private void setupReactContext(ReactApplicationContext reactContext) { <ide> for (ReactInstanceEventListener listener : listeners) { <ide> listener.onReactContextInitialized(reactContext); <ide> } <add> Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); <ide> } <ide> <ide> private void attachMeasuredRootViewToInstance( <ide> ReactRootView rootView, <ide> CatalystInstance catalystInstance) { <add> Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachMeasuredRootViewToInstance"); <ide> UiThreadUtil.assertOnUiThread(); <ide> <ide> // Reset view content as it's going to be populated by the application content from JS <ide> private void attachMeasuredRootViewToInstance( <ide> appParams.putDouble("rootTag", rootTag); <ide> appParams.putMap("initialProps", initialProps); <ide> catalystInstance.getJSModule(AppRegistry.class).runApplication(jsAppModuleName, appParams); <add> Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); <ide> } <ide> <ide> private void detachViewFromInstance( <ide> private ReactApplicationContext createReactContext( <ide> <ide> ReactMarker.logMarker(PROCESS_PACKAGES_START); <ide> Systrace.beginSection( <del> Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, <add> TRACE_TAG_REACT_JAVA_BRIDGE, <ide> "createAndProcessCoreModulesPackage"); <ide> try { <ide> CoreModulesPackage coreModulesPackage = <ide> new CoreModulesPackage(this, mBackBtnHandler, mUIImplementationProvider); <ide> processPackage(coreModulesPackage, reactContext, nativeRegistryBuilder, jsModulesBuilder); <ide> } finally { <del> Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); <add> Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); <ide> } <ide> <ide> // TODO(6818138): Solve use-case of native/js modules overriding <ide> for (ReactPackage reactPackage : mPackages) { <ide> Systrace.beginSection( <del> Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, <add> TRACE_TAG_REACT_JAVA_BRIDGE, <ide> "createAndProcessCustomReactPackage"); <ide> try { <ide> processPackage(reactPackage, reactContext, nativeRegistryBuilder, jsModulesBuilder); <ide> } finally { <del> Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); <add> Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); <ide> } <ide> } <ide> ReactMarker.logMarker(PROCESS_PACKAGES_END); <ide> <ide> ReactMarker.logMarker(BUILD_NATIVE_MODULE_REGISTRY_START); <del> Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "buildNativeModuleRegistry"); <add> Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "buildNativeModuleRegistry"); <ide> NativeModuleRegistry nativeModuleRegistry; <ide> try { <ide> nativeModuleRegistry = nativeRegistryBuilder.build(); <ide> } finally { <del> Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); <add> Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); <ide> ReactMarker.logMarker(BUILD_NATIVE_MODULE_REGISTRY_END); <ide> } <ide> <ide> private ReactApplicationContext createReactContext( <ide> <ide> ReactMarker.logMarker(CREATE_CATALYST_INSTANCE_START); <ide> // CREATE_CATALYST_INSTANCE_END is in JSCExecutor.cpp <del> Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "createCatalystInstance"); <add> Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "createCatalystInstance"); <ide> final CatalystInstance catalystInstance; <ide> try { <ide> catalystInstance = catalystInstanceBuilder.build(); <ide> } finally { <del> Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); <add> Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); <ide> ReactMarker.logMarker(CREATE_CATALYST_INSTANCE_END); <ide> } <ide> <ide> private ReactApplicationContext createReactContext( <ide> catalystInstance.getReactQueueConfiguration().getJSQueueThread().runOnQueue(new Runnable() { <ide> @Override <ide> public void run() { <del> Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "runJSBundle"); <add> Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "runJSBundle"); <ide> try { <ide> catalystInstance.runJSBundle(); <ide> } finally { <del> Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); <add> Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); <ide> ReactMarker.logMarker(RUN_JS_BUNDLE_END); <ide> } <ide> }
1
Javascript
Javascript
simplify impl by leveraging jquery
66fdb36ecbe0ec58ba3367a585b506e11ca1c8ad
<ide><path>src/directives.js <ide> angularDirective("ng:bind-attr", function(expression){ <ide> this.$watch(function(scope){ <ide> var values = scope.$eval(expression); <ide> for(var key in values) { <del> var value = compileBindTemplate(values[key])(scope, element), <del> specialName = BOOLEAN_ATTR[lowercase(key)]; <add> var value = compileBindTemplate(values[key])(scope, element); <ide> if (lastValue[key] !== value) { <ide> lastValue[key] = value; <del> if (specialName) { <del> if (toBoolean(value)) { <del> element.attr(specialName, specialName); <del> } else { <del> element.removeAttr(specialName); <del> } <del> } else { <del> element.attr(key, value); <del> } <add> element.attr(key, BOOLEAN_ATTR[lowercase(key)] ? toBoolean(value) : value); <ide> } <ide> } <ide> });
1
Text
Text
update the return object.values & solution
5503b54f8597b6473f8e08a39c0d0ca4f42b2590
<ide><path>curriculum/challenges/english/10-coding-interview-prep/data-structures/perform-a-union-on-two-sets.md <ide> assert( <ide> ); <ide> ``` <ide> <del>The union of `["a", "b", "c"]` and `["c", "d"]` should return `["a", "b", "c", "d"]`. <add>The union of a Set containing values ["a", "b", "c"] and a Set containing values ["c", "d"] should return a new Set containing values ["a", "b", "c", "d"]. <ide> <ide> ```js <ide> assert( <ide> class Set { <ide> } <ide> // This method will return all the values in the set <ide> values() { <del> return Object.keys(this.dictionary); <add> return Object.values(this.dictionary); <ide> } <ide> // This method will add an element to the set <ide> add(element) { <ide> if (!this.has(element)) { <del> this.dictionary[element] = true; <add> this.dictionary[element] = element; <ide> this.length++; <ide> return true; <ide> } <ide> class Set { <ide> } <ide> <ide> values() { <del> return Object.keys(this.dictionary); <add> return Object.values(this.dictionary); <ide> } <ide> <ide> add(element) { <ide> if (!this.has(element)) { <del> this.dictionary[element] = true; <add> this.dictionary[element] = element; <ide> this.length++; <ide> return true; <ide> }
1
Text
Text
add teletype focus for the coming week
c302ed08da512ab7634ee56cf60dda88da22c16d
<ide><path>docs/focus/2018-03-12.md <ide> - Continue packaging a bundled GPG distribution [atom/squeegpg-native](https://github.com/atom/squeegpg-native) <ide> - Write the JavaScript side of GPG interaction (atom/squeegpg) <ide> - Teletype <add> - Open RFC for [streamlining collaboration set-up](https://github.com/atom/atom/blob/3752dca5b032e3b95bb480a6de73bbde41eb821c/docs/focus/README.md#2-streamline-collaboration-set-up) <add> - Begin adding support for joining a portal via URL ([atom/teletype#109](https://github.com/atom/teletype/issues/109)) <ide> - Tree-sitter <ide> - Xray <ide> - Engineering Improvements
1
PHP
PHP
apply fixes from styleci
eeceb4c254b7d52786ef5e5a4f829bc228c2dcb0
<ide><path>src/Illuminate/Queue/Jobs/JobName.php <ide> <ide> namespace Illuminate\Queue\Jobs; <ide> <del>use Illuminate\Support\Arr; <ide> use Illuminate\Support\Str; <ide> <ide> class JobName
1
Ruby
Ruby
add a formulary class for managing the formulae
ed4992f467e0c3b8b84959d279e2be9d8be25ab1
<ide><path>Library/Homebrew/formula.rb <ide> def initialize name <ide> end <ide> <ide> <add># The Formulary is the collection of all Formulae, of course. <add>class Formulary <add> # Returns all formula names as strings, with or without aliases <add> def self.names with_aliases=false <add> everything = (HOMEBREW_REPOSITORY+'Library/Formula').children.map{|f| f.basename('.rb').to_s } <add> everything.push *Formulary.get_aliases.keys if with_aliases <add> everything.sort <add> end <add> <add> # Loads all formula classes. <add> def self.read_all <add> Formulary.names.each do |name| <add> require Formula.path(name) <add> klass_name = Formula.class_s(name) <add> klass = eval(klass_name) <add> <add> yield name, klass <add> end <add> end <add>end <add> <add> <ide> # Derive and define at least @url, see Library/Formula for examples <ide> class Formula <ide> # Homebrew determines the name
1
Python
Python
escape special characters in the object name
829a43519438f2e7bb15ce26530f8adb47f3f2fa
<ide><path>libcloud/storage/drivers/s3.py <ide> <ide> import time <ide> import httplib <add>import urllib <ide> import copy <ide> import base64 <ide> import hmac <ide> def delete_container(self, container): <ide> return False <ide> <ide> def delete_object(self, obj): <del> # TODO: escape object and container name <add> object_name = self._clean_name(name=obj.name) <ide> response = self.connection.request('/%s/%s' % (obj.container.name, <del> obj.name), <add> object_name), <ide> method='DELETE') <ide> if response.status == httplib.NO_CONTENT: <ide> return True <ide> def delete_object(self, obj): <ide> <ide> return False <ide> <add> def _clean_name(self, name): <add> name = urllib.quote(name) <add> return name <add> <ide> def _to_containers(self, obj, xpath): <ide> return [ self._to_container(element) for element in \ <ide> obj.findall(fixxpath(xpath=xpath, namespace=NAMESPACE))]
1
Python
Python
remove unneeded version checks
c92d924dd3dfa9eb97f65848e04ec9391709bc09
<ide><path>numpy/core/code_generators/genapi.py <ide> except ImportError: <ide> import md5 <ide> md5new = md5.new <del>if sys.version_info[:2] < (2, 6): <del> from sets import Set as set <add> <ide> import textwrap <ide> <ide> from os.path import join <ide><path>numpy/core/defchararray.py <ide> def capitalize(a): <ide> a_arr = numpy.asarray(a) <ide> return _vec_string(a_arr, a_arr.dtype, 'capitalize') <ide> <del>if sys.version_info >= (2, 4): <del> def center(a, width, fillchar=' '): <del> """ <del> Return a copy of `a` with its elements centered in a string of <del> length `width`. <del> <del> Calls `str.center` element-wise. <del> <del> Parameters <del> ---------- <del> a : array_like of str or unicode <ide> <del> width : int <del> The length of the resulting strings <del> fillchar : str or unicode, optional <del> The padding character to use (default is space). <add>def center(a, width, fillchar=' '): <add> """ <add> Return a copy of `a` with its elements centered in a string of <add> length `width`. <ide> <del> Returns <del> ------- <del> out : ndarray <del> Output array of str or unicode, depending on input <del> types <add> Calls `str.center` element-wise. <ide> <del> See also <del> -------- <del> str.center <add> Parameters <add> ---------- <add> a : array_like of str or unicode <ide> <del> """ <del> a_arr = numpy.asarray(a) <del> width_arr = numpy.asarray(width) <del> size = long(numpy.max(width_arr.flat)) <del> if numpy.issubdtype(a_arr.dtype, numpy.string_): <del> fillchar = asbytes(fillchar) <del> return _vec_string( <del> a_arr, (a_arr.dtype.type, size), 'center', (width_arr, fillchar)) <del>else: <del> def center(a, width): <del> """ <del> Return an array with the elements of `a` centered in a string <del> of length width. <add> width : int <add> The length of the resulting strings <add> fillchar : str or unicode, optional <add> The padding character to use (default is space). <ide> <del> Calls `str.center` element-wise. <add> Returns <add> ------- <add> out : ndarray <add> Output array of str or unicode, depending on input <add> types <ide> <del> Parameters <del> ---------- <del> a : array_like of str or unicode <del> width : int <del> The length of the resulting strings <add> See also <add> -------- <add> str.center <ide> <del> Returns <del> ------- <del> out : ndarray, str or unicode <del> Output array of str or unicode, depending on input types <add> """ <add> a_arr = numpy.asarray(a) <add> width_arr = numpy.asarray(width) <add> size = long(numpy.max(width_arr.flat)) <add> if numpy.issubdtype(a_arr.dtype, numpy.string_): <add> fillchar = asbytes(fillchar) <add> return _vec_string( <add> a_arr, (a_arr.dtype.type, size), 'center', (width_arr, fillchar)) <ide> <del> See also <del> -------- <del> str.center <del> """ <del> a_arr = numpy.asarray(a) <del> width_arr = numpy.asarray(width) <del> size = long(numpy.max(width_arr.flat)) <del> return _vec_string( <del> a_arr, (a_arr.dtype.type, size), 'center', (width_arr,)) <ide> <ide> def count(a, sub, start=0, end=None): <ide> """ <ide> def count(a, sub, start=0, end=None): <ide> """ <ide> return _vec_string(a, integer, 'count', [sub, start] + _clean_args(end)) <ide> <add> <ide> def decode(a, encoding=None, errors=None): <ide> """ <ide> Calls `str.decode` element-wise. <ide> def decode(a, encoding=None, errors=None): <ide> return _to_string_or_unicode_array( <ide> _vec_string(a, object_, 'decode', _clean_args(encoding, errors))) <ide> <add> <ide> def encode(a, encoding=None, errors=None): <ide> """ <ide> Calls `str.encode` element-wise. <ide> def encode(a, encoding=None, errors=None): <ide> return _to_string_or_unicode_array( <ide> _vec_string(a, object_, 'encode', _clean_args(encoding, errors))) <ide> <add> <ide> def endswith(a, suffix, start=0, end=None): <ide> """ <ide> Returns a boolean array which is `True` where the string element <ide> def endswith(a, suffix, start=0, end=None): <ide> return _vec_string( <ide> a, bool_, 'endswith', [suffix, start] + _clean_args(end)) <ide> <add> <ide> def expandtabs(a, tabsize=8): <ide> """ <ide> Return a copy of each string element where all tab characters are <ide> def expandtabs(a, tabsize=8): <ide> return _to_string_or_unicode_array( <ide> _vec_string(a, object_, 'expandtabs', (tabsize,))) <ide> <add> <ide> def find(a, sub, start=0, end=None): <ide> """ <ide> For each element, return the lowest index in the string where <ide> def find(a, sub, start=0, end=None): <ide> return _vec_string( <ide> a, integer, 'find', [sub, start] + _clean_args(end)) <ide> <del># if sys.version_info >= (2.6): <del># def format(a, *args, **kwargs): <del># # _vec_string doesn't support kwargs at present <del># raise NotImplementedError <ide> <ide> def index(a, sub, start=0, end=None): <ide> """ <ide> def join(sep, seq): <ide> return _to_string_or_unicode_array( <ide> _vec_string(sep, object_, 'join', (seq,))) <ide> <del>if sys.version_info >= (2, 4): <del> def ljust(a, width, fillchar=' '): <del> """ <del> Return an array with the elements of `a` left-justified in a <del> string of length `width`. <del> <del> Calls `str.ljust` element-wise. <ide> <del> Parameters <del> ---------- <del> a : array_like of str or unicode <del> <del> width : int <del> The length of the resulting strings <del> fillchar : str or unicode, optional <del> The character to use for padding <add>def ljust(a, width, fillchar=' '): <add> """ <add> Return an array with the elements of `a` left-justified in a <add> string of length `width`. <ide> <del> Returns <del> ------- <del> out : ndarray <del> Output array of str or unicode, depending on input type <add> Calls `str.ljust` element-wise. <ide> <del> See also <del> -------- <del> str.ljust <add> Parameters <add> ---------- <add> a : array_like of str or unicode <ide> <del> """ <del> a_arr = numpy.asarray(a) <del> width_arr = numpy.asarray(width) <del> size = long(numpy.max(width_arr.flat)) <del> if numpy.issubdtype(a_arr.dtype, numpy.string_): <del> fillchar = asbytes(fillchar) <del> return _vec_string( <del> a_arr, (a_arr.dtype.type, size), 'ljust', (width_arr, fillchar)) <del>else: <del> def ljust(a, width): <del> """ <del> Return an array with the elements of `a` left-justified in a <del> string of length `width`. <add> width : int <add> The length of the resulting strings <add> fillchar : str or unicode, optional <add> The character to use for padding <ide> <del> Calls `str.ljust` element-wise. <add> Returns <add> ------- <add> out : ndarray <add> Output array of str or unicode, depending on input type <ide> <del> Parameters <del> ---------- <del> a : array_like of str or unicode <del> width : int <del> The length of the resulting strings <add> See also <add> -------- <add> str.ljust <ide> <del> Returns <del> ------- <del> out : ndarray <del> Output array of str or unicode, depending on input type <add> """ <add> a_arr = numpy.asarray(a) <add> width_arr = numpy.asarray(width) <add> size = long(numpy.max(width_arr.flat)) <add> if numpy.issubdtype(a_arr.dtype, numpy.string_): <add> fillchar = asbytes(fillchar) <add> return _vec_string( <add> a_arr, (a_arr.dtype.type, size), 'ljust', (width_arr, fillchar)) <ide> <del> See also <del> -------- <del> str.ljust <del> """ <del> a_arr = numpy.asarray(a) <del> width_arr = numpy.asarray(width) <del> size = long(numpy.max(width_arr.flat)) <del> return _vec_string( <del> a_arr, (a_arr.dtype.type, size), 'ljust', (width_arr,)) <ide> <ide> def lower(a): <ide> """ <ide> def lower(a): <ide> a_arr = numpy.asarray(a) <ide> return _vec_string(a_arr, a_arr.dtype, 'lower') <ide> <add> <ide> def lstrip(a, chars=None): <ide> """ <ide> For each element in `a`, return a copy with the leading characters <ide> def lstrip(a, chars=None): <ide> a_arr = numpy.asarray(a) <ide> return _vec_string(a_arr, a_arr.dtype, 'lstrip', (chars,)) <ide> <del>if sys.version_info >= (2, 5): <del> def partition(a, sep): <del> """ <del> Partition each element in `a` around `sep`. <ide> <del> Calls `str.partition` element-wise. <add>def partition(a, sep): <add> """ <add> Partition each element in `a` around `sep`. <ide> <del> For each element in `a`, split the element as the first <del> occurrence of `sep`, and return 3 strings containing the part <del> before the separator, the separator itself, and the part after <del> the separator. If the separator is not found, return 3 strings <del> containing the string itself, followed by two empty strings. <add> Calls `str.partition` element-wise. <ide> <del> Parameters <del> ---------- <del> a : array_like, {str, unicode} <del> Input array <del> sep : {str, unicode} <del> Separator to split each string element in `a`. <add> For each element in `a`, split the element as the first <add> occurrence of `sep`, and return 3 strings containing the part <add> before the separator, the separator itself, and the part after <add> the separator. If the separator is not found, return 3 strings <add> containing the string itself, followed by two empty strings. <ide> <del> Returns <del> ------- <del> out : ndarray, {str, unicode} <del> Output array of str or unicode, depending on input type. <del> The output array will have an extra dimension with 3 <del> elements per input element. <add> Parameters <add> ---------- <add> a : array_like, {str, unicode} <add> Input array <add> sep : {str, unicode} <add> Separator to split each string element in `a`. <ide> <del> See also <del> -------- <del> str.partition <add> Returns <add> ------- <add> out : ndarray, {str, unicode} <add> Output array of str or unicode, depending on input type. <add> The output array will have an extra dimension with 3 <add> elements per input element. <add> <add> See also <add> -------- <add> str.partition <add> <add> """ <add> return _to_string_or_unicode_array( <add> _vec_string(a, object_, 'partition', (sep,))) <ide> <del> """ <del> return _to_string_or_unicode_array( <del> _vec_string(a, object_, 'partition', (sep,))) <ide> <ide> def replace(a, old, new, count=None): <ide> """ <ide> def replace(a, old, new, count=None): <ide> _vec_string( <ide> a, object_, 'replace', [old, new] +_clean_args(count))) <ide> <add> <ide> def rfind(a, sub, start=0, end=None): <ide> """ <ide> For each element in `a`, return the highest index in the string <ide> def rfind(a, sub, start=0, end=None): <ide> return _vec_string( <ide> a, integer, 'rfind', [sub, start] + _clean_args(end)) <ide> <add> <ide> def rindex(a, sub, start=0, end=None): <ide> """ <ide> Like `rfind`, but raises `ValueError` when the substring `sub` is <ide> def rindex(a, sub, start=0, end=None): <ide> return _vec_string( <ide> a, integer, 'rindex', [sub, start] + _clean_args(end)) <ide> <del>if sys.version_info >= (2, 4): <del> def rjust(a, width, fillchar=' '): <del> """ <del> Return an array with the elements of `a` right-justified in a <del> string of length `width`. <ide> <del> Calls `str.rjust` element-wise. <add>def rjust(a, width, fillchar=' '): <add> """ <add> Return an array with the elements of `a` right-justified in a <add> string of length `width`. <ide> <del> Parameters <del> ---------- <del> a : array_like of str or unicode <add> Calls `str.rjust` element-wise. <ide> <del> width : int <del> The length of the resulting strings <del> fillchar : str or unicode, optional <del> The character to use for padding <add> Parameters <add> ---------- <add> a : array_like of str or unicode <ide> <del> Returns <del> ------- <del> out : ndarray <del> Output array of str or unicode, depending on input type <add> width : int <add> The length of the resulting strings <add> fillchar : str or unicode, optional <add> The character to use for padding <ide> <del> See also <del> -------- <del> str.rjust <add> Returns <add> ------- <add> out : ndarray <add> Output array of str or unicode, depending on input type <ide> <del> """ <del> a_arr = numpy.asarray(a) <del> width_arr = numpy.asarray(width) <del> size = long(numpy.max(width_arr.flat)) <del> if numpy.issubdtype(a_arr.dtype, numpy.string_): <del> fillchar = asbytes(fillchar) <del> return _vec_string( <del> a_arr, (a_arr.dtype.type, size), 'rjust', (width_arr, fillchar)) <del>else: <del> def rjust(a, width): <del> """ <del> Return an array with the elements of `a` right-justified in a <del> string of length `width`. <add> See also <add> -------- <add> str.rjust <ide> <del> Calls `str.rjust` element-wise. <add> """ <add> a_arr = numpy.asarray(a) <add> width_arr = numpy.asarray(width) <add> size = long(numpy.max(width_arr.flat)) <add> if numpy.issubdtype(a_arr.dtype, numpy.string_): <add> fillchar = asbytes(fillchar) <add> return _vec_string( <add> a_arr, (a_arr.dtype.type, size), 'rjust', (width_arr, fillchar)) <ide> <del> Parameters <del> ---------- <del> a : array_like of str or unicode <del> width : int <del> The length of the resulting strings <ide> <del> Returns <del> ------- <del> out : ndarray <del> Output array of str or unicode, depending on input type <add>def rpartition(a, sep): <add> """ <add> Partition (split) each element around the right-most separator. <ide> <del> See also <del> -------- <del> str.rjust <del> """ <del> a_arr = numpy.asarray(a) <del> width_arr = numpy.asarray(width) <del> size = long(numpy.max(width_arr.flat)) <del> return _vec_string( <del> a_arr, (a_arr.dtype.type, size), 'rjust', (width,)) <add> Calls `str.rpartition` element-wise. <ide> <del>if sys.version_info >= (2, 5): <del> def rpartition(a, sep): <del> """ <del> Partition (split) each element around the right-most separator. <add> For each element in `a`, split the element as the last <add> occurrence of `sep`, and return 3 strings containing the part <add> before the separator, the separator itself, and the part after <add> the separator. If the separator is not found, return 3 strings <add> containing the string itself, followed by two empty strings. <ide> <del> Calls `str.rpartition` element-wise. <add> Parameters <add> ---------- <add> a : array_like of str or unicode <add> Input array <add> sep : str or unicode <add> Right-most separator to split each element in array. <ide> <del> For each element in `a`, split the element as the last <del> occurrence of `sep`, and return 3 strings containing the part <del> before the separator, the separator itself, and the part after <del> the separator. If the separator is not found, return 3 strings <del> containing the string itself, followed by two empty strings. <add> Returns <add> ------- <add> out : ndarray <add> Output array of string or unicode, depending on input <add> type. The output array will have an extra dimension with <add> 3 elements per input element. <ide> <del> Parameters <del> ---------- <del> a : array_like of str or unicode <del> Input array <del> sep : str or unicode <del> Right-most separator to split each element in array. <add> See also <add> -------- <add> str.rpartition <ide> <del> Returns <del> ------- <del> out : ndarray <del> Output array of string or unicode, depending on input <del> type. The output array will have an extra dimension with <del> 3 elements per input element. <add> """ <add> return _to_string_or_unicode_array( <add> _vec_string(a, object_, 'rpartition', (sep,))) <ide> <del> See also <del> -------- <del> str.rpartition <ide> <del> """ <del> return _to_string_or_unicode_array( <del> _vec_string(a, object_, 'rpartition', (sep,))) <add>def rsplit(a, sep=None, maxsplit=None): <add> """ <add> For each element in `a`, return a list of the words in the <add> string, using `sep` as the delimiter string. <ide> <del>if sys.version_info >= (2, 4): <del> def rsplit(a, sep=None, maxsplit=None): <del> """ <del> For each element in `a`, return a list of the words in the <del> string, using `sep` as the delimiter string. <add> Calls `str.rsplit` element-wise. <ide> <del> Calls `str.rsplit` element-wise. <add> Except for splitting from the right, `rsplit` <add> behaves like `split`. <ide> <del> Except for splitting from the right, `rsplit` <del> behaves like `split`. <add> Parameters <add> ---------- <add> a : array_like of str or unicode <ide> <del> Parameters <del> ---------- <del> a : array_like of str or unicode <add> sep : str or unicode, optional <add> If `sep` is not specified or `None`, any whitespace string <add> is a separator. <add> maxsplit : int, optional <add> If `maxsplit` is given, at most `maxsplit` splits are done, <add> the rightmost ones. <ide> <del> sep : str or unicode, optional <del> If `sep` is not specified or `None`, any whitespace string <del> is a separator. <del> maxsplit : int, optional <del> If `maxsplit` is given, at most `maxsplit` splits are done, <del> the rightmost ones. <add> Returns <add> ------- <add> out : ndarray <add> Array of list objects <ide> <del> Returns <del> ------- <del> out : ndarray <del> Array of list objects <add> See also <add> -------- <add> str.rsplit, split <ide> <del> See also <del> -------- <del> str.rsplit, split <add> """ <add> # This will return an array of lists of different sizes, so we <add> # leave it as an object array <add> return _vec_string( <add> a, object_, 'rsplit', [sep] + _clean_args(maxsplit)) <ide> <del> """ <del> # This will return an array of lists of different sizes, so we <del> # leave it as an object array <del> return _vec_string( <del> a, object_, 'rsplit', [sep] + _clean_args(maxsplit)) <ide> <ide> def rstrip(a, chars=None): <ide> """ <ide> def rstrip(a, chars=None): <ide> a_arr = numpy.asarray(a) <ide> return _vec_string(a_arr, a_arr.dtype, 'rstrip', (chars,)) <ide> <add> <ide> def split(a, sep=None, maxsplit=None): <ide> """ <ide> For each element in `a`, return a list of the words in the <ide> def split(a, sep=None, maxsplit=None): <ide> return _vec_string( <ide> a, object_, 'split', [sep] + _clean_args(maxsplit)) <ide> <add> <ide> def splitlines(a, keepends=None): <ide> """ <ide> For each element in `a`, return a list of the lines in the <ide> def splitlines(a, keepends=None): <ide> return _vec_string( <ide> a, object_, 'splitlines', _clean_args(keepends)) <ide> <add> <ide> def startswith(a, prefix, start=0, end=None): <ide> """ <ide> Returns a boolean array which is `True` where the string element <ide> def startswith(a, prefix, start=0, end=None): <ide> return _vec_string( <ide> a, bool_, 'startswith', [prefix, start] + _clean_args(end)) <ide> <add> <ide> def strip(a, chars=None): <ide> """ <ide> For each element in `a`, return a copy with the leading and <ide> def strip(a, chars=None): <ide> a_arr = numpy.asarray(a) <ide> return _vec_string(a_arr, a_arr.dtype, 'strip', _clean_args(chars)) <ide> <add> <ide> def swapcase(a): <ide> """ <ide> Return element-wise a copy of the string with <ide> def swapcase(a): <ide> a_arr = numpy.asarray(a) <ide> return _vec_string(a_arr, a_arr.dtype, 'swapcase') <ide> <add> <ide> def title(a): <ide> """ <ide> Return element-wise title cased version of string or unicode. <ide> def title(a): <ide> a_arr = numpy.asarray(a) <ide> return _vec_string(a_arr, a_arr.dtype, 'title') <ide> <add> <ide> def translate(a, table, deletechars=None): <ide> """ <ide> For each element in `a`, return a copy of the string where all <ide> def translate(a, table, deletechars=None): <ide> return _vec_string( <ide> a_arr, a_arr.dtype, 'translate', [table] + _clean_args(deletechars)) <ide> <add> <ide> def upper(a): <ide> """ <ide> Return an array with the elements converted to uppercase. <ide> def upper(a): <ide> a_arr = numpy.asarray(a) <ide> return _vec_string(a_arr, a_arr.dtype, 'upper') <ide> <add> <ide> def zfill(a, width): <ide> """ <ide> Return the numeric string left-filled with zeros <ide> def zfill(a, width): <ide> return _vec_string( <ide> a_arr, (a_arr.dtype.type, size), 'zfill', (width_arr,)) <ide> <add> <ide> def isnumeric(a): <ide> """ <ide> For each element, return True if there are only numeric <ide> def isnumeric(a): <ide> raise TypeError("isnumeric is only available for Unicode strings and arrays") <ide> return _vec_string(a, bool_, 'isnumeric') <ide> <add> <ide> def isdecimal(a): <ide> """ <ide> For each element, return True if there are only decimal <ide> def capitalize(self): <ide> """ <ide> return asarray(capitalize(self)) <ide> <del> if sys.version_info >= (2, 4): <del> def center(self, width, fillchar=' '): <del> """ <del> Return a copy of `self` with its elements centered in a <del> string of length `width`. <del> <del> See also <del> -------- <del> center <del> """ <del> return asarray(center(self, width, fillchar)) <del> else: <del> def center(self, width): <del> """ <del> Return a copy of `self` with its elements centered in a <del> string of length `width`. <add> def center(self, width, fillchar=' '): <add> """ <add> Return a copy of `self` with its elements centered in a <add> string of length `width`. <ide> <del> See also <del> -------- <del> center <del> """ <del> return asarray(center(self, width)) <add> See also <add> -------- <add> center <add> """ <add> return asarray(center(self, width, fillchar)) <ide> <ide> def count(self, sub, start=0, end=None): <ide> """ <ide> def join(self, seq): <ide> """ <ide> return join(self, seq) <ide> <del> if sys.version_info >= (2, 4): <del> def ljust(self, width, fillchar=' '): <del> """ <del> Return an array with the elements of `self` left-justified in a <del> string of length `width`. <del> <del> See also <del> -------- <del> char.ljust <add> def ljust(self, width, fillchar=' '): <add> """ <add> Return an array with the elements of `self` left-justified in a <add> string of length `width`. <ide> <del> """ <del> return asarray(ljust(self, width, fillchar)) <del> else: <del> def ljust(self, width): <del> """ <del> Return an array with the elements of `self` left-justified in a <del> string of length `width`. <add> See also <add> -------- <add> char.ljust <ide> <del> See also <del> -------- <del> ljust <del> """ <del> return asarray(ljust(self, width)) <add> """ <add> return asarray(ljust(self, width, fillchar)) <ide> <ide> def lower(self): <ide> """ <ide> def lstrip(self, chars=None): <ide> """ <ide> return asarray(lstrip(self, chars)) <ide> <del> if sys.version_info >= (2, 5): <del> def partition(self, sep): <del> """ <del> Partition each element in `self` around `sep`. <add> def partition(self, sep): <add> """ <add> Partition each element in `self` around `sep`. <ide> <del> See also <del> -------- <del> partition <del> """ <del> return asarray(partition(self, sep)) <add> See also <add> -------- <add> partition <add> """ <add> return asarray(partition(self, sep)) <ide> <ide> def replace(self, old, new, count=None): <ide> """ <ide> def rindex(self, sub, start=0, end=None): <ide> """ <ide> return rindex(self, sub, start, end) <ide> <del> if sys.version_info >= (2, 4): <del> def rjust(self, width, fillchar=' '): <del> """ <del> Return an array with the elements of `self` <del> right-justified in a string of length `width`. <add> def rjust(self, width, fillchar=' '): <add> """ <add> Return an array with the elements of `self` <add> right-justified in a string of length `width`. <add> <add> See also <add> -------- <add> char.rjust <ide> <del> See also <del> -------- <del> char.rjust <add> """ <add> return asarray(rjust(self, width, fillchar)) <ide> <del> """ <del> return asarray(rjust(self, width, fillchar)) <del> else: <del> def rjust(self, width): <del> """ <del> Return an array with the elements of `self` <del> right-justified in a string of length `width`. <del> <del> See also <del> -------- <del> rjust <del> """ <del> return asarray(rjust(self, width)) <del> <del> if sys.version_info >= (2, 5): <del> def rpartition(self, sep): <del> """ <del> Partition each element in `self` around `sep`. <del> <del> See also <del> -------- <del> rpartition <del> """ <del> return asarray(rpartition(self, sep)) <del> <del> if sys.version_info >= (2, 4): <del> def rsplit(self, sep=None, maxsplit=None): <del> """ <del> For each element in `self`, return a list of the words in <del> the string, using `sep` as the delimiter string. <del> <del> See also <del> -------- <del> char.rsplit <del> <del> """ <del> return rsplit(self, sep, maxsplit) <add> def rpartition(self, sep): <add> """ <add> Partition each element in `self` around `sep`. <add> <add> See also <add> -------- <add> rpartition <add> """ <add> return asarray(rpartition(self, sep)) <add> <add> def rsplit(self, sep=None, maxsplit=None): <add> """ <add> For each element in `self`, return a list of the words in <add> the string, using `sep` as the delimiter string. <add> <add> See also <add> -------- <add> char.rsplit <add> <add> """ <add> return rsplit(self, sep, maxsplit) <ide> <ide> def rstrip(self, chars=None): <ide> """ <ide><path>numpy/core/memmap.py <ide> def __new__(subtype, filename, dtype=uint8, mode='r+', offset=0, <ide> else: <ide> acc = mmap.ACCESS_WRITE <ide> <del> if sys.version_info[:2] >= (2,6): <del> # The offset keyword in mmap.mmap needs Python >= 2.6 <del> start = offset - offset % mmap.ALLOCATIONGRANULARITY <del> bytes -= start <del> offset -= start <del> mm = mmap.mmap(fid.fileno(), bytes, access=acc, offset=start) <del> else: <del> mm = mmap.mmap(fid.fileno(), bytes, access=acc) <add> start = offset - offset % mmap.ALLOCATIONGRANULARITY <add> bytes -= start <add> offset -= start <add> mm = mmap.mmap(fid.fileno(), bytes, access=acc, offset=start) <ide> <ide> self = ndarray.__new__(subtype, shape, dtype=descr, buffer=mm, <ide> offset=offset, order=order) <ide><path>numpy/core/setup.py <ide> def check_funcs(funcs_name): <ide> # config.h in the public namespace, so we have a clash for the common <ide> # functions we test. We remove every function tested by python's <ide> # autoconf, hoping their own test are correct <del> if sys.version_info[:2] >= (2, 5): <del> for f in OPTIONAL_STDFUNCS_MAYBE: <del> if config.check_decl(fname2def(f), <del> headers=["Python.h", "math.h"]): <del> OPTIONAL_STDFUNCS.remove(f) <add> for f in OPTIONAL_STDFUNCS_MAYBE: <add> if config.check_decl(fname2def(f), <add> headers=["Python.h", "math.h"]): <add> OPTIONAL_STDFUNCS.remove(f) <ide> <ide> check_funcs(OPTIONAL_STDFUNCS) <ide> <ide> def _add_decl(f): <ide> # functions we test. We remove every function tested by python's <ide> # autoconf, hoping their own test are correct <ide> _macros = ["isnan", "isinf", "signbit", "isfinite"] <del> if sys.version_info[:2] >= (2, 6): <del> for f in _macros: <del> py_symbol = fname2def("decl_%s" % f) <del> already_declared = config.check_decl(py_symbol, <del> headers=["Python.h", "math.h"]) <del> if already_declared: <del> if config.check_macro_true(py_symbol, <del> headers=["Python.h", "math.h"]): <del> pub.append('NPY_%s' % fname2def("decl_%s" % f)) <del> else: <del> macros.append(f) <del> else: <del> macros = _macros[:] <add> for f in _macros: <add> py_symbol = fname2def("decl_%s" % f) <add> already_declared = config.check_decl(py_symbol, <add> headers=["Python.h", "math.h"]) <add> if already_declared: <add> if config.check_macro_true(py_symbol, <add> headers=["Python.h", "math.h"]): <add> pub.append('NPY_%s' % fname2def("decl_%s" % f)) <add> else: <add> macros.append(f) <ide> # Normally, isnan and isinf are macro (C99), but some platforms only have <ide> # func, or both func and macro version. Check for macro only, and define <ide> # replacement ones if not found. <ide><path>numpy/core/tests/test_defchararray.py <ide> def test_lstrip(self): <ide> ['123 \t 345 \0 ', 'UPPER']]) <ide> <ide> def test_partition(self): <del> if sys.version_info >= (2, 5): <del> P = self.A.partition(asbytes_nested(['3', 'M'])) <del> assert_(issubclass(P.dtype.type, np.string_)) <del> assert_array_equal(P, asbytes_nested([ <del> [(' abc ', '', ''), ('', '', '')], <del> [('12', '3', '45'), ('', 'M', 'ixedCase')], <del> [('12', '3', ' \t 345 \0 '), ('UPPER', '', '')]])) <add> P = self.A.partition(asbytes_nested(['3', 'M'])) <add> assert_(issubclass(P.dtype.type, np.string_)) <add> assert_array_equal(P, asbytes_nested([ <add> [(' abc ', '', ''), ('', '', '')], <add> [('12', '3', '45'), ('', 'M', 'ixedCase')], <add> [('12', '3', ' \t 345 \0 '), ('UPPER', '', '')]])) <ide> <ide> def test_replace(self): <ide> R = self.A.replace(asbytes_nested(['3', 'a']), <ide> def test_rjust(self): <ide> [' FOO', ' FOO']])) <ide> <ide> def test_rpartition(self): <del> if sys.version_info >= (2, 5): <del> P = self.A.rpartition(asbytes_nested(['3', 'M'])) <del> assert_(issubclass(P.dtype.type, np.string_)) <del> assert_array_equal(P, asbytes_nested([ <del> [('', '', ' abc '), ('', '', '')], <del> [('12', '3', '45'), ('', 'M', 'ixedCase')], <del> [('123 \t ', '3', '45 \0 '), ('', '', 'UPPER')]])) <add> P = self.A.rpartition(asbytes_nested(['3', 'M'])) <add> assert_(issubclass(P.dtype.type, np.string_)) <add> assert_array_equal(P, asbytes_nested([ <add> [('', '', ' abc '), ('', '', '')], <add> [('12', '3', '45'), ('', 'M', 'ixedCase')], <add> [('123 \t ', '3', '45 \0 '), ('', '', 'UPPER')]])) <ide> <ide> def test_rsplit(self): <ide> A = self.A.rsplit(asbytes('3')) <ide><path>numpy/core/tests/test_deprecations.py <ide> def tearDown(self): <ide> category=DeprecationWarning) <ide> <ide> <del> @dec.skipif(sys.version_info[:2] < (2, 5)) <ide> def test_deprecations(self): <ide> a = np.array([[[5]]]) <ide> <ide> def tearDown(self): <ide> category=DeprecationWarning) <ide> <ide> <del> @dec.skipif(sys.version_info[:2] < (2, 5)) <ide> def test_deprecations(self): <ide> a = np.array([[5]]) <ide> <ide><path>numpy/core/tests/test_dtype.py <ide> def test_complex_dtype_repr(self): <ide> assert_equal(repr(dt), <ide> "dtype([('a', '<M8[D]'), ('b', '<m8[us]')])") <ide> <del> @dec.skipif(sys.version_info[0] > 2) <add> @dec.skipif(sys.version_info[0] >= 3) <ide> def test_dtype_str_with_long_in_shape(self): <ide> # Pull request #376 <ide> dt = np.dtype('(1L,)i4') <ide><path>numpy/core/tests/test_multiarray.py <ide> def test_usigned_shortshort(self): <ide> def test_usigned_short(self): <ide> dt = np.min_scalar_type(2**16-1) <ide> wanted = np.dtype('uint16') <del> assert_equal(wanted, dt) <add> assert_equal(wanted, dt) <ide> def test_usigned_int(self): <ide> dt = np.min_scalar_type(2**32-1) <ide> wanted = np.dtype('uint32') <del> assert_equal(wanted, dt) <add> assert_equal(wanted, dt) <ide> def test_usigned_longlong(self): <ide> dt = np.min_scalar_type(2**63-1) <ide> wanted = np.dtype('uint64') <del> assert_equal(wanted, dt) <add> assert_equal(wanted, dt) <ide> def test_object(self): <ide> dt = np.min_scalar_type(2**64) <ide> wanted = np.dtype('O') <ide> assert_equal(wanted, dt) <del> <ide> <del>if sys.version_info >= (2, 6): <del> <del> if sys.version_info[:2] == (2, 6): <del> from numpy.core.multiarray import memorysimpleview as memoryview <del> <del> from numpy.core._internal import _dtype_from_pep3118 <del> <del> class TestPEP3118Dtype(object): <del> def _check(self, spec, wanted): <del> dt = np.dtype(wanted) <del> if isinstance(wanted, list) and isinstance(wanted[-1], tuple): <del> if wanted[-1][0] == '': <del> names = list(dt.names) <del> names[-1] = '' <del> dt.names = tuple(names) <del> assert_equal(_dtype_from_pep3118(spec), dt, <del> err_msg="spec %r != dtype %r" % (spec, wanted)) <del> <del> def test_native_padding(self): <del> align = np.dtype('i').alignment <del> for j in range(8): <del> if j == 0: <del> s = 'bi' <del> else: <del> s = 'b%dxi' % j <del> self._check('@'+s, {'f0': ('i1', 0), <del> 'f1': ('i', align*(1 + j//align))}) <del> self._check('='+s, {'f0': ('i1', 0), <del> 'f1': ('i', 1+j)}) <del> <del> def test_native_padding_2(self): <del> # Native padding should work also for structs and sub-arrays <del> self._check('x3T{xi}', {'f0': (({'f0': ('i', 4)}, (3,)), 4)}) <del> self._check('^x3T{xi}', {'f0': (({'f0': ('i', 1)}, (3,)), 1)}) <del> <del> def test_trailing_padding(self): <del> # Trailing padding should be included, *and*, the item size <del> # should match the alignment if in aligned mode <del> align = np.dtype('i').alignment <del> def VV(n): <del> return 'V%d' % (align*(1 + (n-1)//align)) <del> <del> self._check('ix', [('f0', 'i'), ('', VV(1))]) <del> self._check('ixx', [('f0', 'i'), ('', VV(2))]) <del> self._check('ixxx', [('f0', 'i'), ('', VV(3))]) <del> self._check('ixxxx', [('f0', 'i'), ('', VV(4))]) <del> self._check('i7x', [('f0', 'i'), ('', VV(7))]) <del> <del> self._check('^ix', [('f0', 'i'), ('', 'V1')]) <del> self._check('^ixx', [('f0', 'i'), ('', 'V2')]) <del> self._check('^ixxx', [('f0', 'i'), ('', 'V3')]) <del> self._check('^ixxxx', [('f0', 'i'), ('', 'V4')]) <del> self._check('^i7x', [('f0', 'i'), ('', 'V7')]) <del> <del> def test_native_padding_3(self): <del> dt = np.dtype( <del> [('a', 'b'), ('b', 'i'), <del> ('sub', np.dtype('b,i')), ('c', 'i')], <del> align=True) <del> self._check("T{b:a:xxxi:b:T{b:f0:=i:f1:}:sub:xxxi:c:}", dt) <del> <del> dt = np.dtype( <del> [('a', 'b'), ('b', 'i'), ('c', 'b'), ('d', 'b'), <del> ('e', 'b'), ('sub', np.dtype('b,i', align=True))]) <del> self._check("T{b:a:=i:b:b:c:b:d:b:e:T{b:f0:xxxi:f1:}:sub:}", dt) <del> <del> def test_padding_with_array_inside_struct(self): <del> dt = np.dtype( <del> [('a', 'b'), ('b', 'i'), ('c', 'b', (3,)), <del> ('d', 'i')], <del> align=True) <del> self._check("T{b:a:xxxi:b:3b:c:xi:d:}", dt) <del> <del> def test_byteorder_inside_struct(self): <del> # The byte order after @T{=i} should be '=', not '@'. <del> # Check this by noting the absence of native alignment. <del> self._check('@T{^i}xi', {'f0': ({'f0': ('i', 0)}, 0), <del> 'f1': ('i', 5)}) <del> <del> def test_intra_padding(self): <del> # Natively aligned sub-arrays may require some internal padding <del> align = np.dtype('i').alignment <del> def VV(n): <del> return 'V%d' % (align*(1 + (n-1)//align)) <del> <del> self._check('(3)T{ix}', ({'f0': ('i', 0), '': (VV(1), 4)}, (3,))) <del> <del> class TestNewBufferProtocol(object): <del> def _check_roundtrip(self, obj): <del> obj = np.asarray(obj) <del> x = memoryview(obj) <del> y = np.asarray(x) <del> y2 = np.array(x) <del> assert_(not y.flags.owndata) <del> assert_(y2.flags.owndata) <del> assert_equal(y.dtype, obj.dtype) <del> assert_array_equal(obj, y) <del> assert_equal(y2.dtype, obj.dtype) <del> assert_array_equal(obj, y2) <del> <del> def test_roundtrip(self): <del> x = np.array([1,2,3,4,5], dtype='i4') <del> self._check_roundtrip(x) <ide> <del> x = np.array([[1,2],[3,4]], dtype=np.float64) <del> self._check_roundtrip(x) <add>if sys.version_info[:2] == (2, 6): <add> from numpy.core.multiarray import memorysimpleview as memoryview <ide> <del> x = np.zeros((3,3,3), dtype=np.float32)[:,0,:] <del> self._check_roundtrip(x) <add>from numpy.core._internal import _dtype_from_pep3118 <ide> <del> dt = [('a', 'b'), <del> ('b', 'h'), <del> ('c', 'i'), <del> ('d', 'l'), <del> ('dx', 'q'), <del> ('e', 'B'), <del> ('f', 'H'), <del> ('g', 'I'), <del> ('h', 'L'), <del> ('hx', 'Q'), <del> ('i', np.single), <del> ('j', np.double), <del> ('k', np.longdouble), <del> ('ix', np.csingle), <del> ('jx', np.cdouble), <del> ('kx', np.clongdouble), <del> ('l', 'S4'), <del> ('m', 'U4'), <del> ('n', 'V3'), <del> ('o', '?'), <del> ('p', np.half), <del> ] <del> x = np.array( <del> [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, <del> asbytes('aaaa'), 'bbbb', asbytes('xxx'), True, 1.0)], <del> dtype=dt) <del> self._check_roundtrip(x) <add>class TestPEP3118Dtype(object): <add> def _check(self, spec, wanted): <add> dt = np.dtype(wanted) <add> if isinstance(wanted, list) and isinstance(wanted[-1], tuple): <add> if wanted[-1][0] == '': <add> names = list(dt.names) <add> names[-1] = '' <add> dt.names = tuple(names) <add> assert_equal(_dtype_from_pep3118(spec), dt, <add> err_msg="spec %r != dtype %r" % (spec, wanted)) <ide> <del> x = np.array(([[1,2],[3,4]],), dtype=[('a', (int, (2,2)))]) <del> self._check_roundtrip(x) <add> def test_native_padding(self): <add> align = np.dtype('i').alignment <add> for j in range(8): <add> if j == 0: <add> s = 'bi' <add> else: <add> s = 'b%dxi' % j <add> self._check('@'+s, {'f0': ('i1', 0), <add> 'f1': ('i', align*(1 + j//align))}) <add> self._check('='+s, {'f0': ('i1', 0), <add> 'f1': ('i', 1+j)}) <add> <add> def test_native_padding_2(self): <add> # Native padding should work also for structs and sub-arrays <add> self._check('x3T{xi}', {'f0': (({'f0': ('i', 4)}, (3,)), 4)}) <add> self._check('^x3T{xi}', {'f0': (({'f0': ('i', 1)}, (3,)), 1)}) <add> <add> def test_trailing_padding(self): <add> # Trailing padding should be included, *and*, the item size <add> # should match the alignment if in aligned mode <add> align = np.dtype('i').alignment <add> def VV(n): <add> return 'V%d' % (align*(1 + (n-1)//align)) <add> <add> self._check('ix', [('f0', 'i'), ('', VV(1))]) <add> self._check('ixx', [('f0', 'i'), ('', VV(2))]) <add> self._check('ixxx', [('f0', 'i'), ('', VV(3))]) <add> self._check('ixxxx', [('f0', 'i'), ('', VV(4))]) <add> self._check('i7x', [('f0', 'i'), ('', VV(7))]) <add> <add> self._check('^ix', [('f0', 'i'), ('', 'V1')]) <add> self._check('^ixx', [('f0', 'i'), ('', 'V2')]) <add> self._check('^ixxx', [('f0', 'i'), ('', 'V3')]) <add> self._check('^ixxxx', [('f0', 'i'), ('', 'V4')]) <add> self._check('^i7x', [('f0', 'i'), ('', 'V7')]) <add> <add> def test_native_padding_3(self): <add> dt = np.dtype( <add> [('a', 'b'), ('b', 'i'), <add> ('sub', np.dtype('b,i')), ('c', 'i')], <add> align=True) <add> self._check("T{b:a:xxxi:b:T{b:f0:=i:f1:}:sub:xxxi:c:}", dt) <add> <add> dt = np.dtype( <add> [('a', 'b'), ('b', 'i'), ('c', 'b'), ('d', 'b'), <add> ('e', 'b'), ('sub', np.dtype('b,i', align=True))]) <add> self._check("T{b:a:=i:b:b:c:b:d:b:e:T{b:f0:xxxi:f1:}:sub:}", dt) <add> <add> def test_padding_with_array_inside_struct(self): <add> dt = np.dtype( <add> [('a', 'b'), ('b', 'i'), ('c', 'b', (3,)), <add> ('d', 'i')], <add> align=True) <add> self._check("T{b:a:xxxi:b:3b:c:xi:d:}", dt) <add> <add> def test_byteorder_inside_struct(self): <add> # The byte order after @T{=i} should be '=', not '@'. <add> # Check this by noting the absence of native alignment. <add> self._check('@T{^i}xi', {'f0': ({'f0': ('i', 0)}, 0), <add> 'f1': ('i', 5)}) <add> <add> def test_intra_padding(self): <add> # Natively aligned sub-arrays may require some internal padding <add> align = np.dtype('i').alignment <add> def VV(n): <add> return 'V%d' % (align*(1 + (n-1)//align)) <add> <add> self._check('(3)T{ix}', ({'f0': ('i', 0), '': (VV(1), 4)}, (3,))) <add> <add>class TestNewBufferProtocol(object): <add> def _check_roundtrip(self, obj): <add> obj = np.asarray(obj) <add> x = memoryview(obj) <add> y = np.asarray(x) <add> y2 = np.array(x) <add> assert_(not y.flags.owndata) <add> assert_(y2.flags.owndata) <add> assert_equal(y.dtype, obj.dtype) <add> assert_array_equal(obj, y) <add> assert_equal(y2.dtype, obj.dtype) <add> assert_array_equal(obj, y2) <ide> <del> x = np.array([1,2,3], dtype='>i2') <add> def test_roundtrip(self): <add> x = np.array([1,2,3,4,5], dtype='i4') <add> self._check_roundtrip(x) <add> <add> x = np.array([[1,2],[3,4]], dtype=np.float64) <add> self._check_roundtrip(x) <add> <add> x = np.zeros((3,3,3), dtype=np.float32)[:,0,:] <add> self._check_roundtrip(x) <add> <add> dt = [('a', 'b'), <add> ('b', 'h'), <add> ('c', 'i'), <add> ('d', 'l'), <add> ('dx', 'q'), <add> ('e', 'B'), <add> ('f', 'H'), <add> ('g', 'I'), <add> ('h', 'L'), <add> ('hx', 'Q'), <add> ('i', np.single), <add> ('j', np.double), <add> ('k', np.longdouble), <add> ('ix', np.csingle), <add> ('jx', np.cdouble), <add> ('kx', np.clongdouble), <add> ('l', 'S4'), <add> ('m', 'U4'), <add> ('n', 'V3'), <add> ('o', '?'), <add> ('p', np.half), <add> ] <add> x = np.array( <add> [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, <add> asbytes('aaaa'), 'bbbb', asbytes('xxx'), True, 1.0)], <add> dtype=dt) <add> self._check_roundtrip(x) <add> <add> x = np.array(([[1,2],[3,4]],), dtype=[('a', (int, (2,2)))]) <add> self._check_roundtrip(x) <add> <add> x = np.array([1,2,3], dtype='>i2') <add> self._check_roundtrip(x) <add> <add> x = np.array([1,2,3], dtype='<i2') <add> self._check_roundtrip(x) <add> <add> x = np.array([1,2,3], dtype='>i4') <add> self._check_roundtrip(x) <add> <add> x = np.array([1,2,3], dtype='<i4') <add> self._check_roundtrip(x) <add> <add> # Native-only data types can be passed through the buffer interface <add> # only in native byte order <add> if sys.byteorder == 'little': <add> x = np.array([1,2,3], dtype='>q') <add> assert_raises(ValueError, self._check_roundtrip, x) <add> x = np.array([1,2,3], dtype='<q') <ide> self._check_roundtrip(x) <del> <del> x = np.array([1,2,3], dtype='<i2') <add> else: <add> x = np.array([1,2,3], dtype='>q') <ide> self._check_roundtrip(x) <add> x = np.array([1,2,3], dtype='<q') <add> assert_raises(ValueError, self._check_roundtrip, x) <add> <add> def test_roundtrip_half(self): <add> half_list = [ <add> 1.0, <add> -2.0, <add> 6.5504 * 10**4, # (max half precision) <add> 2**-14, # ~= 6.10352 * 10**-5 (minimum positive normal) <add> 2**-24, # ~= 5.96046 * 10**-8 (minimum strictly positive subnormal) <add> 0.0, <add> -0.0, <add> float('+inf'), <add> float('-inf'), <add> 0.333251953125, # ~= 1/3 <add> ] <ide> <del> x = np.array([1,2,3], dtype='>i4') <del> self._check_roundtrip(x) <add> x = np.array(half_list, dtype='>e') <add> self._check_roundtrip(x) <add> x = np.array(half_list, dtype='<e') <add> self._check_roundtrip(x) <add> <add> def test_export_simple_1d(self): <add> x = np.array([1,2,3,4,5], dtype='i') <add> y = memoryview(x) <add> assert_equal(y.format, 'i') <add> assert_equal(y.shape, (5,)) <add> assert_equal(y.ndim, 1) <add> assert_equal(y.strides, (4,)) <add> assert_equal(y.suboffsets, EMPTY) <add> assert_equal(y.itemsize, 4) <add> <add> def test_export_simple_nd(self): <add> x = np.array([[1,2],[3,4]], dtype=np.float64) <add> y = memoryview(x) <add> assert_equal(y.format, 'd') <add> assert_equal(y.shape, (2, 2)) <add> assert_equal(y.ndim, 2) <add> assert_equal(y.strides, (16, 8)) <add> assert_equal(y.suboffsets, EMPTY) <add> assert_equal(y.itemsize, 8) <add> <add> def test_export_discontiguous(self): <add> x = np.zeros((3,3,3), dtype=np.float32)[:,0,:] <add> y = memoryview(x) <add> assert_equal(y.format, 'f') <add> assert_equal(y.shape, (3, 3)) <add> assert_equal(y.ndim, 2) <add> assert_equal(y.strides, (36, 4)) <add> assert_equal(y.suboffsets, EMPTY) <add> assert_equal(y.itemsize, 4) <add> <add> def test_export_record(self): <add> dt = [('a', 'b'), <add> ('b', 'h'), <add> ('c', 'i'), <add> ('d', 'l'), <add> ('dx', 'q'), <add> ('e', 'B'), <add> ('f', 'H'), <add> ('g', 'I'), <add> ('h', 'L'), <add> ('hx', 'Q'), <add> ('i', np.single), <add> ('j', np.double), <add> ('k', np.longdouble), <add> ('ix', np.csingle), <add> ('jx', np.cdouble), <add> ('kx', np.clongdouble), <add> ('l', 'S4'), <add> ('m', 'U4'), <add> ('n', 'V3'), <add> ('o', '?'), <add> ('p', np.half), <add> ] <add> x = np.array( <add> [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, <add> asbytes('aaaa'), 'bbbb', asbytes(' '), True, 1.0)], <add> dtype=dt) <add> y = memoryview(x) <add> assert_equal(y.shape, (1,)) <add> assert_equal(y.ndim, 1) <add> assert_equal(y.suboffsets, EMPTY) <add> <add> sz = sum([dtype(b).itemsize for a, b in dt]) <add> if dtype('l').itemsize == 4: <add> assert_equal(y.format, 'T{b:a:=h:b:i:c:l:d:^q:dx:B:e:@H:f:=I:g:L:h:^Q:hx:=f:i:d:j:^g:k:=Zf:ix:Zd:jx:^Zg:kx:4s:l:=4w:m:3x:n:?:o:@e:p:}') <add> else: <add> assert_equal(y.format, 'T{b:a:=h:b:i:c:q:d:^q:dx:B:e:@H:f:=I:g:Q:h:^Q:hx:=f:i:d:j:^g:k:=Zf:ix:Zd:jx:^Zg:kx:4s:l:=4w:m:3x:n:?:o:@e:p:}') <add> # Cannot test if NPY_RELAXED_STRIDES_CHECKING changes the strides <add> if not (np.ones(1).strides[0] == np.iinfo(np.intp).max): <add> assert_equal(y.strides, (sz,)) <add> assert_equal(y.itemsize, sz) <add> <add> def test_export_subarray(self): <add> x = np.array(([[1,2],[3,4]],), dtype=[('a', ('i', (2,2)))]) <add> y = memoryview(x) <add> assert_equal(y.format, 'T{(2,2)i:a:}') <add> assert_equal(y.shape, EMPTY) <add> assert_equal(y.ndim, 0) <add> assert_equal(y.strides, EMPTY) <add> assert_equal(y.suboffsets, EMPTY) <add> assert_equal(y.itemsize, 16) <add> <add> def test_export_endian(self): <add> x = np.array([1,2,3], dtype='>i') <add> y = memoryview(x) <add> if sys.byteorder == 'little': <add> assert_equal(y.format, '>i') <add> else: <add> assert_equal(y.format, 'i') <ide> <del> x = np.array([1,2,3], dtype='<i4') <del> self._check_roundtrip(x) <add> x = np.array([1,2,3], dtype='<i') <add> y = memoryview(x) <add> if sys.byteorder == 'little': <add> assert_equal(y.format, 'i') <add> else: <add> assert_equal(y.format, '<i') <ide> <del> # Native-only data types can be passed through the buffer interface <del> # only in native byte order <del> if sys.byteorder == 'little': <del> x = np.array([1,2,3], dtype='>q') <del> assert_raises(ValueError, self._check_roundtrip, x) <del> x = np.array([1,2,3], dtype='<q') <del> self._check_roundtrip(x) <del> else: <del> x = np.array([1,2,3], dtype='>q') <del> self._check_roundtrip(x) <del> x = np.array([1,2,3], dtype='<q') <del> assert_raises(ValueError, self._check_roundtrip, x) <del> <del> def test_roundtrip_half(self): <del> half_list = [ <del> 1.0, <del> -2.0, <del> 6.5504 * 10**4, # (max half precision) <del> 2**-14, # ~= 6.10352 * 10**-5 (minimum positive normal) <del> 2**-24, # ~= 5.96046 * 10**-8 (minimum strictly positive subnormal) <del> 0.0, <del> -0.0, <del> float('+inf'), <del> float('-inf'), <del> 0.333251953125, # ~= 1/3 <del> ] <del> <del> x = np.array(half_list, dtype='>e') <add> def test_padding(self): <add> for j in range(8): <add> x = np.array([(1,),(2,)], dtype={'f0': (int, j)}) <ide> self._check_roundtrip(x) <del> x = np.array(half_list, dtype='<e') <del> self._check_roundtrip(x) <del> <del> def test_export_simple_1d(self): <del> x = np.array([1,2,3,4,5], dtype='i') <del> y = memoryview(x) <del> assert_equal(y.format, 'i') <del> assert_equal(y.shape, (5,)) <del> assert_equal(y.ndim, 1) <del> assert_equal(y.strides, (4,)) <del> assert_equal(y.suboffsets, EMPTY) <del> assert_equal(y.itemsize, 4) <del> <del> def test_export_simple_nd(self): <del> x = np.array([[1,2],[3,4]], dtype=np.float64) <del> y = memoryview(x) <del> assert_equal(y.format, 'd') <del> assert_equal(y.shape, (2, 2)) <del> assert_equal(y.ndim, 2) <del> assert_equal(y.strides, (16, 8)) <del> assert_equal(y.suboffsets, EMPTY) <del> assert_equal(y.itemsize, 8) <del> <del> def test_export_discontiguous(self): <del> x = np.zeros((3,3,3), dtype=np.float32)[:,0,:] <del> y = memoryview(x) <del> assert_equal(y.format, 'f') <del> assert_equal(y.shape, (3, 3)) <del> assert_equal(y.ndim, 2) <del> assert_equal(y.strides, (36, 4)) <del> assert_equal(y.suboffsets, EMPTY) <del> assert_equal(y.itemsize, 4) <del> <del> def test_export_record(self): <del> dt = [('a', 'b'), <del> ('b', 'h'), <del> ('c', 'i'), <del> ('d', 'l'), <del> ('dx', 'q'), <del> ('e', 'B'), <del> ('f', 'H'), <del> ('g', 'I'), <del> ('h', 'L'), <del> ('hx', 'Q'), <del> ('i', np.single), <del> ('j', np.double), <del> ('k', np.longdouble), <del> ('ix', np.csingle), <del> ('jx', np.cdouble), <del> ('kx', np.clongdouble), <del> ('l', 'S4'), <del> ('m', 'U4'), <del> ('n', 'V3'), <del> ('o', '?'), <del> ('p', np.half), <del> ] <del> x = np.array( <del> [(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, <del> asbytes('aaaa'), 'bbbb', asbytes(' '), True, 1.0)], <del> dtype=dt) <del> y = memoryview(x) <del> assert_equal(y.shape, (1,)) <del> assert_equal(y.ndim, 1) <del> assert_equal(y.suboffsets, EMPTY) <del> <del> sz = sum([dtype(b).itemsize for a, b in dt]) <del> if dtype('l').itemsize == 4: <del> assert_equal(y.format, 'T{b:a:=h:b:i:c:l:d:^q:dx:B:e:@H:f:=I:g:L:h:^Q:hx:=f:i:d:j:^g:k:=Zf:ix:Zd:jx:^Zg:kx:4s:l:=4w:m:3x:n:?:o:@e:p:}') <del> else: <del> assert_equal(y.format, 'T{b:a:=h:b:i:c:q:d:^q:dx:B:e:@H:f:=I:g:Q:h:^Q:hx:=f:i:d:j:^g:k:=Zf:ix:Zd:jx:^Zg:kx:4s:l:=4w:m:3x:n:?:o:@e:p:}') <del> # Cannot test if NPY_RELAXED_STRIDES_CHECKING changes the strides <del> if not (np.ones(1).strides[0] == np.iinfo(np.intp).max): <del> assert_equal(y.strides, (sz,)) <del> assert_equal(y.itemsize, sz) <del> <del> def test_export_subarray(self): <del> x = np.array(([[1,2],[3,4]],), dtype=[('a', ('i', (2,2)))]) <del> y = memoryview(x) <del> assert_equal(y.format, 'T{(2,2)i:a:}') <del> assert_equal(y.shape, EMPTY) <del> assert_equal(y.ndim, 0) <del> assert_equal(y.strides, EMPTY) <del> assert_equal(y.suboffsets, EMPTY) <del> assert_equal(y.itemsize, 16) <del> <del> def test_export_endian(self): <del> x = np.array([1,2,3], dtype='>i') <del> y = memoryview(x) <del> if sys.byteorder == 'little': <del> assert_equal(y.format, '>i') <del> else: <del> assert_equal(y.format, 'i') <ide> <del> x = np.array([1,2,3], dtype='<i') <del> y = memoryview(x) <del> if sys.byteorder == 'little': <del> assert_equal(y.format, 'i') <del> else: <del> assert_equal(y.format, '<i') <del> <del> def test_padding(self): <del> for j in range(8): <del> x = np.array([(1,),(2,)], dtype={'f0': (int, j)}) <del> self._check_roundtrip(x) <del> <del> def test_reference_leak(self): <del> count_1 = sys.getrefcount(np.core._internal) <del> a = np.zeros(4) <del> b = memoryview(a) <del> c = np.asarray(b) <del> count_2 = sys.getrefcount(np.core._internal) <del> assert_equal(count_1, count_2) <del> <del> def test_padded_struct_array(self): <del> dt1 = np.dtype( <del> [('a', 'b'), ('b', 'i'), ('sub', np.dtype('b,i')), ('c', 'i')], <del> align=True) <del> x1 = np.arange(dt1.itemsize, dtype=np.int8).view(dt1) <del> self._check_roundtrip(x1) <del> <del> dt2 = np.dtype( <del> [('a', 'b'), ('b', 'i'), ('c', 'b', (3,)), ('d', 'i')], <del> align=True) <del> x2 = np.arange(dt2.itemsize, dtype=np.int8).view(dt2) <del> self._check_roundtrip(x2) <del> <del> dt3 = np.dtype( <del> [('a', 'b'), ('b', 'i'), ('c', 'b'), ('d', 'b'), <del> ('e', 'b'), ('sub', np.dtype('b,i', align=True))]) <del> x3 = np.arange(dt3.itemsize, dtype=np.int8).view(dt3) <del> self._check_roundtrip(x3) <del> <del> <del> class TestArrayAttributeDeletion(object): <del> <del> def test_multiarray_writable_attributes_deletion(self): <del> """ticket #2046, should not seqfault, raise AttributeError""" <del> a = np.ones(2) <del> attr = ['shape', 'strides', 'data', 'dtype', 'real', 'imag', 'flat'] <del> for s in attr: <del> assert_raises(AttributeError, delattr, a, s) <del> <del> <del> def test_multiarray_not_writable_attributes_deletion(self): <del> a = np.ones(2) <del> attr = ["ndim", "flags", "itemsize", "size", "nbytes", "base", <del> "ctypes", "T", "__array_interface__", "__array_struct__", <del> "__array_priority__", "__array_finalize__"] <del> for s in attr: <del> assert_raises(AttributeError, delattr, a, s) <del> <del> <del> def test_multiarray_flags_writable_attribute_deletion(self): <del> a = np.ones(2).flags <del> attr = ['updateifcopy', 'aligned', 'writeable'] <del> for s in attr: <del> assert_raises(AttributeError, delattr, a, s) <del> <del> <del> def test_multiarray_flags_not_writable_attribute_deletion(self): <del> a = np.ones(2).flags <del> attr = ["contiguous", "c_contiguous", "f_contiguous", "fortran", <del> "owndata", "fnc", "forc", "behaved", "carray", "farray", <del> "num"] <del> for s in attr: <del> assert_raises(AttributeError, delattr, a, s) <add> def test_reference_leak(self): <add> count_1 = sys.getrefcount(np.core._internal) <add> a = np.zeros(4) <add> b = memoryview(a) <add> c = np.asarray(b) <add> count_2 = sys.getrefcount(np.core._internal) <add> assert_equal(count_1, count_2) <add> <add> def test_padded_struct_array(self): <add> dt1 = np.dtype( <add> [('a', 'b'), ('b', 'i'), ('sub', np.dtype('b,i')), ('c', 'i')], <add> align=True) <add> x1 = np.arange(dt1.itemsize, dtype=np.int8).view(dt1) <add> self._check_roundtrip(x1) <add> <add> dt2 = np.dtype( <add> [('a', 'b'), ('b', 'i'), ('c', 'b', (3,)), ('d', 'i')], <add> align=True) <add> x2 = np.arange(dt2.itemsize, dtype=np.int8).view(dt2) <add> self._check_roundtrip(x2) <add> <add> dt3 = np.dtype( <add> [('a', 'b'), ('b', 'i'), ('c', 'b'), ('d', 'b'), <add> ('e', 'b'), ('sub', np.dtype('b,i', align=True))]) <add> x3 = np.arange(dt3.itemsize, dtype=np.int8).view(dt3) <add> self._check_roundtrip(x3) <add> <add> <add>class TestArrayAttributeDeletion(object): <add> <add> def test_multiarray_writable_attributes_deletion(self): <add> """ticket #2046, should not seqfault, raise AttributeError""" <add> a = np.ones(2) <add> attr = ['shape', 'strides', 'data', 'dtype', 'real', 'imag', 'flat'] <add> for s in attr: <add> assert_raises(AttributeError, delattr, a, s) <add> <add> <add> def test_multiarray_not_writable_attributes_deletion(self): <add> a = np.ones(2) <add> attr = ["ndim", "flags", "itemsize", "size", "nbytes", "base", <add> "ctypes", "T", "__array_interface__", "__array_struct__", <add> "__array_priority__", "__array_finalize__"] <add> for s in attr: <add> assert_raises(AttributeError, delattr, a, s) <add> <add> <add> def test_multiarray_flags_writable_attribute_deletion(self): <add> a = np.ones(2).flags <add> attr = ['updateifcopy', 'aligned', 'writeable'] <add> for s in attr: <add> assert_raises(AttributeError, delattr, a, s) <add> <add> <add> def test_multiarray_flags_not_writable_attribute_deletion(self): <add> a = np.ones(2).flags <add> attr = ["contiguous", "c_contiguous", "f_contiguous", "fortran", <add> "owndata", "fnc", "forc", "behaved", "carray", "farray", <add> "num"] <add> for s in attr: <add> assert_raises(AttributeError, delattr, a, s) <ide> <ide> def test_array_interface(): <ide> # Test scalar coercion within the array interface <ide><path>numpy/core/tests/test_print.py <ide> def check_float_type(tp): <ide> assert_equal(str(tp(1e10)), str(float('1e10')), <ide> err_msg='Failed str formatting for type %s' % tp) <ide> else: <del> if sys.platform == 'win32' and sys.version_info[0] <= 2 and \ <del> sys.version_info[1] <= 5: <del> ref = '1e+010' <del> else: <del> ref = '1e+10' <add> ref = '1e+10' <ide> assert_equal(str(tp(1e10)), ref, <ide> err_msg='Failed str formatting for type %s' % tp) <ide> <ide> def check_complex_type(tp): <ide> assert_equal(str(tp(1e10)), str(complex(1e10)), <ide> err_msg='Failed str formatting for type %s' % tp) <ide> else: <del> if sys.platform == 'win32' and sys.version_info[0] <= 2 and \ <del> sys.version_info[1] <= 5: <del> ref = '(1e+010+0j)' <del> else: <del> ref = '(1e+10+0j)' <add> ref = '(1e+10+0j)' <ide> assert_equal(str(tp(1e10)), ref, <ide> err_msg='Failed str formatting for type %s' % tp) <ide> <ide> def test_complex_types(): <ide> <ide> def test_complex_inf_nan(): <ide> """Check inf/nan formatting of complex types.""" <del> if sys.version_info[:2] >= (2, 6): <del> TESTS = { <del> complex(np.inf, 0): "(inf+0j)", <del> complex(0, np.inf): "inf*j", <del> complex(-np.inf, 0): "(-inf+0j)", <del> complex(0, -np.inf): "-inf*j", <del> complex(np.inf, 1): "(inf+1j)", <del> complex(1, np.inf): "(1+inf*j)", <del> complex(-np.inf, 1): "(-inf+1j)", <del> complex(1, -np.inf): "(1-inf*j)", <del> complex(np.nan, 0): "(nan+0j)", <del> complex(0, np.nan): "nan*j", <del> complex(-np.nan, 0): "(nan+0j)", <del> complex(0, -np.nan): "nan*j", <del> complex(np.nan, 1): "(nan+1j)", <del> complex(1, np.nan): "(1+nan*j)", <del> complex(-np.nan, 1): "(nan+1j)", <del> complex(1, -np.nan): "(1+nan*j)", <del> } <del> else: <del> TESTS = { <del> complex(np.inf, 0): "(inf+0j)", <del> complex(0, np.inf): "infj", <del> complex(-np.inf, 0): "(-inf+0j)", <del> complex(0, -np.inf): "-infj", <del> complex(np.inf, 1): "(inf+1j)", <del> complex(1, np.inf): "(1+infj)", <del> complex(-np.inf, 1): "(-inf+1j)", <del> complex(1, -np.inf): "(1-infj)", <del> complex(np.nan, 0): "(nan+0j)", <del> complex(0, np.nan): "nanj", <del> complex(-np.nan, 0): "(nan+0j)", <del> complex(0, -np.nan): "nanj", <del> complex(np.nan, 1): "(nan+1j)", <del> complex(1, np.nan): "(1+nanj)", <del> complex(-np.nan, 1): "(nan+1j)", <del> complex(1, -np.nan): "(1+nanj)", <del> } <add> TESTS = { <add> complex(np.inf, 0): "(inf+0j)", <add> complex(0, np.inf): "inf*j", <add> complex(-np.inf, 0): "(-inf+0j)", <add> complex(0, -np.inf): "-inf*j", <add> complex(np.inf, 1): "(inf+1j)", <add> complex(1, np.inf): "(1+inf*j)", <add> complex(-np.inf, 1): "(-inf+1j)", <add> complex(1, -np.inf): "(1-inf*j)", <add> complex(np.nan, 0): "(nan+0j)", <add> complex(0, np.nan): "nan*j", <add> complex(-np.nan, 0): "(nan+0j)", <add> complex(0, -np.nan): "nan*j", <add> complex(np.nan, 1): "(nan+1j)", <add> complex(1, np.nan): "(1+nan*j)", <add> complex(-np.nan, 1): "(nan+1j)", <add> complex(1, -np.nan): "(1+nan*j)", <add> } <ide> for tp in [np.complex64, np.cdouble, np.clongdouble]: <ide> for c, s in TESTS.items(): <ide> yield _check_complex_inf_nan, c, s, tp <ide> def check_float_type_print(tp): <ide> if tp(1e10).itemsize > 4: <ide> _test_redirected_print(float(1e10), tp) <ide> else: <del> if sys.platform == 'win32' and sys.version_info[0] <= 2 and \ <del> sys.version_info[1] <= 5: <del> ref = '1e+010' <del> else: <del> ref = '1e+10' <add> ref = '1e+10' <ide> _test_redirected_print(float(1e10), tp, ref) <ide> <ide> def check_complex_type_print(tp): <ide> def check_complex_type_print(tp): <ide> if tp(1e10).itemsize > 8: <ide> _test_redirected_print(complex(1e10), tp) <ide> else: <del> if sys.platform == 'win32' and sys.version_info[0] <= 2 and \ <del> sys.version_info[1] <= 5: <del> ref = '(1e+010+0j)' <del> else: <del> ref = '(1e+10+0j)' <add> ref = '(1e+10+0j)' <ide> _test_redirected_print(complex(1e10), tp, ref) <ide> <ide> _test_redirected_print(complex(np.inf, 1), tp, '(inf+1j)') <ide> def test_complex_type_print(): <ide> for t in [np.complex64, np.cdouble, np.clongdouble] : <ide> yield check_complex_type_print, t <ide> <del>@dec.skipif(sys.version_info[:2] < (2, 6)) <ide> def test_scalar_format(): <ide> """Test the str.format method with NumPy scalar types""" <ide> tests = [('{0}', True, np.bool_), <ide><path>numpy/core/tests/test_umath.py <ide> def test_ldexp(self): <ide> self._check_ldexp('i') <ide> self._check_ldexp('l') <ide> <del> @dec.knownfailureif(sys.platform == 'win32' and sys.version_info < (2, 6), <del> "python.org < 2.6 binaries have broken ldexp in the " <del> "C runtime") <ide> def test_ldexp_overflow(self): <ide> # silence warning emitted on overflow <ide> err = np.seterr(over="ignore") <ide> def test_branch_cuts_failing(self): <ide> def test_against_cmath(self): <ide> import cmath, sys <ide> <del> # cmath.asinh is broken in some versions of Python, see <del> # http://bugs.python.org/issue1381 <del> broken_cmath_asinh = False <del> if sys.version_info < (2,6): <del> broken_cmath_asinh = True <del> <ide> points = [-1-1j, -1+1j, +1-1j, +1+1j] <ide> name_map = {'arcsin': 'asin', 'arccos': 'acos', 'arctan': 'atan', <ide> 'arcsinh': 'asinh', 'arccosh': 'acosh', 'arctanh': 'atanh'} <ide> def test_against_cmath(self): <ide> for p in points: <ide> a = complex(func(np.complex_(p))) <ide> b = cfunc(p) <del> <del> if cname == 'asinh' and broken_cmath_asinh: <del> continue <del> <ide> assert_(abs(a - b) < atol, "%s %s: %s; cmath: %s"%(fname,p,a,b)) <ide> <ide> def check_loss_of_precision(self, dtype): <ide><path>numpy/lib/npyio.py <ide> def __getattribute__(self, key): <ide> <ide> def zipfile_factory(*args, **kwargs): <ide> import zipfile <del> if sys.version_info >= (2, 5): <del> kwargs['allowZip64'] = True <add> kwargs['allowZip64'] = True <ide> return zipfile.ZipFile(*args, **kwargs) <ide> <ide> class NpzFile(object): <ide><path>numpy/lib/utils.py <ide> def get_numarray_include(type=None): <ide> return include_dirs + [get_include()] <ide> <ide> <del>if sys.version_info < (2, 4): <del> # Can't set __name__ in 2.3 <del> import new <del> def _set_function_name(func, name): <del> func = new.function(func.__code__, func.__globals__, <del> name, func.__defaults__, func.__closure__) <del> return func <del>else: <del> def _set_function_name(func, name): <del> func.__name__ = name <del> return func <add>def _set_function_name(func, name): <add> func.__name__ = name <add> return func <add> <ide> <ide> class _Deprecate(object): <ide> """ <ide><path>numpy/polynomial/polyutils.py <ide> class PolyDomainError(PolyError) : <ide> class PolyBase(object) : <ide> pass <ide> <del># <del># We need the any function for python < 2.5 <del># <del>if sys.version_info[:2] < (2,5) : <del> def any(iterable) : <del> for element in iterable: <del> if element : <del> return True <del> return False <del> <ide> # <ide> # Helper functions to convert inputs to 1-D arrays <ide> #
13
Text
Text
change var to const
0e71e4264af70c56cca524b6404f2ff86e745b95
<ide><path>guide/english/javascript/falsy-values/index.md <ide> if (!variable) { <ide> ## General Examples <ide> <ide> ```javascript <del>var string = ""; // <-- falsy <add>const string = ""; // <-- falsy <ide> <del>var filledString = "some string in here"; // <-- truthy <add>const filledString = "some string in here"; // <-- truthy <ide> <del>var zero = 0; // <-- falsy <add>const zero = 0; // <-- falsy <ide> <del>var numberGreaterThanZero; // <-- falsy <add>const numberGreaterThanZero; // <-- falsy <ide> <del>var emptyArray = []; // <-- truthy, we'll explore more about this next <add>const emptyArray = []; // <-- truthy, we'll explore more about this next <ide> <del>var emptyObject = {}; // <-- truthy <add>const emptyObject = {}; // <-- truthy <ide> ``` <ide> <ide> ## Fun With Arrays
1
PHP
PHP
add mysql fulltext support
36c99a358f19381f874185c8613c3748fae30dd9
<ide><path>lib/Cake/Model/Datasource/Database/Mysql.php <ide> public function index($model) { <ide> $table = $this->fullTableName($model); <ide> $old = version_compare($this->getVersion(), '4.1', '<='); <ide> if ($table) { <del> $indices = $this->_execute('SHOW INDEX FROM ' . $table); <add> $indexes = $this->_execute('SHOW INDEX FROM ' . $table); <ide> // @codingStandardsIgnoreStart <ide> // MySQL columns don't match the cakephp conventions. <del> while ($idx = $indices->fetch(PDO::FETCH_OBJ)) { <add> while ($idx = $indexes->fetch(PDO::FETCH_OBJ)) { <ide> if ($old) { <ide> $idx = (object)current((array)$idx); <ide> } <ide> if (!isset($index[$idx->Key_name]['column'])) { <ide> $col = array(); <ide> $index[$idx->Key_name]['column'] = $idx->Column_name; <del> $index[$idx->Key_name]['unique'] = intval($idx->Non_unique == 0); <add> if ($idx->Index_type === 'FULLTEXT') { <add> $index[$idx->Key_name]['type'] = strtolower($idx->Index_type); <add> } else { <add> $index[$idx->Key_name]['unique'] = intval($idx->Non_unique == 0); <add> } <ide> } else { <ide> if (!empty($index[$idx->Key_name]['column']) && !is_array($index[$idx->Key_name]['column'])) { <ide> $col[] = $index[$idx->Key_name]['column']; <ide> public function index($model) { <ide> } <ide> } <ide> // @codingStandardsIgnoreEnd <del> $indices->closeCursor(); <add> $indexes->closeCursor(); <ide> } <ide> return $index; <ide> } <ide> protected function _alterIndexes($table, $indexes) { <ide> if (isset($indexes['drop'])) { <ide> foreach ($indexes['drop'] as $name => $value) { <ide> $out = 'DROP '; <del> if ($name == 'PRIMARY') { <add> if ($name === 'PRIMARY') { <ide> $out .= 'PRIMARY KEY'; <ide> } else { <del> $out .= 'KEY ' . $name; <add> $out .= 'KEY ' . $this->startQuote . $name . $this->endQuote; <ide> } <ide> $alter[] = $out; <ide> } <ide> } <ide> if (isset($indexes['add'])) { <del> foreach ($indexes['add'] as $name => $value) { <del> $out = 'ADD '; <del> if ($name == 'PRIMARY') { <del> $out .= 'PRIMARY '; <del> $name = null; <del> } else { <del> if (!empty($value['unique'])) { <del> $out .= 'UNIQUE '; <del> } <del> } <del> if (is_array($value['column'])) { <del> $out .= 'KEY ' . $name . ' (' . implode(', ', array_map(array(&$this, 'name'), $value['column'])) . ')'; <del> } else { <del> $out .= 'KEY ' . $name . ' (' . $this->name($value['column']) . ')'; <del> } <del> $alter[] = $out; <add> $add = $this->buildIndex($indexes['add']); <add> foreach ($add as $index) { <add> $alter[] = 'ADD ' . $index; <ide> } <ide> } <ide> return $alter; <ide><path>lib/Cake/Model/Datasource/DboSource.php <ide> protected function _buildFieldParameters($columnString, $columnData, $position) <ide> } <ide> <ide> /** <del> * Format indexes for create table <add> * Format indexes for create table. <ide> * <ide> * @param array $indexes <ide> * @param string $table <ide> public function buildIndex($indexes, $table = null) { <ide> } else { <ide> if (!empty($value['unique'])) { <ide> $out .= 'UNIQUE '; <add> } elseif (!empty($value['type']) && strtoupper($value['type']) === 'FULLTEXT') { <add> $out .= 'FULLTEXT '; <ide> } <ide> $name = $this->startQuote . $name . $this->endQuote; <ide> } <ide><path>lib/Cake/Test/Case/Model/CakeSchemaTest.php <ide> public function testGenerateTable() { <ide> ); <ide> $result = $this->Schema->generateTable('posts', $posts); <ide> $this->assertRegExp('/public \$posts/', $result); <add> <add> $posts = array( <add> 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), <add> 'author_id' => array('type' => 'integer', 'null' => false), <add> 'title' => array('type' => 'string', 'null' => false), <add> 'body' => array('type' => 'text', 'null' => true, 'default' => null), <add> 'published' => array('type' => 'string', 'null' => true, 'default' => 'N', 'length' => 1), <add> 'created' => array('type' => 'datetime', 'null' => true, 'default' => null), <add> 'updated' => array('type' => 'datetime', 'null' => true, 'default' => null), <add> 'indexes' => array( <add> 'PRIMARY' => array('column' => 'id', 'unique' => true), <add> 'MyFtIndex' => array('column' => array('title', 'body'), 'type' => 'fulltext') <add> ) <add> ); <add> $result = $this->Schema->generateTable('fields', $posts); <add> $this->assertRegExp('/public \$fields/', $result); <add> $this->assertPattern('/\'type\' \=\> \'fulltext\'/', $result); <ide> } <ide> <ide> /** <ide><path>lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php <ide> public function testIndexDetection() { <ide> $result = $this->Dbo->index('with_multiple_compound_keys', false); <ide> $this->Dbo->rawQuery('DROP TABLE ' . $name); <ide> $this->assertEquals($expected, $result); <add> <add> $name = $this->Dbo->fullTableName('with_fulltext'); <add> $this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, name varchar(255), description text, primary key(id), FULLTEXT KEY `MyFtIndex` ( `name`, `description` )) ENGINE=MyISAM;'); <add> $expected = array( <add> 'PRIMARY' => array('column' => 'id', 'unique' => 1), <add> 'MyFtIndex' => array('column' => array('name', 'description'), 'type' => 'fulltext') <add> ); <add> $result = $this->Dbo->index('with_fulltext', false); <add> $this->Dbo->rawQuery('DROP TABLE ' . $name); <add> $this->assertEquals($expected, $result); <ide> } <ide> <ide> /** <ide> public function testAlterSchemaIndexes() { <ide> <ide> $result = $this->Dbo->alterSchema($schemaB->compare($schemaA)); <ide> $this->assertContains("ALTER TABLE $table", $result); <del> $this->assertContains('ADD KEY name_idx (`name`),', $result); <del> $this->assertContains('ADD KEY group_idx (`group1`),', $result); <del> $this->assertContains('ADD KEY compound_idx (`group1`, `group2`),', $result); <add> $this->assertContains('ADD KEY `name_idx` (`name`),', $result); <add> $this->assertContains('ADD KEY `group_idx` (`group1`),', $result); <add> $this->assertContains('ADD KEY `compound_idx` (`group1`, `group2`),', $result); <ide> $this->assertContains('ADD PRIMARY KEY (`id`);', $result); <ide> <ide> //Test that the string is syntactically correct <ide> public function testAlterSchemaIndexes() { <ide> $result = $this->Dbo->alterSchema($schemaC->compare($schemaB)); <ide> $this->assertContains("ALTER TABLE $table", $result); <ide> $this->assertContains('DROP PRIMARY KEY,', $result); <del> $this->assertContains('DROP KEY name_idx,', $result); <del> $this->assertContains('DROP KEY group_idx,', $result); <del> $this->assertContains('DROP KEY compound_idx,', $result); <del> $this->assertContains('ADD KEY id_name_idx (`id`, `name`),', $result); <del> $this->assertContains('ADD UNIQUE KEY name_idx (`name`),', $result); <del> $this->assertContains('ADD KEY group_idx (`group2`),', $result); <del> $this->assertContains('ADD KEY compound_idx (`group2`, `group1`);', $result); <add> $this->assertContains('DROP KEY `name_idx`,', $result); <add> $this->assertContains('DROP KEY `group_idx`,', $result); <add> $this->assertContains('DROP KEY `compound_idx`,', $result); <add> $this->assertContains('ADD KEY `id_name_idx` (`id`, `name`),', $result); <add> $this->assertContains('ADD UNIQUE KEY `name_idx` (`name`),', $result); <add> $this->assertContains('ADD KEY `group_idx` (`group2`),', $result); <add> $this->assertContains('ADD KEY `compound_idx` (`group2`, `group1`);', $result); <ide> <ide> $query = $this->Dbo->getConnection()->prepare($result); <ide> $this->assertEquals($query->queryString, $result); <ide> public function testAlterSchemaIndexes() { <ide> $result = $this->Dbo->alterSchema($schemaA->compare($schemaC)); <ide> <ide> $this->assertContains("ALTER TABLE $table", $result); <del> $this->assertContains('DROP KEY name_idx,', $result); <del> $this->assertContains('DROP KEY group_idx,', $result); <del> $this->assertContains('DROP KEY compound_idx,', $result); <del> $this->assertContains('DROP KEY id_name_idx;', $result); <add> $this->assertContains('DROP KEY `name_idx`,', $result); <add> $this->assertContains('DROP KEY `group_idx`,', $result); <add> $this->assertContains('DROP KEY `compound_idx`,', $result); <add> $this->assertContains('DROP KEY `id_name_idx`;', $result); <ide> <ide> $query = $this->Dbo->getConnection()->prepare($result); <ide> $this->assertEquals($query->queryString, $result); <ide> public function testBuildIndex() { <ide> $result = $this->Dbo->buildIndex($data); <ide> $expected = array('UNIQUE KEY `MyIndex` (`id`, `name`)'); <ide> $this->assertEquals($expected, $result); <add> <add> $data = array( <add> 'MyFtIndex' => array('column' => array('name', 'description'), 'type' => 'fulltext') <add> ); <add> $result = $this->Dbo->buildIndex($data); <add> $expected = array('FULLTEXT KEY `MyFtIndex` (`name`, `description`)'); <add> $this->assertEquals($expected, $result); <ide> } <ide> <ide> /**
4
PHP
PHP
strengthen typing in the new method
0c86b956b51c465fcf2b865f12681855a8a2ca1c
<ide><path>src/View/Helper/FormHelper.php <ide> public function getValueSources(): array <ide> /** <ide> * Extracts valid value sources. <ide> * <del> * @param string|string[] $sources A string or a list of strings identifying a source. <add> * @param string[] $sources A a list of strings identifying a source. <ide> * @return string[] <ide> */ <del> protected function _extractValidValueSources($sources): array <add> protected function _extractValidValueSources(array $sources): array <ide> { <del> return array_values(array_intersect((array)$sources, $this->_supportedValueSources)); <add> return array_values(array_intersect($sources, $this->_supportedValueSources)); <ide> } <ide> <ide> /** <ide> protected function _extractValidValueSources($sources): array <ide> */ <ide> public function setValueSources($sources) <ide> { <del> $this->_valueSources = $this->_extractValidValueSources($sources); <add> $this->_valueSources = $this->_extractValidValueSources((array) $sources); <ide> <ide> return $this; <ide> }
1
Text
Text
add pretrain example
543073bf9d998e5efaa1065a36c4eecef2f86668
<ide><path>website/docs/api/cli.md <ide> in the section `[paths]`. <ide> > #### Example <ide> > <ide> > ```cli <del>> $ python -m spacy train config.cfg --paths.train="./train" --paths.dev="./dev" --output output_dir <add>> $ python -m spacy train config.cfg --output output_dir --paths.train="./train" --paths.dev="./dev" <ide> > ``` <ide> <ide> ```cli <ide> auto-generated by setting `--pretraining` on <ide> <ide> </Infobox> <ide> <add>> #### Example <add>> <add>> ```cli <add>> $ python -m spacy pretrain config.cfg output_pretrain --paths.raw_text="data.jsonl" <add>> ``` <add> <add> <ide> ```cli <ide> $ python -m spacy pretrain [config_path] [output_dir] [--code] [--resume-path] [--epoch-resume] [--gpu-id] [overrides] <ide> ```
1
Ruby
Ruby
fix empty url_for with nested modules #707
b7889524bfe861e38aa7f384ed116f2b15068fe1
<ide><path>actionpack/lib/action_controller/routing.rb <ide> def generate(options, request) <ide> <ide> options = options.symbolize_keys <ide> defaults = request.path_parameters.symbolize_keys <del> options = defaults if options.empty? # Get back the current url if no options was passed <del> expand_controller_path!(options, defaults) <add> if options.empty? then options = defaults.clone # Get back the current url if no options was passed <add> else expand_controller_path!(options, defaults) # Expand the supplied controller path. <add> end <ide> defaults.delete_if {|k, v| options.key?(k) && options[k].nil?} # Remove defaults that have been manually cleared using :name => nil <ide> <ide> failures = [] <ide><path>actionpack/test/controller/routing_tests.rb <ide> def test_default_dropped_with_nil_option <ide> @request.path_parameters = {:controller => 'content', :action => 'action', :id => '10'} <ide> verify_generate 'content/action', {:id => nil} <ide> end <add> <add> def test_url_to_self <add> @request.path_parameters = {:controller => 'admin/users', :action => 'index'} <add> verify_generate 'admin/users', {} <add> end <ide> end <ide> <ide> #require '../assertions/action_pack_assertions.rb'
2
Go
Go
add log entries for daemon startup/shutdown
595987fd082165b0c5739993b374bb5b6fa3f466
<ide><path>cmd/dockerd/daemon.go <ide> func (cli *DaemonCli) start(opts *daemonOptions) (err error) { <ide> return err <ide> } <ide> <add> logrus.Info("Starting up") <add> <ide> cli.configFile = &opts.configFile <ide> cli.flags = opts.flags <ide> <ide> func (cli *DaemonCli) start(opts *daemonOptions) (err error) { <ide> return errors.Wrap(errAPI, "shutting down due to ServeAPI error") <ide> } <ide> <add> logrus.Info("Daemon shutdown complete") <ide> return nil <ide> } <ide> <ide><path>cmd/dockerd/daemon_unix.go <ide> import ( <ide> "github.com/docker/docker/pkg/homedir" <ide> "github.com/docker/libnetwork/portallocator" <ide> "github.com/pkg/errors" <add> "github.com/sirupsen/logrus" <ide> "golang.org/x/sys/unix" <ide> ) <ide> <ide> func (cli *DaemonCli) initContainerD(ctx context.Context) (func(time.Duration) e <ide> return nil, errors.Wrap(err, "could not determine whether the system containerd is running") <ide> } <ide> if !ok { <add> logrus.Debug("Containerd not running, starting daemon managed containerd") <ide> opts, err := cli.getContainerdDaemonOpts() <ide> if err != nil { <ide> return nil, errors.Wrap(err, "failed to generate containerd options") <ide> func (cli *DaemonCli) initContainerD(ctx context.Context) (func(time.Duration) e <ide> if err != nil { <ide> return nil, errors.Wrap(err, "failed to start containerd") <ide> } <add> logrus.Debug("Started daemon managed containerd") <ide> cli.Config.ContainerdAddr = r.Address() <ide> <ide> // Try to wait for containerd to shutdown <ide><path>internal/test/daemon/daemon.go <ide> func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error { <ide> return errors.Errorf("[%s] Daemon exited and never started", d.id) <ide> case <-tick: <ide> ctx, cancel := context.WithTimeout(context.TODO(), 2*time.Second) <del> req := req.WithContext(ctx) <del> <del> resp, err := client.Do(req) <add> resp, err := client.Do(req.WithContext(ctx)) <ide> cancel() <ide> if err != nil { <ide> d.log.Logf("[%s] error pinging daemon on start: %v", d.id, err) <ide> func (d *Daemon) Stop(t testingT) { <ide> // If it timeouts, a SIGKILL is sent. <ide> // Stop will not delete the daemon directory. If a purged daemon is needed, <ide> // instantiate a new one with NewDaemon. <del>func (d *Daemon) StopWithError() error { <add>func (d *Daemon) StopWithError() (err error) { <ide> if d.cmd == nil || d.Wait == nil { <ide> return errDaemonNotStarted <ide> } <ide> defer func() { <del> d.log.Logf("[%s] Daemon stopped", d.id) <add> if err == nil { <add> d.log.Logf("[%s] Daemon stopped", d.id) <add> } else { <add> d.log.Logf("[%s] Error when stopping daemon: %v", d.id, err) <add> } <ide> d.logFile.Close() <ide> d.cmd = nil <ide> }() <ide> func (d *Daemon) Restart(t testingT, args ...string) { <ide> // RestartWithError will restart the daemon by first stopping it and then starting it. <ide> func (d *Daemon) RestartWithError(arg ...string) error { <ide> if err := d.StopWithError(); err != nil { <del> d.log.Logf("[%s] Error when stopping daemon: %v", d.id, err) <ide> return err <ide> } <ide> return d.StartWithError(arg...)
3
Text
Text
fix links to download parsey models
9a463f1e8f75e4a95dca5dd4542ccde9aef37704
<ide><path>syntaxnet/g3doc/universal.md <ide> # Parsey Universal. <ide> <ide> A collection of pretrained syntactic models is now available for download at <del>`http://download.tensorflow.org/models/<language>.zip` <add>`http://download.tensorflow.org/models/parsey_universal/<language>.zip` <ide> <ide> After downloading and unzipping a model, you can run it similarly to <ide> Parsey McParseface with:
1
PHP
PHP
remove blank line
1aeceec0a3550735728d122fa3bb3ec4994270cd
<ide><path>tests/TestCase/Database/ConnectionTest.php <ide> class ConnectionTest extends TestCase <ide> */ <ide> protected $nestedTransactionStates = []; <ide> <del> <ide> public function setUp() <ide> { <ide> parent::setUp(); <ide><path>tests/TestCase/ORM/QueryTest.php <ide> public function testNotSoFarMatchingWithContainOnTheSameAssociation() <ide> $this->assertEquals(2, $result->_matchingData['tags']->id); <ide> } <ide> <del> <ide> /** <ide> * Tests that it is possible to find large numeric values. <ide> *
2
Text
Text
fix the instruction of running next
d9ea4ce3123bd6a764de16f3245bc88d206c08df
<ide><path>README.md <ide> Install it: <ide> $ npm install next --save <ide> ``` <ide> <add>and add a script to your package.json like this: <add> <add>```json <add>{ <add> "scripts": { <add> "start": "next" <add> } <add>} <add>``` <add> <ide> After that, the file-system is the main API. Every `.js` file becomes a route that gets automatically processed and rendered. <ide> <ide> Populate `./pages/index.js` inside your project: <ide> export default () => ( <ide> ) <ide> ``` <ide> <del>and then just run `next` and go to `http://localhost:3000` <add>and then just run `npm start` and go to `http://localhost:3000` <ide> <ide> So far, we get: <ide>
1
PHP
PHP
refactor the encryption class
f6aecf706a4022bed6b11929522664d1cebfee08
<ide><path>system/crypt.php <ide> private static function randomizer() <ide> { <ide> return MCRYPT_DEV_RANDOM; <ide> } <del> else <del> { <del> return MCRYPT_RAND; <del> } <add> <add> return MCRYPT_RAND; <ide> } <ide> <ide> /**
1
Javascript
Javascript
update code style
37777d7cb37de4a3fc1d59657e1a2392a8d47a5c
<ide><path>editor/js/Config.js <ide> var Config = function () { <ide> 'project/renderer/gammaOutput': false, <ide> 'project/renderer/shadows': true, <ide> 'project/renderer/showHelpers': true, <del> 'project/renderer/sceneCameras': 'topRight', <ide> 'project/renderer/showSceneCameras': true, <ide> <ide> 'project/vr': false, <ide><path>editor/js/Viewport.js <ide> var Viewport = function ( editor ) { <ide> <ide> var optionSelected = config.getKey( 'project/renderer/showSceneCameras' ) === true; <ide> sceneCameraDisplay.setDisplay( optionSelected && Object.keys( cameras ).length > 0 ? 'block' : 'none' ); <del> if(optionSelected === false) <del> { <del> cameraSelect.setValue(camera.uuid); <add> if ( optionSelected === false ) { <add> <add> cameraSelect.setValue( camera.uuid ); <ide> render(); <add> <ide> } <ide> <ide> } );
2
Python
Python
update logarithm docs as per theory.
c74cdc87822f62156db3e10e3bb566d54fa41745
<ide><path>numpy/core/code_generators/ufunc_docstrings.py <ide> def add_newdoc(place, name, doc): <ide> ----- <ide> Logarithm is a multivalued function: for each `x` there is an infinite <ide> number of `z` such that `exp(z) = x`. The convention is to return the <del> `z` whose imaginary part lies in `[-pi, pi]`. <add> `z` whose imaginary part lies in `(-pi, pi]`. <ide> <ide> For real-valued input data types, `log` always returns real output. For <ide> each value that cannot be expressed as a real number or infinity, it <ide> def add_newdoc(place, name, doc): <ide> has a branch cut `[-inf, 0]` and is continuous from above on it. `log` <ide> handles the floating-point negative zero as an infinitesimal negative <ide> number, conforming to the C99 standard. <add> <add> In the cases where the input has a negative real part and a very small <add> negative complex part (approaching 0), the result is so close to `-pi` <add> that it evaluates to exactly `-pi`. <ide> <ide> References <ide> ---------- <ide> def add_newdoc(place, name, doc): <ide> ----- <ide> Logarithm is a multivalued function: for each `x` there is an infinite <ide> number of `z` such that `10**z = x`. The convention is to return the <del> `z` whose imaginary part lies in `[-pi, pi]`. <add> `z` whose imaginary part lies in `(-pi, pi]`. <ide> <ide> For real-valued input data types, `log10` always returns real output. <ide> For each value that cannot be expressed as a real number or infinity, <ide> def add_newdoc(place, name, doc): <ide> `log10` handles the floating-point negative zero as an infinitesimal <ide> negative number, conforming to the C99 standard. <ide> <add> In the cases where the input has a negative real part and a very small <add> negative complex part (approaching 0), the result is so close to `-pi` <add> that it evaluates to exactly `-pi`. <add> <ide> References <ide> ---------- <ide> .. [1] M. Abramowitz and I.A. Stegun, "Handbook of Mathematical Functions", <ide> def add_newdoc(place, name, doc): <ide> <ide> Logarithm is a multivalued function: for each `x` there is an infinite <ide> number of `z` such that `2**z = x`. The convention is to return the `z` <del> whose imaginary part lies in `[-pi, pi]`. <add> whose imaginary part lies in `(-pi, pi]`. <ide> <ide> For real-valued input data types, `log2` always returns real output. <ide> For each value that cannot be expressed as a real number or infinity, <ide> def add_newdoc(place, name, doc): <ide> handles the floating-point negative zero as an infinitesimal negative <ide> number, conforming to the C99 standard. <ide> <add> In the cases where the input has a negative real part and a very small <add> negative complex part (approaching 0), the result is so close to `-pi` <add> that it evaluates to exactly `-pi`. <add> <ide> Examples <ide> -------- <ide> >>> x = np.array([0, 1, 2, 2**4])
1
PHP
PHP
remove unused property
9faec97267258d1c6b292c23a53c8285a2bd84cb
<ide><path>src/Console/ShellDispatcher.php <ide> */ <ide> class ShellDispatcher { <ide> <del>/** <del> * Contains command switches parsed from the command line. <del> * <del> * @var array <del> */ <del> public $params = []; <del> <ide> /** <ide> * Contains arguments parsed from the command line. <ide> *
1
Javascript
Javascript
fix banner for old node version
523d39ad923ad67a8d6a61a217f1b4fd869e2a17
<ide><path>local-cli/server/formatBanner.js <ide> var BOTTOM_RIGHT = '\u2518'; <ide> function formatBanner(message, options) { <ide> options = options || {}; <ide> _.defaults(options, { <del> chalkFunction: (fn) => fn, <add> chalkFunction: _.identity, <ide> width: 80, <ide> marginLeft: 0, <ide> marginRight: 0,
1
Python
Python
add push_to_hub method to processors
2d02f7b29b8c18a68260378246f9e26621021c30
<ide><path>src/transformers/processing_utils.py <ide> from pathlib import Path <ide> <ide> from .dynamic_module_utils import custom_object_save <add>from .file_utils import PushToHubMixin, copy_func <ide> from .tokenization_utils_base import PreTrainedTokenizerBase <add>from .utils import logging <ide> <ide> <add>logger = logging.get_logger(__name__) <add> <ide> # Dynamically import the Transformers module to grab the attribute classes of the processor form their names. <ide> spec = importlib.util.spec_from_file_location( <ide> "transformers", Path(__file__).parent / "__init__.py", submodule_search_locations=[Path(__file__).parent] <ide> } <ide> <ide> <del>class ProcessorMixin: <add>class ProcessorMixin(PushToHubMixin): <ide> """ <ide> This is a mixin used to provide saving/loading functionality for all processor classes. <ide> """ <ide> def __repr__(self): <ide> attributes_repr = "\n".join(attributes_repr) <ide> return f"{self.__class__.__name__}:\n{attributes_repr}" <ide> <del> def save_pretrained(self, save_directory): <add> def save_pretrained(self, save_directory, push_to_hub: bool = False, **kwargs): <ide> """ <ide> Saves the attributes of this processor (feature extractor, tokenizer...) in the specified directory so that it <ide> can be reloaded using the [`~ProcessorMixin.from_pretrained`] method. <ide> def save_pretrained(self, save_directory): <ide> save_directory (`str` or `os.PathLike`): <ide> Directory where the feature extractor JSON file and the tokenizer files will be saved (directory will <ide> be created if it does not exist). <add> push_to_hub (`bool`, *optional*, defaults to `False`): <add> Whether or not to push your processor to the Hugging Face model hub after saving it. <add> <add> <Tip warning={true}> <add> <add> Using `push_to_hub=True` will synchronize the repository you are pushing to with `save_directory`, <add> which requires `save_directory` to be a local clone of the repo you are pushing to if it's an existing <add> folder. Pass along `temp_dir=True` to use a temporary directory instead. <add> <add> </Tip> <add> <add> kwargs: <add> Additional key word arguments passed along to the [`~file_utils.PushToHubMixin.push_to_hub`] method. <ide> """ <add> if push_to_hub: <add> commit_message = kwargs.pop("commit_message", None) <add> repo = self._create_or_get_repo(save_directory, **kwargs) <add> <ide> os.makedirs(save_directory, exist_ok=True) <ide> # If we have a custom config, we copy the file defining it in the folder and set the attributes so it can be <ide> # loaded from the Hub. <ide> def save_pretrained(self, save_directory): <ide> if isinstance(attribute, PreTrainedTokenizerBase): <ide> del attribute.init_kwargs["auto_map"] <ide> <add> if push_to_hub: <add> url = self._push_to_hub(repo, commit_message=commit_message) <add> logger.info(f"Processor pushed to the hub in this commit: {url}") <add> <ide> @classmethod <ide> def from_pretrained(cls, pretrained_model_name_or_path, **kwargs): <ide> r""" <ide> def _get_arguments_from_pretrained(cls, pretrained_model_name_or_path, **kwargs) <ide> <ide> args.append(attribute_class.from_pretrained(pretrained_model_name_or_path, **kwargs)) <ide> return args <add> <add> <add>ProcessorMixin.push_to_hub = copy_func(ProcessorMixin.push_to_hub) <add>ProcessorMixin.push_to_hub.__doc__ = ProcessorMixin.push_to_hub.__doc__.format( <add> object="processor", object_class="AutoProcessor", object_files="processor files" <add>) <ide><path>tests/test_processor_auto.py <ide> ) <ide> SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/vocab.json") <ide> <del>SAMPLE_FEATURE_EXTRACTION_CONFIG_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures") <add>SAMPLE_PROCESSOR_CONFIG_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures") <ide> <ide> <ide> class AutoFeatureExtractorTest(unittest.TestCase): <ide> def setUpClass(cls): <ide> <ide> @classmethod <ide> def tearDownClass(cls): <add> try: <add> delete_repo(token=cls._token, name="test-processor") <add> except HTTPError: <add> pass <add> <add> try: <add> delete_repo(token=cls._token, name="test-processor-org", organization="valid_org") <add> except HTTPError: <add> pass <add> <ide> try: <ide> delete_repo(token=cls._token, name="test-dynamic-processor") <ide> except HTTPError: <ide> pass <ide> <add> def test_push_to_hub(self): <add> processor = Wav2Vec2Processor.from_pretrained(SAMPLE_PROCESSOR_CONFIG_DIR) <add> with tempfile.TemporaryDirectory() as tmp_dir: <add> processor.save_pretrained( <add> os.path.join(tmp_dir, "test-processor"), push_to_hub=True, use_auth_token=self._token <add> ) <add> <add> new_processor = Wav2Vec2Processor.from_pretrained(f"{USER}/test-processor") <add> for k, v in processor.feature_extractor.__dict__.items(): <add> self.assertEqual(v, getattr(new_processor.feature_extractor, k)) <add> self.assertDictEqual(new_processor.tokenizer.get_vocab(), processor.tokenizer.get_vocab()) <add> <add> def test_push_to_hub_in_organization(self): <add> processor = Wav2Vec2Processor.from_pretrained(SAMPLE_PROCESSOR_CONFIG_DIR) <add> <add> with tempfile.TemporaryDirectory() as tmp_dir: <add> processor.save_pretrained( <add> os.path.join(tmp_dir, "test-processor-org"), <add> push_to_hub=True, <add> use_auth_token=self._token, <add> organization="valid_org", <add> ) <add> <add> new_processor = Wav2Vec2Processor.from_pretrained("valid_org/test-processor-org") <add> for k, v in processor.feature_extractor.__dict__.items(): <add> self.assertEqual(v, getattr(new_processor.feature_extractor, k)) <add> self.assertDictEqual(new_processor.tokenizer.get_vocab(), processor.tokenizer.get_vocab()) <add> <ide> def test_push_to_hub_dynamic_processor(self): <ide> CustomFeatureExtractor.register_for_auto_class() <ide> CustomTokenizer.register_for_auto_class() <ide> CustomProcessor.register_for_auto_class() <ide> <del> feature_extractor = CustomFeatureExtractor.from_pretrained(SAMPLE_FEATURE_EXTRACTION_CONFIG_DIR) <add> feature_extractor = CustomFeatureExtractor.from_pretrained(SAMPLE_PROCESSOR_CONFIG_DIR) <ide> <ide> with tempfile.TemporaryDirectory() as tmp_dir: <ide> vocab_file = os.path.join(tmp_dir, "vocab.txt")
2
Text
Text
change the info to the same as in gitconfig
1f93b63b11fabef5a8f252c149c2c641e21ae0d8
<ide><path>README.md <ide> information about the governance of the io.js project, see <ide> * **Sam Roberts** &lt;vieuxtech@gmail.com&gt; ([@sam-github](https://github.com/sam-github)) <ide> * **Wyatt Preul** &lt;wpreul@gmail.com&gt; ([@geek](https://github.com/geek)) <ide> * **Brian White** &lt;mscdex@mscdex.net&gt; ([@mscdex](https://github.com/mscdex)) <del>* **Christian Vaagland Tellnes** &lt;christian@tellnes.com&gt; ([@tellnes](https://github.com/tellnes)) <add>* **Christian Tellnes** &lt;christian@tellnes.no&gt; ([@tellnes](https://github.com/tellnes)) <ide> * **Robert Kowalski** &lt;rok@kowalski.gd&gt; ([@robertkowalski](https://github.com/robertkowalski)) <ide> * **Julian Duque** &lt;julianduquej@gmail.com&gt; ([@julianduque](https://github.com/julianduque)) <ide> * **Johan Bergström** &lt;bugs@bergstroem.nu&gt; ([@jbergstroem](https://github.com/jbergstroem))
1
Text
Text
fix typo in website readme.md
37a3772fffe95737667bcea6721c9b839598ddc4
<ide><path>website/README.md <ide> For example: <ide> +h(2, "link-id") Headline 2 with link to #link-id <ide> ``` <ide> <del>Code blocks are implemented using the `+code` or `+aside-code` (to display them in the sidebar). A `.` is added after the mixin call to preserve whitespace: <add>Code blocks are implemented using `+code` or `+aside-code` (to display them in the right sidebar). A `.` is added after the mixin call to preserve whitespace: <ide> <ide> ```pug <ide> +code("This is a label").
1
Ruby
Ruby
move caskdependencies to its own file
4216da7629c21be66e8cf609fdfbf133b1e6bc6f
<ide><path>Library/Homebrew/cask_dependent.rb <add># An adapter for casks to provide dependency information in a formula-like interface <add>class CaskDependent <add> def initialize(cask) <add> @cask = cask <add> end <add> <add> def name <add> @cask.token <add> end <add> <add> def full_name <add> @cask.full_name <add> end <add> <add> def runtime_dependencies <add> recursive_dependencies <add> end <add> <add> def deps <add> @deps ||= begin <add> @cask.depends_on.formula.map do |f| <add> Dependency.new f <add> end <add> end <add> end <add> <add> def requirements <add> @requirements ||= begin <add> requirements = [] <add> dsl_reqs = @cask.depends_on <add> <add> dsl_reqs.arch&.each do |arch| <add> requirements << ArchRequirement.new([:x86_64]) if arch[:bits] == 64 <add> requirements << ArchRequirement.new([arch[:type]]) <add> end <add> dsl_reqs.cask.each do |cask_ref| <add> requirements << Requirement.new([{ cask: cask_ref }]) <add> end <add> requirements << dsl_reqs.macos if dsl_reqs.macos <add> requirements << X11Requirement.new if dsl_reqs.x11 <add> <add> requirements <add> end <add> end <add> <add> def recursive_dependencies(&block) <add> Dependency.expand(self, &block) <add> end <add> <add> def recursive_requirements(&block) <add> Requirement.expand(self, &block) <add> end <add> <add> def any_version_installed? <add> @cask.installed? <add> end <add>end <ide><path>Library/Homebrew/cmd/deps.rb <ide> def dependents(formulae_or_casks) <ide> if formula_or_cask.is_a?(Formula) <ide> formula_or_cask <ide> else <del> Dependent.new(formula_or_cask) <add> CaskDependent.new(formula_or_cask) <ide> end <ide> end <ide> end <ide> def recursive_deps_tree(f, prefix, recursive) <ide> <ide> @dep_stack.pop <ide> end <del> <del> class Dependent <del> def initialize(cask) <del> @cask = cask <del> end <del> <del> def name <del> @cask.token <del> end <del> <del> def full_name <del> @cask.full_name <del> end <del> <del> def runtime_dependencies <del> recursive_dependencies <del> end <del> <del> def deps <del> @deps ||= begin <del> @cask.depends_on.formula.map do |f| <del> Dependency.new f <del> end <del> end <del> end <del> <del> def requirements <del> @requirements ||= begin <del> requirements = [] <del> dsl_reqs = @cask.depends_on <del> <del> dsl_reqs.arch&.each do |arch| <del> requirements << ArchRequirement.new([:x86_64]) if arch[:bits] == 64 <del> requirements << ArchRequirement.new([arch[:type]]) <del> end <del> dsl_reqs.cask.each do |cask_ref| <del> requirements << Requirement.new([{ cask: cask_ref }]) <del> end <del> requirements << dsl_reqs.macos if dsl_reqs.macos <del> requirements << X11Requirement.new if dsl_reqs.x11 <del> <del> requirements <del> end <del> end <del> <del> def recursive_dependencies(&block) <del> Dependency.expand(self, &block) <del> end <del> <del> def recursive_requirements(&block) <del> Requirement.expand(self, &block) <del> end <del> <del> def any_version_installed? <del> @cask.installed? <del> end <del> end <ide> end
2
Text
Text
update jasmine link
8192b8c27ff2e3165f022cbdf691b30e61986861
<ide><path>docs/docs/09.4-test-utils.md <ide> prev: class-name-manipulation.html <ide> next: clone-with-props.html <ide> --- <ide> <del>`React.addons.TestUtils` makes it easy to test React components in the testing framework of your choice (we use [Jasmine](http://pivotal.github.io/jasmine/) with [jsdom](https://github.com/tmpvar/jsdom)). <add>`React.addons.TestUtils` makes it easy to test React components in the testing framework of your choice (we use [Jasmine](http://jasmine.github.io) with [jsdom](https://github.com/tmpvar/jsdom)). <ide> <ide> ### Simulate <ide>
1
Javascript
Javascript
introduce 'statics' for class specification
79b9d5af627a6f0e5c6c3496d7e3161df871f899
<ide><path>src/core/ReactCompositeComponent.js <ide> var SpecPolicy = keyMirror({ <ide> */ <ide> var ReactCompositeComponentInterface = { <ide> <del> /** <del> * An array of Mixin objects to include when defining your component. <del> * <del> * @type {array} <del> * @optional <del> */ <del> mixins: SpecPolicy.DEFINE_MANY, <del> <del> /** <del> * Definition of prop types for this component. <del> * <del> * @type {object} <del> * @optional <del> */ <del> propTypes: SpecPolicy.DEFINE_MANY_MERGED, <del> <del> /** <del> * Definition of context types for this component. <del> * <del> * @type {object} <del> * @optional <del> */ <del> contextTypes: SpecPolicy.DEFINE_MANY_MERGED, <del> <del> /** <del> * Definition of context types this component sets for its children. <del> * <del> * @type {object} <del> * @optional <del> */ <del> childContextTypes: SpecPolicy.DEFINE_MANY_MERGED, <del> <add> statics: { <add> /** <add> * An array of Mixin objects to include when defining your component. <add> * <add> * @type {array} <add> * @optional <add> */ <add> mixins: SpecPolicy.DEFINE_MANY, <add> <add> /** <add> * Definition of prop types for this component. <add> * <add> * @type {object} <add> * @optional <add> */ <add> propTypes: SpecPolicy.DEFINE_MANY_MERGED, <add> <add> /** <add> * Definition of context types for this component. <add> * <add> * @type {object} <add> * @optional <add> */ <add> contextTypes: SpecPolicy.DEFINE_MANY_MERGED, <add> <add> /** <add> * Definition of context types this component sets for its children. <add> * <add> * @type {object} <add> * @optional <add> */ <add> childContextTypes: SpecPolicy.DEFINE_MANY_MERGED <add> }, <ide> <ide> // ==== Definition methods ==== <ide> <ide> var ReactCompositeComponentInterface = { <ide> }; <ide> <ide> /** <del> * Mapping from class specification keys to special processing functions. <add> * Mapping from class specification static keys to special processing functions. <add> * <add> * These are all defined inside the "statics" key in the class spec: <add> * <add> * React.createClass({ <add> * statics: { <add> * mixins: [FooMixin] <add> * }, <add> * render: function() {...} <add> * }) <ide> * <ide> * Although these are declared in the specification when defining classes <ide> * using `React.createClass`, they will not be on the component's prototype. <ide> */ <del>var RESERVED_SPEC_KEYS = { <del> displayName: function(Constructor, displayName) { <del> Constructor.displayName = displayName; <del> }, <del> mixins: function(Constructor, mixins) { <add>var RESERVED_STATIC_SPEC_KEYS = { <add> mixins: function(ConvenienceConstructor, mixins) { <ide> if (mixins) { <ide> for (var i = 0; i < mixins.length; i++) { <del> mixSpecIntoComponent(Constructor, mixins[i]); <add> mixSpecIntoComponent(ConvenienceConstructor, mixins[i]); <ide> } <ide> } <ide> }, <del> childContextTypes: function(Constructor, childContextTypes) { <add> childContextTypes: function(ConvenienceConstructor, childContextTypes) { <add> var Constructor = ConvenienceConstructor.componentConstructor; <ide> validateTypeDef( <ide> Constructor, <ide> childContextTypes, <ide> ReactPropTypeLocations.childContext <ide> ); <ide> Constructor.childContextTypes = childContextTypes; <ide> }, <del> contextTypes: function(Constructor, contextTypes) { <add> contextTypes: function(ConvenienceConstructor, contextTypes) { <add> var Constructor = ConvenienceConstructor.componentConstructor; <ide> validateTypeDef( <ide> Constructor, <ide> contextTypes, <ide> ReactPropTypeLocations.context <ide> ); <ide> Constructor.contextTypes = contextTypes; <ide> }, <del> propTypes: function(Constructor, propTypes) { <add> propTypes: function(ConvenienceConstructor, propTypes) { <add> var Constructor = ConvenienceConstructor.componentConstructor; <ide> validateTypeDef( <ide> Constructor, <ide> propTypes, <ide> var RESERVED_SPEC_KEYS = { <ide> } <ide> }; <ide> <add>/** <add> * Mapping from class specification keys to special processing functions. <add> * <add> * Although these are declared in the specification when defining classes <add> * using `React.createClass`, they will not be on the component's prototype. <add> */ <add>var RESERVED_SPEC_KEYS = { <add> // TODO: move this to RESERVED_STATIC_SPEC_KEYS, but this requires also <add> // changing the JSX transform. <add> displayName: function(ConvenienceConstructor, displayName) { <add> ConvenienceConstructor.componentConstructor.displayName = displayName; <add> }, <add> <add> statics: function(ConvenienceConstructor, statics) { <add> mixStaticSpecIntoComponent(ConvenienceConstructor, statics); <add> } <add>}; <add> <ide> function validateTypeDef(Constructor, typeDef, location) { <ide> for (var propName in typeDef) { <ide> if (typeDef.hasOwnProperty(propName)) { <ide> function validateTypeDef(Constructor, typeDef, location) { <ide> } <ide> } <ide> <del>function validateMethodOverride(proto, name) { <del> var specPolicy = ReactCompositeComponentInterface[name]; <add>function validateMethodOverride(proto, name, isStatic) { <add> var specPolicy = isStatic ? <add> ReactCompositeComponentInterface.statics[name] : <add> ReactCompositeComponentInterface[name]; <ide> <ide> // Disallow overriding of base class methods unless explicitly allowed. <del> if (ReactCompositeComponentMixin.hasOwnProperty(name)) { <add> if (!isStatic && ReactCompositeComponentMixin.hasOwnProperty(name)) { <ide> invariant( <ide> specPolicy === SpecPolicy.OVERRIDE_BASE, <ide> 'ReactCompositeComponentInterface: You are attempting to override ' + <ide> function validateMethodOverride(proto, name) { <ide> } <ide> } <ide> <del> <ide> function validateLifeCycleOnReplaceState(instance) { <ide> var compositeLifeCycleState = instance._compositeLifeCycleState; <ide> invariant( <ide> function validateLifeCycleOnReplaceState(instance) { <ide> * Custom version of `mixInto` which handles policy validation and reserved <ide> * specification keys when building `ReactCompositeComponent` classses. <ide> */ <del>function mixSpecIntoComponent(Constructor, spec) { <add>function mixSpecIntoComponent(ConvenienceConstructor, spec) { <add> var Constructor = ConvenienceConstructor.componentConstructor; <ide> var proto = Constructor.prototype; <ide> for (var name in spec) { <ide> var property = spec[name]; <ide> if (!spec.hasOwnProperty(name) || !property) { <ide> continue; <ide> } <del> validateMethodOverride(proto, name); <add> <add> validateMethodOverride(proto, name, false); <ide> <ide> if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) { <del> RESERVED_SPEC_KEYS[name](Constructor, property); <add> RESERVED_SPEC_KEYS[name](ConvenienceConstructor, property); <add> } else if (RESERVED_STATIC_SPEC_KEYS.hasOwnProperty(name)) { <add> if (__DEV__) { <add> console.warn( <add> 'createClass(...): `' + name + '` is now a static property and ' + <add> 'should be defined inside "statics".' <add> ); <add> } <add> RESERVED_STATIC_SPEC_KEYS[name](ConvenienceConstructor, property); <ide> } else { <ide> // Setup methods on prototype: <ide> // The following member methods should not be automatically bound: <ide> function mixSpecIntoComponent(Constructor, spec) { <ide> } <ide> } <ide> <add>function mixStaticSpecIntoComponent(ConvenienceConstructor, statics) { <add> if (!statics) { <add> return; <add> } <add> for (var name in statics) { <add> var property = statics[name]; <add> if (!statics.hasOwnProperty(name) || !property) { <add> return; <add> } <add> <add> validateMethodOverride(ConvenienceConstructor, name, true); <add> <add> if (RESERVED_STATIC_SPEC_KEYS.hasOwnProperty(name)) { <add> RESERVED_STATIC_SPEC_KEYS[name](ConvenienceConstructor, property); <add> } else { <add> var isInherited = name in ConvenienceConstructor; <add> var result = property; <add> if (isInherited) { <add> var existingProperty = ConvenienceConstructor[name]; <add> if (ReactCompositeComponentInterface.statics[name] === <add> SpecPolicy.DEFINE_MANY_MERGED) { <add> result = createMergedResultFunction(existingProperty, property); <add> } else { <add> result = createChainedFunction(existingProperty, property); <add> } <add> } <add> ConvenienceConstructor[name] = result; <add> ConvenienceConstructor.componentConstructor[name] = result; <add> } <add> } <add>} <add> <ide> /** <ide> * Merge two objects, but throw if both contain the same key. <ide> * <ide> var ReactCompositeComponent = { <ide> var Constructor = function() {}; <ide> Constructor.prototype = new ReactCompositeComponentBase(); <ide> Constructor.prototype.constructor = Constructor; <del> mixSpecIntoComponent(Constructor, spec); <add> <add> var ConvenienceConstructor = function(props, children) { <add> var instance = new Constructor(); <add> instance.construct.apply(instance, arguments); <add> return instance; <add> }; <add> ConvenienceConstructor.componentConstructor = Constructor; <add> ConvenienceConstructor.originalSpec = spec; <add> <add> mixSpecIntoComponent(ConvenienceConstructor, spec); <ide> <ide> invariant( <ide> Constructor.prototype.render, <ide> var ReactCompositeComponent = { <ide> } <ide> } <ide> <del> var ConvenienceConstructor = function(props, children) { <del> var instance = new Constructor(); <del> instance.construct.apply(instance, arguments); <del> return instance; <del> }; <del> ConvenienceConstructor.componentConstructor = Constructor; <del> ConvenienceConstructor.originalSpec = spec; <ide> return ConvenienceConstructor; <ide> }, <ide> <ide><path>src/core/__tests__/ReactCompositeComponent-test.js <ide> describe('ReactCompositeComponent', function() { <ide> <ide> it('should normalize props with default values', function() { <ide> var Component = React.createClass({ <del> propTypes: {key: ReactPropTypes.string.isRequired}, <add> statics: { <add> propTypes: {key: ReactPropTypes.string.isRequired} <add> }, <ide> getDefaultProps: function() { <ide> return {key: 'testKey'}; <ide> }, <ide> describe('ReactCompositeComponent', function() { <ide> <ide> it('should check default prop values', function() { <ide> var Component = React.createClass({ <del> propTypes: {key: ReactPropTypes.string.isRequired}, <add> statics: { <add> propTypes: {key: ReactPropTypes.string.isRequired} <add> }, <ide> getDefaultProps: function() { <ide> return {key: null}; <ide> }, <ide> describe('ReactCompositeComponent', function() { <ide> <ide> it('should check declared prop types', function() { <ide> var Component = React.createClass({ <del> propTypes: { <del> key: ReactPropTypes.string.isRequired <add> statics: { <add> propTypes: { <add> key: ReactPropTypes.string.isRequired <add> } <ide> }, <ide> render: function() { <ide> return <span>{this.props.key}</span>; <ide> describe('ReactCompositeComponent', function() { <ide> expect(function() { <ide> React.createClass({ <ide> displayName: 'Component', <del> propTypes: { <del> key: null <add> statics: { <add> propTypes: { <add> key: null <add> } <ide> }, <ide> render: function() { <ide> return <span>{this.props.key}</span>; <ide> describe('ReactCompositeComponent', function() { <ide> expect(function() { <ide> React.createClass({ <ide> displayName: 'Component', <del> contextTypes: { <del> key: null <add> statics: { <add> contextTypes: { <add> key: null <add> } <ide> }, <ide> render: function() { <ide> return <span>{this.props.key}</span>; <ide> describe('ReactCompositeComponent', function() { <ide> expect(function() { <ide> React.createClass({ <ide> displayName: 'Component', <del> childContextTypes: { <del> key: null <add> statics: { <add> childContextTypes: { <add> key: null <add> } <ide> }, <ide> render: function() { <ide> return <span>{this.props.key}</span>; <ide> describe('ReactCompositeComponent', function() { <ide> } <ide> }; <ide> var Component = React.createClass({ <del> mixins: [Mixin], <add> statics: { <add> mixins: [Mixin] <add> }, <ide> getInitialState: function() { <ide> return {component: true}; <ide> }, <ide> describe('ReactCompositeComponent', function() { <ide> } <ide> }; <ide> var Component = React.createClass({ <del> mixins: [Mixin], <add> statics: { <add> mixins: [Mixin] <add> }, <ide> getInitialState: function() { <ide> return {x: true}; <ide> }, <ide> describe('ReactCompositeComponent', function() { <ide> } <ide> }; <ide> var Component = React.createClass({ <del> mixins: [Mixin], <add> statics: { <add> mixins: [Mixin] <add> }, <ide> getInitialState: function() { <ide> return {x: true}; <ide> }, <ide> describe('ReactCompositeComponent', function() { <ide> } <ide> }); <ide> <add> it('should warn when using deprecated non-static spec keys', function() { <add> var warn = console.warn; <add> console.warn = mocks.getMockFunction(); <add> try { <add> React.createClass({ <add> mixins: [{}], <add> propTypes: { <add> foo: ReactPropTypes.string <add> }, <add> contextTypes: { <add> foo: ReactPropTypes.string <add> }, <add> childContextTypes: { <add> foo: ReactPropTypes.string <add> }, <add> render: function() { <add> return <div />; <add> } <add> }); <add> expect(console.warn.mock.calls.length).toBe(4); <add> expect(console.warn.mock.calls[0][0]).toBe( <add> 'createClass(...): `mixins` is now a static property and should ' + <add> 'be defined inside "statics".' <add> ); <add> expect(console.warn.mock.calls[1][0]).toBe( <add> 'createClass(...): `propTypes` is now a static property and should ' + <add> 'be defined inside "statics".' <add> ); <add> expect(console.warn.mock.calls[2][0]).toBe( <add> 'createClass(...): `contextTypes` is now a static property and ' + <add> 'should be defined inside "statics".' <add> ); <add> expect(console.warn.mock.calls[3][0]).toBe( <add> 'createClass(...): `childContextTypes` is now a static property and ' + <add> 'should be defined inside "statics".' <add> ); <add> } catch (e) { <add> throw e; <add> } finally { <add> console.warn = warn; <add> } <add> }); <add> <ide> it('should pass context', function() { <ide> var childInstance = null; <ide> var grandchildInstance = null; <ide> <ide> var Parent = React.createClass({ <del> childContextTypes: { <del> foo: ReactPropTypes.string, <del> depth: ReactPropTypes.number <add> statics: { <add> childContextTypes: { <add> foo: ReactPropTypes.string, <add> depth: ReactPropTypes.number <add> } <ide> }, <ide> <ide> getChildContext: function() { <ide> describe('ReactCompositeComponent', function() { <ide> }); <ide> <ide> var Child = React.createClass({ <del> contextTypes: { <del> foo: ReactPropTypes.string, <del> depth: ReactPropTypes.number <del> }, <add> statics: { <add> contextTypes: { <add> foo: ReactPropTypes.string, <add> depth: ReactPropTypes.number <add> }, <ide> <del> childContextTypes: { <del> depth: ReactPropTypes.number <add> childContextTypes: { <add> depth: ReactPropTypes.number <add> } <ide> }, <ide> <ide> getChildContext: function() { <ide> describe('ReactCompositeComponent', function() { <ide> }); <ide> <ide> var Grandchild = React.createClass({ <del> contextTypes: { <del> foo: ReactPropTypes.string, <del> depth: ReactPropTypes.number <add> statics: { <add> contextTypes: { <add> foo: ReactPropTypes.string, <add> depth: ReactPropTypes.number <add> } <ide> }, <ide> <ide> render: function() { <ide> describe('ReactCompositeComponent', function() { <ide> <ide> it('should check context types', function() { <ide> var Component = React.createClass({ <del> contextTypes: { <del> foo: ReactPropTypes.string.isRequired <add> statics: { <add> contextTypes: { <add> foo: ReactPropTypes.string.isRequired <add> } <ide> }, <ide> <ide> render: function() { <ide> describe('ReactCompositeComponent', function() { <ide> <ide> it('should check child context types', function() { <ide> var Component = React.createClass({ <del> childContextTypes: { <del> foo: ReactPropTypes.string.isRequired, <del> bar: ReactPropTypes.number <add> statics: { <add> childContextTypes: { <add> foo: ReactPropTypes.string.isRequired, <add> bar: ReactPropTypes.number <add> } <ide> }, <ide> <ide> getChildContext: function() { <ide> describe('ReactCompositeComponent', function() { <ide> <ide> it('should filter out context not in contextTypes', function() { <ide> var Component = React.createClass({ <del> contextTypes: { <del> foo: ReactPropTypes.string <add> statics: { <add> contextTypes: { <add> foo: ReactPropTypes.string <add> } <ide> }, <ide> <ide> render: function() { <ide> describe('ReactCompositeComponent', function() { <ide> var actualComponentDidUpdate; <ide> <ide> var Parent = React.createClass({ <del> childContextTypes: { <del> foo: ReactPropTypes.string.isRequired, <del> bar: ReactPropTypes.string.isRequired <add> statics: { <add> childContextTypes: { <add> foo: ReactPropTypes.string.isRequired, <add> bar: ReactPropTypes.string.isRequired <add> } <ide> }, <ide> <ide> getChildContext: function() { <ide> describe('ReactCompositeComponent', function() { <ide> }); <ide> <ide> var Component = React.createClass({ <del> contextTypes: { <del> foo: ReactPropTypes.string <add> statics: { <add> contextTypes: { <add> foo: ReactPropTypes.string <add> } <ide> }, <ide> <ide> componentWillReceiveProps: function(nextProps, nextContext) { <ide> describe('ReactCompositeComponent', function() { <ide> expect(actualComponentWillUpdate).toEqual({foo: 'def'}); <ide> expect(actualComponentDidUpdate).toEqual({foo: 'abc'}); <ide> }); <add> <add> it('should support statics', function() { <add> var Component = React.createClass({ <add> statics: { <add> abc: 'def' <add> }, <add> <add> render: function() { <add> return <span />; <add> } <add> }); <add> var instance = <Component />; <add> ReactTestUtils.renderIntoDocument(instance); <add> expect(instance.constructor.abc).toBe('def'); <add> expect(Component.abc).toBe('def'); <add> }); <add> <add> it('should support statics in mixins', function() { <add> var Mixin = { <add> statics: { <add> foo: 'bar' <add> } <add> }; <add> var Component = React.createClass({ <add> mixins: [Mixin], <add> <add> statics: { <add> abc: 'def' <add> }, <add> <add> render: function() { <add> return <span />; <add> } <add> }); <add> var instance = <Component />; <add> ReactTestUtils.renderIntoDocument(instance); <add> expect(instance.constructor.foo).toBe('bar'); <add> expect(Component.foo).toBe('bar'); <add> expect(instance.constructor.abc).toBe('def'); <add> expect(Component.abc).toBe('def'); <add> }); <add> <add> it("should throw if mixins override each others' statics", function() { <add> expect(function() { <add> var Mixin = { <add> statics: { <add> abc: 'foo' <add> } <add> }; <add> React.createClass({ <add> statics: { <add> mixins: [Mixin], <add> abc: 'bar' <add> }, <add> <add> render: function() { <add> return <span />; <add> } <add> }); <add> }).toThrow( <add> 'Invariant Violation: ReactCompositeComponentInterface: You are ' + <add> 'attempting to define `abc` on your component more than once. This ' + <add> 'conflict may be due to a mixin.' <add> ); <add> }); <ide> });
2
Text
Text
fix copyright instructions
6e21a15c5212c3d11bd48bf6e645acf33833af41
<ide><path>CONTRIBUTING.md <ide> If you are adding a new file it should have a header like this: <ide> <ide> ``` <ide> /** <del> * Copyright 2016 Netflix, Inc. <add> * Copyright (c) 2016-present, RxJava Contributors. <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.
1
PHP
PHP
tweak a few mapping things
46d7ce05617512b609dde4ca07d43f19413e5508
<ide><path>src/Illuminate/Bus/Dispatcher.php <ide> public function mapUsing(Closure $mapper) <ide> * Map the command to a handler within a given root namespace. <ide> * <ide> * @param mixed $command <del> * @param string $rootNamespace <add> * @param string $commandNamespace <add> * @param string $handlerNamespace <ide> * @return string <ide> */ <del> public static function simpleMapping($command, $rootNamespace) <add> public static function simpleMapping($command, $commandNamespace, $handlerNamespace) <ide> { <del> $command = str_replace($rootNamespace.'\Commands', '', get_class($command)); <add> $command = str_replace($commandNamespace, '', get_class($command)); <ide> <del> return $rootNamespace.'\Handlers\Commands\\'.trim($command, '\\').'Handler@handle'; <add> return $handlerNamespace.'\\'.trim($command, '\\').'Handler@handle'; <ide> } <ide> <ide> }
1
Javascript
Javascript
use the same kind of strings for radio values
d51e7e86ffbb82f2912d3687ab160c4448a68b6d
<ide><path>src/core/annotation.js <ide> class ButtonWidgetAnnotation extends WidgetAnnotation { <ide> } <ide> for (const key of normalAppearance.getKeys()) { <ide> if (key !== "Off") { <del> this.data.buttonValue = key; <add> this.data.buttonValue = this._decodeFormValue(key); <ide> break; <ide> } <ide> } <ide><path>test/unit/annotation_spec.js <ide> describe("annotation", function () { <ide> }, done.fail); <ide> }); <ide> <add> it("should handle radio buttons with a field value not an ascii string", function (done) { <add> const parentDict = new Dict(); <add> parentDict.set("V", Name.get("\x91I=\x91\xf0\x93\xe0\x97e3")); <add> <add> const normalAppearanceStateDict = new Dict(); <add> normalAppearanceStateDict.set("\x91I=\x91\xf0\x93\xe0\x97e3", null); <add> <add> const appearanceStatesDict = new Dict(); <add> appearanceStatesDict.set("N", normalAppearanceStateDict); <add> <add> buttonWidgetDict.set("Ff", AnnotationFieldFlag.RADIO); <add> buttonWidgetDict.set("Parent", parentDict); <add> buttonWidgetDict.set("AP", appearanceStatesDict); <add> <add> const buttonWidgetRef = Ref.get(124, 0); <add> const xref = new XRefMock([ <add> { ref: buttonWidgetRef, data: buttonWidgetDict }, <add> ]); <add> <add> AnnotationFactory.create( <add> xref, <add> buttonWidgetRef, <add> pdfManagerMock, <add> idFactoryMock <add> ).then(({ data }) => { <add> expect(data.annotationType).toEqual(AnnotationType.WIDGET); <add> expect(data.checkBox).toEqual(false); <add> expect(data.radioButton).toEqual(true); <add> expect(data.fieldValue).toEqual("‚I=‚ðfiàŠe3"); <add> expect(data.buttonValue).toEqual("‚I=‚ðfiàŠe3"); <add> done(); <add> }, done.fail); <add> }); <add> <ide> it("should handle radio buttons without a field value", function (done) { <ide> const normalAppearanceStateDict = new Dict(); <ide> normalAppearanceStateDict.set("2", null);
2
Python
Python
add snapshots to demo code and a snapshot fix
ca96c9b659772d9fb22cd15219dc460a4f284c93
<ide><path>demos/gce_demo.py <ide> def main(): <ide> zones = gce.ex_list_zones() <ide> display('Zones', zones) <ide> <add> snapshots = gce.ex_list_snapshots() <add> display('Snapshots', snapshots) <add> <ide> # == Clean up any old demo resources == <ide> print('Cleaning up any "%s" resources:' % DEMO_BASE_NAME) <ide> clean_up(gce, DEMO_BASE_NAME, all_nodes, <del> all_addresses + all_volumes + firewalls + networks) <add> all_addresses + all_volumes + firewalls + networks + snapshots) <ide> <del> # == Create Node with non-persistent disk == <add> # == Create Node with disk auto-created == <ide> if MAX_NODES > 1: <del> print('Creating Node with non-persistent disk:') <add> print('Creating Node with auto-created disk:') <ide> name = '%s-np-node' % DEMO_BASE_NAME <ide> node_1 = gce.create_node(name, 'n1-standard-1', 'debian-7', <ide> ex_tags=['libcloud']) <ide> def main(): <ide> if gce.detach_volume(volume, ex_node=node_1): <ide> print(' Detached %s from %s' % (volume.name, node_1.name)) <ide> <del> # == Create Node with persistent disk == <del> print('Creating Node with Persistent disk:') <add> # == Create Snapshot == <add> print('Creating a snapshot from existing disk:') <add> # Create a disk to snapshot <add> vol_name = '%s-snap-template' % DEMO_BASE_NAME <add> image = gce.ex_get_image('debian-7') <add> vol = gce.create_volume(None, vol_name, image=image) <add> print(' Created disk %s to shapshot' % DEMO_BASE_NAME) <add> # Snapshot volume <add> snapshot = vol.snapshot('%s-snapshot' % DEMO_BASE_NAME) <add> print(' Snapshot %s created' % snapshot.name) <add> <add> # == Create Node with existing disk == <add> print('Creating Node with existing disk:') <ide> name = '%s-persist-node' % DEMO_BASE_NAME <ide> # Use objects this time instead of names <ide> # Get latest Debian 7 image <ide> image = gce.ex_get_image('debian-7') <ide> # Get Machine Size <ide> size = gce.ex_get_size('n1-standard-1') <del> # Create Disk. Size is None to just take default of image <add> # Create Disk from Snapshot created above <ide> volume_name = '%s-boot-disk' % DEMO_BASE_NAME <del> volume = gce.create_volume(None, volume_name, image=image) <add> volume = gce.create_volume(None, volume_name, snapshot=snapshot) <add> print(' Created %s from snapshot' % volume.name) <ide> # Create Node with Disk <ide> node_2 = gce.create_node(name, size, image, ex_tags=['libcloud'], <ide> ex_boot_disk=volume) <ide> def main(): <ide> networks = gce.ex_list_networks() <ide> display('Networks', networks) <ide> <add> snapshots = gce.ex_list_snapshots() <add> display('Snapshots', snapshots) <add> <ide> if CLEANUP: <ide> print('Cleaning up %s resources created.' % DEMO_BASE_NAME) <ide> clean_up(gce, DEMO_BASE_NAME, nodes, <del> addresses + volumes + firewalls + networks) <add> addresses + volumes + firewalls + networks + snapshots) <ide> <ide> if __name__ == '__main__': <ide> main() <ide><path>libcloud/compute/drivers/gce.py <ide> def _create_vol_req(self, size, name, location=None, image=None, <ide> volume_data['description'] = 'Image: %s' % ( <ide> image.extra['selfLink']) <ide> if snapshot: <del> # Check for full URI to not break backward-compatibility <del> if snapshot.startswith('https'): <del> snapshot_link = snapshot <del> else: <del> if not hasattr(snapshot, 'name'): <del> snapshot = self.ex_get_snapshot(snapshot) <del> snapshot_link = snapshot.extra['selfLink'] <add> if not hasattr(snapshot, 'name'): <add> # Check for full URI to not break backward-compatibility <add> if snapshot.startswith('https'): <add> snapshot = self._get_components_from_path(snapshot)['name'] <add> snapshot = self.ex_get_snapshot(snapshot) <add> snapshot_link = snapshot.extra['selfLink'] <ide> volume_data['sourceSnapshot'] = snapshot_link <ide> volume_data['description'] = 'Snapshot: %s' % (snapshot_link) <ide> location = location or self.zone
2