text:
"""
Client for Messaging Content Store HTTP services APIs.

"""
import requests
import json

class ContentStoreApiClient(object):

    """
    Client for Content Store API.

    :param str auth_token:

        An access token.

    :param str api_url:
        The full URL of the API. Defaults to
        ``http://testserver/contentstore``.

    """

    def __init__(self, auth_token, api_url=None, session=None):
        self.auth_token = auth_token
        if api_url is None:
            api_url = "http://testserver/contentstore"
        self.api_url = api_url
        self.headers = {
            'Authorization': 'Token ' + auth_token,
            'Content-Type': 'application/json'
        }
        if session is None:
            session = requests.Session()
        session.headers.update(self.headers)
        self.session = session

    def call(self, endpoint, method, obj=None, params=None, data=None):
        if obj is None:
            url = '%s/%s' % (self.api_url.rstrip('/'), endpoint)
        else:
            url = '%s/%s/%s' % (self.api_url.rstrip('/'), endpoint, obj)
        result = {
            'get': self.session.get,
            'post': self.session.post,
            'put': self.session.post,
            'delete': self.session.delete,
        }.get(method, None)(url, params=params, data=json.dumps(data))
        result.raise_for_status()
        return result.json()

    def get_messagesets(self, params=None):
        return self.call('messageset', 'get', params=params)

    def get_messageset(self, messageset_id):
        return self.call('messageset', 'get', obj=messageset_id)

    def get_messageset_messages(self, messageset_id):
        return self.call('messageset', 'get',
                         obj='%s/messages' % messageset_id)

    def create_messageset(self, messageset):
        return self.call('messageset', 'post', data=messageset)

    def update_messageset(self, messageset_id, messageset):
        return self.call('messageset', 'put', obj=messageset_id,
                         data=messageset)

    def delete_messageset(self, messageset_id):
        return self.call('messageset', 'delete', obj=messageset_id)

    def get_messages(self, params=None):
        return self.call('message', 'get', params=params)

    def get_message(self, message_id):
        return self.call('message', 'get', obj=message_id)

    def get_message_content(self, message_id):
        return self.call('message', 'get',
                         obj='%s/content' % message_id)

    def create_message(self, message):
        return self.call('message', 'post', data=message)

    def update_message(self, message_id, message):
        return self.call('message', 'put', obj=message_id,
                         data=message)

    def delete_message(self, message_id):
        return self.call('message', 'delete', obj=message_id)

    def get_schedules(self, params=None):
        return self.call('schedule', 'get', params=params)

    def get_schedule(self, schedule_id):
        return self.call('schedule', 'get', obj=schedule_id)

    def create_schedule(self, schedule):
        return self.call('schedule', 'post', data=schedule)

    def update_schedule(self, schedule_id, schedule):
        return self.call('schedule', 'put', obj=schedule_id,
                         data=schedule)

    def delete_schedule(self, schedule_id):
        return self.call('schedule', 'delete', obj=schedule_id)

    def get_binarycontents(self, params=None):
        return self.call('binarycontent', 'get', params=params)

    def get_binarycontent(self, binarycontent_id):
        return self.call('binarycontent', 'get', obj=binarycontent_id)

    def create_binarycontent(self, binarycontent):
        post_data = {
            "content": binarycontent
        }
        url = '%s/binarycontent/' % (self.api_url.rstrip('/'),)
        result = self.session.post(url, data=post_data,
                                   format='multipart')
        result.raise_for_status()
        return result.json()

    def update_binarycontent(self, binarycontent_id, binarycontent):
        post_data = {
            "content": binarycontent
        }
        url = '%s/binarycontent/%s/' % (self.api_url.rstrip('/'),
                                        binarycontent_id)
        result = self.session.put(url, data=post_data,
                                  format='multipart')
        result.raise_for_status()
        return result.json()

    def delete_binarycontent(self, binarycontent_id):
        return self.call('binarycontent', 'delete', obj=binarycontent_id)


text:
import React, { Component, PropTypes } from "react"
import Link from "statinamic/lib/Link"

export default class PageError extends Component {

  static propTypes = {
    error: PropTypes.oneOfType([ PropTypes.number, PropTypes.string ]),
    errorText: PropTypes.string,
  };

  static defaultProps = {
    error: 404,
    errorText: "Page Not Found",
  }

  render() {
    const {
      error,
      errorText,
    } = this.props

    return (

{ error }

{ errorText }

        <Link to="/">← Homepage</Link>

    )
  }
}

redpajama_set_name: RedPajamaGithub


text:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.mixedreality.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.mixedreality.models.OperationDisplay;
import com.azure.resourcemanager.mixedreality.models.OperationProperties;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

/** REST API operation. */
@Fluent
public final class OperationInner {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationInner.class);

    /*
     * Operation name: {provider}/{resource}/{operation}
     */
    @JsonProperty(value = "name")
    private String name;

    /*
     * The object that represents the operation.
     */
    @JsonProperty(value = "display")
    private OperationDisplay display;

    /*
     * Whether or not this is a data plane operation
     */
    @JsonProperty(value = "isDataAction")
    private Boolean isDataAction;

    /*
     * The origin
     */
    @JsonProperty(value = "origin")
    private String origin;

    /*
     * Properties of the operation
     */
    @JsonProperty(value = "properties")
    private OperationProperties properties;

    /**
     * Get the name property: Operation name: {provider}/{resource}/{operation}.
     *
     * @return the name value.
     */
    public String name() {
        return this.name;
    }

    /**
     * Set the name property: Operation name: {provider}/{resource}/{operation}.
     *
     * @param name the name value to set.
     * @return the OperationInner object itself.
     */
    public OperationInner withName(String name) {
        this.name = name;
        return this;
    }

    /**
     * Get the display property: The object that represents the operation.
     *
     * @return the display value.
     */
    public OperationDisplay display() {
        return this.display;
    }

    /**
     * Set the display property: The object that represents the operation.
     *
     * @param display the display value to set.
     * @return the OperationInner object itself.
     */
    public OperationInner withDisplay(OperationDisplay display) {
        this.display = display;
        return this;
    }

    /**
     * Get the isDataAction property: Whether or not this is a data plane operation.
     *
     * @return the isDataAction value.
     */
    public Boolean isDataAction() {
        return this.isDataAction;
    }

    /**
     * Set the isDataAction property: Whether or not this is a data plane operation.
     *
     * @param isDataAction the isDataAction value to set.
     * @return the OperationInner object itself.
     */
    public OperationInner withIsDataAction(Boolean isDataAction) {
        this.isDataAction = isDataAction;
        return this;
    }

    /**
     * Get the origin property: The origin.
     *
     * @return the origin value.
     */
    public String origin() {
        return this.origin;
    }

    /**
     * Set the origin property: The origin.
     *
     * @param origin the origin value to set.
     * @return the OperationInner object itself.
     */
    public OperationInner withOrigin(String origin) {
        this.origin = origin;
        return this;
    }

    /**
     * Get the properties property: Properties of the operation.
     *
     * @return the properties value.
     */
    public OperationProperties properties() {
        return this.properties;
    }

    /**
     * Set the properties property: Properties of the operation.
     *
     * @param properties the properties value to set.
     * @return the OperationInner object itself.
     */
    public OperationInner withProperties(OperationProperties properties) {
        this.properties = properties;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (display() != null) {
            display().validate();
        }
        if (properties() != null) {
            properties().validate();
        }
    }
}


text:
package com.ld33.game;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.TimeUtils;

public abstract class GameObject {
	public float x,y,w,h,xVel,yVel,xAccel,yAccel;
	protected final long spawnTime = TimeUtils.millis();
	final public void onStep(double deltaTime, int mouseX, int mouseY){
		xVel += xAccel*deltaTime;
		yVel += yAccel*deltaTime;
		x += xVel*deltaTime;
		y += yVel*deltaTime;
		this.onStepHook(deltaTime, mouseX, mouseY);
	}
	protected void onStepHook(double deltaTime, int mouseX, int mouseY){}
	public void render(SpriteBatch batch, Texture sprite){}
}


text:
package org.apache.flink.table.operations;

import org.apache.flink.annotation.Internal;
import org.apache.flink.table.api.internal.SelectResultProvider;

import java.util.Collections;
import java.util.HashMap;

/**
 * Special, internal kind of {@link ModifyOperation} that
 * collects the content of {@link QueryOperation} to local.
 */
@Internal
public class SelectSinkOperation implements ModifyOperation {

	private final QueryOperation child;
	// help the client to get the execute result from a specific sink.
	private SelectResultProvider resultProvider;

	public SelectSinkOperation(QueryOperation child) {
		this.child = child;
	}

	public void setSelectResultProvider(SelectResultProvider resultProvider) {
		this.resultProvider = resultProvider;
	}

	public SelectResultProvider getSelectResultProvider() {
		return resultProvider;
	}

	@Override
	public QueryOperation getChild() {
		return child;
	}

	@Override
	public <T> T accept(ModifyOperationVisitor<T> visitor) {
		return visitor.visit(this);
	}

	@Override
	public String asSummaryString() {
		return OperationUtils.formatWithChildren(
			"SelectSink",
			new HashMap<>(),
			Collections.singletonList(child),
			Operation::asSummaryString);
	}

}


text:
Local Function Status
=====================

This is a checklist for current and outstanding work on the local functions
feature, as spec'd in [local-functions.md](./local-functions.md).

--------------------

Known issues
============

Compiler:

- [ ] Parser builds nodes for local functions when feature not enabled (#9940)
- [ ] Compiler crash: base call to state machine method, in state machine
  method (#9872)
- [ ] Need custom warning for unused local function (#9661)
- [ ] Generate quick action does not offer to generate local (#9352)
- [ ] Parser ambiguity research (#10388)
- [ ] Dynamic support (#10389)
- [ ] Referring to local function in expression tree (#10390)
- [ ] Resolve definite assignment rules (#10391)
- [ ] Remove support for `var` return type (#10392)
- [ ] Update error messages (#10393)

IDE:

- [ ] Some selections around local functions fail extract method refactoring
  [ ] (#8719)
- [ ] Extracting local function passed to an Action introduces compiler error
  [ ] (#8718)
- [ ] Ctrl+. on a delegate invocation crashes VS (via Extract method) (#8717)
- [ ] Inline temp introduces compiler error (#8716)
- [ ] Call hierarchy search never terminates on local functions (#8654)
- [ ] Nav bar doesn't support local functions (#8648)
- [ ] No outlining for local functions (#8647)
- [ ] Squiggles all over the place when using an unsupported modifier (#8645)
- [ ] Peek definition errors out on local function (#8644)
- [ ] Void keyword not recommended while declaring local function (#8616)
- [ ] Change signature doesn't update the signature of the local function (#8539)

Feature Completeness Progress
=============================

- [x] N-level nested local functions
- [x] Capture
    - Works alongside lambdas and behaves very similarly in fallback cases
    - Has zero-allocation closures (struct frames by ref) on functions never
      converted to a delegate and are not an iterator/async
- [x] Standard parameter features
    - params
    - ref/out
    - named/optional
- [x] Visibility
    - May revisit design (currently shadows, may do overloads)
- [x] Generics
    - Nongeneric local functions in generic methods (same as lambdas).
    - Generic local functions in nongeneric methods.
    - Generic local functions in generic methods.
    - Arbitrary nesting of generic local functions.
    - Generic local functions with constraints.
- [x] Inferred return type
- [x] Iterators
- [x] Async


text:
class CreateServers < ActiveRecord::Migration
  def change
    create_table :servers do |t|
      t.string :name
      t.string :token
      t.string :ip
      t.timestamp :last_heartbeat

      t.timestamps null: false
    end
  end
end


text:
require 'facebook_chat/version'
require 'facebook_chat/client'
require 'facebook_chat/x_facebook_platform'

module FacebookChat
end


text:
package org.opensmartgridplatform.cucumber.core.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;

import org.opensmartgridplatform.cucumber.core.Keys;
import org.opensmartgridplatform.cucumber.core.ScenarioContext;
import org.opensmartgridplatform.shared.application.config.AbstractConfig;

/**
 * Base class for the application configuration.
 */
public abstract class BaseApplicationConfiguration extends AbstractConfig {

    private static final Logger LOGGER = LoggerFactory.getLogger(BaseApplicationConfiguration.class);

    @Value("${timeout}")
    private Integer timeout;

    @Value("${sleeptime}")
    private Integer sleeptime;

    @Value("${tempdir}")
    private String tempdir;

    /**
     * Gets the timeout. Either from the configuration (in war or
     * /etc/osp/test/global-cucumber.properties), or from the scenariocontext
     * (for a specific test).
     *
     * @return An integer representing the timeout.
     */
    public Integer getTimeout() {

        Integer retval = this.timeout;

        // For certain scenario's it is necessary to enlarge the timeout.
        if (ScenarioContext.current().get(Keys.TIMEOUT) != null) {
            retval = Integer.parseInt(ScenarioContext.current().get(Keys.TIMEOUT).toString());
        }

        LOGGER.debug("Using timeout [{}] seconds in the tests.", retval);

        return retval;
    }

    public Integer getSleepTime() {
        return this.sleeptime;
    }

    public String getTempDir() {
        return this.tempdir;
    }
}


text:
package org.zaproxy.zap.extension.pscan.scanner;

import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;

import net.htmlparser.jericho.Source;
import org.apache.commons.httpclient.URI;
import org.apache.commons.httpclient.URIException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.parosproxy.paros.network.HttpHeader;
import org.parosproxy.paros.network.HttpMalformedHeaderException;
import org.parosproxy.paros.network.HttpMessage;
import org.zaproxy.zap.extension.pscan.PluginPassiveScanner;
import org.zaproxy.zap.utils.Stats;
import org.zaproxy.zap.utils.StatsListener;

class StatsPassiveScannerUnitTest {
    private StatsListener listener;
    private PluginPassiveScanner scanner;

    @BeforeEach
    void setUp() {
        scanner = new StatsPassiveScanner();
        listener = spy(StatsListener.class);
        Stats.addListener(listener);
    }

    @AfterEach
    void cleanup() {
        Stats.removeListener(listener);
    }

    @Test
    void shouldCountOnlyCodeAndTimingGivenNoContentType()
            throws URIException, HttpMalformedHeaderException {
        // Given
        HttpMessage msg = new HttpMessage(new URI("http://example.com/", true));
        // When
        scanner.scanHttpResponseReceive(msg, -1, new Source(""));
        // Then
        verify(listener)
                .counterInc("http://example.com", StatsPassiveScanner.CODE_STATS_PREFIX + "0");
        verify(listener)
                .counterInc(
                        "http://example.com", StatsPassiveScanner.RESPONSE_TIME_STATS_PREFIX + "0");
        Mockito.verifyNoMoreInteractions(listener);
    }

    @Test
    void shouldCountMessageWithContentTypeOnce() throws URIException, HttpMalformedHeaderException {
        // Given
        HttpMessage msg = new HttpMessage(new URI("http://example.com/", true));
        msg.getResponseHeader().addHeader(HttpHeader.CONTENT_TYPE, "text/html");
        // When
        scanner.scanHttpResponseReceive(msg, -1, new Source(""));
        // Then
        verify(listener)
                .counterInc("http://example.com", StatsPassiveScanner.CODE_STATS_PREFIX + "0");
        verify(listener)
                .counterInc(
                        "http://example.com",
                        StatsPassiveScanner.CONTENT_TYPE_STATS_PREFIX + "text/html");
        verify(listener)
                .counterInc(
                        "http://example.com", StatsPassiveScanner.RESPONSE_TIME_STATS_PREFIX + "0");
    }

    @Test
    void shouldProperlyParseAndCountSegmentedContentType()
            throws URIException, HttpMalformedHeaderException {
        // Given
        String contentType = "multipart/byteranges; boundary=00000000000000000018";
        HttpMessage msg = new HttpMessage(new URI("http://example.com/", true));
        msg.getResponseHeader().addHeader(HttpHeader.CONTENT_TYPE, contentType);
        // When
        scanner.scanHttpResponseReceive(msg, -1, new Source(""));
        // Then
        verify(listener)
                .counterInc(
                        "http://example.com",
                        StatsPassiveScanner.CONTENT_TYPE_STATS_PREFIX + "multipart/byteranges");
    }

    @Test
    void shouldProperlyParseAndCountSegmentedContentTypeIncludingCharset()
            throws URIException, HttpMalformedHeaderException {
        // Given
        String contentType = "multipart/byteranges; charset=UTF-8; boundary=00000000000000000018";
        HttpMessage msg = new HttpMessage(new URI("http://example.com/", true));
        msg.getResponseHeader().addHeader(HttpHeader.CONTENT_TYPE, contentType);
        // When
        scanner.scanHttpResponseReceive(msg, -1, new Source(""));
        // Then
        verify(listener)
                .counterInc(
                        "http://example.com",
                        StatsPassiveScanner.CONTENT_TYPE_STATS_PREFIX
                                + "multipart/byteranges; charset=UTF-8");
    }

    @Test
    void shouldProperlyParseAndCountSegmentedContentTypeIncludingCharsetAsLastSegment()
            throws URIException, HttpMalformedHeaderException {
        // Given
        String contentType = "multipart/byteranges; boundary=00000000000000000018; charset=UTF-8";
        HttpMessage msg = new HttpMessage(new URI("http://example.com/", true));
        msg.getResponseHeader().addHeader(HttpHeader.CONTENT_TYPE, contentType);
        // When
        scanner.scanHttpResponseReceive(msg, -1, new Source(""));
        // Then
        verify(listener)
                .counterInc(
                        "http://example.com",
                        StatsPassiveScanner.CONTENT_TYPE_STATS_PREFIX
                                + "multipart/byteranges; charset=UTF-8");
    }

    @Test
    void
            shouldProperlyParseAndCountSegmentedContentTypeIncludingCharsetAndSpuriousTrailingSeperator()
                    throws URIException, HttpMalformedHeaderException {
        // Given
        String contentType = "multipart/byteranges; charset=UTF-8; boundary=00000000000000000018; ";
        HttpMessage msg = new HttpMessage(new URI("http://example.com/", true));
        msg.getResponseHeader().addHeader(HttpHeader.CONTENT_TYPE, contentType);
        // When
        scanner.scanHttpResponseReceive(msg, -1, new Source(""));
        // Then
        verify(listener)
                .counterInc(
                        "http://example.com",
                        StatsPassiveScanner.CONTENT_TYPE_STATS_PREFIX
                                + "multipart/byteranges; charset=UTF-8");
    }
}


text:
UOrbitingMovementComponent::UOrbitingMovementComponent()
{
	// Set this component to be initialized when the game starts, and to be ticked every frame.  You can turn these features
	// off to improve performance if you don't need them.
	bWantsBeginPlay = true;
	PrimaryComponentTick.bCanEverTick = true;
	RotationSpeed = 5;
	OrbitDistance = 100;
	CurrentValue = 0;
	RotateToFaceOutwards = true;
	// ...
}

// Called when the game starts
void UOrbitingMovementComponent::BeginPlay()
{
	Super::BeginPlay();

	// ...

}

// Called every frame
void UOrbitingMovementComponent::TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction )
{
	Super::TickComponent( DeltaTime, TickType, ThisTickFunction );

	float CurrentValueInRadians = FMath::DegreesToRadians<float>(CurrentValue);

	SetRelativeLocation(
		FVector(OrbitDistance * FMath::Cos(CurrentValueInRadians),
		OrbitDistance * FMath::Sin(CurrentValueInRadians),
		RelativeLocation.Z));

	if (RotateToFaceOutwards)
	{
		FVector LookDir = (RelativeLocation).GetSafeNormal();
		FRotator LookAtRot = LookDir.Rotation();
		SetRelativeRotation(LookAtRot);
	}
	CurrentValue = FMath::Fmod(CurrentValue + (RotationSpeed* DeltaTime) ,360);
	// ...
}


text:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Threading;
using Microsoft.CodeAnalysis.Editor.Host;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Navigation;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.Text.Shared.Extensions;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Utilities;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.Editor.Implementation.InlineRename
{
    [Export(typeof(IInlineRenameService))]
    [Export(typeof(InlineRenameService))]
    internal class InlineRenameService : IInlineRenameService
    {
        private readonly IThreadingContext _threadingContext;
        private readonly IUIThreadOperationExecutor _uiThreadOperationExecutor;
        private readonly ITextBufferAssociatedViewService _textBufferAssociatedViewService;
        private readonly IAsynchronousOperationListener _asyncListener;
        private readonly IEnumerable<IRefactorNotifyService> _refactorNotifyServices;
        private readonly ITextBufferFactoryService _textBufferFactoryService;
        private readonly IFeatureServiceFactory _featureServiceFactory;
        private InlineRenameSession? _activeRenameSession;

        [ImportingConstructor]
        [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
        public InlineRenameService(
            IThreadingContext threadingContext,
            IUIThreadOperationExecutor uiThreadOperationExecutor,
            ITextBufferAssociatedViewService textBufferAssociatedViewService,
            ITextBufferFactoryService textBufferFactoryService,
            IFeatureServiceFactory featureServiceFactory,
            [ImportMany] IEnumerable<IRefactorNotifyService> refactorNotifyServices,
            IAsynchronousOperationListenerProvider listenerProvider)
        {
            _threadingContext = threadingContext;
            _uiThreadOperationExecutor = uiThreadOperationExecutor;
            _textBufferAssociatedViewService = textBufferAssociatedViewService;
            _textBufferFactoryService = textBufferFactoryService;
            _featureServiceFactory = featureServiceFactory;
            _refactorNotifyServices = refactorNotifyServices;
            _asyncListener = listenerProvider.GetListener(FeatureAttribute.Rename);
        }

        public InlineRenameSessionInfo StartInlineSession(
            Document document,
            TextSpan textSpan,
            CancellationToken cancellationToken)
        {
            if (_activeRenameSession != null)
            {
                throw new InvalidOperationException(EditorFeaturesResources.An_active_inline_rename_session_is_still_active_Complete_it_before_starting_a_new_one);
            }

            var editorRenameService = document.GetRequiredLanguageService<IEditorInlineRenameService>();
            var renameInfo = editorRenameService.GetRenameInfoAsync(document, textSpan.Start, cancellationToken).WaitAndGetResult(cancellationToken);

            var readOnlyOrCannotNavigateToSpanSessionInfo = IsReadOnlyOrCannotNavigateToSpan(renameInfo, document, cancellationToken);
            if (readOnlyOrCannotNavigateToSpanSessionInfo != null)
            {
                return readOnlyOrCannotNavigateToSpanSessionInfo;
            }

            if (!renameInfo.CanRename)
            {
                return new InlineRenameSessionInfo(renameInfo.LocalizedErrorMessage);
            }

            var snapshot = document.GetTextSynchronously(cancellationToken).FindCorrespondingEditorTextSnapshot();
            Contract.ThrowIfNull(snapshot, "The document used for starting the inline rename session should still be open and associated with a snapshot.");

            ActiveSession = new InlineRenameSession(
                _threadingContext,
                this,
                document.Project.Solution.Workspace,
                renameInfo.TriggerSpan.ToSnapshotSpan(snapshot),
                renameInfo,
                _uiThreadOperationExecutor,
                _textBufferAssociatedViewService,
                _textBufferFactoryService,
                _featureServiceFactory,
                _refactorNotifyServices,
                _asyncListener);

            return new InlineRenameSessionInfo(ActiveSession);

            static InlineRenameSessionInfo? IsReadOnlyOrCannotNavigateToSpan(IInlineRenameInfo renameInfo, Document document, CancellationToken cancellationToken)
            {
                if (renameInfo is IInlineRenameInfo inlineRenameInfo && inlineRenameInfo.DefinitionLocations != default)
                {
                    var workspace = document.Project.Solution.Workspace;
                    var navigationService = workspace.Services.GetRequiredService<IDocumentNavigationService>();

                    foreach (var documentSpan in inlineRenameInfo.DefinitionLocations)
                    {
                        var sourceText = documentSpan.Document.GetTextSynchronously(cancellationToken);
                        var textSnapshot = sourceText.FindCorrespondingEditorTextSnapshot();

                        if (textSnapshot != null)
                        {
                            var buffer = textSnapshot.TextBuffer;
                            var originalSpan = documentSpan.SourceSpan.ToSnapshotSpan(textSnapshot).TranslateTo(buffer.CurrentSnapshot, SpanTrackingMode.EdgeInclusive);

                            if (buffer.IsReadOnly(originalSpan))
                            {
                                return new InlineRenameSessionInfo(EditorFeaturesResources.You_cannot_rename_this_element_because_it_is_contained_in_a_read_only_file);
                            }
                        }

                        if (!navigationService.CanNavigateToSpan(workspace, document.Id, documentSpan.SourceSpan, cancellationToken))
                        {
                            return new InlineRenameSessionInfo(EditorFeaturesResources.You_cannot_rename_this_element_because_it_is_in_a_location_that_cannot_be_navigated_to);
                        }
                    }
                }

                return null;
            }
        }

        IInlineRenameSession? IInlineRenameService.ActiveSession => _activeRenameSession;

        internal InlineRenameSession? ActiveSession
        {
            get
            {
                return _activeRenameSession;
            }

            set
            {
                var previousSession = _activeRenameSession;
                _activeRenameSession = value;
                ActiveSessionChanged?.Invoke(this, new ActiveSessionChangedEventArgs(previousSession!));
            }
        }

        /// <summary>
        /// Raised when the ActiveSession property has changed.
        /// </summary>
        internal event EventHandler<ActiveSessionChangedEventArgs>? ActiveSessionChanged;

        internal class ActiveSessionChangedEventArgs : EventArgs
        {
            public ActiveSessionChangedEventArgs(InlineRenameSession previousSession)
                => this.PreviousSession = previousSession;

            public InlineRenameSession PreviousSession { get; }
        }
    }
}


text:
using namespace Halide;

int main(int argc, char **argv) {
    Func f, g;
    Var x, y;
    RDom r(0, 100);

    // This reduction recursively expands its bounds. The
    // initialization step will evaluate y from -1 to 101, and the
    // update step will use y from 0 to 100. Faulty bounds inference
    // might get this wrong.

    // This behavior is now disallowed, so this test has been moved
    // into the error category.
    ImageParam input(Int(32), 2);
    f(x, y) = input(x, y);
    f(r, y) = f(r, y-1) + f(r, y+1);

    f.compute_root();

    g(x, y) = f(x, y);

    g.infer_input_bounds(100, 100);

    Image<int> in(input.get());
    assert(in.height() == 102 && in.width() == 100);

    return 0;
}


text:
function installAndroidSDK {
    brew install android-sdk
    export ANDROID_HOME=/usr/local/opt/android-sdk
    export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
    echo yes | android update sdk --all --no-ui --force -t 2 #platform tools
    echo yes | android update sdk --all --no-ui --force -t 1 #tools
    echo yes | android update sdk --all --no-ui --force -t 11 #build-tool
    echo yes | android update sdk --all --no-ui --force -t 39 #sdk android-19
    echo yes | android update sdk --all --no-ui --force -t 35 #sdk android-23
    echo yes | android update sdk --all --no-ui --force -t 96 #sys-img
    echo yes | android update sdk --all --no-ui --force -t 160 #support
}

function createAVD {
    echo no | android create avd --force -n weexavd -t android-19 --abi default/armeabi-v7a
}

function startAVD {
  emulator -avd weexavd -no-audio -no-window
}

function waitForEmulator {
  local bootanim=""
  export PATH=$(dirname $(dirname $(which android)))/platform-tools:$PATH
  until [[ "$bootanim" =~ "stopped" ]]; do
    sleep 5
    bootanim=$(adb -e shell getprop init.svc.bootanim 2>&1)
    echo "emulator status=$bootanim"
  done
  adb shell input keyevent 82 &
}

function setup_cpt {
    target_android='android'
    target_ios='ios'
    target_danger='danger'
    target_jsfm='jsfm'

    target=${1:-$target_android}

    if [ $target = $target_android ]; then
        setupBasic
        installAndroidSDK
        JAVA_HOME=$(/usr/libexec/java_home) npm install -g macaca-android
        createAVD
        startAVD &
        npm install
        export DISPLAY=:99.0
    elif [ $target = $target_ios ]
    then
        setupBasic
        npm install -g macaca-ios
        npm install
        gem install danger danger-xcode_summary xcpretty xcpretty-json-formatter
    elif [ $target = $target_jsfm ]
    then
        npm install
    else
        gem install danger danger-xcode_summary xcpretty xcpretty-json-formatter
    fi
}

function setupBasic {
    brew update
    brew install nvm
    export CHROME_BIN=chromium-browser
    source $(brew --prefix nvm)/nvm.sh
    nvm install 7.0.0
    brew install ios-webkit-debug-proxy
    npm install -g macaca-cli
}

function printEnvInfo {
    node -v
    nvm ls
    printenv
}

function test_cpt {
    echo 'cilog:start test ......'

    target_android='android'
    target_ios='ios'
    target_danger='danger'
    target_jsfm='jsfm'

    target=${1:-$target_android}
    echo "cilog: target: $target"

    if [ $target = $target_android ]; then
        ./test/serve.sh 2&>1 > /dev/null &
        export ANDROID_HOME=/usr/local/opt/android-sdk
        cd android && ./run-ci.sh && cd $TRAVIS_BUILD_DIR
        waitForEmulator
        JAVA_HOME=$(/usr/libexec/java_home) run_in_ci=true ./test/run.sh
    elif [ $target = $target_ios ]
    then
        ./test/serve.sh 2&>1 > /dev/null &
        xcodebuild -project ios/sdk/WeexSDK.xcodeproj test -scheme WeexSDKTests CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -destination 'platform=iOS Simulator,name=iPhone 6' | XCPRETTY_JSON_FILE_OUTPUT=ios/sdk/xcodebuild.json xcpretty -f `xcpretty-json-formatter`
        run_in_ci=true ./test/run.sh ios
    elif [ $target = $target_jsfm ]
    then
        npm run build
        npm run test
    else
        xcodebuild -project ios/sdk/WeexSDK.xcodeproj test -scheme WeexSDKTests CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -destination 'platform=iOS Simulator,name=iPhone 6' | XCPRETTY_JSON_FILE_OUTPUT=ios/sdk/xcodebuild.json xcpretty -f `xcpretty-json-formatter`
        bundle exec danger
    fi
}


text:
Editando el Registro de esta Tienda

    <?php echo form_open('tiendas/cambiar'); ?>
     <?php foreach ($data as $item): ?>

          ID
          <input type="text" class="form-control" id="id" name="tiendas[id]" value="<?php echo @$item['id']?>" >

          Nombre de la Tienda
          <input type="text" class="form-control" id="nombre" name="tiendas[nombre]" placeholder="Nombre" value="<?php echo @$item['nombre']?>" >

          Ubicacion
          <input class="form-control" id="ubicacion" name="tiendas[ubicacion]" placeholder="Ubicacion" value="<?php echo @$item['ubicacion']?>">

          Telefono
          <input class="form-control" id="telefono" name="tiendas[telefono]" placeholder="Telefono" value="<?php echo @$item['telefono']?>">

          Email
          <input type="email" class="form-control" id="email" name="tiendas[email]" placeholder="Correo Electronico" value="<?php echo @$item['email']?>">

    <?php endforeach; ?>

        <button type="submit" class="btn btn-primary">Guardar Cambios</button>


text:
package dit4c.scheduler

import dit4c.scheduler.utils.SchedulerConfig
import scala.concurrent.Future
import akka.actor.Props
import dit4c.scheduler.service.ClusterManager
import dit4c.scheduler.domain.ConfigProvider
import dit4c.scheduler.runner.RktRunner
import java.nio.file.Paths
import akka.actor.Actor
import akka.actor.ActorRef
import akka.actor.Terminated
import akka.actor.ActorLogging
import akka.stream.ActorMaterializer
import scala.concurrent.Await
import scala.concurrent.duration._
import dit4c.scheduler.service.PortalMessageBridge
import akka.pattern.BackoffSupervisor
import akka.pattern.Backoff
import akka.event.LoggingReceive
import dit4c.scheduler.domain.Instance
import dit4c.scheduler.service.KeyManager
import akka.util.Timeout
import scala.concurrent.ExecutionContext
import akka.actor.AllForOneStrategy

object Scheduler {

  def apply(config: SchedulerConfig): Unit = {
    (new SchedulerEnvironment(config))()
  }

  protected class SchedulerEnvironment(config: SchedulerConfig) extends utils.ActorModule {

    override def appName = config.name

    def apply(): Future[Unit] = {
      import system.dispatcher
      system.actorOf(Props(classOf[Scheduler], config), "scheduler")
      system.whenTerminated.map(_ => ())
    }

  }

}

class Scheduler(config: SchedulerConfig) extends Actor with ActorLogging {
  import akka.http.scaladsl.server._
  import akka.actor.SupervisorStrategy._

  override val supervisorStrategy = AllForOneStrategy() {
    case _: Exception => Escalate
  }

  override def preStart {
    import context.dispatcher
    implicit val materializer = ActorMaterializer()(context.system)
    val keyManager = context.actorOf(
        KeyManager.props(config.armoredPgpKeyrings),
        "key-manager")
    val clusterAggregateManager = context.actorOf(
        ClusterManager.props(configProvider(keyManager), config.knownClusters),
        "cluster-aggregate-manager")
    val pmbSupervisor = context.actorOf(BackoffSupervisor.props(
        Backoff.onStop(
          Props(classOf[PortalMessageBridge], keyManager, config.portalUri),
          childName = "portal-message-bridge",
          minBackoff = 500.milliseconds,
          maxBackoff = 15.seconds,
          randomFactor = 0.1)),
        "pmb-supervisor")
    // TODO: remove need for this kludge
    context.system.eventStream.subscribe(self, classOf[Instance.StatusReport])
  }

  override def postStop {
    context.system.terminate
  }

  override def receive = LoggingReceive {
    case msg: KeyManager.Command =>
      context.child("key-manager").foreach { child =>
        child.forward(msg)
      }
    case msg if Some(sender) == context.child("cluster-aggregate-manager") =>
      context.child("pmb-supervisor").foreach { child =>
        child.forward(msg)
      }
    case msg if Some(sender) == context.child("pmb-supervisor") =>
      context.child("cluster-aggregate-manager").foreach { child =>
        child.forward(msg)
      }
    case msg: Instance.StatusReport => // TODO: remove need for this kludge
      context.child("pmb-supervisor").foreach { child =>
        child.forward(msg)
      }
    case unknown =>
      log.warning(s"Unknown message from $sender: $unknown")
  }

  private def configProvider(
      keyManager: ActorRef)(implicit ec: ExecutionContext): ConfigProvider = new ConfigProvider {
    override def rktRunnerConfig =
      RktRunner.Config(
          Paths.get("/var/lib/dit4c-rkt"),
          "dit4c-instance",
          config.authImage,
          config.listenerImage,
          config.storageImage,
          config.uploadImage)
    override def sshKeys = {
      import akka.pattern.ask
      implicit val timeout = Timeout(1.minute)
      (keyManager ? KeyManager.GetOpenSshKeyPairs)
        .collect {
          case KeyManager.OpenSshKeyPairs(pairs) =>
            pairs
        }
    }

  }
}


text:
package hu.transfet.unideb.application.service;

import hu.transfet.unideb.application.model.player.Player;
import hu.transfet.unideb.application.model.player.PlayerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
Egy osztaly,mely implementalja a {@link PlayerService}
 * Ezen osztaly metodusaival tudunk a jatekosokhoz hozzaferni, illetve modositani az adatbazisban.

 */

@Service
public class PlayerServiceImpl implements PlayerService {

    /**
     * A player service {@link PlayerRepository}-ja.
     */
    @Autowired
    private PlayerRepository playerRepository;

    @Override
    public List<Player> findAllPlayer() {
        return playerRepository.findAll();
    }

    @Override
    public void addPlayer(Player player) {
        playerRepository.save(player);
    }

    @Override
    public void deletePlayer(Player player) {

        playerRepository.delete(player);
    }

    @Override
    public void updatePlayerPointAndTime(String player, Double point, Double time) {
        playerRepository.updatePlayerPointAndTime(player, point, time);
    }

    @Override
    public Player findById(Long iD) {
        return playerRepository.findPlayerById(iD);
    }

}


text:
from strategy.trade import Trade, Deal

class SimpleTrade(Trade):
	"""
	最简单的交易模块,如果预期上涨买1手,如果预期下跌卖1手,如果预期平则平仓
	"""

	def __init__(self):
		super(SimpleTrade, self).__init__()
		self.status = 0

	def trade(self, signal, dataset):
		if signal != self.status:
			amount = signal - self.status
			self.status = signal
			return [Deal(dataset.time, dataset.target, amount, dataset.price)]


text:
Title: An update on the pandas documentation
Slug: pandas-documentation-update
Tags: pandas

## Some context

This post is mainly a technical post on what's the status of the pandas documentation.
But let me provide a bit of context on where this comes from.

It's a personal opinion, but I think pandas is one of the clearest examples of how open
source is transforming the data world (together with some other projects like scikit-learn,
Jupyter, R...). Is likely that pandas contributed to the huge growth of
Python, a language that not many people knew about when pandas development started.

![](/static/img/blog/pandas_doc/panda_book.jpeg)

And I think its documentation has been the clearest example of the paradox of open
source software. While pandas users were growing to the millions, and it was adopted in thousands
of companies (including the largest companies in the world), almost nobody spent any time
or money in its documentation (which requires a lot of work to be of high quality). It's surely not to blame the
very few people (3 or 4 at times) who were maintaining the project. They had enough dealing with thousands of
issues, updates in the many and fast changing dependencies, releasing new versions... While also
implementing new features and fixing bugs themselves. And even more considering that most of that
work was done as volunteers, in evenings after work or in weekends.

More than 2 years ago I sent to the project my first pull request, fixing a single docstring
(one of the around 2,000 in the project). And decided to spend a significant amount of
my also volunteer time (after work and during weekends) in improving that part. That also
was one of the main reasons for starting the [Python sprints](https://python-sprints.github.io)
group.

More than two years later, not much changed (apparently). But if you care about my opinion,
I'm sure very soon pandas will have one of the best documentations of any open source project. This
post explains all the work done by hundreds of people in the last couple of years, and the work
that is still missing, and how we are going to approach it.

**If you work for a company that is making money using pandas, and that would be more productive
and make even more money if pandas documentation was better, please contact a pandas maintainer
including [myself](mailto:garcia.marc@gmail.com) or [NumFOCUS](https://www.numfocus.org).
We are happy to discuss funding opportunities, including small grants or helping your company
hire people to work on pandas.**

## The problem with the docstrings

The pandas API is huge, and includes around 2,000 functions, methods, classes, attributes...
Each of them with a page in the documentation.
Given the very reduced number of developers pandas had, and the huge demand and urgency for a dataframe
library in Python, most of those API pages couldn't be created with high standards when the
features were implemented. See for example the
[Resampler.last](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.resample.Resampler.last.html)
page.

It may not be obvious for people who haven't contributed to a project like pandas before,
but improving a docstring, and make it as useful for readers as possible, it's not 5 minutes
of work. Based on the work done by lots of contributors over the last year, I would estimate
it takes around 1 day of work of an experienced pandas user. You can see the docstring of
[Resampler.bfill](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.resample.Resampler.bfill.html)
to see what I'd consider a good docstring.

Considering this estimate of 1 day per docstring, and the around 2,000 docstrings, it's
easy to calculate that it'd take around 8 years for a single person working full time,
to have all them fixed. And that excludes the time of maintainers to review the changes,
provide feedback, merge...

## The pandas documentation sprint

![](/static/img/blog/pandas_doc/pandas_sprint.png)

As it's obvious that a single person can't do much, one of the things that was tried
was to organize a [worldwide pandas sprint](https://python-sprints.github.io/pandas/).

The sprint was extremely successful in many ways. 30 local users groups participated,
from places as diverse as Korea, Hong Kong, India, Turkey, Kenya, Nigeria, Argentina
or Brazil, besides many cities in Europe and US. Difficult to say how many people
participated, but we estimate there where around 500 people helping make pandas
documentation for a whole Saturday.

I think there are no words to describe how amazing that is. How many people offered
to organize sprints with their local groups. And how many people joined them in every
sprint. The organizers had to prepare the event for weeks, both for logistics but also
for the technical part of leading a lot of people in their first open source contributing.

A big responsible for this success was [NumFOCUS](https://numfocus.org/). For several
years now NumFOCUS has done extraordinary efforts on building the PyData community.
Having a connected network of more than 150 user groups made it very easy to communicate
and reach all the people who could be interested.

The feedback I received from the participants and organizers was very positive, and people
enjoyed the experience (which I personally think it's much more important than the
contributions made). And there were around 200 documentation pages that were fixed
because of the sprint (10% of the total).

But not everything was so positive. The sprint also made evident that the problem of
fixing the documentation was not the number of contributors. The bottleneck happened
to be the maintainers. The sprint created a total disruption of the project for more than two
weeks. And this period wasn't longer because the maintainers were spending day and night
reviewing the pull requests from the sprint. In many cases it was the maintainers who
had to finish the work started during the sprint. Many pull requests contained great
work, but were discontinued, and they required important changes that had to be done
by the maintainers. The last PR from the sprint was merged almost a year later than
the sprint.

More information about the sprint can be found in this
[NumFOCUS write up](https://numfocus.org/blog/worldwide-pandas-sprint).

## The validation script

We anticipated before the sprint, that reviewing the contributions would be a lot
of work. And we developed a script to automate part of it. The idea was to automatically
detect things like:

- The documented parameters of a function need to match the actual parameters in the signature
- Conventions like starting sentences with a capital letter or finishing with a period
- Ensure that some sections we'd like to always have are present (like Examples)
- Formats that make Sphinx render the documentation incorrectly, like missing spaces before the
  colon between a parameter name and its type

We managed to have several of these ready for the sprint. But to keep all the docstrings consistent
and rendering correctly, we needed many more. Many people spent a significant amount of time adding
new checks to the script, and we are currently able to automatically detect
[more than 40 possible problems in docstrings](https://github.com/pandas-dev/pandas/blob/master/scripts/validate_docstrings.py#L63).

Of course not everything can be validated, think of correct grammar, wrong, inaccurate or misleading
information, examples that are not clear... But validating almost every formatting issue automatically
will definitely save a lot of time of reviewers. Who will be able to focus on the things that
can't be automated.

Some other projects had interest in using our validation script, so it's been recently moved to
[numpydoc](https://github.com/numpy/numpydoc)

![](/static/img/blog/numpydoc_validation.png)

## Continuous Integration

During the sprint, we provided clear instructions, and we had mentors in each of the 30 different
locations. So, everybody was probably aware that the validation script was one of the main things
they had to check. But regular contributors don't get this sort of induction. So, ideally we would
like to run the checks automatically in the CI, so contributors are aware of any problem in their
proposed changes. But there are some things to consider.

With Travis, our main CI system, the errors ended up in a huge log, that only experienced
pandas developers are able to understand. See for example [this job](https://travis-ci.org/pandas-dev/pandas/jobs/484898115)
and make sure you wait until it's fully loaded. :)

Luckily, at the time our script was being implemented, Numba set up Azure Pipelines for their CI, and we
decided to use it to complement Travis. The main reason was that we required more computational
power for the huge test set of pandas, and the large number of builds. But, I think the clarity
on how the errors can be reported, is as convenient as the 30 concurrent jobs the Azure team
offered us. Compare this with the previous Travis log:

![](https://user-images.githubusercontent.com/10058240/47961709-1ca90800-e008-11e8-80d7-cccc2c2e5776.png)

We were very ambitious, and somehow pioneers in what we were doing, and it wasn't
easy to get what we wanted. But The Azure team was extremely helpful, and the final
presentation of errors in docstrings, as well as the linting errors and others was
much clearer. And friendly for first time contributors.

Azure pipelines was an improvement, but we still had some challenges. The integration
with GitHub wasn't great, and it required following two links and navigating a somehow
confusing interface to arrive to the page where the errors were being presented in a
better interface than TravisCI.

Just few days ago we moved this docstring validation, among other things, to
[GitHub Actions](https://github.com/features/actions). So far the experience has been
great, and we keep the same advantages as with Pipelines, and also we have a better
integration of the CI with GitHub. And the configuration is also simpler and a bit
more intuitive than with Pipelines.

We are still figuring out how to notify contributors with a human-readable message
about problems in the CI. Since only experienced contributors know how to find the
problems by themselves. And that's taking time from the reviewers, for a task that
could be easily automated. With GitHub Actions is very easy to write comments in
a pull request, so the only remaining challenge is to obtain all the failures in
all the jobs in a run. But hopefully that's not too complex and we can have it in
place soon.

Another important thing that the continuos integration can do for us, is to let
us visualize the documentation before being merged. In many cases, small details
make the documentation render in an incorrect way. Like a bold style that doesn't
finish when it's expected to finish. Or a broken table that renders as plain text.

This has been challenging until now, since CI systems don't do this automatically,
and it's tricky to implement manually. CircleCI provided this feature, but to
access the rendered documentation you have to know the url and replace the id of
your build on it. Maintainers could do that in a not very efficient way, but
first-time contributors couldn't guess.

Implementing it manually has a main challenge. The CI is usually only able to
access passwords and keys when a pull request is merged. Otherwise a malicious
pull request could access the key and leak it. An option to overcome this limitation
would be to host in a server a GitHub application that receives a webhook when
a pull request is opened or updated, and its docs are built. After being triggered
it would fetch the docs, and publish them somewhere, using a key only accessible
in the server.

Implementing that has been in our backlog for a while. But there is another problem.
Where to host all these copies of the documentation. We use GitHub pages to
host the latest version of our docs. But since Git/GitHub track all the history
of changes, the repo would grow huge very quickly if we add all our docs (around
50Mb) for every pull request.

The solution to this may come easier than expected, since GitHub Actions seems to be consideting
implementing it. Not sure when that could be ready, if ever. In the meantime [OVH](https://www.ovh.co.uk/)
has recently started sponsoring a new pandas cloud hosting, were we can temporary store
all these versions of the docs. This is being implemented now, and with some
luck should be in production soon. If we implement our GitHub app to publish the docs, the
new hosting and GitHub Actions will make it much easier than it was before.
GitHub Actions will also
make very simple to delete the docs for a PR once it is merged or closed.

## Validating docstrings in the CI

Two key pieces to validate contributions to the pandas docstrings are in place:

- A validation script with lots of checks
- A CI system friendly with first time contributors

But there is a last piece needed. If we activate the validation in the CI, we will
have 1,000 docstrings, or more, reporting errors in the CI for every PR. Basically,
we will be reported of every error in every docstring that needs to be fixed every
time the CI runs.

Would be useful to be able to get the errors being introduced, so no more errors
are added, while we fix the ones we already have. But this is not feasible (would be
too complex and too slow).

This leaves us in a unfortunate position, of only being able to validate what has
already been fixed. Which is extremely useful, as we can guarantee that things don't
get worse. But it doesn't solve our problem of improving the docstrings that need it yet.

So, what can be done? I think it's useful to divide the docstring checks in two
different categories:

- The pure formatting things (like having periods at the end of sentences)
- The ones that require knowledge of pandas and the object being documented
  (like adding examples of how to use an function, or adding an undocumented parameter)

The ones in the first category are somehow easy to fix. And many can be fixes at a time
(in a single pull request), working in one after the other, without stopping much to
understand things.

Once all the errors of a kind have been fixed, we can start validating that specific
error in the CI. And we guarantee that no more errors of that kind will ever happen.

And what is even better. Once all those formatting errors are fixed, we can start
working on the docstrings, one at a time. Where a person spends enough time understanding
the function being documented to become an expert. To a point where it can focus on
improving the content, writing a nice summary, useful examples, and document parameters
in an accurate way. And that person won't need to become an expert in reStructuredText
formatting, because the CI warn about any issue. And the person will be able to fix
any problem without requiring time from a maintainer.

We already completely fixed several of the more than 40, and we validate that the errors are
not added again:

- **GL03**: Use of double blank lines when one would be expected
- **GL04**: Private classes mentioned in public docstrings
- **GL05**: Tabs used instead of 4 spaces
- **GL06**: An unknown section is found
- **GL07**: Sections in the wrong order
- **GL09**: Deprecation warning in the wrong position
- **GL10**: Sphinx directives incorrectly formatted
- **SS04**: Summary contains heading whitespaces
- **SS05**: Summary staring with infinitive verb, not third-person
- **PR03**: Parameters are in the wrong order (compared to the signature)
- **PR04**: Parameters without type
- **PR05**: Parameter type finishing with a period (it shouldn't)
- **PR10**: Missing space before colon splitting parameter name and type
- **RT01**: No Returns section
- **RT04**: Returns description should start with a capital letter
- **RT05**: Returns description should finish with a period
- **SA01**: No See Also section found
- **SA02**: See Also description should finish with a period
- **SA03**: See Also description should start with a capital letter
- **SA05**: Unneeded prefix in See Also section object
- **EX04**: pandas or NumPy explicitly imported in the examples (we assume they are always imported)

Those validations have been added to the [code\_checks.sh](https://github.com/pandas-dev/pandas/blob/master/ci/code_checks.sh#L289)
script, which is responsible for many code quality checks (linting, typing, avoidance of unwanted patterns...).

But there are still many errors that need to be fixed, including formatting errors.

We are able to get the list of all the errors that we can automatically detect,
with the same script that analyzes a docstring, but without passing an object as a parameter::

    $ ./scripts/validate_docstrings.py --format=json > docstrings.json

This will output a JSON file that can easily be loaded into pandas,
and see what needs to be fixed:

```python
import pandas

(pandas.read_json('docstrings.json', orient='index')
      .loc[:, 'errors']
      .map(lambda err_list: '|'.join([err[0] for err in err_list]))
      .str.get_dummies('|')
      .sum(axis='index')
      .sort_values()
      .plot.barh())
```

![](/static/img/blog/pandas_doc/pandas_docstring_errors.png)

We can see how there are 18 different validations with docstrings that don't pass them.

The list of all the validations and their error codes can be found in the same
[validation script code](https://github.com/pandas-dev/pandas/blob/master/scripts/validate_docstrings.py#L77).

We can see for example, how the error `GL08`, happening more than 500 times, means that
the objects don't have a docstring at all. See for example
[Series.empty](http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.empty.html)
Or the second most frequent error, `RT03`
means that it is not documented what is being returned (the return type is present, but
there is no description on what's the returned object).

In total we have 2,441 errors that we can detect automatically. That includes docstrings that
need to be fully created. And creating them requires a lot of time, since there is no documentation
of them, and analyzing the source code, experimenting... is required.

## Where do we come from?

Analyzing the docstrings of past versions of pandas we can see that pandas 0.23 had
7,136 errors, with the current validations. pandas 0.23 was released on the 16th of
May of 2018, couple of month after the worldwide sprint with 500 people. Most of the
work of that sprint was already present in that version.

This is the detail of errors at that time:

![](/static/img/blog/pandas_doc/pandas_docstring_errors_023.png)

So, in 18 months we fixed two thirds of the errors. Assuming it takes the same amount
of time to fix every error, and that we continue at the same pace, in 9 months more we
should have all them fixed. This would amazing, but it's clearly false that all errors
require the same time, and it's obvious that we started by the easy ones. But we are
getting closer.

## Parallelization, a game changer

Our work is every time more challenging and time consuming. Remember that we started with
small formatting changes like adding a period at the end of a sentence, and we are going
to write full docstrings. So, we need to become smarter and more efficient on how we work on the
documentation. And the most important part is being able to work in parallel, since there is
not much a single person can do.

Of the around 2,000 docstrings, around 1,400 still have errors (considering errors detected
by the script). Imagine that tomorrow we want to start working on all them. One of the main
problems would be to detect who works on what, and avoid duplicate work. Many people volunteered
in the past to help make the pandas documentation better, and there may be 1,400 people
out there who could be happy to help if they knew exactly what to do.

How this is usually solved in open source is by creating issues. Then people assigned the
issue they want to work to themselves, and as people join the party, they check in the
list of unassigned issues what else need to be done.

Unfortunately, a workflow as simple as this has been problematic in GitHub. While GitHub
provides a nice interface for issues, and implements the functionality of assignees, it's
limited to members of the organization (core developers). While this is useful for small
corporate projects, assignees is unused in pandas, and people have been assigning them
issues by mentioning their interest in a comment. Which it kind of works, but it doesn't
let people find unassigned issues in an easy way.

Recently, we found a hack in pandas, that people is starting to use. With GitHub actions,
we are able to assign issues to people who adds a comment with the exact word `take.
While this is far from optimal, since most users won't be aware of this, it can be very
useful when organizing sprints or coordinated events, where we can communicate with
contributors. We can also write in the issue description about this new feature, so
creating a batch of issues automatically, that we expect people to assign to themselves
seems feasible.

That's a game changer in parallelizing the work, since it makes the logistics much
simpler in coordinating the contributors. See more information about this new
workflow in this [recent blog post](https://datapythonista.github.io/blog/new-pandas-workflow.html)
I wrote.

But there are still some challenges:

In many cases, pandas has templates for a docstring, that are reused in more
than one object. So different objects can use the same docstring, and it's not
easy to identify which. Creating issues automatically for each object can still
cause overlap in the work.

While many things can be automated, the main bottleneck are still the reviews of
the changes. There are few people who has the knowledge and experience in pandas
to provide feedback on whether the changes to the documentation are reasonable.
And who has the permissions to merge changes into pandas. And almost all them
are volunteer, and need to take care of other obligations like full time jobs
and family.

## The future

![](/static/img/blog/pandas_doc/panda_babies.jpeg)

Exciting times are coming for the pandas documentation. Not only the content, but
also a whole new theme is being implemented. So, soon the documentation will
look much better.

The CI is getting closer to a level where we can automate as much as possible,
and be very efficient in coordinating the documentation efforts. As well as
let first-time contributors be quite autonomous, and progress independently on
their work until a maintainer can really add value.

Not only the number of maintainers in the project has been growing significantly
in the last couple of years, but a new role of triaggers has been implemented,
which can be useful in this effor.

[NumFOCUS](https://numfocus.org/) has recently awarded us a small development
grant to work on the documentation. And not only will help with the documentation
but hopefully will address a problem as big as it, diversity. A group of people
from groups underrepresented as pandas contributors will be helping with the
documentation, and organizing sprints in different locations to help and
encourage more people to contribute to it.

Increasing the diversity of the background of the contributors, will not only
help with the quantity of the documentation pages, but also its quantity.
pandas should be useful for a wide variety of people. If the documentation is
made and reviewed by people from different backgrounds (academic backgrounds,
geography, gender...) it will be clearer and more useful to more people, and
will better accomplish its goal.

The sprints are likely to be in Jakarta, Cairo and Berlin. If you can increase
the diversity of the pandas contributors and want to participate, feel free
to contact me for more details and updates.

If you would like to organize a pandas documentation sprint for minorities in
a different location, please also get in touch. We are unlikely to be able to
provide funds, but we can help you with everything else.

**And if your company would benefit from a better pandas documentation, please
consider supporting the project. From funding to the project, to funding of
specific developments. And also you can consider hosting an event in your
office, letting your employees spend part of their time working on pandas,
providing in-kind donations, or anything you can think of. Please message
me or any other maintainer to discuss about opportunities.**


text:
namespace eja
{
	// Component
	derived_id_component(group_option_component, group_option);
}

#endif


text:
package org.gradle.internal.nativeintegration.filesystem.services;

import net.rubygrapefruit.platform.FileInfo;
import net.rubygrapefruit.platform.Files;
import org.gradle.internal.file.FileMetadataSnapshot;
import org.gradle.internal.nativeintegration.filesystem.DefaultFileMetadata;
import org.gradle.internal.nativeintegration.filesystem.FileMetadataAccessor;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;

public class NativePlatformBackedFileMetadataAccessor implements FileMetadataAccessor {
    private final Files files;

    public NativePlatformBackedFileMetadataAccessor(Files files) {
        this.files = files;
    }

    @Override
    public FileMetadataSnapshot stat(File f) {
        FileInfo stat = files.stat(f, true);
        switch (stat.getType()) {
            case File:
                return DefaultFileMetadata.file(stat.getLastModifiedTime(), stat.getSize());
            case Directory:
                return DefaultFileMetadata.directory();
            case Missing:
                return DefaultFileMetadata.missing();
            default:
                throw new IllegalArgumentException("Unrecognised file type: " + stat.getType());
        }
    }

    @Override
    @SuppressWarnings("Since15")
    public FileMetadataSnapshot stat(Path path) throws IOException {
        return stat(path.toFile());
    }
}


text:
module Melchior.Crypto where

import Melchior.Data.String

md5 :: String -> String
md5 s = jsStringToString $ primMd5 $ stringToJSString s

foreign import js "Crypto.md5(%1)"
  primMd5 :: JSString -> JSString


text:
function y = medmad(x, dim)
%MEDMAD Median absolute deviation from the median.
%
%   For vectors, MEDMAD(X) is the median absolute deviation from the median of
%   the elements in X, i.e., MEDIAN(ABS(X - MEDIAN(X))).
%
%   For matrices, MEDMAD(X) is a row vector containing the medmad value of each
%   column.
%
%   In general, MEDMAD(X) is the medmad value of the elements along the first
%   non-singleton dimension of X.
%
%   MEDMAD(X,DIM) is the medmad value along the dimension DIM of X.
%
%   For symmetric probability distributions, the theoretical medmad value
%   equals one half the inter-quartile range.
%
%   See also MEAN, STD, MIN, MAX, COV.

%   Author:      Peter J. Acklam
%   Time-stamp:  2004-09-22 19:12:20 +0200
%   E-mail:      pjacklam@online.no
%   URL:         http://home.online.no/~pjacklam

   nargsin = nargin;
   error(nargchk(1, 2, nargsin));

   sx = size(x);
   dx = ndims(x);

   % get first non-singleton dimension, or 1 if none found
   if nargsin < 2
      k = find(sx ~= 1);
         if isempty(k)
         dim = 1;
      else
         dim = k(1);
      end
   else
      if any(size(dim) ~= 1) || dim < 1 || dim ~= round(dim)
         error('Dimension must be a scalar positive integer.');
      end
   end

   n = size(x, dim);

   % degenerate cases
   if isempty(x) | n == 1
      sy = sx;
      if dim <= dx
         sy(dim) = 1;
      end
      y = zeros(sy);
      return;
   end

   % compute median along dimension `dim'
   m = median(x, dim);

   % replicate median along dimension `dim'
   r = ones(1, dx);
   r(dim) = n;
   m = repmat(m, r);

   % compute the absolute deviation from the median
   y = abs(x - m);

   % compute the median of along dimension `dim'
   y = median(y, dim);

   return

%    % Alternative implementation:
%
%    % permute and reshape so DIM becomes the row dimension of a 2-D array
%    perm = 1:dx;
%    perm([1 dim]) = [dim 1];
%    x = reshape(permute(x, perm), [n prod(sx)/n]);
%
%    % compute the median and replicate it
%    m = median(x, 1);
%    m = repmat(m, [n 1]);
%
%    % subtract the median, take absolute values, and compute median of the
%    % result
%    y = abs(x - m);
%    y = median(y, 1);
%
%    % reshape and permute back
%    sy = sx;
%    sy(dim) = 1;
%    y = permute(reshape(y, sy(perm)), perm);
%
%    return


text:
pub struct Visual {
    elements: Vec<VisualElement>
}

pub enum VisualElement {
    Static(String),
    SimpleAnimation(String),
}


text:
using System;
using System.Collections.Generic;
using System.IO;
using QuantConnect.Interfaces;
using QuantConnect.Logging;
using QuantConnect.Util;

namespace QuantConnect.Lean.Engine.DataFeeds
{
    /// <summary>
    /// An implementation of <see cref="IFutureChainProvider"/> that reads the list of contracts from open interest zip data files
    /// </summary>
    public class BacktestingFutureChainProvider : IFutureChainProvider
    {
        /// <summary>
        /// Gets the list of future contracts for a given underlying symbol
        /// </summary>
        /// <param name="symbol">The underlying symbol</param>
        /// <param name="date">The date for which to request the future chain (only used in backtesting)</param>
        /// <returns>The list of future contracts</returns>
        public IEnumerable<Symbol> GetFutureContractList(Symbol symbol, DateTime date)
        {
            if (symbol.SecurityType != SecurityType.Future)
            {
                throw new NotSupportedException($"BacktestingFutureChainProvider.GetFutureContractList(): SecurityType.Future is expected but was {symbol.SecurityType}");
            }

            // build the future contract list from the open interest zip file entry names

            // build the zip file name for open interest data
            var zipFileName = LeanData.GenerateZipFilePath(Globals.DataFolder, symbol, date, Resolution.Minute, TickType.OpenInterest);

            if (!File.Exists(zipFileName))
            {
                Log.Trace($"BacktestingFutureChainProvider.GetFutureContractList(): File not found: {zipFileName}");
                yield break;
            }

            // generate and return the contract symbol for each zip entry
            var zipEntryNames = Compression.GetZipEntryFileNames(zipFileName);
            foreach (var zipEntryName in zipEntryNames)
            {
                yield return LeanData.ReadSymbolFromZipEntry(symbol, Resolution.Minute, zipEntryName);
            }
        }
    }
}


text:
iware::cpu::architecture_t iware::cpu::architecture() noexcept {
	SYSTEM_INFO sysinfo;
	GetSystemInfo(&sysinfo);

	switch(sysinfo.wProcessorArchitecture) {
		case PROCESSOR_ARCHITECTURE_AMD64:
			return iware::cpu::architecture_t::x64;
		case PROCESSOR_ARCHITECTURE_ARM:
			return iware::cpu::architecture_t::arm;
		case PROCESSOR_ARCHITECTURE_IA64:
			return iware::cpu::architecture_t::itanium;
		case PROCESSOR_ARCHITECTURE_INTEL:
			return iware::cpu::architecture_t::x86;
		default:
			return iware::cpu::architecture_t::unknown;
	}
}

#endif


text:
package gov.va.med.lom.javaBroker.rpc.user.models;

import gov.va.med.lom.javaBroker.rpc.BaseBean;

import java.io.Serializable;
import java.util.Date;

public class Notification extends BaseBean implements Serializable {

  private String info;
  private String patient;
  private String location;
  private String urgency;
  private Date alertDateTime;
  private String alertDateTimeStr;
  private String text;
  private String forwardingInfo;
  private String xqaid;
  private String comment;
  private String orderType;
  private String orderInfo;
  private int followUp;
  private int recordId;

  public Notification() {
    this.info = null;
    this.patient = null;
    this.location = null;
    this.urgency = null;
    this.alertDateTime = null;
    this.alertDateTimeStr = null;
    this.text = null;
    this.forwardingInfo = null;
    this.xqaid = null;
    this.comment = null;
    this.orderType = null;
    this.orderInfo = null;
    this.followUp = 0;
    this.recordId = 0;
  }

  public Date getAlertDateTime() {
    return alertDateTime;
  }

  public void setAlertDateTime(Date alertDateTime) {
    this.alertDateTime = alertDateTime;
  }

  public String getAlertDateTimeStr() {
    return alertDateTimeStr;
  }

  public void setAlertDateTimeStr(String alertDateTime) {
    this.alertDateTimeStr = alertDateTime;
  }

  public String getComment() {
    return comment;
  }

  public void setComment(String comment) {
    this.comment = comment;
  }

  public int getFollowUp() {
    return followUp;
  }

  public void setFollowUp(int followUp) {
    this.followUp = followUp;
  }

  public String getForwardingInfo() {
    return forwardingInfo;
  }

  public void setForwardingInfo(String forwardingInfo) {
    this.forwardingInfo = forwardingInfo;
  }

  public String getInfo() {
    return info;
  }

  public void setInfo(String info) {
    this.info = info;
  }

  public String getLocation() {
    return location;
  }

  public void setLocation(String location) {
    this.location = location;
  }

  public String getPatient() {
    return patient;
  }

  public void setPatient(String patient) {
    this.patient = patient;
  }

  public int getRecordId() {
    return recordId;
  }

  public void setRecordId(int recordId) {
    this.recordId = recordId;
  }

  public String getText() {
    return text;
  }

  public void setText(String text) {
    this.text = text;
  }

  public String getUrgency() {
    return urgency;
  }

  public void setUrgency(String urgency) {
    this.urgency = urgency;
  }

  public String getXqaid() {
    return xqaid;
  }

  public void setXqaid(String xqaid) {
    this.xqaid = xqaid;
  }

  public String getOrderType() {
    return orderType;
  }

  public void setOrderType(String orderType) {
    this.orderType = orderType;
  }

  public String getOrderInfo() {
    return orderInfo;
  }

  public void setOrderInfo(String orderInfo) {
    this.orderInfo = orderInfo;
  }
}


text:
<!doctype html>

  <title>Empty page</title>
  <link rel="Shortcut Icon" href="/favicon.ico" />
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css"/>


text: This project automates a set of lights (presumably a traffic light) to aid in parking a car.


text:
return Def.ActorFrame {
	--note graphic
	NOTESKIN:LoadActor(Var "Button", "Tap Note") .. {
		InitCommand=cmd(blend,"BlendMode_Add";playcommand,"Glow");
		W1Command=cmd(playcommand,"Glow");
		W2Command=cmd(playcommand,"Glow");
		W3Command=cmd(playcommand,"Glow");
		W4Command=cmd();
		W5Command=cmd();

		HitMineCommand=cmd(playcommand,"Glow");
		GlowCommand=cmd(setstate,0;finishtweening;diffusealpha,1.0;zoom,1.0;linear,0.15;diffusealpha,0.9;zoom,1.15;linear,0.15;diffusealpha,0.0;zoom,1.3);
		HeldCommand=cmd(playcommand,"Glow");
	};
	--tap
	NOTESKIN:LoadActor(Var "Button", "Ready Receptor")..{
		Name="Tap";
		--Frames = { { Frame = 2 ; Delay = 1 } };
		TapCommand=cmd(finishtweening;diffusealpha,1;zoom,1;linear,0.2;diffusealpha,0;zoom,1.2);
		InitCommand=cmd(pause;setstate,2;playcommand,"Tap");
		HeldCommand=cmd(playcommand,"Tap");
		ColumnJudgmentMessageCommand=cmd(playcommand,"Tap");
		--TapNoneCommand=cmd(playcommand,"Tap");
	};
	--explosion
	LoadActor("_flash")..{
		InitCommand=cmd(blend,"BlendMode_Add";playcommand,"Glow");
		W1Command=cmd(playcommand,"Glow");
		W2Command=cmd(playcommand,"Glow");
		W3Command=cmd(playcommand,"Glow");
		W4Command=cmd();
		W5Command=cmd();
		--HoldingOnCommand=cmd(playcommand,"Glow");
		HitMineCommand=cmd(playcommand,"Glow");
		HeldCommand=cmd(playcommand,"Glow");
		GlowCommand=cmd(setstate,0;finishtweening;diffusealpha,1;zoom,1;linear,0.2;diffusealpha,0;zoom,1.2);
	};
	--thing...
	Def.Quad {
		InitCommand=cmd(zoomto,50,5000;diffusealpha,0);
		HitMineCommand=cmd(finishtweening;diffusealpha,1;linear,0.3;diffusealpha,0);
	};
}


text:
/*
 * CSS Styles that are needed by jScrollPane for it to operate correctly.
 *
 * Include this stylesheet in your site or copy and paste the styles below into your stylesheet - jScrollPane
 * may not operate correctly without them.
 */

.jspContainer
{
	overflow: hidden;
	position: relative;
}

.jspPane
{
	position: absolute;
}

.jspVerticalBar
{

	position: absolute;
	top: 0;
	left: 10;
	width: 2px;
	height: 100%;
	background-color: transparent;

}

.jspHorizontalBar
{
	position: absolute;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 16px;
	background: red;
}

.jspVerticalBar *,
.jspHorizontalBar *
{
	margin: 0;
	padding: 0;
}

.jspCap
{
	display: none;
}

.jspHorizontalBar .jspCap
{
	float: left;
}

.jspTrack
{
	background-color: #3b8946;
	position: relative;
	-webkit-border-radius: 1px/5px;
	-moz-border-radius: 1px/5px;
	border-radius: 1px/5px;
	z-index: 250;
}

.jspDrag
{

	-webkit-border-radius: 3px;
	-moz-border-radius: 3px;
	border-radius: 3px;
	background-color: #33783d;

	position: relative;
	top: 0;
	left: -2;
	cursor: pointer;
	width: 6px;

	position: relative;
	top: 0;

	cursor: pointer;

}

.jspHorizontalBar .jspTrack,
.jspHorizontalBar .jspDrag
{
	float: left;
	height: 100%;
}

.jspArrow
{

	background: transparent;
	text-indent: -20000px;
	display: block;
	cursor: pointer;
	height: 16px;

	display: block;
	cursor: pointer;

}

.jspArrow.jspDisabled
{
	cursor: default;

	background: transparent;

}

.jspVerticalBar .jspArrow
{

	height: 16px;
}

.jspHorizontalBar .jspArrow
{
	width: 16px;
	float: left;
	height: 100%;
}

.jspVerticalBar .jspArrow:focus
{
	outline: none;
}

.jspCorner
{
	background: #eeeef4;
	float: left;
	height: 100%;
}

.jspArrowUp {
	background-color: transparent;
}

/* Yuk! CSS Hack for IE6 3 pixel bug :( */
* html .jspCorner
{
	margin: 0 -3px 0 0;
}