original_string: public function calculate($sampleids, \core_analytics\analysable $analysable, $starttime = false, $endtime = false) {
  
          if (!PHPUNIT_TEST && CLI_SCRIPT) {
              echo '.';
          }
  
          $calculations = [];
          foreach ($sampleids as $sampleid => $unusedsampleid) {
  
              // No time limits when calculating the target to train models.
              $calculatedvalue = $this->calculate_sample($sampleid, $analysable, $starttime, $endtime);
  
              if (!is_null($calculatedvalue)) {
                  if ($this->is_linear() &&
                          ($calculatedvalue > static::get_max_value() || $calculatedvalue < static::get_min_value())) {
                      throw new \coding_exception('Calculated values should be higher than ' . static::get_min_value() .
                          ' and lower than ' . static::get_max_value() . '. ' . $calculatedvalue . ' received');
                  } else if (!$this->is_linear() && static::is_a_class($calculatedvalue) === false) {
                      throw new \coding_exception('Calculated values should be one of the target classes (' .
                          json_encode(static::get_classes()) . '). ' . $calculatedvalue . ' received');
                  }
              }
              $calculations[$sampleid] = $calculatedvalue;
          }
          return $calculations;
      }
code: public function calculate($sampleids, \core_analytics\analysable $analysable, $starttime = false, $endtime = false) {
  
          if (!PHPUNIT_TEST && CLI_SCRIPT) {
              echo '.';
          }
  
          $calculations = [];
          foreach ($sampleids as $sampleid => $unusedsampleid) {
  
              // No time limits when calculating the target to train models.
              $calculatedvalue = $this->calculate_sample($sampleid, $analysable, $starttime, $endtime);
  
              if (!is_null($calculatedvalue)) {
                  if ($this->is_linear() &&
                          ($calculatedvalue > static::get_max_value() || $calculatedvalue < static::get_min_value())) {
                      throw new \coding_exception('Calculated values should be higher than ' . static::get_min_value() .
                          ' and lower than ' . static::get_max_value() . '. ' . $calculatedvalue . ' received');
                  } else if (!$this->is_linear() && static::is_a_class($calculatedvalue) === false) {
                      throw new \coding_exception('Calculated values should be one of the target classes (' .
                          json_encode(static::get_classes()) . '). ' . $calculatedvalue . ' received');
                  }
              }
              $calculations[$sampleid] = $calculatedvalue;
          }
          return $calculations;
      }
code_tokens: public function calculate ( $ sampleids , \ core_analytics \ analysable $ analysable , $ starttime = false , $ endtime = false ) { if ( ! PHPUNIT_TEST && CLI_SCRIPT ) { echo '.' ; } $ calculations = [ ] ; foreach ( $ sampleids as $ sampleid => $ unusedsampleid ) { // No time limits when calculating the target to train models. $ calculatedvalue = $ this -> calculate_sample ( $ sampleid , $ analysable , $ starttime , $ endtime ) ; if ( ! is_null ( $ calculatedvalue ) ) { if ( $ this -> is_linear ( ) && ( $ calculatedvalue > static :: get_max_value ( ) || $ calculatedvalue < static :: get_min_value ( ) ) ) { throw new \ coding_exception ( 'Calculated values should be higher than ' . static :: get_min_value ( ) . ' and lower than ' . static :: get_max_value ( ) . '. ' . $ calculatedvalue . ' received' ) ; } else if ( ! $ this -> is_linear ( ) && static :: is_a_class ( $ calculatedvalue ) === false ) { throw new \ coding_exception ( 'Calculated values should be one of the target classes (' . json_encode ( static :: get_classes ( ) ) . '). ' . $ calculatedvalue . ' received' ) ; } } $ calculations [ $ sampleid ] = $ calculatedvalue ; } return $ calculations ; }
docstring: Calculates the target.
  
  Returns an array of values which size matches $sampleids size.
  
  Rows with null values will be skipped as invalid by time splitting methods.
  
  @param array $sampleids
  @param \core_analytics\analysable $analysable
  @param int $starttime
  @param int $endtime
  @return array The format to follow is [userid] = scalar|null
docstring_tokens: Calculates the target .