@param $experimentKey string Key for experiment.
@param $variationId string ID for variation.

@return Variation Entity corresponding to the provided experiment key and variation ID.
Dummy entity is returned if key or ID is invalid.
488641
public function getVariationFromId($experimentKey, $variationId)
    {
        if (isset($this->_variationIdMap[$experimentKey])
            && isset($this->_variationIdMap[$experimentKey][$variationId])
        ) {
            return $this->_variationIdMap[$experimentKey][$variationId];
        }

        $this->_logger->log(
            Logger::ERROR,
            sprintf(
                'No variation ID "%s" defined in datafile for experiment "%s".',
                $variationId,
                $experimentKey
            )
        );
        $this->_errorHandler->handleError(new InvalidVariationException('Provided variation is not in datafile.'));
        return new Variation();
    }
810679
public function getVariationForExperiment($experimentId)
    {
        $decision = $this->getDecisionForExperiment($experimentId);
        if (!is_null($decision)) {
            return $decision->getVariationId();
        }

        return null;
    }
1147487
public function setVariationOfId($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->variation_of_id !== $v) {
            $this->variation_of_id = $v;
            $this->modifiedColumns[SkillTableMap::COL_VARIATION_OF_ID] = true;
        }

        if ($this->aVariationOf !== null && $this->aVariationOf->getId() !== $v) {
            $this->aVariationOf = null;
        }

        return $this;
    }
197644
def get_row_from_id(self, experiment_id):
		
		row = [row for row in self if row.experiment_id == experiment_id]
		if len(row) > 1:
			raise ValueError("duplicate ids in experiment table")
		if len(row) == 0:
			raise ValueError("id '%s' not found in table" % experiment_id)

		return row[0]
668931
protected function buildVariantDocumentAndAssignToParentResult(ResponseAdapter $response, $variantAccessKey, SearchResult $resultDocument)
    {
        foreach ($response->{'expanded'}->{$variantAccessKey}->{'docs'} as $variantDocumentArray) {
            $fields = get_object_vars($variantDocumentArray);
            $variantDocument = new SearchResult($fields);

            $variantSearchResult = $this->resultBuilder->fromApacheSolrDocument($variantDocument);
            $variantSearchResult->setIsVariant(true);
            $variantSearchResult->setVariantParent($resultDocument);

            $resultDocument->addVariant($variantSearchResult);
        }
    }
358825
private Variant loadVariantWhenAuthorized(final HttpServletRequest request) {
        // extract the pushApplicationID and its secret from the HTTP Basic
        // header:
        final String[] credentials = HttpBasicHelper.extractUsernameAndPasswordFromBasicHeader(request);
        final String variantID = credentials[0];
        final String secret = credentials[1];

        final Variant variant = genericVariantService.findByVariantID(variantID);
        if (variant != null && variant.getSecret().equals(secret)) {
            return variant;
        }

        // unauthorized...
        return null;
    }
982701
public static String getVariantKey(Map<String, String> variants) {

		String variantKey = "";
		if (variants != null) {
			variantKey = getVariantKey(variants, variants.keySet());
		}

		return variantKey;
	}
614973
def get_experiment_from_id(self, experiment_id):
    

    experiment = self.experiment_id_map.get(experiment_id)

    if experiment:
      return experiment

    self.logger.error('Experiment ID "%s" is not in datafile.' % experiment_id)
    self.error_handler.handle_error(exceptions.InvalidExperimentException(enums.Errors.INVALID_EXPERIMENT_KEY_ERROR))
    return None
1035518
public static Variation attemptToGetAsVariant(String part)
    {
        // Annoyingly JAXB won't bind Variation as an enum, so we have to do this manually.
        // TODO - can we do something more clever... eg make StoneTypes, WoodTypes etc inherit from an XSD baseclass,
        // and have an object in the schemas that returns a list, so we can just iterate...
        try
        {
            StoneTypes var = StoneTypes.valueOf(part.toUpperCase());
            if (var != null)
            {
                Variation bv = new Variation();
                bv.setValue(var.value());
                return bv;
            }
        }
        catch (Exception e)
        {
            // Does nothing.
        }
        try
        {
            WoodTypes var = WoodTypes.valueOf(part.toUpperCase());
            if (var != null)
            {
                Variation bv = new Variation();
                bv.setValue(var.value());
                return bv;
            }
        }
        catch (Exception e)
        {
            // Does nothing.
        }
        try
        {
            FlowerTypes var = FlowerTypes.fromValue(part);
            if (var != null)
            {
                Variation bv = new Variation();
                bv.setValue(var.value());
                return bv;
            }
        }
        catch (Exception e)
        {
            // Does nothing.
        }
        try
        {
            EntityTypes var = EntityTypes.fromValue(part);
            if (var != null)
            {
                Variation bv = new Variation();
                bv.setValue(var.value());
                return bv;
            }
        }
        catch (Exception e)
        {
            // Does nothing.
        }
        try
        {
            MonsterEggTypes var = MonsterEggTypes.fromValue(part);
            if (var != null)
            {
                Variation bv = new Variation();
                bv.setValue(var.value());
                return bv;
            }
        }
        catch (Exception e)
        {
            // Does nothing.
        }
        try
        {
            ShapeTypes var = ShapeTypes.fromValue(part);
            if (var != null)
            {
                Variation bv = new Variation();
                bv.setValue(var.value());
                return bv;
            }
        }
        catch (Exception e)
        {
            // Does nothing.
        }
        try
        {
            HalfTypes var = HalfTypes.fromValue(part);
            if (var != null)
            {
                Variation bv = new Variation();
                bv.setValue(var.value());
                return bv;
            }
        }
        catch (Exception e)
        {
            // Does nothing.
        }
        return null;
    }
1068182
public function addVariant(VariantInterface $variant)
    {
        if (!$this->hasVariant($variant)) {
            $variant->setObject($this);
            $this->variants->add($variant);
        }

        return $this;
    }
37388
function rootExperiments(fn) {
  enqueue(function() {
    var data = {};
    var experimentIds = window._vwo_exp_ids;
    if (!experimentIds) return fn();
    each(experimentIds, function(experimentId) {
      var variationName = variation(experimentId);
      if (variationName) data[experimentId] = variationName;
    });
    fn(null, data);
  });
}
536595
func (h *Client) ExperimentID(experimentID string) *Client {
	h.experimentID = experimentID
	h.experimentIDSet = true
	return h
}
871635
def identity(ctx, variant_id):
    
    if not variant_id:
        LOG.warning("Please provide a variant id")
        ctx.abort()

    adapter = ctx.obj['adapter']
    version = ctx.obj['version']
    
    LOG.info("Search variants {0}".format(adapter))
    
    result = adapter.get_clusters(variant_id)
    if result.count() == 0:
        LOG.info("No hits for variant %s", variant_id)
        return
    
    for res in result:
        click.echo(res)
136660
def variation_name(self, variation_name):
        

        if variation_name is None:
            raise ValueError("Invalid value for `variation_name`, must not be `None`")
        if len(variation_name) > 255:
            raise ValueError("Invalid value for `variation_name`, length must be less than `255`")

        self._variation_name = variation_name
725628
public function getDecisionForExperiment($experimentId)
    {
        if (isset($this->_experiment_bucket_map[$experimentId])) {
            return $this->_experiment_bucket_map[$experimentId];
        }

        return null;
    }
447188
public function chooseVariant($variants)
    {
        $count = count($variants);
        if (0 === $count) {
            return null;
        }

        $chosenCount = mt_rand(0, $count - 1);
        $keys = array_keys($variants);

        return $variants[$keys[$chosenCount]];
    }
1026311
public function createVariantAttributeRelation($productId, array $requestData)
    {
        $variant = $this->retrieveProductById($productId);
        $attribute = $this->retrieveAttributeById($this->getProperty($requestData, 'attributeId'));

        // Only add if relation does not already exists.
        if (!$variant->getVariantAttributes()->contains($attribute)) {
            $variant->addVariantAttribute($attribute);
        }

        return $variant;
    }