Ejemplo n.º 1
0
 /**
  * Executes this check
  *
  * @param   xp.compiler.ast.Node node
  * @param   xp.compiler.types.Scope scope
  * @return  bool
  */
 public function verify(\xp\compiler\ast\Node $node, \xp\compiler\types\Scope $scope)
 {
     $field = \cast($node, 'xp.compiler.ast.FieldNode');
     if ($scope->declarations[0] instanceof \xp\compiler\ast\InterfaceNode) {
         return ['I403', 'Interfaces may not have field declarations'];
     }
 }
Ejemplo n.º 2
0
 /**
  * Executes this check
  *
  * @param   xp.compiler.ast.Node node
  * @param   xp.compiler.types.Scope scope
  * @return  bool
  */
 public function verify(\xp\compiler\ast\Node $node, \xp\compiler\types\Scope $scope)
 {
     $a = \cast($node, 'xp.compiler.ast.AssignmentNode');
     if (!$this->isWriteable($a->variable)) {
         return ['A403', 'Cannot assign to ' . ($a->variable instanceof \lang\Generic ? nameof($a->variable) : \xp::stringOf($a->variable)) . 's'];
     }
 }
 /**
  * Executes this check
  *
  * @param   xp.compiler.ast.Node node
  * @param   xp.compiler.types.Scope scope
  * @return  bool
  */
 public function verify(\xp\compiler\ast\Node $node, \xp\compiler\types\Scope $scope)
 {
     $member = \cast($node, 'xp.compiler.ast.RoutineNode');
     if (!isset($member->comment) && !$scope->declarations[0]->synthetic) {
         return ['D201', 'No api doc for member ' . $scope->declarations[0]->name->compoundName() . '::' . $member->getName()];
     }
 }
 /**
  * Executes this check
  *
  * @param   xp.compiler.ast.Node node
  * @param   xp.compiler.types.Scope scope
  * @return  bool
  */
 public function verify(\xp\compiler\ast\Node $node, \xp\compiler\types\Scope $scope)
 {
     $access = \cast($node, 'xp.compiler.ast.ArrayAccessNode');
     $type = $scope->typeOf($access->target);
     $result = TypeName::$VAR;
     $message = null;
     if ($type->isArray()) {
         $result = $type->arrayComponentType();
     } else {
         if ($type->isMap()) {
             $result = $type->mapComponentType();
         } else {
             if ($type->isClass()) {
                 $ptr = new TypeInstance($scope->resolveType($type));
                 if ($ptr->hasIndexer()) {
                     $result = $ptr->getIndexer()->type;
                 } else {
                     $message = ['T305', 'Type ' . $ptr->name() . ' does not support offset access'];
                 }
             } else {
                 if ($type->isVariable()) {
                     $message = ['T203', 'Array access (var)' . $access->hashCode() . ' verification deferred until runtime'];
                 } else {
                     if ('string' === $type->name) {
                         $result = $type;
                     } else {
                         $message = ['T305', 'Using array-access on unsupported type ' . $type->toString()];
                     }
                 }
             }
         }
     }
     $scope->setType($access, $result);
     return $message;
 }
 /**
  * Executes this check
  *
  * @param   xp.compiler.ast.Node node
  * @param   xp.compiler.types.Scope scope
  * @return  bool
  */
 public function verify(\xp\compiler\ast\Node $node, \xp\compiler\types\Scope $scope)
 {
     $routine = \cast($node, 'xp.compiler.ast.PropertyNode');
     if ($scope->declarations[0] instanceof \xp\compiler\ast\InterfaceNode) {
         return ['I403', 'Interfaces may not have properties'];
     }
 }
 /**
  * Executes this check
  *
  * @param   xp.compiler.ast.Node node
  * @param   xp.compiler.types.Scope scope
  * @return  bool
  */
 public function verify(\xp\compiler\ast\Node $node, \xp\compiler\types\Scope $scope)
 {
     $routine = \cast($node, 'xp.compiler.ast.RoutineNode');
     $qname = $scope->declarations[0]->name->compoundName() . '::' . $routine->getName();
     $empty = $routine->body === null;
     if ($scope->declarations[0] instanceof \xp\compiler\ast\InterfaceNode) {
         if (!$empty) {
             return ['R403', 'Interface methods may not have a body ' . $qname];
         } else {
             if ($routine->modifiers !== MODIFIER_PUBLIC && $routine->modifiers !== 0) {
                 return ['R401', 'Interface methods may only be public ' . $qname];
             }
         }
     } else {
         if (Modifiers::isAbstract($routine->modifiers) && !$empty) {
             return ['R403', 'Abstract methods may not have a body ' . $qname];
         } else {
             if (!Modifiers::isAbstract($routine->modifiers) && $empty) {
                 return ['R401', 'Non-abstract methods must have a body ' . $qname];
             }
         }
         if ($routine->extension && !Modifiers::isStatic($routine->modifiers)) {
             return ['E403', 'Extension methods must be static ' . $qname];
         }
     }
 }
 /**
  * Executes this check
  *
  * @param   xp.compiler.ast.Node node
  * @param   xp.compiler.types.Scope scope
  * @return  bool
  */
 public function verify(\xp\compiler\ast\Node $node, \xp\compiler\types\Scope $scope)
 {
     $decl = \cast($node, 'xp.compiler.ast.TypeDeclarationNode');
     if (!isset($decl->comment) && !$decl->synthetic) {
         return ['D201', 'No api doc for type ' . $decl->name->compoundName()];
     }
 }
 /**
  * Executes this check
  *
  * @param   xp.compiler.ast.Node node
  * @param   xp.compiler.types.Scope scope
  * @return  bool
  */
 public function verify(\xp\compiler\ast\Node $node, \xp\compiler\types\Scope $scope)
 {
     $access = \cast($node, 'xp.compiler.ast.MemberAccessNode');
     // Verify type
     // * var: Might have method
     // * primitive, array, map, int: Definitely don't have fields
     $type = $scope->typeOf($access->target);
     if ($type->isVariable()) {
         return ['T203', 'Member access (var).' . $access->name . '() verification deferred until runtime'];
     } else {
         if (!$type->isClass()) {
             return ['T305', 'Using member access on unsupported type ' . $type->compoundName()];
         }
     }
     // Verify target method exists
     $target = new \xp\compiler\types\TypeInstance($scope->resolveType($type));
     if ($target->hasField($access->name)) {
         $member = $target->getField($access->name);
     } else {
         if ($target->hasProperty($access->name)) {
             $member = $target->getProperty($access->name);
         } else {
             return ['T404', 'No such field $' . $access->name . ' in ' . $target->name()];
         }
     }
     // Verify visibility
     if (!($member->modifiers & MODIFIER_PUBLIC)) {
         $enclosing = $scope->resolveType($scope->declarations[0]->name);
         if ($member->modifiers & MODIFIER_PRIVATE && !$enclosing->equals($target) || $member->modifiers & MODIFIER_PROTECTED && !($enclosing->equals($target) || $enclosing->isSubclassOf($target))) {
             return ['T403', sprintf('Accessing %s %s::$%s from %s', implode(' ', \lang\reflect\Modifiers::namesOf($member->modifiers)), $target->name(), $member->name, $enclosing->name())];
         }
     }
 }
 /**
  * Executes this check
  *
  * @param   xp.compiler.ast.Node node
  * @param   xp.compiler.types.Scope scope
  * @return  bool
  */
 public function verify(\xp\compiler\ast\Node $node, \xp\compiler\types\Scope $scope)
 {
     $v = \cast($node, 'xp.compiler.ast.VariableNode');
     if (!$scope->getType($v)) {
         return ['V404', 'Uninitialized variable ' . $v->name];
     }
 }
Ejemplo n.º 10
0
 /** @return string */
 public function code()
 {
     $r = '';
     foreach ($this->nodes as $node) {
         $r .= "\n" . cast($node, 'net.daringfireball.markdown.Text')->value;
     }
     return substr($r, 1);
 }
Ejemplo n.º 11
0
 /**
  * Executes this check
  *
  * @param   xp.compiler.ast.Node node
  * @param   xp.compiler.types.Scope scope
  * @return  bool
  */
 public function verify(\xp\compiler\ast\Node $node, \xp\compiler\types\Scope $scope)
 {
     $arm = cast($node, 'xp.compiler.ast.ArmNode');
     foreach ($arm->initializations as $i => $init) {
         $type = $scope->resolveType($scope->typeOf($init), false);
         if (!$type->isSubclassOf(self::$closeable)) {
             return ['A403', 'Type ' . $type->name() . ' for assignment #' . ($i + 1) . ' in ARM block is not closeable'];
         }
     }
 }
Ejemplo n.º 12
0
 /**
  * Add expansion `${kind.X}` with a given expansion function `f(X)`
  *
  * @param  string $kind
  * @param  [:var]|function(string): string $expansion
  * @return self
  */
 public function expanding($kind, $expansion)
 {
     $this->expansion = $this->expansion ?: clone self::$env;
     if ($expansion instanceof \ArrayAccess || is_array($expansion) && 0 !== key($expansion)) {
         $func = function ($name) use($expansion) {
             return isset($expansion[$name]) ? $expansion[$name] : null;
         };
     } else {
         $func = cast($expansion, 'function(string): string');
     }
     $this->expansion->expand($kind, $func);
     return $this;
 }
Ejemplo n.º 13
0
/**
 * Loader
 *
 * @param array $attr
 * @param array $item
 *
 * @return mixed
 */
function loader(array $attr, array $item)
{
    $item[$attr['id']] = cast($attr, $item[$attr['id']] ?? null);
    $callback = fqn('loader_' . $attr['type']);
    if (is_callable($callback)) {
        return $callback($attr, $item);
    }
    // @todo
    if ($attr['backend'] === 'json') {
        return loader_json($attr, $item);
    }
    return $item[$attr['id']];
}
Ejemplo n.º 14
0
 /**
  * Optimize a given node
  *
  * @param   xp.compiler.ast.Node in
  * @param   xp.compiler.types.Scope scope
  * @param   xp.compiler.optimize.Optimizations optimizations
  * @param   xp.compiler.ast.Node optimized
  */
 public function optimize(\xp\compiler\ast\Node $in, \xp\compiler\types\Scope $scope, Optimizations $optimizations)
 {
     $method = \cast($in, 'xp.compiler.ast.RoutineNode');
     // Search for return statement, then see if anything comes after it
     $s = sizeof($method->body);
     foreach ($method->body as $i => $statement) {
         if ($statement instanceof ReturnNode && $i < $s) {
             $method->body = array_slice($method->body, 0, $i + 1);
             // Include return
             break;
         }
     }
     return $method;
 }
Ejemplo n.º 15
0
 private static function cast($_inputs)
 {
     if (is_object($_inputs)) {
         if (class_exists($_inputs->getEqType_name())) {
             return cast($_inputs, $_inputs->getEqType_name());
         }
     }
     if (is_array($_inputs)) {
         $return = array();
         foreach ($_inputs as $input) {
             $return[] = self::cast($input);
         }
         return $return;
     }
     return $_inputs;
 }
Ejemplo n.º 16
0
 /**
  * Optimize a given node
  *
  * @param   xp.compiler.ast.Node in
  * @param   xp.compiler.types.Scope scope
  * @param   xp.compiler.optimize.Optimizations optimizations
  * @param   xp.compiler.ast.Node optimized
  */
 public function optimize(\xp\compiler\ast\Node $in, \xp\compiler\types\Scope $scope, Optimizations $optimizations)
 {
     $assign = cast($in, 'xp.compiler.ast.AssignmentNode');
     $assign->expression = $optimizations->optimize($assign->expression, $scope);
     // Optimize "<var>= <var>+ <expr>" to "<var>+= <expr>"
     if ($assign->expression instanceof BinaryOpNode && isset(self::$optimizable[$assign->expression->op]) && $assign->variable->equals($assign->expression->lhs)) {
         $assign = new AssignmentNode(['variable' => $assign->variable, 'expression' => $assign->expression->rhs, 'op' => self::$optimizable[$assign->expression->op]]);
     }
     // Optimize "<var>-= -<expr>" to "<var>+= <expr>"
     // Optimize "<var>+= -<expr>" to "<var>-= <expr>"
     if ($assign->expression instanceof UnaryOpNode && '-' === $assign->expression->op && isset(self::$switch[$assign->op])) {
         $assign = new AssignmentNode(['variable' => $assign->variable, 'expression' => $assign->expression->expression, 'op' => self::$switch[$assign->op]]);
     }
     // Not optimizable
     return $assign;
 }
/**
 * Index dedecms post
 * @param Array $var_array
 */
function doIndex($var_array)
{
    $options = new OpensearchOptionValues();
    global $IndexColumns;
    if ($options->isValid) {
        $doc = new \stdClass();
        foreach ($IndexColumns as $k => $v) {
            if (isset($var_array[$k])) {
                $colName = isset($v["label"]) ? $v["label"] : $k;
                $doc->{$colName} = isset($v["type"]) ? cast($var_array[$k], $v["type"]) : $var_array[$k];
            }
        }
        $openSearchService = new \OpenserachService($options);
        $openSearchService->submitDoc($doc);
    }
}
 /**
  * Executes this check
  *
  * @param   xp.compiler.ast.Node node
  * @param   xp.compiler.types.Scope scope
  * @return  bool
  */
 public function verify(\xp\compiler\ast\Node $node, \xp\compiler\types\Scope $scope)
 {
     $call = \cast($node, 'xp.compiler.ast.MethodCallNode');
     // Verify type
     // * var: Might have method
     // * primitive, array, map, int: Definitely don't have methods
     $type = $scope->typeOf($call->target);
     if ($type->isVariable()) {
         return ['T203', 'Member call (var).' . $call->name . '() verification deferred until runtime'];
     } else {
         if (!$type->isClass()) {
             return ['T305', 'Using member calls on unsupported type ' . $type->compoundName()];
         }
     }
     return $this->verifyMethod($type, $call->name, $scope);
 }
 /**
  * Executes this check
  *
  * @param   xp.compiler.ast.Node node
  * @param   xp.compiler.types.Scope scope
  * @return  bool
  */
 public function verify(\xp\compiler\ast\Node $node, \xp\compiler\types\Scope $scope)
 {
     $type = \cast($node, 'xp.compiler.ast.TypeDeclarationNode');
     if (!$type->body) {
         return;
     }
     // Short-circuit
     $index = [];
     $qname = $type->name->compoundName();
     foreach ($type->body as $member) {
         $key = $member->hashCode();
         if (isset($index[$key])) {
             return ['C409', 'Cannot redeclare ' . $qname . '::' . $key];
         }
         $index[$key] = true;
     }
 }
Ejemplo n.º 20
0
 /**
  * Executes this check
  *
  * @param   xp.compiler.ast.Node node
  * @param   xp.compiler.types.Scope scope
  * @return  bool
  */
 public function verify(\xp\compiler\ast\Node $node, \xp\compiler\types\Scope $scope)
 {
     $m = \cast($node, 'xp.compiler.ast.MethodNode');
     if (!($m->modifiers & MODIFIER_INLINE)) {
         return;
     }
     // Ignore these
     // Body must consist of a one line...
     if (1 !== ($s = sizeof($m->body))) {
         return ['I402', 'Only one-liners can be inlined: ' . $m->name . '() has ' . $s . ' statements'];
     }
     // ...which must be of the form "return <EXPR>;"
     if (!$m->body[0] instanceof \xp\compiler\ast\ReturnNode) {
         return ['I403', 'Only one-line return statements can be inlined: ' . $m->name . '()'];
     }
     // OK
     return null;
 }
Ejemplo n.º 21
0
 /**
  * Optimize a given node
  *
  * @param   xp.compiler.ast.Node in
  * @param   xp.compiler.types.Scope scope
  * @param   xp.compiler.optimize.Optimizations optimizations
  * @param   xp.compiler.ast.Node optimized
  */
 public function optimize(\xp\compiler\ast\Node $in, \xp\compiler\types\Scope $scope, Optimizations $optimizations)
 {
     $try = cast($in, 'xp.compiler.ast.TryNode');
     // try { } catch (... $e) { ... } => NOOP
     // try { } finally { ..[1].. }    => [1]
     if (0 === sizeof($try->statements)) {
         $last = $try->handling[sizeof($try->handling) - 1];
         if ($last instanceof FinallyNode) {
             return new StatementsNode($last->statements);
         } else {
             return new NoopNode();
         }
     }
     // try { ..[1].. } catch (... $e) { throw $e; } => [1]
     if (1 === sizeof($try->handling) && $try->handling[0] instanceof CatchNode && 1 === sizeof($try->handling[0]->statements) && $try->handling[0]->statements[0] instanceof ThrowNode && $try->handling[0]->variable === $try->handling[0]->statements[0]->expression->name) {
         return new StatementsNode($try->statements);
     }
     return $in;
 }
Ejemplo n.º 22
0
 private static function cast($_inputs, $_eqLogic = null)
 {
     if (is_object($_inputs) && class_exists($_inputs->getEqType() . 'Cmd')) {
         if ($_eqLogic != null) {
             $_inputs->_eqLogic = $_eqLogic;
         }
         return cast($_inputs, $_inputs->getEqType() . 'Cmd');
     }
     if (is_array($_inputs)) {
         $return = array();
         foreach ($_inputs as $input) {
             if ($_eqLogic != null) {
                 $input->_eqLogic = $_eqLogic;
             }
             $return[] = self::cast($input);
         }
         return $return;
     }
     return $_inputs;
 }
Ejemplo n.º 23
0
Archivo: attr.php Proyecto: akilli/qnd
/**
 * Cast to appropriate php type
 *
 * @param array $attr
 * @param mixed $value
 *
 * @return mixed
 */
function cast(array $attr, $value)
{
    if (in_array($value, [null, '']) && !empty($attr['nullable'])) {
        return null;
    }
    if ($attr['backend'] === 'bool') {
        return boolval($value);
    }
    if ($attr['backend'] === 'int') {
        return intval($value);
    }
    if ($attr['backend'] === 'decimal') {
        return floatval($value);
    }
    if ($attr['multiple'] && is_array($value)) {
        foreach ($value as $k => $v) {
            $value[$k] = cast($attr, $v);
        }
        return $value;
    }
    return strval($value);
}
Ejemplo n.º 24
0
/**
 * Validator
 *
 * @param array $attr
 * @param array $item
 *
 * @return bool
 */
function validator(array $attr, array &$item) : bool
{
    if (!in_array('edit', $attr['actions'])) {
        return true;
    }
    $item[$attr['id']] = cast($attr, $item[$attr['id']] ?? null);
    if ($item[$attr['id']] === null && !empty($attr['nullable'])) {
        return true;
    }
    $attr['opt'] = opt($attr);
    $valid = true;
    $callback = fqn('validator_' . $attr['type']);
    if (is_callable($callback)) {
        $valid = $callback($attr, $item);
    } else {
        // @todo
        switch ($attr['frontend']) {
            case 'checkbox':
            case 'radio':
            case 'select':
                $valid = validator_opt($attr, $item);
                break;
            case 'password':
            case 'textarea':
                $valid = validator_text($attr, $item);
                break;
            case 'date':
            case 'time':
                $valid = validator_datetime($attr, $item);
                break;
            case 'file':
                $valid = validator_file($attr, $item);
                break;
        }
    }
    return $valid && validator_uniq($attr, $item) && validator_required($attr, $item) && validator_boundary($attr, $item);
}
 /**
  * Creation constructor
  *
  * @param   io.streams.InputStream stream
  */
 public function __construct(InputStream $stream)
 {
     parent::__construct(cast($stream, 'io.streams.Seekable'));
 }
Ejemplo n.º 26
0
 function anomaly_score($input_data, $by_name = true)
 {
     /*
      Returns the anomaly score given by the iforest
     
      To produce an anomaly score, we evaluate each tree in the iforest
      for its depth result (see the depth method in the AnomalyTree
      object for details). We find the average of these depths
      to produce an `observed_mean_depth`. We calculate an
      `expected_mean_depth` using the `sample_size` and `mean_depth`
      parameters which come as part of the forest message.
      We combine those values as seen below, which should result in a
      value between 0 and 1.
     */
     //Checks and cleans input_data leaving the fields used in the model
     $input_data = $this->filter_input_data($input_data, $by_name);
     // Strips affixes for numeric values and casts to the final field type
     $input_data = cast($input_data, $this->fields);
     $depth_sum = 0;
     if ($this->iforest != null) {
         foreach ($this->iforest as $tree) {
             $depth = $tree->depth($input_data);
             $depth_sum += $depth[0];
         }
         $observed_mean_depth = floatval($depth_sum) / count($this->iforest);
         return pow(2, -$observed_mean_depth / $this->expected_mean_depth);
     } else {
         error_log("We could not find the iforest information to compute the anomaly score. Please, rebuild your Anomaly object from a complete anomaly detector resource");
         throw new Exception("We could not find the iforest information to compute the anomaly score. Please, rebuild your Anomaly object from a complete anomaly detector resource");
     }
 }
Ejemplo n.º 27
0
 public function catchExpectedWithMismatchingMessage()
 {
     $this->suite->addTest(newinstance(TestCase::class, ['fixture'], ['#[@test, @expect(class= "lang.IllegalArgumentException", withMessage= "Hello")] fixture' => function () {
         throw new IllegalArgumentException('Test');
     }]));
     $r = $this->suite->run();
     $this->assertEquals(1, $r->failureCount());
     $this->assertEquals('Expected lang.IllegalArgumentException\'s message "Test" differs from expected /Hello/', cast($r->outcomeOf($this->suite->testAt(0)), 'unittest.TestFailure')->reason->getMessage());
 }
Ejemplo n.º 28
0
 public function catchExpectedWithMismatchingMessage()
 {
     $this->suite->addTest(new SimpleTestCase('catchExpectedWithWrongMessage'));
     $r = $this->suite->run();
     $this->assertEquals(1, $r->failureCount());
     $this->assertEquals('Expected lang.IllegalArgumentException\'s message differs', cast($r->outcomeOf($this->suite->testAt(0)), 'unittest.TestFailure')->reason->getMessage());
 }
Ejemplo n.º 29
0
 public function predict($input_data, $by_name = true, $print_path = false, $out = STDOUT, $with_confidence = false, $missing_strategy = Tree::LAST_PREDICTION, $add_confidence = false, $add_path = false, $add_distribution = false, $add_count = false, $add_median = false, $add_next = false, $add_min = false, $add_max = false, $multiple = null)
 {
     /*
              Makes a prediction based on a number of field values.
              By default the input fields must be keyed by field name but you can use
             `by_name` to input them directly keyed by id.
     */
     # Checks if this is a regression model, using PROPORTIONAL
     # missing_strategy
     $tree = $this->tree;
     if ($tree != null && $tree->regression && $missing_strategy == Tree::PROPORTIONAL && !$this->regression_ready) {
         throw new Exception("You needed to use proportional missing strategy, \n                         for regressions. Please install them before, using local predictions for the model.");
     }
     # Checks and cleans input_data leaving the fields used in the model
     $input_data = $this->filter_input_data($input_data, $by_name);
     # Strips affixes for numeric values and casts to the final field type
     $input_data = cast($input_data, $this->fields);
     $prediction = $tree->predict($input_data, null, $missing_strategy);
     # Prediction path
     if ($print_path == true) {
         fwrite($out, join(" AND ", $prediction->path) . ' => ' . $prediction->output . "\n");
         fclose($out);
     }
     $output = $prediction;
     if ($with_confidence == true) {
         $output = $prediction;
     }
     if ($multiple != null && !$tree->regression) {
         $output = array();
         $total_instances = floatval($prediction->count);
         $index = 0;
         foreach ($prediction->distribution as $index => $data) {
             $category = $data[0];
             $instances = $data[1];
             if (is_string($multiple) && $multiple == 'all' or is_int($multiple) && $index < $multiple) {
                 $prediction_dict = array('prediction' => $category, 'confidence' => ws_confidence($category, $prediction->distribution), 'probability' => $instances / $total_instances, 'count' => $instances);
                 array_push($output, $prediction_dict);
             }
         }
     } else {
         if ($add_confidence || $add_path || $add_distribution || $add_count || $add_median || $add_next || $add_min || $add_max) {
             $output = (object) array('prediction' => $prediction->output);
             if ($add_confidence) {
                 $output->confidence = $prediction->confidence;
             }
             if ($add_path) {
                 $output->path = $prediction->path;
             }
             if ($add_distribution) {
                 $output->distribution = $prediction->distribution;
                 $output->distribution_unit = $prediction->distribution_unit;
             }
             if ($add_count) {
                 $output->count = $prediction->count;
             }
             if ($tree->regression && $add_median) {
                 $output->median = $prediction->median;
             }
             if ($add_next) {
                 $field = count($prediction->children) == 0 ? null : $prediction->children[0]->predicate->field;
                 if ($field != null && array_key_exists($field, $this->fields)) {
                     $field = $this->fields->{$field}->name;
                 }
                 $output->next = $field;
             }
             if ($tree->regression && $add_min) {
                 $output->min = $prediction->min;
             }
             if ($tree->regression && $add_max) {
                 $output->max = $prediction->max;
             }
         }
     }
     return $output;
 }
Ejemplo n.º 30
0
 public function primitive()
 {
     cast('primitive', Object::class);
 }