{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Basic core" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This module contains all the basic functions we need in other modules of the fastai library (split with [`torch_core`](/torch_core.html#torch_core) that contains the ones requiring pytorch). Its documentation can easily be skipped at a first read, unless you want to know what a given function does." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "hide_input": true }, "outputs": [], "source": [ "from fastai.gen_doc.nbdoc import *\n", "from fastai.core import * " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Global constants" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`default_cpus = min(16, num_cpus())`
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Check functions" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "hide_input": true }, "outputs": [ { "data": { "text/markdown": [ "has_arg
[source][test]has_arg
(**`func`**, **`arg`**) → `bool`\n",
"\n",
"No tests found for has_arg
. To contribute a test please refer to this guide and this discussion.
ifnone
[source][test]ifnone
(**`a`**:`Any`, **`b`**:`Any`) → `Any`\n",
"\n",
"is1d
[source][test]is1d
(**`a`**:`Collection`\\[`T_co`\\]) → `bool`\n",
"\n",
"is_listy
[source][test]is_listy
(**`x`**:`Any`) → `bool`\n",
"\n",
"is_tuple
[source][test]is_tuple
(**`x`**:`Any`) → `bool`\n",
"\n",
"arange_of
[source][test]arange_of
(**`x`**)\n",
"\n",
"No tests found for arange_of
. To contribute a test please refer to this guide and this discussion.
array
[source][test]array
(**`a`**, **`dtype`**:`type`=***`None`***, **\\*\\*`kwargs`**) → `ndarray`\n",
"\n",
"Tests found for array
:
Some other tests where array
is used:
pytest -sv tests/test_core.py::test_arrays_split
[source]pytest -sv tests/test_core.py::test_even_mults
[source]pytest -sv tests/test_core.py::test_idx_dict
[source]pytest -sv tests/test_core.py::test_is1d
[source]pytest -sv tests/test_core.py::test_itembase_eq
[source]pytest -sv tests/test_core.py::test_itembase_hash
[source]pytest -sv tests/test_core.py::test_one_hot
[source]pytest -sv tests/test_torch_core.py::test_model_type
[source]pytest -sv tests/test_torch_core.py::test_tensor_array_monkey_patch
[source]pytest -sv tests/test_torch_core.py::test_tensor_with_ndarray
[source]pytest -sv tests/test_torch_core.py::test_to_detach
[source]To run tests please refer to this guide.
arrays_split
[source][test]arrays_split
(**`mask`**:`ndarray`, **\\*`arrs`**:`NPArrayableList`) → `SplitArrayList`\n",
"\n",
"chunks
[source][test]chunks
(**`l`**:`Collection`\\[`T_co`\\], **`n`**:`int`) → `Iterable`\n",
"\n",
"df_names_to_idx
[source][test]df_names_to_idx
(**`names`**:`IntsOrStrs`, **`df`**:`DataFrame`)\n",
"\n",
"extract_kwargs
[source][test]extract_kwargs
(**`names`**:`StrList`, **`kwargs`**:`KWArgs`)\n",
"\n",
"No tests found for extract_kwargs
. To contribute a test please refer to this guide and this discussion.
idx_dict
[source][test]idx_dict
(**`a`**)\n",
"\n",
"index_row
[source][test]index_row
(**`a`**:`Union`\\[`Collection`\\[`T_co`\\], `DataFrame`, `Series`\\], **`idxs`**:`Collection`\\[`int`\\]) → `Any`\n",
"\n",
"No tests found for index_row
. To contribute a test please refer to this guide and this discussion.
\n", " | 0 | \n", "1 | \n", "
---|---|---|
0 | \n", "9 | \n", "0 | \n", "
1 | \n", "8 | \n", "1 | \n", "
2 | \n", "7 | \n", "2 | \n", "
3 | \n", "6 | \n", "3 | \n", "
4 | \n", "5 | \n", "4 | \n", "
5 | \n", "4 | \n", "5 | \n", "
6 | \n", "3 | \n", "6 | \n", "
7 | \n", "2 | \n", "7 | \n", "
8 | \n", "1 | \n", "8 | \n", "
9 | \n", "0 | \n", "9 | \n", "
listify
[source][test]listify
(**`p`**:`OptListOrItem`=***`None`***, **`q`**:`OptListOrItem`=***`None`***)\n",
"\n",
"random_split
[source][test]random_split
(**`valid_pct`**:`float`, **\\*`arrs`**:`NPArrayableList`) → `SplitArrayList`\n",
"\n",
"range_of
[source][test]range_of
(**`x`**)\n",
"\n",
"No tests found for range_of
. To contribute a test please refer to this guide and this discussion.
series2cat
[source][test]series2cat
(**`df`**:`DataFrame`, **\\*`col_names`**)\n",
"\n",
"\n", " | a | \n", "b | \n", "
---|---|---|
0 | \n", "1 | \n", "f | \n", "
1 | \n", "1 | \n", "e | \n", "
2 | \n", "1 | \n", "f | \n", "
3 | \n", "2 | \n", "g | \n", "
4 | \n", "2 | \n", "g | \n", "
5 | \n", "2 | \n", "g | \n", "
split_kwargs_by_func
[source][test]split_kwargs_by_func
(**`kwargs`**, **`func`**)\n",
"\n",
"No tests found for split_kwargs_by_func
. To contribute a test please refer to this guide and this discussion.
to_int
[source][test]to_int
(**`b`**:`Any`) → `Union`\\[`int`, `List`\\[`int`\\]\\]\n",
"\n",
"uniqueify
[source][test]uniqueify
(**`x`**:`Series`, **`sort`**:`bool`=***`False`***) → `List`\\[`T`\\]\n",
"\n",
"class
PrePostInitMeta
[source][test]PrePostInitMeta
(**`name`**, **`bases`**, **`dct`**) :: `type`\n",
"\n",
"No tests found for PrePostInitMeta
. To contribute a test please refer to this guide and this discussion.
download_url
[source][test]download_url
(**`url`**:`str`, **`dest`**:`str`, **`overwrite`**:`bool`=***`False`***, **`pbar`**:`ProgressBar`=***`None`***, **`show_progress`**=***`True`***, **`chunk_size`**=***`1048576`***, **`timeout`**=***`4`***, **`retries`**=***`5`***)\n",
"\n",
"find_classes
[source][test]find_classes
(**`folder`**:`Path`) → `FilePathList`\n",
"\n",
"join_path
[source][test]join_path
(**`fname`**:`PathOrStr`, **`path`**:`PathOrStr`=***`'.'`***) → `Path`\n",
"\n",
"join_paths
[source][test]join_paths
(**`fnames`**:`FilePathList`, **`path`**:`PathOrStr`=***`'.'`***) → `FilePathList`\n",
"\n",
"loadtxt_str
[source][test]loadtxt_str
(**`path`**:`PathOrStr`) → `ndarray`\n",
"\n",
"No tests found for loadtxt_str
. To contribute a test please refer to this guide and this discussion.
save_texts
[source][test]save_texts
(**`fname`**:`PathOrStr`, **`texts`**:`StrList`)\n",
"\n",
"No tests found for save_texts
. To contribute a test please refer to this guide and this discussion.
num_cpus
[source][test]num_cpus
() → `int`\n",
"\n",
"parallel
[source][test]parallel
(**`func`**, **`arr`**:`Collection`\\[`T_co`\\], **`max_workers`**:`int`=***`None`***, **`leave`**=***`False`***)\n",
"\n",
"No tests found for parallel
. To contribute a test please refer to this guide and this discussion.
partition
[source][test]partition
(**`a`**:`Collection`\\[`T_co`\\], **`sz`**:`int`) → `List`\\[`Collection`\\[`T_co`\\]\\]\n",
"\n",
"partition_by_cores
[source][test]partition_by_cores
(**`a`**:`Collection`\\[`T_co`\\], **`n_cpus`**:`int`) → `List`\\[`Collection`\\[`T_co`\\]\\]\n",
"\n",
"No tests found for partition_by_cores
. To contribute a test please refer to this guide and this discussion.
class
ItemBase
[source][test]ItemBase
(**`data`**:`Any`)\n",
"\n",
"apply_tfms
[source][test]apply_tfms
(**`tfms`**:`Collection`\\[`T_co`\\], **\\*\\*`kwargs`**)\n",
"\n",
"No tests found for apply_tfms
. To contribute a test please refer to this guide and this discussion.
show
[source][test]show
(**`ax`**:`Axes`, **\\*\\*`kwargs`**)\n",
"\n",
"No tests found for show
. To contribute a test please refer to this guide and this discussion.
class
Category
[source][test]Category
(**`data`**, **`obj`**) :: [`ItemBase`](/core.html#ItemBase)\n",
"\n",
"class
EmptyLabel
[source][test]EmptyLabel
() :: [`ItemBase`](/core.html#ItemBase)\n",
"\n",
"No tests found for EmptyLabel
. To contribute a test please refer to this guide and this discussion.
class
MultiCategory
[source][test]MultiCategory
(**`data`**, **`obj`**, **`raw`**) :: [`ItemBase`](/core.html#ItemBase)\n",
"\n",
"class
FloatItem
[source][test]FloatItem
(**`obj`**) :: [`ItemBase`](/core.html#ItemBase)\n",
"\n",
"camel2snake
[source][test]camel2snake
(**`name`**:`str`) → `str`\n",
"\n",
"even_mults
[source][test]even_mults
(**`start`**:`float`, **`stop`**:`float`, **`n`**:`int`) → `ndarray`\n",
"\n",
"func_args
[source][test]func_args
(**`func`**) → `bool`\n",
"\n",
"No tests found for func_args
. To contribute a test please refer to this guide and this discussion.
noop
[source][test]noop
(**`x`**)\n",
"\n",
"one_hot
[source][test]one_hot
(**`x`**:`Collection`\\[`int`\\], **`c`**:`int`)\n",
"\n",
"show_some
[source][test]show_some
(**`items`**:`Collection`\\[`T_co`\\], **`n_max`**:`int`=***`5`***, **`sep`**:`str`=***`','`***)\n",
"\n",
"No tests found for show_some
. To contribute a test please refer to this guide and this discussion.
subplots
[source][test]subplots
(**`rows`**:`int`, **`cols`**:`int`, **`imgsize`**:`int`=***`4`***, **`figsize`**:`Optional`\\[`Tuple`\\[`int`, `int`\\]\\]=***`None`***, **`title`**=***`None`***, **\\*\\*`kwargs`**)\n",
"\n",
"text2html_table
[source][test]text2html_table
(**`items`**:`Tokens`) → `str`\n",
"\n",
"No tests found for text2html_table
. To contribute a test please refer to this guide and this discussion.
is_dict
[source][test]is_dict
(**`x`**:`Any`) → `bool`\n",
"\n",
"