Formats the datasets.

@return void
421983
public function formatDatasets()
    {
        $datasets = Collection::make($this->datasets);

        return json_encode([
            'columns' => Collection::make($this->datasets)
                ->each(function ($dataset) {
                    $dataset->matchValues(count($this->labels));
                })
                ->map(function ($dataset) {
                    return $dataset->format($this->labels);
                })
                ->toArray(),
            'type'  => $datasets->first()->type,
            'types' => $datasets->mapWithKeys(function ($d) {
                return [$d->name => $d->type];
            })->toArray(),
        ]);
    }
1371253
private function buildFormatterList()
    {
        if (!$this->isObject(self::$formatters)) {
            $formatters = new ArrayObject([]);
            foreach (self::$formatters as $fk => $fv) {
                $formatters->key($fk, new ArrayObject($fv));
            }
            self::$formatters = $formatters;
        }
    }
414
public function display(): void
    {
        if (null === $this->format) {
            $this->format = self::DEFAULT_FORMAT;
        }

        $this->render($this->buildLine());
    }
742069
public function writeData(): array
    {
        $dataBuilder = new DataBuilder();
        $dataBuilder->setString('t', $this->type, '')
                    ->setString('n', $this->name, '')
                    ->setArray('l', $this->labels->writeData(), null, [])
                    ->setArray('d', $this->descriptions->writeData(), null, [])
                    ->setInteger('r', $this->providesRecipeLocalisation ? 1 : 0, 0)
                    ->setInteger('m', $this->providesMachineLocalisation ? 1 : 0, 0)
                    ->setString('i', $this->iconHash, '')
                    ->setInteger('e', $this->isNew ? 1 : 0, 1);
        return $dataBuilder->getData();
    }
656940
public function setHeadData($data)
	{
		if (empty($data) || !is_array($data))
		{
			return;
		}

		$this->title        = (isset($data['title']) && !empty($data['title'])) ? $data['title'] : $this->title;
		$this->description  = (isset($data['description']) && !empty($data['description'])) ? $data['description'] : $this->description;
		$this->link         = (isset($data['link']) && !empty($data['link'])) ? $data['link'] : $this->link;

		$this->_metaTags    = (isset($data['metaTags']) && !empty($data['metaTags'])) ? $data['metaTags'] : $this->_metaTags;
		$this->_links       = (isset($data['links']) && !empty($data['links'])) ? $data['links'] : $this->_links;
		$this->_styleSheets = (isset($data['styleSheets']) && !empty($data['styleSheets'])) ? $data['styleSheets'] : $this->_styleSheets;
		$this->_style       = (isset($data['style']) && !empty($data['style'])) ? $data['style'] : $this->_style;
		$this->_scripts     = (isset($data['scripts']) && !empty($data['scripts'])) ? $data['scripts'] : $this->_scripts;
		$this->_script      = (isset($data['script']) && !empty($data['script'])) ? $data['script'] : $this->_script;
		$this->_custom      = (isset($data['custom']) && !empty($data['custom'])) ? $data['custom'] : $this->_custom;

		return $this;
	}
366670
public function fit(Dataset $dataset) : void
    {
        $columns = $dataset->columnsByType(DataType::CATEGORICAL);

        $this->categories = [];

        foreach ($columns as $column => $values) {
            $categories = array_values(array_unique($values));

            $this->categories[$column] = array_flip($categories);
        }
    }
881751
public function formatOptions(bool $strict = false, bool $noBraces = false)
    {
        $colors = [];
        $default = 0;
        foreach ($this->datasets as $dataset) {
            $color = $this->default_colors[$default];
            if (array_key_exists('color', $dataset->options)) {
                $color = $dataset->options['color'];
                unset($dataset->options['color']);
            } else {
                $default++;
            }
            array_push($colors, $color);
        }

        $this->options([
            'colors' => $colors,
        ]);

        return parent::formatOptions($strict, $noBraces);
    }
10070
public function setupFormats()
    {
//through HTTP_ACCEPT
        if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], '*/*') === false) {
            foreach ($this->outputFormats as $formatCode => $formatMethod) {
                if (strpos($_SERVER['HTTP_ACCEPT'], $formatCode) !== false) {
                    $this->outputFormat = $formatCode;
                    break;
                }
            }
        }

//through uri suffix
        if (preg_match('/\.(\w+)$/i', $this->getUrl(), $matches)) {
            if (isset($this->outputFormats[$matches[1]])) {
                $this->outputFormat = $matches[1];
                $url = $this->getUrl();
                $this->setUrl(substr($url, 0, (strlen($this->outputFormat) * -1) - 1));
            }
        }

//through _format parametr
        if (isset($_GET['_format'])) {
            if (isset($this->outputFormats[$_GET['_format']])) {
                $this->outputFormat = $_GET['_format'];
            }
        }

        return $this;
    }
1013318
public function formatData()
    {
        $this->formatter->addData($this->data);

        try {
            $formatted = $this->formatter->format();
        } catch (DataException $e) {
            throw new FormattingException('The provided data has been incorrectly formatted.');
        }

        return $formatted;
    }
457887
public function tables()
    {
        $schema = $this->db->connection()
            ->getDoctrineConnection()
            ->getSchemaManager();

        $tables = $schema->listTableNames();

        foreach ($tables as $table) {
            $columns = $this->describer->describe($table);

            yield compact('table', 'columns');
        }
    }
97402
public function format() {

        /*         * Add the mandatary props* */
        if (!is_null($this->locale)) {
            $result[self::LOCALE_KEY] = $this->locale;
        }

        if (!is_null($this->sender)) {
            $result[self::SENDER_KEY] = $this->sender;
        }

        if (!is_null($this->senderEmail)) {
            $result[self::SENDEREMAIL_KEY] = $this->senderEmail;
        }
        if (!is_null($this->subject)) {
            $result[self::SUBJECT_KEY] = $this->subject;
        }
        if (!is_null($this->contactsListID)) {
            $result[self::CONTACTLISTID_KEY] = $this->contactsListID;
        }
        /*         * Add the optional props if any* */
        if (!is_null($this->optionalProperties)) {
            $result = array_merge($result, $this->optionalProperties);
        }


        return $result;
    }
1214739
public function format() {

        /*         * Add the mandatary props* */
        if (!is_null($this->name)) {
            $result[self::NAME_KEY] = $this->name;
        }

        /*         * Add the optional props if any* */
        if (!is_null($this->optionalProperties)) {
            $result = array_merge($result, $this->optionalProperties);
        }


        return $result;
    }
212395
public function format()
    {
        $result = [
            'Action' => $this->action,
            'Contacts' => [],
        ];

        $contacts = $this->contacts;
        $contactsArray = array_map(function (Contact $contact) {
            return $contact->format();
        }, $contacts);

        $result['Contacts'] = $contactsArray;

        return $result;
    }
1082138
protected function setFormData()
    {
        foreach ($this->validFields as $field => $params) {
            if (isset($params["rename"])) {
                $field = $params["rename"];
            }
            if ($params['type'] == "single") {
                if (isset($this->fieldData[$field])) {
                    $this->formData[$field] = $this->fieldData[$field];
                }
            } elseif ($params['type'] == "product") {
                if (!isset($this->formData[$field])) {
                    $this->formData[$field] = array();
                }
                foreach ($this->products as $num => $product) {
                    if (isset($product[$params["paramName"]])) {
                        $this->formData[$field][$num] = $product[$params["paramName"]];
                    }
                }
            }
        }
    }
1168812
private function format()
    {
        $request_uri = sprintf('%s %s', $this->request->getMethod(), $this->request->getBasePath().$this->request->getPathInfo());

        $ret = [
            'meta' => [
                'api_version'   => $this->getVersion(),
                'request'       => $request_uri,
                'response_time' => $this->responseTime,
                'http_code'     => $this->code,
                'error_type'    => $this->errorType,
                'error_message' => $this->errorMessage,
                'error_details' => $this->errorDetails,
                'charset'       => 'UTF-8',
            ],
            'response'          => $this->data,
        ];

        switch ($this->responseType) {
            case self::FORMAT_JSON:
            default:
                return new JsonResponse($ret);
            case self::FORMAT_YAML:
                if ($ret['response'] instanceof \stdClass) {
                    $ret['response'] = [];
                }

                $dumper = new Dumper();

                return new Response($dumper->dump($ret, 8));
            case self::FORMAT_JSONP:
                $response = new JsonResponse($ret);
                $response->setCallback(trim($this->request->get('callback')));

                return $response;
                break;
        }
    }
230814
public function format()
	{
		foreach($this->matches as $key => $match)
		{
			$potential = str_replace(['[', ']'], '', $match);

			// Seperate by comma
			$potential = explode(',', $potential);

			// Classes can have a dot seperator Class.method
			$mask = $potential[0];
			if(strpos($potential[0], '.') !== false) {
				$parts = explode('.', $potential[0]);
				$mask = $parts[0];
			}

			// The first value will be the mask name
			if($this->collection->getMethod()->has($mask))
			{
				$this->formatted[$mask] = Array();

				// Add the raw match so we can replace this
				$this->formatted[$mask]['raw'] = $match;
				$this->formatted[$mask]['params'] = Array();
				
				// Remove the name from the array
				unset($potential[0]);

				$this->processValues($mask, $potential);
			
			} else {
				
				// This isnt a mask
				unset($this->matches[$key]);
			}
		}	
	}
214538
def _format_list(self, data):
        
        dataset = "["
        i = 0
        for el in data:
            if pd.isnull(el):
                dataset += "null"
            else:
                dtype = type(data[i])
                if dtype == int or dtype == float:
                    dataset += str(el)
                else:
                    dataset += '"' + el + '"'
            if i < len(data) - 1:
                dataset += ', '
        dataset += "]"
        return dataset