vimeo / ablincoln Goto Github PK
View Code? Open in Web Editor NEWA library for online experiments.
License: Other
A library for online experiments.
License: Other
PHPunit fails as the array subscripts are negative numbers when using 32 bit integers and modulo
revamp readme to better address differences between python + php port and usage at Vimeo
Think about renaming repository to better establish relationship between original PlanOut release and PHP port (e.g. keep ABLincoln as an internal use name and release repo as PlanOut-PHP)
Referring to the python reference implementation, it is possible to specify a compound primary_unit (e.g.: [ 'distinct_id', 'country' ] ) when setting up a SimpleNamespace. However, in PHP an exception is thrown in _getSegment() when an array of units is specified:
SimpleNamespace.php:_getSegment() line 174:
$assignment->segment = new Random\RandomInteger(
['min' => 0, 'max' => $this->num_segments - 1],
['unit' => $this->inputs[$this->primary_unit]]
);
$this->inputs can't be indexed by $this->primary_unit, which is an array. Both parity with python and the helper function SimpleNamespace.php:setPrimaryUnit($value) (where scalar $value is converted to an array automatically), suggest that compound units would be supported.
The following sample program exercises the issue:
use \Vimeo\ABLincoln\Namespaces\SimpleNamespace;
use \Vimeo\ABLincoln\Experiments\SimpleExperiment;
use \Vimeo\ABLincoln\Operators\Random as Random;
class MyExperiment extends SimpleExperiment {
public function assign($params, $inputs) {
$params->button_color = new Random\WeightedChoice( ['choices'=>['red', 'blue'], 'weights' => [ 0.5, 0.5 ] ], $inputs);
}
}
class MyNamespace extends \Vimeo\ABLincoln\Namespaces\SimpleNamespace {
public function setup() {
$this->name = 'My Namespace';
$this->num_segments = 10;
$this->primary_unit = [ 'distinct_id', 'country' ];
}
public function setupExperiments() {
$this->addExperiment('My Experiment', MyExperiment, 5);
}
}
$ns = new MyNamespace(['country' => 'US', 'distinct_id' => 'slkf982-fjfs894hg-ishgfjgh']);
print $ns->get('button_color');
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.