text:
"use strict";

const isValidMove = require("./is-valid-move");
const makeMove = require("./make-move");
const _ = require("lodash");
const getAceyDeucey = require("./get-acey-deucey");
const findAvailableSpaces = require("./find-available-spaces");
const constants = require("./constants");

function isValidTurn(gameState, diceRoll, proposedMoves) {
    const winningIndex = gameState.isPlayerOne ? constants.PLAYER_ONE_END_SPACE : constants.PLAYER_TWO_END_SPACE;
    const playerMultiplier = gameState.isPlayerOne ? 1 : -1;

    function areWinningMoves(moves) {
        return _(moves)
            .map(move => _.clamp(
                move.currentPosition + (move.numberOfSpaces * playerMultiplier),
                constants.PLAYER_TWO_END_SPACE,
                constants.PLAYER_ONE_END_SPACE
            ))
            .includes(winningIndex);
    }

    function checkAceyDeuceyDice() {
        // three dice and not an acey deucey
        const aceyDeucey = getAceyDeucey(diceRoll);
        if (aceyDeucey.isAceyDeucey === false) {
            return false;
        }

        // dice don't match number of proposed moves and need to be checked against [1, 2]
        // if there are no moves, there should not be available spaces for 1 or 2
        if (!proposedMoves.length) {
            return thereAreNotAvailableSpaces([1, 2]);
        }
        // if there is one move, it needs to be 1 or 2 spaces and there can't be available spaces for the second number
        if (proposedMoves.length === 1) {
            if (!_([1, 2]).includes(proposedMoves[0].numberOfSpaces)) {
                return false;
            }
            const aceyOrDeucey = proposedMoves[0].numberOfSpaces === 1 ? 2 : 1;
            return thereAreNotAvailableSpaces([aceyOrDeucey]);
        }

        const firstTwoProposedMoves = _.take(proposedMoves, 2);
        function firstTwoProposedMovesInclude(nums) {
            return _(firstTwoProposedMoves).map("numberOfSpaces").sortBy().isEqual(nums);
        }

        // one and two have not been moved first
        if (!firstTwoProposedMovesInclude([1,2])) {
            if (!areWinningMoves(firstTwoProposedMoves) || !firstTwoProposedMovesInclude([1, 1])) {
                return false;
            }
        }

        const sortedAceyDeuceyRoll = createSortedExtendedRoll(3, aceyDeucey.doublesVal);

        // number of rolls doesn't match number of proposed moves but the 1 and 2 have been used

        const noAceyOrDeucey = _.drop(proposedMoves, 2);
        const numDoublesToAdd = proposedMoves.length - 2;
        const doublesRollsToCheck = getExtension(numDoublesToAdd, aceyDeucey.doublesVal);
        if (proposedMoves.length < sortedAceyDeuceyRoll.length) {
            if (proposedMoves.length === 2) {
                return thereAreNotAvailableSpaces([sortedAceyDeuceyRoll[2]]);
            }
            return thereAreNotAvailableSpaces([sortedAceyDeuceyRoll[2]]) &&
                areDiceAndMovesEqual(doublesRollsToCheck, noAceyOrDeucey);
        }

        // the number of moves exceeds the number of rolls
        if (proposedMoves.length > sortedAceyDeuceyRoll.length) {
            return false;
        }
        // the numbers match
        return areDiceAndMovesEqual(doublesRollsToCheck, noAceyOrDeucey);
    }

    function checkDoublesDice() {
        // number of moves is less than the number of rolls
        if (proposedMoves.length === 0) {
            return thereAreNotAvailableSpaces(diceRoll);
        }

        if (proposedMoves.length < 4) {
            const numDoublesToAdd = proposedMoves.length;
            const usedDoublesRoll = getExtension(numDoublesToAdd, diceRoll[0]);
            return thereAreNotAvailableSpaces([diceRoll[0]]) && areDiceAndMovesEqual(usedDoublesRoll, proposedMoves);
        }

        if (proposedMoves.length > 4) {
            return false;
        }

        const doublesRoll = createSortedExtendedRoll(2, diceRoll[0]);
        return areDiceAndMovesEqual(doublesRoll, proposedMoves);
    }

    function getExtension(numToExtend, rollNum) {
        return _(numToExtend).range().map(() => rollNum).value();
    }

    function createSortedExtendedRoll(numToExtend, rollNum) {
        return _.sortBy(diceRoll.concat(getExtension(numToExtend, rollNum)));
    }

    function areDiceAndMovesEqual(diceRoll, moves) {
        function checkWinningMoves(diceRoll, moves) {
            return _(moves)
                .sortBy("numberOfSpaces")
                .every((move, index) => {
                    const proposedSpace = move.currentPosition + (move.numberOfSpaces * playerMultiplier);
                    if (proposedSpace === winningIndex) {
                        return move.numberOfSpaces <= diceRoll[index];
                    } else {
                        return move.numberOfSpaces === diceRoll[index];
                    }
                });
        }
        if (areWinningMoves(moves)) {
            if (diceRoll.length === 2 && diceRoll[0] !== diceRoll[1]) {
                const firstProposedSpace = moves[0].currentPosition + (moves[0].numberOfSpaces * playerMultiplier);
                if (firstProposedSpace === winningIndex) {
                    const reversedDice = _(diceRoll).clone().reverse();
                    return checkWinningMoves(diceRoll, moves) || checkWinningMoves(reversedDice, moves);
                }
            }
            return checkWinningMoves(diceRoll, moves);
        }
        return _(moves)
            .map("numberOfSpaces")
            .sortBy()
            .isEqual(diceRoll);
    }

    function thereAreNotAvailableSpaces(rollToCheck) {
        if (proposedMoves.length === 0) {
            return !_.some(rollToCheck, roll => findAvailableSpaces(gameState, roll).length);
        }

        let newGameState = gameState;
        for (const move of proposedMoves) {
            if (isValidMove(newGameState, move)) {
                newGameState = makeMove(newGameState, move);
            } else {
                break;
            }
        }
        return !findAvailableSpaces(newGameState, rollToCheck[0]).length;
    }

    function proposedMovesMatchDice() {
        // dice aren't valid
        if (!_(diceRoll).every(roll => _.inRange(roll, 1, 7)) || diceRoll.length > 3 || diceRoll.length < 2) {
            return false;
        }

        // acey deucey roll
        if (diceRoll.length === 3) {
            return checkAceyDeuceyDice();
        }

        // doubles roll
        if (diceRoll[0] === diceRoll[1]) {
            return checkDoublesDice();
        }

        // normal roll
        if (proposedMoves.length > 2) {
            return false;
        }

        if (proposedMoves.length === 0) {
            return thereAreNotAvailableSpaces(diceRoll);
        }

        if (proposedMoves.length === 1) {
            // number of spaces doesn't match dice
            if (!_.includes(diceRoll, proposedMoves[0].numberOfSpaces)) {
                const proposedSpace = _.clamp(
                    proposedMoves[0].currentPosition + proposedMoves[0].numberOfSpaces * playerMultiplier,
                    constants.PLAYER_TWO_END_SPACE,
                    constants.PLAYER_ONE_END_SPACE
                );
                const isWinningSpace = winningIndex === proposedSpace;

                return isWinningSpace && _.some(diceRoll, roll => roll > proposedMoves[0].numberOfSpaces);
            }
            const unusedRoll = proposedMoves[0].numberOfSpaces === diceRoll[0] ? diceRoll[1] : diceRoll[0];
            return thereAreNotAvailableSpaces([unusedRoll]);
        }

        const sortedDice = _.sortBy(diceRoll);
        return areDiceAndMovesEqual(sortedDice, proposedMoves);
    }

    function proposedMovesAreValid(gameState, proposedMoves) {
        if (!proposedMoves.length) {
            return true;
        }

        const firstMove = proposedMoves[0];

        if (!isValidMove(gameState, firstMove)) {
            return false;
        }

        const newProposedMoves = proposedMoves.slice(1);
        const newGameState = makeMove(gameState, firstMove);

        return proposedMovesAreValid(newGameState, newProposedMoves);

    }
    return proposedMovesMatchDice() && proposedMovesAreValid(gameState, proposedMoves);
}

module.exports = isValidTurn;


text:
package com.github.zabbixjavaclient.converter;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class GroupConverter extends ListToMapConverter<Integer> {

    @Override
    public String getIdKey() {
        return "groupid";
    }
}

redpajama_set_name: RedPajamaGithub


text:
namespace SqlNotebookScript.Interpreter.Ast;

public sealed class ReturnStmt : Stmt
{
    public Expr Value { get; set; }

    protected override Node GetChild() => Value;
}


text:
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.02.29 at 03:34:24 PM GMT
//

package uk.ac.ebi.xml.jaxb;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.datatype.XMLGregorianCalendar;

/**
 *
Java class for anonymous complex type.
 *
 *
The following schema fragment specifies the expected content contained within this class.
 *
 *

 * <complexType>
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element ref="{}accession"/>
 *         <element ref="{}id"/>
 *         <element ref="{}name"/>
 *         <element ref="{}arraydesign" maxOccurs="unbounded"/>
 *         <element ref="{}assays"/>
 *         <element ref="{}bibliography" maxOccurs="unbounded"/>
 *         <element ref="{}bioassaydatagroup"/>
 *         <element ref="{}experimentalfactor" maxOccurs="unbounded"/>
 *         <element ref="{}experimenttype" maxOccurs="unbounded"/>
 *         <element ref="{}fgemdatafiles"/>
 *         <element ref="{}lastupdatedate"/>
 *         <element ref="{}loaddate"/>
 *         <element ref="{}miamescores"/>
 *         <element ref="{}minseqescores"/>
 *         <element ref="{}provider"/>
 *         <element ref="{}rawdatafiles"/>
 *         <element ref="{}releasedate"/>
 *         <element ref="{}sampleattribute" maxOccurs="unbounded"/>
 *         <element ref="{}samples" maxOccurs="unbounded"/>
 *         <element ref="{}secondaryaccession"/>
 *         <element ref="{}species" maxOccurs="unbounded"/>
 *         <element ref="{}submissiondate"/>
 *         <element ref="{}user" maxOccurs="unbounded"/>
 *         <element ref="{}experimentdesign" maxOccurs="unbounded" minOccurs="0"/>
 *         <element ref="{}description" maxOccurs="unbounded"/>
 *         <element ref="{}protocol" maxOccurs="unbounded" minOccurs="0"/>
 *         <element ref="{}seqdatauri" minOccurs="0"/>
 *         <element ref="{}source"/>
 *       </sequence>
 *       <attribute name="loadedinatlas" type="{http://www.w3.org/2001/XMLSchema}boolean" default="false" />
 *     </restriction>
 *   </complexContent>
 * </complexType>
 *

 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "accession",
    "id",
    "name",
    "arraydesign",
    "assays",
    "bibliography",
    "bioassaydatagroup",
    "experimentalfactor",
    "experimenttype",
    "fgemdatafiles",
    "lastupdatedate",
    "loaddate",
    "miamescores",
    "minseqescores",
    "provider",
    "rawdatafiles",
    "releasedate",
    "sampleattribute",
    "samples",
    "secondaryaccession",
    "species",
    "submissiondate",
    "user",
    "experimentdesign",
    "description",
    "protocol",
    "seqdatauri",
    "source"
})
@XmlRootElement(name = "experiment")
public class Experiment {

    @XmlElement(required = true)
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlSchemaType(name = "NMTOKEN")
    protected String accession;
    @XmlElement(required = true)
    protected String id;
    @XmlElement(required = true)
    protected String name;
    @XmlElement(required = true)
    protected List<Arraydesign> arraydesign;
    @XmlElement(required = true)
    protected BigInteger assays;
    @XmlElement(required = true)
    protected List<Bibliography> bibliography;
    @XmlElement(required = true)
    protected Bioassaydatagroup bioassaydatagroup;
    @XmlElement(required = true)
    protected List<Experimentalfactor> experimentalfactor;
    @XmlElement(required = true)
    protected List<String> experimenttype;
    @XmlElement(required = true)
    protected Fgemdatafiles fgemdatafiles;
    @XmlElement(required = true)
    @XmlSchemaType(name = "date")
    protected XMLGregorianCalendar lastupdatedate;
    @XmlElement(required = true)
    @XmlSchemaType(name = "date")
    protected XMLGregorianCalendar loaddate;
    @XmlElement(required = true)
    protected Miamescores miamescores;
    @XmlElement(required = true)
    protected Minseqescores minseqescores;
    @XmlElement(required = true)
    protected Provider provider;
    @XmlElement(required = true)
    protected Rawdatafiles rawdatafiles;
    @XmlElement(required = true)
    @XmlSchemaType(name = "date")
    protected XMLGregorianCalendar releasedate;
    @XmlElement(required = true)
    protected List<Sampleattribute> sampleattribute;
    @XmlElement(required = true)
    protected List<BigInteger> samples;
    @XmlElement(required = true)
    @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
    @XmlSchemaType(name = "NCName")
    protected String secondaryaccession;
    @XmlElement(required = true)
    protected List<String> species;
    @XmlElement(required = true)
    @XmlSchemaType(name = "date")
    protected XMLGregorianCalendar submissiondate;
    @XmlElement(required = true)
    protected List<User> user;
    protected List<String> experimentdesign;
    @XmlElement(required = true)
    protected List<Description> description;
    protected List<Protocol> protocol;
    @XmlSchemaType(name = "anyURI")
    protected String seqdatauri;
    @XmlElement(required = true)
    protected Source source;
    @XmlAttribute
    protected Boolean loadedinatlas;

    /**
     * Gets the value of the accession property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getAccession() {
        return accession;
    }

    /**
     * Sets the value of the accession property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setAccession(String value) {
        this.accession = value;
    }

    /**
     * Gets the value of the id property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getId() {
        return id;
    }

    /**
     * Sets the value of the id property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setId(String value) {
        this.id = value;
    }

    /**
     * Gets the value of the name property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the value of the name property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setName(String value) {
        this.name = value;
    }

    /**
     * Gets the value of the arraydesign property.
     *
     *

     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a set method for the arraydesign property.
     *
     *

     * For example, to add a new item, do as follows:
     *

     *    getArraydesign().add(newItem);
     *

     *
     *
     *

     * Objects of the following type(s) are allowed in the list
     * {@link Arraydesign }
     *
     *
     */
    public List<Arraydesign> getArraydesign() {
        if (arraydesign == null) {
            arraydesign = new ArrayList<Arraydesign>();
        }
        return this.arraydesign;
    }

    /**
     * Gets the value of the assays property.
     *
     * @return
     *     possible object is
     *     {@link BigInteger }
     *
     */
    public BigInteger getAssays() {
        return assays;
    }

    /**
     * Sets the value of the assays property.
     *
     * @param value
     *     allowed object is
     *     {@link BigInteger }
     *
     */
    public void setAssays(BigInteger value) {
        this.assays = value;
    }

    /**
     * Gets the value of the bibliography property.
     *
     *

     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a set method for the bibliography property.
     *
     *

     * For example, to add a new item, do as follows:
     *

     *    getBibliography().add(newItem);
     *

     *
     *
     *

     * Objects of the following type(s) are allowed in the list
     * {@link Bibliography }
     *
     *
     */
    public List<Bibliography> getBibliography() {
        if (bibliography == null) {
            bibliography = new ArrayList<Bibliography>();
        }
        return this.bibliography;
    }

    /**
     * Gets the value of the bioassaydatagroup property.
     *
     * @return
     *     possible object is
     *     {@link Bioassaydatagroup }
     *
     */
    public Bioassaydatagroup getBioassaydatagroup() {
        return bioassaydatagroup;
    }

    /**
     * Sets the value of the bioassaydatagroup property.
     *
     * @param value
     *     allowed object is
     *     {@link Bioassaydatagroup }
     *
     */
    public void setBioassaydatagroup(Bioassaydatagroup value) {
        this.bioassaydatagroup = value;
    }

    /**
     * Gets the value of the experimentalfactor property.
     *
     *

     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a set method for the experimentalfactor property.
     *
     *

     * For example, to add a new item, do as follows:
     *

     *    getExperimentalfactor().add(newItem);
     *

     *
     *
     *

     * Objects of the following type(s) are allowed in the list
     * {@link Experimentalfactor }
     *
     *
     */
    public List<Experimentalfactor> getExperimentalfactor() {
        if (experimentalfactor == null) {
            experimentalfactor = new ArrayList<Experimentalfactor>();
        }
        return this.experimentalfactor;
    }

    /**
     * Gets the value of the experimenttype property.
     *
     *

     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a set method for the experimenttype property.
     *
     *

     * For example, to add a new item, do as follows:
     *

     *    getExperimenttype().add(newItem);
     *

     *
     *
     *

     * Objects of the following type(s) are allowed in the list
     * {@link String }
     *
     *
     */
    public List<String> getExperimenttype() {
        if (experimenttype == null) {
            experimenttype = new ArrayList<String>();
        }
        return this.experimenttype;
    }

    /**
     * Gets the value of the fgemdatafiles property.
     *
     * @return
     *     possible object is
     *     {@link Fgemdatafiles }
     *
     */
    public Fgemdatafiles getFgemdatafiles() {
        return fgemdatafiles;
    }

    /**
     * Sets the value of the fgemdatafiles property.
     *
     * @param value
     *     allowed object is
     *     {@link Fgemdatafiles }
     *
     */
    public void setFgemdatafiles(Fgemdatafiles value) {
        this.fgemdatafiles = value;
    }

    /**
     * Gets the value of the lastupdatedate property.
     *
     * @return
     *     possible object is
     *     {@link XMLGregorianCalendar }
     *
     */
    public XMLGregorianCalendar getLastupdatedate() {
        return lastupdatedate;
    }

    /**
     * Sets the value of the lastupdatedate property.
     *
     * @param value
     *     allowed object is
     *     {@link XMLGregorianCalendar }
     *
     */
    public void setLastupdatedate(XMLGregorianCalendar value) {
        this.lastupdatedate = value;
    }

    /**
     * Gets the value of the loaddate property.
     *
     * @return
     *     possible object is
     *     {@link XMLGregorianCalendar }
     *
     */
    public XMLGregorianCalendar getLoaddate() {
        return loaddate;
    }

    /**
     * Sets the value of the loaddate property.
     *
     * @param value
     *     allowed object is
     *     {@link XMLGregorianCalendar }
     *
     */
    public void setLoaddate(XMLGregorianCalendar value) {
        this.loaddate = value;
    }

    /**
     * Gets the value of the miamescores property.
     *
     * @return
     *     possible object is
     *     {@link Miamescores }
     *
     */
    public Miamescores getMiamescores() {
        return miamescores;
    }

    /**
     * Sets the value of the miamescores property.
     *
     * @param value
     *     allowed object is
     *     {@link Miamescores }
     *
     */
    public void setMiamescores(Miamescores value) {
        this.miamescores = value;
    }

    /**
     * Gets the value of the minseqescores property.
     *
     * @return
     *     possible object is
     *     {@link Minseqescores }
     *
     */
    public Minseqescores getMinseqescores() {
        return minseqescores;
    }

    /**
     * Sets the value of the minseqescores property.
     *
     * @param value
     *     allowed object is
     *     {@link Minseqescores }
     *
     */
    public void setMinseqescores(Minseqescores value) {
        this.minseqescores = value;
    }

    /**
     * Gets the value of the provider property.
     *
     * @return
     *     possible object is
     *     {@link Provider }
     *
     */
    public Provider getProvider() {
        return provider;
    }

    /**
     * Sets the value of the provider property.
     *
     * @param value
     *     allowed object is
     *     {@link Provider }
     *
     */
    public void setProvider(Provider value) {
        this.provider = value;
    }

    /**
     * Gets the value of the rawdatafiles property.
     *
     * @return
     *     possible object is
     *     {@link Rawdatafiles }
     *
     */
    public Rawdatafiles getRawdatafiles() {
        return rawdatafiles;
    }

    /**
     * Sets the value of the rawdatafiles property.
     *
     * @param value
     *     allowed object is
     *     {@link Rawdatafiles }
     *
     */
    public void setRawdatafiles(Rawdatafiles value) {
        this.rawdatafiles = value;
    }

    /**
     * Gets the value of the releasedate property.
     *
     * @return
     *     possible object is
     *     {@link XMLGregorianCalendar }
     *
     */
    public XMLGregorianCalendar getReleasedate() {
        return releasedate;
    }

    /**
     * Sets the value of the releasedate property.
     *
     * @param value
     *     allowed object is
     *     {@link XMLGregorianCalendar }
     *
     */
    public void setReleasedate(XMLGregorianCalendar value) {
        this.releasedate = value;
    }

    /**
     * Gets the value of the sampleattribute property.
     *
     *

     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a set method for the sampleattribute property.
     *
     *

     * For example, to add a new item, do as follows:
     *

     *    getSampleattribute().add(newItem);
     *

     *
     *
     *

     * Objects of the following type(s) are allowed in the list
     * {@link Sampleattribute }
     *
     *
     */
    public List<Sampleattribute> getSampleattribute() {
        if (sampleattribute == null) {
            sampleattribute = new ArrayList<Sampleattribute>();
        }
        return this.sampleattribute;
    }

    /**
     * Gets the value of the samples property.
     *
     *

     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a set method for the samples property.
     *
     *

     * For example, to add a new item, do as follows:
     *

     *    getSamples().add(newItem);
     *

     *
     *
     *

     * Objects of the following type(s) are allowed in the list
     * {@link BigInteger }
     *
     *
     */
    public List<BigInteger> getSamples() {
        if (samples == null) {
            samples = new ArrayList<BigInteger>();
        }
        return this.samples;
    }

    /**
     * Gets the value of the secondaryaccession property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getSecondaryaccession() {
        return secondaryaccession;
    }

    /**
     * Sets the value of the secondaryaccession property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setSecondaryaccession(String value) {
        this.secondaryaccession = value;
    }

    /**
     * Gets the value of the species property.
     *
     *

     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a set method for the species property.
     *
     *

     * For example, to add a new item, do as follows:
     *

     *    getSpecies().add(newItem);
     *

     *
     *
     *

     * Objects of the following type(s) are allowed in the list
     * {@link String }
     *
     *
     */
    public List<String> getSpecies() {
        if (species == null) {
            species = new ArrayList<String>();
        }
        return this.species;
    }

    /**
     * Gets the value of the submissiondate property.
     *
     * @return
     *     possible object is
     *     {@link XMLGregorianCalendar }
     *
     */
    public XMLGregorianCalendar getSubmissiondate() {
        return submissiondate;
    }

    /**
     * Sets the value of the submissiondate property.
     *
     * @param value
     *     allowed object is
     *     {@link XMLGregorianCalendar }
     *
     */
    public void setSubmissiondate(XMLGregorianCalendar value) {
        this.submissiondate = value;
    }

    /**
     * Gets the value of the user property.
     *
     *

     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a set method for the user property.
     *
     *

     * For example, to add a new item, do as follows:
     *

     *    getUser().add(newItem);
     *

     *
     *
     *

     * Objects of the following type(s) are allowed in the list
     * {@link User }
     *
     *
     */
    public List<User> getUser() {
        if (user == null) {
            user = new ArrayList<User>();
        }
        return this.user;
    }

    /**
     * Gets the value of the experimentdesign property.
     *
     *

     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a set method for the experimentdesign property.
     *
     *

     * For example, to add a new item, do as follows:
     *

     *    getExperimentdesign().add(newItem);
     *

     *
     *
     *

     * Objects of the following type(s) are allowed in the list
     * {@link String }
     *
     *
     */
    public List<String> getExperimentdesign() {
        if (experimentdesign == null) {
            experimentdesign = new ArrayList<String>();
        }
        return this.experimentdesign;
    }

    /**
     * Gets the value of the description property.
     *
     *

     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a set method for the description property.
     *
     *

     * For example, to add a new item, do as follows:
     *

     *    getDescription().add(newItem);
     *

     *
     *
     *

     * Objects of the following type(s) are allowed in the list
     * {@link Description }
     *
     *
     */
    public List<Description> getDescription() {
        if (description == null) {
            description = new ArrayList<Description>();
        }
        return this.description;
    }

    /**
     * Gets the value of the protocol property.
     *
     *

     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a set method for the protocol property.
     *
     *

     * For example, to add a new item, do as follows:
     *

     *    getProtocol().add(newItem);
     *

     *
     *
     *

     * Objects of the following type(s) are allowed in the list
     * {@link Protocol }
     *
     *
     */
    public List<Protocol> getProtocol() {
        if (protocol == null) {
            protocol = new ArrayList<Protocol>();
        }
        return this.protocol;
    }

    /**
     * Gets the value of the seqdatauri property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getSeqdatauri() {
        return seqdatauri;
    }

    /**
     * Sets the value of the seqdatauri property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setSeqdatauri(String value) {
        this.seqdatauri = value;
    }

    /**
     * Gets the value of the source property.
     *
     * @return
     *     possible object is
     *     {@link Source }
     *
     */
    public Source getSource() {
        return source;
    }

    /**
     * Sets the value of the source property.
     *
     * @param value
     *     allowed object is
     *     {@link Source }
     *
     */
    public void setSource(Source value) {
        this.source = value;
    }

    /**
     * Gets the value of the loadedinatlas property.
     *
     * @return
     *     possible object is
     *     {@link Boolean }
     *
     */
    public boolean isLoadedinatlas() {
        if (loadedinatlas == null) {
            return false;
        } else {
            return loadedinatlas;
        }
    }

    /**
     * Sets the value of the loadedinatlas property.
     *
     * @param value
     *     allowed object is
     *     {@link Boolean }
     *
     */
    public void setLoadedinatlas(Boolean value) {
        this.loadedinatlas = value;
    }

}


text:
<?php

namespace PHPCompiler;

use PHPUnit\Framework\TestCase;

abstract class BaseTest extends TestCase {

    protected string $BIN = '';
    protected static string $DIR = __DIR__;

    const EXPECTATIONS = [
        'EXPECT',
        'EXPECTF',
        'EXPECTREGEX',
    ];

    const EXTERNAL_SECTIONS = [
        'FILE',
        'EXPECT',
        'EXPECTF',
        'EXPECTREGEX',
    ];

    const REQUIRED_SECTIONS = [
        'FILE',
        self::EXPECTATIONS,
    ];

    const UNSUPPORTED_SECTIONS = [
        'REDIRECTTEST',
        'REQUEST',
        'POST',
        'PUT',
        'POST_RAW',
        'GZIP_POST',
        'DEFLATE_POST',
        'GET',
        'COOKIE',
        'HEADERS',
        'CGI',
        'EXPECTHEADERS',
        'EXTENSIONS',
        'PHPDBG',
    ];

    public static function providePHPTests(): \Generator {
        yield from self::providePHPTestsFromDir(static::$DIR . '/cases');
    }

    private static function providePHPTestsFromDir(string $dir): \Generator {
        foreach (new \DirectoryIterator($dir) as $path) {
            if (!$path->isDir() || $path->isDot()) {
                continue;
            }
            yield from self::providePHPTestsFromDir($path->getPathname());
        }
        foreach (new \GlobIterator($dir . '/*.phpt') as $test) {
            yield self::parsePHPT($test->getPathname(), $test->getBasename());
        }
    }

    private static function parsePHPT(string $filename, string $basename): array {
        $sections = [];
        $section = '';
        foreach (file($filename) as $line) {
            if (preg_match('(^--([_A-Z]+)--)', $line, $result)) {
                $section = $result[1];
                $sections[$section] = '';
                continue;
            }
            if (empty($section)) {
                throw new \LogicException("Invalid PHPT file: empty section header");
            }
            $sections[$section] .= $line;
        }
        if (!isset($sections['TEST'])) {
            throw new \LogicException("Every test must have a name");
        }
        if (isset($sections['FILEEOF'])) {
            $sections['FILE'] = rtrim($sections['FILEEOF'], "\r\n");
            unset($sections['FILEEOF']);
        }
        self::parseExternal($sections, dirname($filename));
        if (!self::validate($sections)) {
            throw new \LogicException("Invalid PHPT File");
        }
        foreach (self::UNSUPPORTED_SECTIONS as $section) {
            if (isset($sections[$section])) {
                throw new \LogicException("PHPT $section sections are not supported");
            }
        }
        return [
            trim($sections["TEST"]),
            $sections['FILE'],
            $sections,
        ];
    }

    private static function parseExternal(array &$sections, string $testdir): void {
        foreach (self::EXTERNAL_SECTIONS as $section) {
            if (isset($sections[$section . '_EXTERNAL'])) {
                $filename = trim($sections[$section . '_EXTERNAL']);
                if (!is_file($testdir . '/' . $filename)) {
                    throw new \RuntimeException("Could not load external file $filename");
                }
                $sections[$section] = file_get_contents($testdir . '/' . $filename);
            }
        }
    }

    private static function validate(array &$sections): bool {
        foreach (self::REQUIRED_SECTIONS as $section) {
            if (is_array($section)) {
                foreach ($section as $any) {
                    if (isset($sections[$any])) {
                        continue 2;
                    }
                }
                return false;
            } elseif (!isset($sections[$section])) {
                return false;
            }
        }
        return true;
    }

    /**
     * @dataProvider providePHPTests
     */
    public function testCases(string $name, string $code, array $sections): void {
        $PHP = escapeshellcmd(PHP_BINARY);
        $descriptorSepc = [
            0 => ['pipe', 'r'],
            1 => ['pipe', 'w'],
            2 => ['pipe', 'w'],
        ];
        $pipes = [];
        $proc = proc_open("$PHP {$this->BIN}", $descriptorSepc, $pipes);
        fwrite($pipes[0], $code);
        fclose($pipes[0]);
        $result = stream_get_contents($pipes[1]);
        fclose($pipes[1]);
        proc_close($proc);
        $this->assertExpect($result, $sections);
    }

    const ASSERTIONS = [
        'EXPECT' => 'assertEquals',
        'EXPECTF' => 'assertStringMatchesFormat',
        'EXPECTREGEX' => 'assertRegExp',
    ];

    protected function assertExpect(string $result, array $sections): void {
        $actual = $this->normalize($result);
        foreach (self::ASSERTIONS as $action => $selectedAssertion) {
            if (isset($sections[$action])) {
                $content = preg_replace('(\r\n?)', "\n", trim($sections[$action]));
                $content = $this->normalize($content);
                $expected = $action === "EXPECTREGEX" ? "/{$content}/" : $content;
                if ($expected === null) {
                    throw new \LogicException("No PHPT expectation found");
                }
                $this->$selectedAssertion($expected, $actual);
                return;
            }
        }
        throw new \RuntimeException('No PHPT assertion found');
    }

    protected function normalize(string $string): string {
        $result = preg_replace('(\r\n)', "\n", trim($string)); // get rid of \r\n
        $result = preg_replace('(^\s+)m', '', $result); // get rid of leading whitespace
        $result = preg_replace('(\s+$)m', '', $result); // get rid of trailing whitespace
        $result = preg_replace('(\n\n+)', "\n", $result); // get rid of blank lines
        return $result;
    }

}


text:
<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/cloud/retail/v2/product_service.proto

namespace Google\Cloud\Retail\V2;

use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;

/**
 * Request message for [DeleteProduct][] method.
 *
 * Generated from protobuf message google.cloud.retail.v2.DeleteProductRequest
 */
class DeleteProductRequest extends \Google\Protobuf\Internal\Message
{
    /**
     * Required. Full resource name of [Product][google.cloud.retail.v2.Product],
     * such as
     * `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`.
     * If the caller does not have permission to delete the
     * [Product][google.cloud.retail.v2.Product], regardless of whether or not it
     * exists, a PERMISSION_DENIED error is returned.
     * If the [Product][google.cloud.retail.v2.Product] to delete does not exist,
     * a NOT_FOUND error is returned.
     * The [Product][google.cloud.retail.v2.Product] to delete can neither be a
     * [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION]
     * [Product][google.cloud.retail.v2.Product] member nor a
     * [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY]
     * [Product][google.cloud.retail.v2.Product] with more than one
     * [variants][google.cloud.retail.v2.Product.Type.VARIANT]. Otherwise, an
     * INVALID_ARGUMENT error is returned.
     * All inventory information for the named
     * [Product][google.cloud.retail.v2.Product] will be deleted.
     *
     * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
     */
    private $name = '';

    /**
     * Constructor.
     *
     * @param array $data {
     *     Optional. Data for populating the Message object.
     *
     *     @type string $name
     *           Required. Full resource name of [Product][google.cloud.retail.v2.Product],
     *           such as
     *           `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`.
     *           If the caller does not have permission to delete the
     *           [Product][google.cloud.retail.v2.Product], regardless of whether or not it
     *           exists, a PERMISSION_DENIED error is returned.
     *           If the [Product][google.cloud.retail.v2.Product] to delete does not exist,
     *           a NOT_FOUND error is returned.
     *           The [Product][google.cloud.retail.v2.Product] to delete can neither be a
     *           [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION]
     *           [Product][google.cloud.retail.v2.Product] member nor a
     *           [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY]
     *           [Product][google.cloud.retail.v2.Product] with more than one
     *           [variants][google.cloud.retail.v2.Product.Type.VARIANT]. Otherwise, an
     *           INVALID_ARGUMENT error is returned.
     *           All inventory information for the named
     *           [Product][google.cloud.retail.v2.Product] will be deleted.
     * }
     */
    public function __construct($data = NULL) {
        \GPBMetadata\Google\Cloud\Retail\V2\ProductService::initOnce();
        parent::__construct($data);
    }

    /**
     * Required. Full resource name of [Product][google.cloud.retail.v2.Product],
     * such as
     * `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`.
     * If the caller does not have permission to delete the
     * [Product][google.cloud.retail.v2.Product], regardless of whether or not it
     * exists, a PERMISSION_DENIED error is returned.
     * If the [Product][google.cloud.retail.v2.Product] to delete does not exist,
     * a NOT_FOUND error is returned.
     * The [Product][google.cloud.retail.v2.Product] to delete can neither be a
     * [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION]
     * [Product][google.cloud.retail.v2.Product] member nor a
     * [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY]
     * [Product][google.cloud.retail.v2.Product] with more than one
     * [variants][google.cloud.retail.v2.Product.Type.VARIANT]. Otherwise, an
     * INVALID_ARGUMENT error is returned.
     * All inventory information for the named
     * [Product][google.cloud.retail.v2.Product] will be deleted.
     *
     * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Required. Full resource name of [Product][google.cloud.retail.v2.Product],
     * such as
     * `projects/*/locations/global/catalogs/default_catalog/branches/default_branch/products/some_product_id`.
     * If the caller does not have permission to delete the
     * [Product][google.cloud.retail.v2.Product], regardless of whether or not it
     * exists, a PERMISSION_DENIED error is returned.
     * If the [Product][google.cloud.retail.v2.Product] to delete does not exist,
     * a NOT_FOUND error is returned.
     * The [Product][google.cloud.retail.v2.Product] to delete can neither be a
     * [Product.Type.COLLECTION][google.cloud.retail.v2.Product.Type.COLLECTION]
     * [Product][google.cloud.retail.v2.Product] member nor a
     * [Product.Type.PRIMARY][google.cloud.retail.v2.Product.Type.PRIMARY]
     * [Product][google.cloud.retail.v2.Product] with more than one
     * [variants][google.cloud.retail.v2.Product.Type.VARIANT]. Otherwise, an
     * INVALID_ARGUMENT error is returned.
     * All inventory information for the named
     * [Product][google.cloud.retail.v2.Product] will be deleted.
     *
     * Generated from protobuf field string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = {
     * @param string $var
     * @return $this
     */
    public function setName($var)
    {
        GPBUtil::checkString($var, True);
        $this->name = $var;

        return $this;
    }

}


text:
package com.amazonaws.services.ram.model;

import javax.annotation.Generated;

/**
 * <p>
 * The specified resource type is not valid.
 * </p>
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class InvalidResourceTypeException extends com.amazonaws.services.ram.model.AWSRAMException {
    private static final long serialVersionUID = 1L;

    /**
     * Constructs a new InvalidResourceTypeException with the specified error message.
     *
     * @param message
     *        Describes the error encountered.
     */
    public InvalidResourceTypeException(String message) {
        super(message);
    }

}


text:
/// <reference path="../_references.ts" />

'use strict';

import gulp = require("gulp");
var sequence: Function = require("run-sequence");
import fs = require("fs");
import os = require("os");
import path = require("path");
import rename = require("gulp-rename");

var header: string = "../docs/header.md";
var changeLog: string = "../docs/changelog.md";
var dest: string = "../README.md";

gulp.task("make-readme:copy-header",() => {
    return gulp.src(path.normalize(header))
        .pipe(rename(path.basename(dest)))
        .pipe(gulp.dest(path.dirname(dest)));
});

gulp.task("make-readme:append-last-change",(cb: gulp.ITaskCallback) => {
    var log: string[] = fs.readFileSync(path.normalize(changeLog), "utf8").split(os.EOL + "-");
    fs.appendFile(path.normalize(dest), os.EOL + log[0], cb);
});

gulp.task("make-readme",(cb: gulp.ITaskCallback) => {
    sequence("make-readme:copy-header", "make-readme:append-last-change", cb);
});


text:
/**
 * @file ballbound.hpp
 *
 * Bounds that are useful for binary space partitioning trees.
 * Interface to a ball bound that works in arbitrary metric spaces.
 *
 * This file is part of mlpack 1.0.12.
 *
 * mlpack is free software; you may redstribute it and/or modify it under the
 * terms of the 3-clause BSD license.  You should have received a copy of the
 * 3-clause BSD license along with mlpack.  If not, see
 * http://www.opensource.org/licenses/BSD-3-Clause for more information.
 */

#ifndef __MY_MLPACK_CORE_TREE_BALLBOUND_HPP
#define __MY_MLPACK_CORE_TREE_BALLBOUND_HPP

#include <mips/my_mlpack/core.hpp>
#include <mips/my_mlpack/core/metrics/lmetric.hpp>

namespace mips {
namespace bound {

/**
 * Ball bound that works in the regular Euclidean metric space.
 *
 * @tparam VecType Type of vector (arma::vec or arma::spvec).
 */
template<typename VecType = arma::vec>
class BallBound
{
 public:
  typedef VecType Vec;

 private:
  double radius;
  VecType center;

 public:
  BallBound() : radius(0) { }

  /**
   * Create the ball bound with the specified dimensionality.
   *
   * @param dimension Dimensionality of ball bound.
   */
  BallBound(const size_t dimension) : radius(0), center(dimension) { }

  /**
   * Create the ball bound with the specified radius and center.
   *
   * @param radius Radius of ball bound.
   * @param center Center of ball bound.
   */
  BallBound(const double radius, const VecType& center) :
      radius(radius), center(center) { }

  //! Get the radius of the ball.
  double Radius() const { return radius; }
  //! Modify the radius of the ball.
  double& Radius() { return radius; }

  //! Get the center point of the ball.
  const VecType& Center() const { return center; }
  //! Modify the center point of the ball.
  VecType& Center() { return center; }

  // Get the range in a certain dimension.
  math::Range operator[](const size_t i) const;

  /**
   * Determines if a point is within this bound.
   */
  bool Contains(const VecType& point) const;

  /**
   * Gets the center.
   *
   * Don't really use this directly.  This is only here for consistency
   * with DHrectBound, so it can plug in more directly if a "centroid"
   * is needed.
   */
  void CalculateMidpoint(VecType& centroid) const;

  /**
   * Calculates minimum bound-to-point squared distance.
   */
  double MinDistance(const VecType& point) const;

  /**
   * Calculates minimum bound-to-bound squared distance.
   */
  double MinDistance(const BallBound& other) const;

  /**
   * Computes maximum distance.
   */
  double MaxDistance(const VecType& point) const;

  /**
   * Computes maximum distance.
   */
  double MaxDistance(const BallBound& other) const;

  /**
   * Calculates minimum and maximum bound-to-point distance.
   */
  math::Range RangeDistance(const VecType& other) const;

  /**
   * Calculates minimum and maximum bound-to-bound distance.
   *
   * Example: bound1.MinDistanceSq(other) for minimum distance.
   */
  math::Range RangeDistance(const BallBound& other) const;

  /**
   * Expand the bound to include the given node.
   */
  const BallBound& operator|=(const BallBound& other);

  /**
   * Expand the bound to include the given point.  The centroid is recalculated
   * to be the center of all of the given points.
   *
   * @tparam MatType Type of matrix; could be arma::mat, arma::spmat, or a
   *     vector.
   * @tparam data Data points to add.
   */
  template<typename MatType>
  const BallBound& operator|=(const MatType& data);

  /**
   * Returns a string representation of this object.
   */
  std::string ToString() const;

};

}; // namespace bound
}; // namespace mlpack

#include "ballbound_impl.hpp"

#endif // __MLPACK_CORE_TREE_DBALLBOUND_HPP


text:
documenteer.toml reference
##########################

Rubin's Sphinx user guide configuration with |documenteer.conf.guide| uses a :file:`documenteer.toml` file, located next to the Sphinx :file:`conf.py` file to configure metadata about the project.
This page describes the schema for this :file:`documenteer.toml` file.
For a step-by-step guide, see :doc:`configuration`.

[project] table
===============

The ``[project]`` table is where most of the project's metadata is set.

|required|

title
-----

|required|

Name of the project, used as titles throughout the documentation site.
The title can be different from the package name, if that's the local standard.

.. code-block:: toml

   [project]
   title = "Documenteer"

.. _guide-project-base-url:

base\_url
---------

|optional| |py-auto|

The root URL of the documentation project, used to set the `canonical URL link rel <https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel#attr-canonical>`__, which is valuable for search engines.

.. code-block:: toml

   [project]
   base_url = "https://documenteer.lsst.io"

copyright
---------

|optional|

The copyright statement, which should exclude the "Copyright" prefix.

.. code-block:: toml

   [project]
   copyright = "2015-2022 Association of Universities for Research in Astronomy, Inc. (AURA)"

.. _guide-project-github-url:

github\_url
-----------

|optional| |py-auto|

The URL for the project's GitHub source repository.
When set, a link to the repository is included in the site's header.

.. code-block:: toml

   [project]
   github_url = "https://github.com/lsst-sqre/documenteer"

.. _guide-project-github-default-branch:

github_default_branch
---------------------

|optional|

The default branch on GitHub.
Default is ``main``.
Used in conjunction with the "Edit on GitHub" link, see :ref:`sphinx.show_github_edit_link <guide-project-show-github-edit-link>`.

.. _guide-project-version:

version
-------

|optional| |py-auto|

The project's version, which is set to the standard Sphinx ``version`` and ``release`` configuration variables.

[project.python]
================

|optional|

Projects that use a :file:`pyproject.toml` to set their build metadata can include a ``[project.python]`` table in :file:`documenteer.toml`.
With this, many metadata values are automatically detected — look for |py-auto| badges above.

.. note::

   If a value is directly set, such as :ref:`guide-project-version`, that value will override will override information discovered from the Python project itself.

.. seealso::

   :doc:`pyproject-configuration`

package
-------

|required|

This is the Python project's name, as set in the ``name`` field of the ``[project]`` table in :file:`pyproject.toml`.
*Note that the package name can be different from the Python module name.*
Setting this field actives automatic metadata discovery for Python projects.

.. code-block:: toml

   [project]

   [project.python]
   package = "documenteer"

documentation\_url\_key
-----------------------

|optional|

By default the :ref:`guide-project-base-url` is detected from the ``Homepage`` field in the ``[project.urls]`` table of :file:`pyproject.toml`.
If your documentation's URL is associated with a different field label, set that with ``documentation_url_key``.

github\_url\_key
----------------

|optional|

By default the :ref:`guide-project-github-url` is detected from the ``Source`` field in the ``[project.urls]`` table of :file:`pyproject.toml`.
If your GitHub repository's URL is associated with a different field label, set that with ``github_url_key``.

[sphinx]
========

|optional|

This ``[sphinx]`` table allows you to set a number of Sphinx configurations that you would normally set through the :file:`conf.py` file.

disable_primary_sidebars
------------------------

|optional|

On some pages the default sidebar (on the left) is inappropriate, such as index pages that already contain a table of contents as their main content.
In that case, you can set individual pages or globs (without extensions) of pages that are shown without
the primary sidebar.
The default is ``["index"]`` to remove the sidebar from the homepage.

.. code-block:: toml

   [sphinx]
   disable_primary_sidebars = [
     "**/index",
     "changelog"
   ]

.. note::

   This configuration is for the **primary** sidebar, on the left side, containing side or section-level navigation links.
   To remove the page-level contents sidebar, on the right side, add ``:html_theme.sidebar_secondary.remove:`` to the *page's* file metadata.

extensions
----------

|optional|

A list of Sphinx extensions to append to the extensions included in the Documenteer configuration preset (see |documenteer.conf.guide|).
Duplicate extensions are ignored.

Remember that additional packages may need to be added to your project's Python dependencies (such as in a ``requirements.txt`` or ``pyproject.toml`` file).

nitpicky
--------

|optional|

Set to ``true`` to escalate Sphinx warnings to errors, which is useful for leveraging CI to notify you of any syntax errors.
The default is ``false``.

.. code-block:: toml

   [sphinx]
   nitpicky = true

See ``nitpick_ignore`` and ``nitpick_ignore_regex`` for ways to suppress unavoidable errors.

nitpick_ignore
--------------

|optional|

A list of Sphinx warnings to ignore.
Each item is a tuple of two items:

1. ``type``, often the reStructuredText role or directive creating the error/warning.
2. ``target``, often the argument to the reStructuredText role.

.. code-block:: toml

   [sphinx]
   nitpick_ignore = [
     ["py:class", "fastapi.applications.FastAPI"],
     ["py:class", "httpx.AsyncClient"],
     ["py:class", "pydantic.main.BaseModel"],
   ]

This configuration extends the Sphinx ``nitpick_ignore`` configuration.

nitpick_ignore_regex
--------------------

|optional|

A list of Sphinx warnings to ignore, formatted as regular expressions.
Each item is a tuple of two items:

1. ``type``, a regular expression of the warning type.
2. ``target``, a regular expression of the warning target.

.. code-block:: toml

   [sphinx]
   nitpick_ignore_regex = [
     ['py:.*', 'fastapi.*'],
     ['py:.*', 'httpx.*'],
     ['py:.*', 'pydantic*'],
   ]

.. tip::

   Use single quotes for literal strings in TOML.

This configuration extends the Sphinx ``nitpick_ignore_regex`` configuration.

.. _guide-project-rst-epilog-file:

rst_epilog_file
---------------

|optional|

Set this as a path to a reStructuredText file (relative to :file:`documenteer.toml` and :file:`conf.py`) containing substitutions and link targets that are available to all documentation pages.
This configuration sets Sphinx's ``rst_epilog`` configuration.
If set, the file is also included in the Sphinx source ignore list to prevent it from becoming a standalone page.

.. code-block:: toml
   :caption: documenteer.toml

    [sphinx]
    rst_epilog_file = "_rst_epilog.rst"

.. code-block:: rst
   :caption: _rst_epilog.rst

   .. _Astropy Project: https://www.astropy.org

   .. |required| replace:: :bdg-primary-line:`Required`
   .. |optional| replace:: :bdg-secondary-line:`Optional`

See :doc:`rst-epilog`.

python_api_dir
--------------

|optional|

Set this to the directory where Python API documentation is generated, through automodapi_.
The default value is ``api``, which is a good standard for Python projects with a public API.

If the Python API is oriented towards contributors, such as in an application or service, you can change the default:

.. code-block:: toml

   [sphinx]
   python_api_dir = "dev/api/contents"

[sphinx.theme]
==============

|optional|

Configurations related to the Sphinx HTML theme.

.. _guide-project-header-links-before-dropdown:

header_links_before_dropdown
----------------------------

|optional|

Number of links to show in the navigation head before folding extra items into a "More" dropdown.
The default is 5.

If the section titles are long you may need to reduce this number.

.. _guide-project-show-github-edit-link:

show_github_edit_link
---------------------

|optional|

Default is ``true``, so that each page contains a link to edit its source on GitHub.

This configuration requires information about the GitHub repository from these other configurations:

- :ref:`project.github_url <guide-project-github-url>`
- :ref:`project.github_default_branch <guide-project-github-default-branch>`

[sphinx.intersphinx]
====================

|optional|

Configurations related to Intersphinx_ for linking to other Sphinx projects.

[sphinx.intersphinx.projects]
=============================

|optional|

A table of Sphinx projects.
The labels are targets for the :external+sphinx:rst:role:`external` role.
The values are URLs to the root of Sphinx documentation projects.

.. code-block:: toml

   [sphinx.intersphinx.projects]
   sphinx = "https://www.sphinx-doc.org/en/master/"
   documenteer = "https://documenteer.lsst.io"
   python = "https://docs.python.org/3/"

See the Intersphinx_ documentation for details on linking to other Sphinx projects.

[sphinx.linkcheck]
==================

|optional|

Configurations related to Sphinx's linkcheck_ builder.

ignore
------

|optional|

List of URL regular expressions patterns to ignore checking.
These are appended to the ``linkcheck_ignore`` configuration.


text:
package org.apache.beam.sdk.extensions.protobuf;

import static org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkArgument;

import com.google.protobuf.Descriptors;
import com.google.protobuf.Descriptors.EnumValueDescriptor;
import com.google.protobuf.Descriptors.FieldDescriptor;
import com.google.protobuf.Descriptors.OneofDescriptor;
import com.google.protobuf.Message;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.beam.sdk.extensions.protobuf.ProtoSchemaLogicalTypes.Fixed32;
import org.apache.beam.sdk.extensions.protobuf.ProtoSchemaLogicalTypes.Fixed64;
import org.apache.beam.sdk.extensions.protobuf.ProtoSchemaLogicalTypes.SFixed32;
import org.apache.beam.sdk.extensions.protobuf.ProtoSchemaLogicalTypes.SFixed64;
import org.apache.beam.sdk.extensions.protobuf.ProtoSchemaLogicalTypes.SInt32;
import org.apache.beam.sdk.extensions.protobuf.ProtoSchemaLogicalTypes.SInt64;
import org.apache.beam.sdk.extensions.protobuf.ProtoSchemaLogicalTypes.UInt32;
import org.apache.beam.sdk.extensions.protobuf.ProtoSchemaLogicalTypes.UInt64;
import org.apache.beam.sdk.schemas.Schema;
import org.apache.beam.sdk.schemas.Schema.Field;
import org.apache.beam.sdk.schemas.Schema.FieldType;
import org.apache.beam.sdk.schemas.logicaltypes.EnumerationType;
import org.apache.beam.sdk.schemas.logicaltypes.NanosDuration;
import org.apache.beam.sdk.schemas.logicaltypes.NanosInstant;
import org.apache.beam.sdk.schemas.logicaltypes.OneOfType;
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.Lists;
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.Maps;
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.Sets;

/**
 * This class provides utilities for inferring a Beam schema from a protocol buffer.
 *
 *
The following proto primitive types map to the following Beam types:
 *
 *

 *
INT32 maps to FieldType.INT32
 *
INT64 maps to FieldType.INT64
 *
FLOAT maps to FieldType.FLOAT
 *
DOUBLE maps to FieldType.DOUBLE
 *
BOOL maps to FieldType.BOOLEAN
 *
STRING maps to FieldType.STRING
 *
BYTES maps to FieldType.BYTES
 *

 *
 *
The following proto numeric types do not have have native Beam primitive types. LogicalType
 * objects were created to represent these types. Normal numeric types are used as the base type of
 * each of these logical types, so SQL queries should work as normal.
 *
 *

 *
UINT32 maps to FieldType.logicalType(new ProtoSchemaLogicalTypes.UInt32()))
 *
SINT32 maps to FieldType.logicalType(new ProtoSchemaLogicalTypes.SInt32()))
 *
FIXED32 maps to FieldType.logicalType(new ProtoSchemaLogicalTypes.Fixed32()))
 *
SFIXED32 maps to FieldType.logicalType(new ProtoSchemaLogicalTypes.SFixed32()))
 *
UINT64 maps to FieldType.logicalType(new ProtoSchemaLogicalTypes.UInt64()))
 *
SINT64 maps to FieldType.logicalType(new ProtoSchemaLogicalTypes.SInt64()))
 *
FIXED64 maps to FieldType.logicalType(new ProtoSchemaLogicalTypes.Fixed64()))
 *
SFIXED64 maps to FieldType.logicalType(new ProtoSchemaLogicalTypes.SFixed64()))
 *

 *
 *
Protobuf maps are mapped to Beam FieldType.MAP types. Protobuf repeated fields are mapped to
 * Beam FieldType.ARRAY types.
 *
 *
Beam schemas include the EnumerationType logical type to represent enumerations, and protobuf
 * enumerations are translated to this logical type. The base representation type for this logical
 * type is an INT32.
 *
 *
Beam schemas include the OneOfType logical type to represent unions, and protobuf oneOfs are
 * translated to this logical type. The base representation type for this logical type is a subrow
 * containing an optional field for each oneof option.
 *
 *
google.com.protobuf.Timestamp messages cannot be translated to FieldType.DATETIME types, as
 * the proto type represents nanonseconds and Beam's native type does not currently support that. a
 * new TimestampNanos logical type has been introduced to allow representing nanosecond timestamp,
 * as well as a DurationNanos logical type to represent google.com.protobuf.Duration types.
 *
 *
As primitive types are mapped to a not nullable scalar type their nullable counter
 * parts "wrapper classes" are translated to nullable types, as follows.
 *
 *

 *
google.protobuf.Int32Value maps to a nullable FieldType.INT32
 *
google.protobuf.Int64Value maps to a nullable FieldType.INT64
 *
google.protobuf.UInt32Value maps to a nullable FieldType.logicalType(new UInt32())
 *
google.protobuf.UInt64Value maps to a nullable Field.logicalType(new UInt64())
 *
google.protobuf.FloatValue maps to a nullable FieldType.FLOAT
 *
google.protobuf.DoubleValue maps to a nullable FieldType.DOUBLE
 *
google.protobuf.BoolValue maps to a nullable FieldType.BOOLEAN
 *
google.protobuf.StringValue maps to a nullable FieldType.STRING
 *
google.protobuf.BytesValue maps to a nullable FieldType.BYTES
 *

 *
 *
All message in Protobuf are translated to a nullable Row, except for the well known types
 * listed above. The rest of the nullable rules are as follows.
 *
 *

 *
Proto3 primitive types are not nullable
 *
Proto2 required types are not nullable
 *
Proto2 optional are not nullable as having an optional value doesn't mean it has not
 *       value. The spec states it has the optional value.
 *
Arrays are not nullable, as proto arrays always have an empty array when no value is
 *       set.
 *
Maps are not nullable, as proto maps always have an empty map when no value is set
 *
Elements in an array are not nullable, as nulls are not allowed in an array
 *
Names and Values are not nullable, as nulls are not allowed. Rows are nullable, as
 *       messages are nullable.
 *
Messages, as well as Well Known Types are nullable, unless using proto2 and the required
 *       label is specified.
 *

 */
@SuppressWarnings({
  "rawtypes" // TODO(https://issues.apache.org/jira/browse/BEAM-10556)
})
class ProtoSchemaTranslator {
  public static final String SCHEMA_OPTION_META_NUMBER = "beam:option:proto:meta:number";

  public static final String SCHEMA_OPTION_META_TYPE_NAME = "beam:option:proto:meta:type_name";

  /** Option prefix for options on messages. */
  public static final String SCHEMA_OPTION_MESSAGE_PREFIX = "beam:option:proto:message:";

  /** Option prefix for options on fields. */
  public static final String SCHEMA_OPTION_FIELD_PREFIX = "beam:option:proto:field:";

  /** Attach a proto field number to a type. */
  static Field withFieldNumber(Field field, int number) {
    return field.withOptions(
        Schema.Options.builder().setOption(SCHEMA_OPTION_META_NUMBER, FieldType.INT32, number));
  }

  /** Return the proto field number for a type. */
  static int getFieldNumber(Field field) {
    return field.getOptions().getValue(SCHEMA_OPTION_META_NUMBER);
  }

  /** Return a Beam scheam representing a proto class. */
  static Schema getSchema(Class<? extends Message> clazz) {
    return getSchema(ProtobufUtil.getDescriptorForClass(clazz));
  }

  static Schema getSchema(Descriptors.Descriptor descriptor) {
    /* OneOfComponentFields refers to the field number in the protobuf where the component subfields
     * are. This is needed to prevent double inclusion of the component fields.*/
    Set<Integer> oneOfComponentFields = Sets.newHashSet();
    /* OneOfFieldLocation stores the field number of the first field in the OneOf. Using this, we can use the location
    of the first field in the OneOf as the location of the entire OneOf.*/
    Map<Integer, Field> oneOfFieldLocation = Maps.newHashMap();
    List<Field> fields = Lists.newArrayListWithCapacity(descriptor.getFields().size());
    for (OneofDescriptor oneofDescriptor : descriptor.getOneofs()) {
      List<Field> subFields = Lists.newArrayListWithCapacity(oneofDescriptor.getFieldCount());
      Map<String, Integer> enumIds = Maps.newHashMap();
      for (FieldDescriptor fieldDescriptor : oneofDescriptor.getFields()) {
        oneOfComponentFields.add(fieldDescriptor.getNumber());
        // Store proto field number in a field option.
        FieldType fieldType = beamFieldTypeFromProtoField(fieldDescriptor);
        subFields.add(
            withFieldNumber(
                Field.nullable(fieldDescriptor.getName(), fieldType), fieldDescriptor.getNumber()));
        checkArgument(
            enumIds.putIfAbsent(fieldDescriptor.getName(), fieldDescriptor.getNumber()) == null);
      }
      FieldType oneOfType = FieldType.logicalType(OneOfType.create(subFields, enumIds));
      oneOfFieldLocation.put(
          oneofDescriptor.getFields().get(0).getNumber(),
          Field.of(oneofDescriptor.getName(), oneOfType));
    }

    for (Descriptors.FieldDescriptor fieldDescriptor : descriptor.getFields()) {
      int fieldDescriptorNumber = fieldDescriptor.getNumber();
      if (!oneOfComponentFields.contains(fieldDescriptorNumber)) {
        // Store proto field number in metadata.
        FieldType fieldType = beamFieldTypeFromProtoField(fieldDescriptor);
        fields.add(
            withFieldNumber(Field.of(fieldDescriptor.getName(), fieldType), fieldDescriptorNumber)
                .withOptions(getFieldOptions(fieldDescriptor)));
        /* Note that descriptor.getFields() returns an iterator in the order of the fields in the .proto file, not
         * in field number order. Therefore we can safely insert the OneOfField at the field of its first component.*/
      } else {
        Field oneOfField = oneOfFieldLocation.get(fieldDescriptorNumber);
        if (oneOfField != null) {
          fields.add(oneOfField);
        }
      }
    }
    return Schema.builder()
        .addFields(fields)
        .setOptions(
            getSchemaOptions(descriptor)
                .setOption(
                    SCHEMA_OPTION_META_TYPE_NAME, FieldType.STRING, descriptor.getFullName()))
        .build();
  }

  private static FieldType beamFieldTypeFromProtoField(
      Descriptors.FieldDescriptor protoFieldDescriptor) {
    FieldType fieldType = null;
    if (protoFieldDescriptor.isMapField()) {
      FieldDescriptor keyFieldDescriptor =
          protoFieldDescriptor.getMessageType().findFieldByName("key");
      FieldDescriptor valueFieldDescriptor =
          protoFieldDescriptor.getMessageType().findFieldByName("value");
      fieldType =
          FieldType.map(
              beamFieldTypeFromProtoField(keyFieldDescriptor).withNullable(false),
              beamFieldTypeFromProtoField(valueFieldDescriptor).withNullable(false));
    } else if (protoFieldDescriptor.isRepeated()) {
      fieldType =
          FieldType.array(
              beamFieldTypeFromSingularProtoField(protoFieldDescriptor).withNullable(false));
    } else {
      fieldType = beamFieldTypeFromSingularProtoField(protoFieldDescriptor);
    }
    return fieldType;
  }

  private static FieldType beamFieldTypeFromSingularProtoField(
      Descriptors.FieldDescriptor protoFieldDescriptor) {
    Descriptors.FieldDescriptor.Type fieldDescriptor = protoFieldDescriptor.getType();
    FieldType fieldType;
    switch (fieldDescriptor) {
      case INT32:
        fieldType = FieldType.INT32;
        break;
      case INT64:
        fieldType = FieldType.INT64;
        break;
      case FLOAT:
        fieldType = FieldType.FLOAT;
        break;
      case DOUBLE:
        fieldType = FieldType.DOUBLE;
        break;
      case BOOL:
        fieldType = FieldType.BOOLEAN;
        break;
      case STRING:
        fieldType = FieldType.STRING;
        break;
      case BYTES:
        fieldType = FieldType.BYTES;
        break;
      case UINT32:
        fieldType = FieldType.logicalType(new UInt32());
        break;
      case SINT32:
        fieldType = FieldType.logicalType(new SInt32());
        break;
      case FIXED32:
        fieldType = FieldType.logicalType(new Fixed32());
        break;
      case SFIXED32:
        fieldType = FieldType.logicalType(new SFixed32());
        break;
      case UINT64:
        fieldType = FieldType.logicalType(new UInt64());
        break;
      case SINT64:
        fieldType = FieldType.logicalType(new SInt64());
        break;
      case FIXED64:
        fieldType = FieldType.logicalType(new Fixed64());
        break;
      case SFIXED64:
        fieldType = FieldType.logicalType(new SFixed64());
        break;

      case ENUM:
        Map<String, Integer> enumValues = Maps.newHashMap();
        for (EnumValueDescriptor enumValue : protoFieldDescriptor.getEnumType().getValues()) {
          if (enumValues.putIfAbsent(enumValue.getName(), enumValue.getNumber()) != null) {
            throw new RuntimeException("Aliased enumerations not currently supported.");
          }
        }
        fieldType = FieldType.logicalType(EnumerationType.create(enumValues));
        break;
      case MESSAGE:
      case GROUP:
        String fullName = protoFieldDescriptor.getMessageType().getFullName();
        switch (fullName) {
          case "google.protobuf.Timestamp":
            fieldType = FieldType.logicalType(new NanosInstant());
            break;
          case "google.protobuf.Int32Value":
          case "google.protobuf.UInt32Value":
          case "google.protobuf.Int64Value":
          case "google.protobuf.UInt64Value":
          case "google.protobuf.FloatValue":
          case "google.protobuf.DoubleValue":
          case "google.protobuf.StringValue":
          case "google.protobuf.BoolValue":
          case "google.protobuf.BytesValue":
            fieldType =
                beamFieldTypeFromSingularProtoField(
                    protoFieldDescriptor.getMessageType().findFieldByNumber(1));
            break;
          case "google.protobuf.Duration":
            fieldType = FieldType.logicalType(new NanosDuration());
            break;
          case "google.protobuf.Any":
            throw new RuntimeException("Any not yet supported");
          default:
            fieldType = FieldType.row(getSchema(protoFieldDescriptor.getMessageType()));
        }
        // all messages are nullable in Proto
        if (protoFieldDescriptor.isOptional()) {
          fieldType = fieldType.withNullable(true);
        }
        break;
      default:
        throw new RuntimeException("Field type not matched.");
    }
    return fieldType;
  }

  private static Schema.Options.Builder getFieldOptions(FieldDescriptor fieldDescriptor) {
    return getOptions(SCHEMA_OPTION_FIELD_PREFIX, fieldDescriptor.getOptions().getAllFields());
  }

  private static Schema.Options.Builder getSchemaOptions(Descriptors.Descriptor descriptor) {
    return getOptions(SCHEMA_OPTION_MESSAGE_PREFIX, descriptor.getOptions().getAllFields());
  }

  private static Schema.Options.Builder getOptions(
      String prefix, Map<FieldDescriptor, Object> allFields) {
    Schema.Options.Builder optionsBuilder = Schema.Options.builder();
    for (Map.Entry<FieldDescriptor, Object> entry : allFields.entrySet()) {
      FieldDescriptor fieldDescriptor = entry.getKey();
      FieldType fieldType = beamFieldTypeFromProtoField(fieldDescriptor);

      switch (fieldType.getTypeName()) {
        case BYTE:
        case BYTES:
        case INT16:
        case INT32:
        case INT64:
        case DECIMAL:
        case FLOAT:
        case DOUBLE:
        case STRING:
        case BOOLEAN:
        case LOGICAL_TYPE:
        case ROW:
        case ARRAY:
        case ITERABLE:
          Field field = Field.of("OPTION", fieldType);
          ProtoDynamicMessageSchema schema = ProtoDynamicMessageSchema.forSchema(Schema.of(field));
          optionsBuilder.setOption(
              prefix + fieldDescriptor.getFullName(),
              fieldType,
              schema.createConverter(field).convertFromProtoValue(entry.getValue()));
          break;
        case MAP:
        case DATETIME:
        default:
          throw new IllegalStateException("These datatypes are not possible in extentions.");
      }
    }
    return optionsBuilder;
  }
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Untaint strings</title>

taint

Other Services

Taint Functions

PHP Manual

untaint

(PECL taint >=0.1.0)

untaint — Untaint strings

Description

   bool untaint
    ( string &$string
   [, string $...
  ] )

    Untaint strings

Parameters

string

...

Return Values

taint

Other Services

Taint Functions

PHP Manual


text:
"""
Unit tests for ./yaml_parse.py
"""

import os
import numpy as np
import cPickle
import tempfile
from numpy.testing import assert_
from pylearn2.config.yaml_parse import load, load_path, initialize
from os import environ, close
from decimal import Decimal
from tempfile import mkstemp
from pylearn2.utils import serial
from pylearn2.utils.exc import reraise_as
import yaml

def test_load_path():
    fd, fname = tempfile.mkstemp()
    with os.fdopen(fd, 'wb') as f:
        f.write("a: 23")
    loaded = load_path(fname)
    assert_(loaded['a'] == 23)
    os.remove(fname)

def test_obj():
    loaded = load("a: !obj:decimal.Decimal { value : '1.23' }")
    assert_(isinstance(loaded['a'], Decimal))

def test_floats():
    loaded = load("a: { a: -1.23, b: 1.23e-1 }")
    assert_(isinstance(loaded['a']['a'], float))
    assert_(isinstance(loaded['a']['b'], float))
    assert_((loaded['a']['a'] + 1.23) < 1e-3)
    assert_((loaded['a']['b'] - 1.23e-1) < 1e-3)

def test_import():
    loaded = load("a: !import 'decimal.Decimal'")
    assert_(loaded['a'] == Decimal)

def test_import_string():
    loaded = load("a: !import decimal.Decimal")
    assert_(loaded['a'] == Decimal)

def test_import_colon():
    loaded = load("a: !import:decimal.Decimal")
    assert_(loaded['a'] == Decimal)

def test_preproc_rhs():
    environ['TEST_VAR'] = '10'
    loaded = load('a: "${TEST_VAR}"')
    print "loaded['a'] is %s" % loaded['a']
    assert_(loaded['a'] == "10")
    del environ['TEST_VAR']

def test_preproc_pkl():
    fd, fname = tempfile.mkstemp()
    with os.fdopen(fd, 'wb') as f:
        d = ('a', 1)
        cPickle.dump(d, f)
    environ['TEST_VAR'] = fname
    loaded = load('a: !pkl: "${TEST_VAR}"')
    assert_(loaded['a'] == d)
    del environ['TEST_VAR']

def test_late_preproc_pkl():
    fd, fname = tempfile.mkstemp()
    with os.fdopen(fd, 'wb') as f:
        array = np.arange(10)
        np.save(f, array)
    environ['TEST_VAR'] = fname
    loaded = load('a: !obj:pylearn2.datasets.npy_npz.NpyDataset '
                  '{ file: "${TEST_VAR}"}\n')
    # Assert the unsubstituted TEST_VAR is in yaml_src
    assert_(loaded['a'].yaml_src.find("${TEST_VAR}") != -1)
    del environ['TEST_VAR']

def test_unpickle():
    fd, fname = tempfile.mkstemp()
    with os.fdopen(fd, 'wb') as f:
        d = {'a': 1, 'b': 2}
        cPickle.dump(d, f)
    loaded = load("{'a': !pkl: '%s'}" % fname)
    assert_(loaded['a'] == d)
    os.remove(fname)

def test_unpickle_key():
    fd, fname = tempfile.mkstemp()
    with os.fdopen(fd, 'wb') as f:
        d = ('a', 1)
        cPickle.dump(d, f)
    loaded = load("{!pkl: '%s': 50}" % fname)
    assert_(loaded.keys()[0] == d)
    assert_(loaded.values()[0] == 50)
    os.remove(fname)

def test_multi_constructor_obj():
    """
    Tests whether multi_constructor_obj throws an exception when
    the keys in mapping are None.
    """
    try:
        load("a: !obj:decimal.Decimal { 1 }")
    except TypeError as e:
        assert str(e) == "Received non string object (1) as key in mapping."
        pass
    except Exception, e:
        error_msg = "Got the unexpected error: %s" % (e)
        reraise_as(ValueError(error_msg))

def test_duplicate_keywords():
    """
    Tests whether there are doublicate keywords in the yaml
    """
    initialize()
    yamlfile = """{
            "model": !obj:pylearn2.models.mlp.MLP {
            "layers": [
                     !obj:pylearn2.models.mlp.Sigmoid {
                         "layer_name": 'h0',
                         "dim": 20,
                         "sparse_init": 15,
                     }],
            "nvis": 784,
            "nvis": 384,
        }
    }"""

    try:
        load(yamlfile)
    except yaml.constructor.ConstructorError, e:
        message = str(e)
        assert message.endswith("found duplicate key (nvis)")
        pass
    except Exception, e:
        error_msg = "Got the unexpected error: %s" % (e)
        raise TypeError(error_msg)

def test_duplicate_keywords_2():
    """
    Tests whether duplicate keywords as independent parameters works fine.
    """
    initialize()
    yamlfile = """{
             "model": !obj:pylearn2.models.rbm.GaussianBinaryRBM {

                 "vis_space" : &vis_space !obj:pylearn2.space.Conv2DSpace {
                    "shape" : [32,32],
                    "num_channels" : 3
                },
                "hid_space" : &hid_space !obj:pylearn2.space.Conv2DSpace {
                    "shape" : [27,27],
                    "num_channels" : 10
                },
                "transformer" :
                        !obj:pylearn2.linear.conv2d.make_random_conv2D {
                    "irange" : .05,
                    "input_space" : *vis_space,
                    "output_space" : *hid_space,
                    "kernel_shape" : [6,6],
                    "batch_size" : &batch_size 5
                },
                "energy_function_class" :
                     !obj:pylearn2.energy_functions.rbm_energy.grbm_type_1 {},
                "learn_sigma" : True,
                "init_sigma" : .3333,
                "init_bias_hid" : -2.,
                "mean_vis" : False,
                "sigma_lr_scale" : 1e-3

             }
    }"""

    load(yamlfile)

def test_parse_null_as_none():
    """
    Tests whether None may be passed via yaml kwarg null.
    """
    initialize()
    yamlfile = """{
             "model": !obj:pylearn2.models.autoencoder.Autoencoder {

                 "nvis" : 1024,
                 "nhid" : 64,
                 "act_enc" : Null,
                 "act_dec" : null

             }
    }"""
    load(yamlfile)

class DumDum(object):
    pass

def test_pkl_yaml_src_field():
    """
    Tests a regression where yaml_src wasn't getting correctly set on pkls.
    """
    try:
        fd, fn = mkstemp()
        close(fd)
        o = DumDum()
        o.x = ('a', 'b', 'c')
        serial.save(fn, o)
        yaml = '!pkl: \'' + fn + '\'\n'
        loaded = load(yaml)
        assert loaded.x == ('a', 'b', 'c')
        assert loaded.yaml_src == yaml
    finally:
        os.remove(fn)

def test_instantiate_regression():
    """
    Test a case where instantiated objects were not getting correctly
    reused across references.
    """
    yaml = ("{'a': &test !obj:pylearn2.config.tests.test_yaml_parse.DumDum {},"
            " 'b': *test}")
    obj = load(yaml)
    assert obj['a'] is obj['b']

if __name__ == "__main__":
    test_multi_constructor_obj()
    test_duplicate_keywords()
    test_duplicate_keywords_2()
    test_unpickle_key()


text:
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TRL.Common.Models;
using TRL.Common.Data;
using TRL.Configuration;

namespace TRL.Common.Test.Configuration
{
    [TestClass]
    public class ArbitrageLegSettingsFactoryTests
    {
        [TestMethod]
        public void Configuration_ArbitrageLegFactory_test()
        {
            string prefix = "SSTR_LeftLeg";
            IGenericFactory<IEnumerable<StrategyHeader>> factory =
                new ArbitrageLegSettingsFactory(prefix);

            IEnumerable<StrategyHeader> leftLeg = factory.Make();

            Assert.AreEqual(3, leftLeg.Count());
            Assert.AreEqual(81, leftLeg.ElementAt(0).Id);
            Assert.AreEqual(82, leftLeg.ElementAt(1).Id);
            Assert.AreEqual(83, leftLeg.ElementAt(2).Id);
            Assert.AreEqual("BP12345-RF-01", leftLeg.ElementAt(0).Portfolio);
            Assert.AreEqual("BP12345-RF-01", leftLeg.ElementAt(1).Portfolio);
            Assert.AreEqual("BP12345-RF-01", leftLeg.ElementAt(2).Portfolio);
            Assert.AreEqual("RTS-12.13_FT", leftLeg.ElementAt(0).Symbol);
            Assert.AreEqual("MIX-12.13_FT", leftLeg.ElementAt(1).Symbol);
            Assert.AreEqual("GOLD-12.13_FT", leftLeg.ElementAt(2).Symbol);
            Assert.AreEqual("Arbitrage spread left leg", leftLeg.ElementAt(0).Description);
            Assert.AreEqual("Arbitrage spread left leg", leftLeg.ElementAt(1).Description);
            Assert.AreEqual("Arbitrage spread left leg", leftLeg.ElementAt(2).Description);
            Assert.AreEqual(5, leftLeg.ElementAt(0).Amount);
            Assert.AreEqual(3, leftLeg.ElementAt(1).Amount);
            Assert.AreEqual(8, leftLeg.ElementAt(2).Amount);
        }

        [TestMethod]
        public void Configuration_ArbitrageLegFactory_three_portfolios_test()
        {
            string prefix = "SSTR_RightLeg";
            IGenericFactory<IEnumerable<StrategyHeader>> factory =
                new ArbitrageLegSettingsFactory(prefix);

            IEnumerable<StrategyHeader> leftLeg = factory.Make();

            Assert.AreEqual(3, leftLeg.Count());
            Assert.AreEqual(91, leftLeg.ElementAt(0).Id);
            Assert.AreEqual(92, leftLeg.ElementAt(1).Id);
            Assert.AreEqual(93, leftLeg.ElementAt(2).Id);
            Assert.AreEqual("BP12345-RF-01", leftLeg.ElementAt(0).Portfolio);
            Assert.AreEqual("BP12345-RF-02", leftLeg.ElementAt(1).Portfolio);
            Assert.AreEqual("BP12345-RF-03", leftLeg.ElementAt(2).Portfolio);
            Assert.AreEqual("Si-12.13_FT", leftLeg.ElementAt(0).Symbol);
            Assert.AreEqual("Eu-12.13_FT", leftLeg.ElementAt(1).Symbol);
            Assert.AreEqual("VTBR-12.13_FT", leftLeg.ElementAt(2).Symbol);
            Assert.AreEqual("Arbitrage spread right leg", leftLeg.ElementAt(0).Description);
            Assert.AreEqual("Arbitrage spread right leg", leftLeg.ElementAt(1).Description);
            Assert.AreEqual("Arbitrage spread right leg", leftLeg.ElementAt(2).Description);
            Assert.AreEqual(25, leftLeg.ElementAt(0).Amount);
            Assert.AreEqual(20, leftLeg.ElementAt(1).Amount);
            Assert.AreEqual(50, leftLeg.ElementAt(2).Amount);
        }

        [TestMethod]
        public void Configuration_ArbitrageLegFactory_returns_empty_collection_for_nonexistent_prefix_test()
        {
            string prefix = "SSTB_RightLeg";
            IGenericFactory<IEnumerable<StrategyHeader>> factory =
                new ArbitrageLegSettingsFactory(prefix);

            IEnumerable<StrategyHeader> leftLeg = factory.Make();

            Assert.AreEqual(0, leftLeg.Count());
        }
    }
}


text:
INSERT INTO
  albums (title, artist)
VALUES
  ('Malibu', 'Anderson .Paak'),
  ('A Seat at the Table', 'Solange Knowles'),
  ('Melodrama', 'Lorde'),
  ('In Rainbows', 'Radiohead')
;

INSERT INTO
  users (name, email, password)
VALUES
  ('Arya Stark', 'NoOne@ravens.com', 'needle'),
  ('Jon Snow', 'KingOfTheNorth@ravens.com', 'ghost'),
  ('Daenerys Targaryen', 'Khaleesi@ravens.com', 'dragons')
  ;

  INSERT INTO
  reviews (content, user_id, album_id)
VALUES
  ('I liked it, good album.', 1, 1),
  ('It was ok', 1, 2),
  ('Reminds me of my youth.', 1, 3),
  ('It was terrible. ''nuff said.', 2, 1)
  ;


text:
#ifndef DEVTOOLS_CDBG_DEBUGLETS_JAVA_JNI_USER_ID_PROVIDER_H_
#define DEVTOOLS_CDBG_DEBUGLETS_JAVA_JNI_USER_ID_PROVIDER_H_

#include "common.h"
#include "jni_utils.h"
#include "user_id_provider.h"

namespace devtools {
namespace cdbg {

// Invokes com.google.devtools.cdbg.UserIdProvider to expose end user identity
// to the debugger agent.
class JniUserIdProvider : public UserIdProvider {
 public:
  // The "factory" callback creates a Java object implementing the
  // com.google.devtools.cdbg.UserIdProvider interface.
  explicit JniUserIdProvider(std::function<JniLocalRef()> factory);

  void Collect() override;

  bool Format(std::string* kind, std::string* id) override;

 private:
  // Callback that creates a Java object implementing the
  // com.google.devtools.cdbg.UserIdProvider interface.
  std::function<JniLocalRef()> factory_;

  // Global reference to Java class implementing the
  // com.google.devtools.cdbg.UserIdProvider interface.
  JniGlobalRef provider_;

  DISALLOW_COPY_AND_ASSIGN(JniUserIdProvider);
};

}  // namespace cdbg
}  // namespace devtools

#endif  // DEVTOOLS_CDBG_DEBUGLETS_JAVA_JNI_USER_ID_PROVIDER_H_


text:
import React from 'react'
import Form from 'admin/components/form'
import Access from '../../components/access'

class Edit extends React.Component {

  static contextTypes = {
    container: React.PropTypes.object,
    modal: React.PropTypes.object
  }

  render() {
    return <Form {...this._getForm()} />
  }

  _getForm() {
    return {
      title: 'Edit Role',
      method: 'patch',
      endpoint: `/admin/team/roles/${this.props.id}`,
      action: `/admin/team/roles/${this.props.id}`,
      onCancel: this.context.modal.pop,
      onSuccess: this.context.modal.pop,
      sections: [
        {
          fields: [
            { label: 'Title', name: 'title', type: 'textfield' },
            { label: 'Description', name: 'description', type: 'textarea' },
            { label: 'Access', name: 'description', type: Access }
          ]
        }
      ]
    }
  }

}

export default Edit


text:
namespace Microsoft.Azure.Management.Network.Models
{
    using Azure;
    using Management;
    using Network;
    using Newtonsoft.Json;
    using System.Linq;

    /// <summary>
    /// Describes the storage location for a packet capture session.
    /// </summary>
    public partial class PacketCaptureStorageLocation
    {
        /// <summary>
        /// Initializes a new instance of the PacketCaptureStorageLocation
        /// class.
        /// </summary>
        public PacketCaptureStorageLocation() { }

        /// <summary>
        /// Initializes a new instance of the PacketCaptureStorageLocation
        /// class.
        /// </summary>
        /// <param name="storageId">The ID of the storage account to save the
        /// packet capture session. Required if no local file path is
        /// provided.</param>
        /// <param name="storagePath">The URI of the storage path to save the
        /// packet capture. Must be a well-formed URI describing the location
        /// to save the packet capture.</param>
        /// <param name="filePath">A valid local path on the targeting VM. Must
        /// include the name of the capture file (*.cap). For linux virtual
        /// machine it must start with /var/captures. Required if no storage ID
        /// is provided, otherwise optional.</param>
        public PacketCaptureStorageLocation(string storageId = default(string), string storagePath = default(string), string filePath = default(string))
        {
            StorageId = storageId;
            StoragePath = storagePath;
            FilePath = filePath;
        }

        /// <summary>
        /// Gets or sets the ID of the storage account to save the packet
        /// capture session. Required if no local file path is provided.
        /// </summary>
        [JsonProperty(PropertyName = "storageId")]
        public string StorageId { get; set; }

        /// <summary>
        /// Gets or sets the URI of the storage path to save the packet
        /// capture. Must be a well-formed URI describing the location to save
        /// the packet capture.
        /// </summary>
        [JsonProperty(PropertyName = "storagePath")]
        public string StoragePath { get; set; }

        /// <summary>
        /// Gets or sets a valid local path on the targeting VM. Must include
        /// the name of the capture file (*.cap). For linux virtual machine it
        /// must start with /var/captures. Required if no storage ID is
        /// provided, otherwise optional.
        /// </summary>
        [JsonProperty(PropertyName = "filePath")]
        public string FilePath { get; set; }

    }
}


text:
#ifndef MODULES_TEEM_CONVERTERS_SplitFieldIntoNrrdData_H
#define MODULES_TEEM_CONVERTERS_SplitFieldIntoNrrdData_H

#include <Dataflow/Network/Module.h>
#include <Modules/Legacy/Teem/Converters/share.h>

namespace SCIRun {
namespace Modules {
namespace Teem {

  class SCISHARE SplitFieldIntoNrrdData : public Dataflow::Networks::Module,
    public Has1InputPort<FieldPortTag>,
    public Has3OutputPorts<NrrdPortTag, NrrdPortTag, NrrdPortTag>
  {
  public:
    SplitFieldIntoNrrdData();
    virtual void execute() override;
    virtual void setStateDefaults() override;

    INPUT_PORT(0, InputField, Field);
    OUTPUT_PORT(0, Data, NrrdDataType);
    OUTPUT_PORT(1, Points, NrrdDataType);
    OUTPUT_PORT(2, Connections, NrrdDataType);

    MODULE_TRAITS_AND_INFO(ModuleHasUIAndAlgorithm)
  };

}}}

#endif


text:
package similarity;

import java.nio.charset.Charset;
import java.nio.charset.MalformedInputException;

import org.apache.jena.atlas.AtlasException;
import org.junit.Before;
import org.junit.Test;

import es.upm.oeg.cidercl.extraction.OntologyExtractor;
import es.upm.oeg.semanticmeasures.impl.crosslingual.CLESABetweenOntologyEntities;
import es.upm.oeg.semanticmeasures.impl.monolingual.SoftTFIDFBetweenOntologyEntities;

/*
 * pruebas de similitud usando CIDER-CL como servicio para los papers anotados con SDO
 */
public class CiderSimilarityTest {

//	@Test
	public void similarityBetweenTwoInstancesSameOntology(){

		try{
		double monoSim, clSim;

//		// programm committee
//		String uriA = "http://www.example.org/sentence18988";
//
//		String ontologyA = "file:./src/test/resources/data/sdo-A01S01APowellOptimizationApproachforExampleBasedSkinningttl.ttl";
//
//		// comite de programa
//
//		String uriB = "http://www.example.org/sentence8988";
//		String ontologyB = "file:./src/test/resources/exampleCreator-2.ttl";

		/// EJEMPLO CIDER
		// programm committee
				String uriA = "http://www.example.org/index.html";

				String ontologyA = "file:./src/test/resources/exampleCreator.ttl";

				// comite de programa

				String uriB = "http://www.example.org/index.html";
				String ontologyB = "file:./test/exampleCreator-2.ttl";

		SoftTFIDFBetweenOntologyEntities measure = new SoftTFIDFBetweenOntologyEntities(ontologyA, ontologyA);
		monoSim = measure.getValue(OntologyExtractor.modelObtaining(ontologyA), uriA ,
				OntologyExtractor.modelObtaining(ontologyA), uriB);

		System.out.println( "---MONO-LINGUAL SIMILARITY between " + uriA + " and " + uriB + ": " + monoSim + " ---");
		}
		catch (AtlasException e){
			e.printStackTrace();
		}

	}

	public static void main(String args[]) {

		double monoSim, clSim;

//		String uriA = "http://cmt_en#c-4268400-1612321";
//		String ontologyA = "file:./test/cmt-en.owl";
//		String uriB = "http://cmt_es#c-7348985-5560772";
//		String ontologyB = "file:./test/cmt-es.owl";
		String uriC = "http://sigkdd_en#c-0407849-6361536";
		String ontologyC = "file:./test/sigkdd-en.owl";

		// programm committee
		String uriA = "http://www.example.org/index.html";

		String ontologyA = "file:./src/test/resources/exampleCreator.ttl";

		// comite de programa

		String uriB = "http://www.example.org/index.html";
		String ontologyB = "file:./src/test/resources/exampleCreator-2.ttl";

//		CLESABetweenOntologyEntities clesa = new CLESABetweenOntologyEntities();
//
//		clSim = clesa.getValue(OntologyExtractor.modelObtaining(ontologyA),  uriA,  null,
//				OntologyExtractor.modelObtaining(ontologyB) , uriB, null);

		SoftTFIDFBetweenOntologyEntities measure = new SoftTFIDFBetweenOntologyEntities(ontologyA, ontologyB);
//		SoftTFIDFBetweenOntologyEntities measure = new SoftTFIDFBetweenOntologyEntities(ontologyA, ontologyC);
		monoSim = measure.getValue(OntologyExtractor.modelObtaining(ontologyA), uriA ,
				OntologyExtractor.modelObtaining(ontologyB), uriB);

//		System.out.println( "---CROSS-LINGUAL SIMILARITY between " + uriA + " and " + uriB + ": " + clSim + " ---");
		System.out.println( "---MONO-LINGUAL SIMILARITY between " + uriA + " and " + uriC + ": " + monoSim + " ---");

	 }// end-main

}


text:
.class public Lo/nt$iF;
.super Lo/ʜ;

# interfaces
.implements Lo/ハ;

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lo/nt;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x9
    name = "iF"
.end annotation

.annotation system Ldalvik/annotation/Signature;
    value = {
        "Lo/\u029c;Lo/\uff8a<Ljava/lang/Long;>;"
    }
.end annotation

# direct methods
.method public constructor <init>(Ljava/lang/String;I)V
    .locals 0

    invoke-direct {p0, p1, p2}, Lo/ʜ;-><init>(Ljava/lang/String;I)V

    return-void
.end method


text:
using System;
using Server.Network;
using Server.Items;

namespace Server.Items
{
	[FlipableAttribute( 0x2D21, 0x2D2D )]
	public class AssassinSpike : BaseKnife
	{
		public override WeaponAbility PrimaryAbility{ get{ return WeaponAbility.InfectiousStrike; } }
		public override WeaponAbility SecondaryAbility{ get{ return WeaponAbility.ShadowStrike; } }

		public override int AosStrengthReq{ get{ return 15; } }
		public override int AosMinDamage{ get{ return 10; } }
		public override int AosMaxDamage{ get{ return 12; } }
		public override int AosSpeed{ get{ return 50; } }
		public override float MlSpeed{ get{ return 2.00f; } }

		public override int OldStrengthReq{ get{ return 15; } }
		public override int OldMinDamage{ get{ return 10; } }
		public override int OldMaxDamage{ get{ return 12; } }
		public override int OldSpeed{ get{ return 50; } }

		public override int DefMissSound{ get{ return 0x239; } }
		public override SkillName DefSkill { get { return SkillName.Fencing; } }

		public override int InitMinHits{ get{ return 30; } } // TODO
		public override int InitMaxHits{ get{ return 60; } } // TODO

		[Constructable]
		public AssassinSpike() : base( 0x2D21 )
		{
			Weight = 4.0;
		}

		public AssassinSpike( Serial serial ) : base( serial )
		{
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.WriteEncodedInt( 0 ); // version
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadEncodedInt();
		}
	}
}


text:
import argparse
import subprocess
import sys
import os
from collections import namedtuple

SCRIPT_DIR = os.path.realpath(os.path.dirname(__file__))

def parse_args():
    parser = argparse.ArgumentParser(description="Runs GPT-2 performance tests.")
    parser.add_argument("--binary_dir", required=True, help="Path to the ORT binary directory.")
    parser.add_argument("--training_data_root", required=True, help="Path to the training data root directory.")
    parser.add_argument("--model_root", required=True, help="Path to the model root directory.")
    return parser.parse_args()

# TODO - review to finalize params
def main():
    args = parse_args()

    Config = namedtuple("Config", ["use_mixed_precision", "max_seq_length", "batch_size"])
    configs = [Config(True, 1024, 1), Config(False, 1024, 1)]

    # run GPT-2 training
    for c in configs:
        print(
            "######## testing name - "
            + ("fp16-" if c.use_mixed_precision else "fp32-")
            + str(c.max_seq_length)
            + " ##############"
        )
        cmds = [
            os.path.join(args.binary_dir, "onnxruntime_training_gpt2"),
            "--model_name",
            os.path.join(
                args.model_root,
                "megatron-gpt2_hidden-size-1024_num-layers-24_vocab-size-50257_num-attention-heads-16_max-position-embeddings-1024_optimized_opset12",
            ),
            "--train_data_dir",
            os.path.join(args.training_data_root, "train"),
            "--test_data_dir",
            os.path.join(args.training_data_root, "test"),
            "--train_batch_size",
            str(c.batch_size),
            "--mode",
            "train",
            "--max_seq_length",
            str(c.max_seq_length),
            "--num_train_steps",
            "640",
            "--gradient_accumulation_steps",
            "1",
            "--perf_output_dir",
            os.path.join(SCRIPT_DIR, "results"),
        ]

        if c.use_mixed_precision:
            cmds.append("--use_mixed_precision"),

        subprocess.run(cmds).check_returncode()

    return 0

if __name__ == "__main__":
    sys.exit(main())