fastcore の API リファレンス
fastcore (AnswerDotAI/fastcore) の公開 API 187 件 —— クラス 30、関数 155、メソッド 2。実際のソースを静的解析して抽出した正確なシグネチャを掲載しています。
リポジトリ: AnswerDotAI/fastcore
| 種別 | 件数 |
|---|---|
| クラス | 30 |
| 関数 | 155 |
| メソッド | 2 |
API 一覧
class
fastcore.aio.CachedAwaitableCache the result from an awaitable
func
fastcore.aio.acache(f)Cache results of async function `f`
func
fastcore.aio.disable_async_magics(ip)Undo `enable_async_magics` on `ip`
func
fastcore.aio.maybe_await(o)Await `o` if needed, and return it
func
fastcore.aio.noopa(x=None, *args, **kwargs)Do nothing (async)
func
fastcore.ansi.ansi2html(text)Convert ANSI colors to HTML colors.
func
fastcore.ansi.ansi2latex(text)Convert ANSI colors to LaTeX colors.
func
fastcore.ansi.strip_ansi(source, term_queries:bool=False)Remove ANSI escape codes from text.
func
fastcore.apisurface.snake(s:str)Convert an identifier-ish string to snake_case.
class
fastcore.basics.BasicReprBase class for objects needing a basic `__repr__`
class
fastcore.basics.DepPropProperty decorator with dependency update triggering
class
fastcore.basics.FloatAn extensible `float`
class
fastcore.basics.GetAttrBaseBasic delegation of `__getattr__` and `__dir__`
class
fastcore.basics.ImportEnumAn `Enum` that can have its values imported
class
fastcore.basics.InfInfinite lists
class
fastcore.basics.IntAn extensible `int`
class
fastcore.basics.NotStrBehaves like a `str`, but isn't an instance of one
class
fastcore.basics.PrettyStringLittle hack to get strings to show properly in Jupyter.
class
fastcore.basics.ShowPrintBase class that prints for `show`
class
fastcore.basics.StrAn extensible `str`
class
fastcore.basics.StrEnumAn `ImportEnum` that behaves like a `str`
class
fastcore.basics.ValEnumAn `ImportEnum` that stringifies using values
class
fastcore.basics.adict`dict` subclass that also provides access to keys as attrs
func
fastcore.basics.anno_ret(func)Get the return annotation of `func`
func
fastcore.basics.annotations(o)Annotations for `o`, or `type(o)`
func
fastcore.basics.basic_repr(flds=None)Minimal `__repr__`
func
fastcore.basics.camel2snake(name)Convert CamelCase to snake_case
func
fastcore.basics.camel2words(s, space=' ')Convert CamelCase to 'spaced words'
func
fastcore.basics.compile_re(pat)Compile `pat` if it's not None
func
fastcore.basics.concat(colls) -> listConcatenate all collections and items as a list
func
fastcore.basics.getattrs(o, *default=None, *attrs)List of all `attrs` in `o`
func
fastcore.basics.getcallable(o, attr)Calls `getattr` with a default of `noop`
func
fastcore.basics.hasattrs(o, attrs)Test whether `o` contains all `attrs`
func
fastcore.basics.humanize(x)Concise human-readable `x`, e.g.
func
fastcore.basics.ifnone(a, b)`b` if `a` is None else `a`
class
fastcore.basics.ignore_exceptionsContext manager to ignore exceptions
func
fastcore.basics.in_(x, a)`True` if `x in a`
func
fastcore.basics.is_array(x)`True` if `x` supports `__array__` or `iloc`
func
fastcore.basics.joins(sep, its)Sugar for `sep.join(map(str, its))`
func
fastcore.basics.listify(o=None, *use_list=False, *match=None, *rest)Convert `o` to a `list`
func
fastcore.basics.mapt(func, *iterables)Tuplified `map`
func
fastcore.basics.maybe_attr(o, attr)`getattr(o,attr,o)`
func
fastcore.basics.merge(*ds)Merge all dictionaries in `ds`
func
fastcore.basics.negate(f)Returns the negation of `f`
func
fastcore.basics.num_cpus()Get number of cpus
func
fastcore.basics.otherwise(x, tst, y)`y if tst(x) else x`
func
fastcore.basics.partition(coll, f)Partition a collection by a predicate
func
fastcore.basics.range_of(x)All indices of collection `x` (i.e.
func
fastcore.basics.ret_false(*args, **kwargs)Predicate: always `False`
func
fastcore.basics.ret_true(*args, **kwargs)Predicate: always `True`
func
fastcore.basics.risinstance(types, obj=None)Curried `isinstance` but with args reversed
func
fastcore.basics.set_nested_idx(coll, value, *idxs)Set value indexed like `nested_idx
func
fastcore.basics.setify(o)Turn any list like-object into a set.
func
fastcore.basics.snake2camel(s)Convert snake_case to CamelCase
func
fastcore.basics.str2date(s:str) -> date`date.fromisoformat` with empty string handling
func
fastcore.basics.str2dt(s:str) -> datetime`datetime.fromisoformat` with `Z` suffix and empty string handling
func
fastcore.basics.str2float(s:str)Convert `s` to a float
func
fastcore.basics.str2int(s) -> intConvert `s` to an `int`
func
fastcore.basics.str2list(s:str)Convert `s` to a list
func
fastcore.basics.str_enum(name, *vals)Simplified creation of `StrEnum` types
func
fastcore.basics.strcat(its, sep:str='') -> strConcatenate stringified items `its`
func
fastcore.basics.tonull(x)Convert `None` to `null`
func
fastcore.basics.try_attrs(obj, *attrs)Return first attr that exists in `obj`
func
fastcore.basics.tuplify(o, use_list=False, match=None)Make `o` a tuple
func
fastcore.basics.val2idx(x)Dict from value to index
class
fastcore.docments.MarkdownRendererMarkdown renderer for `show_doc`
func
fastcore.docments.docments(s, full=False, eval_str=False, returns=True, args_kwargs=False)Get docments for `s`
func
fastcore.docments.get_dataclass_source(s)Get source code for dataclass `s`
func
fastcore.docments.get_name(obj)Get the name of `obj`
func
fastcore.docments.parse_docstring(sym)Parse a numpy-style docstring in `sym`
func
fastcore.docments.qual_name(obj)Get the qualified name of `obj`
class
fastcore.docscrape.NumpyDocStringParses a numpydoc string to an abstract representation
class
fastcore.docscrape.ReaderA line-based string reader.
func
fastcore.docscrape.dedent_lines(lines, split=True)Deindent a list of lines maximally
class
fastcore.foundation.CollBaseBase class for composing a list of `items`
class
fastcore.foundation.LBehaves like a list of `items` but can also index with list of indices or masks
func
fastcore.foundation.accumulate(self:L, f=operator.add, initial=None)Same as `itertools.accumulate`
func
fastcore.foundation.argfirst(self:L, f, negate=False)Return index of first matching item
func
fastcore.foundation.combinations(self:L, r)Same as `itertools.combinations`
func
fastcore.foundation.compress(self:L, selectors)Same as `itertools.compress`
func
fastcore.foundation.concat(self:L)Concatenate all elements of list
func
fastcore.foundation.copy(self:L)Same as `list.copy`, but returns an `L`
func
fastcore.foundation.dropwhile(self:L, f)Same as `itertools.dropwhile`
func
fastcore.foundation.enumerate(self:L)Same as `enumerate`
func
fastcore.foundation.first(self:L, f, negate=False)Return first matching item
func
fastcore.foundation.flatten(self:L)Recursively flatten nested iterables (except strings)
func
fastcore.foundation.groupby(self:L, key, val=noop)Same as `fastcore.basics.groupby`
func
fastcore.foundation.is_bool(x)Check whether `x` is a bool or None
func
fastcore.foundation.itemgot(self:L, *idxs)Create new `L` with item `idx` of all `items`
func
fastcore.foundation.last(self:L, f, negate=False)Return last matching item
func
fastcore.foundation.map_first(self:L, f=noop, g=noop, *args, **kwargs)First element of `map_filter`
func
fastcore.foundation.pairwise(self:L)Same as `itertools.pairwise`
func
fastcore.foundation.permutations(self:L, r=None)Same as `itertools.permutations`
func
fastcore.foundation.range(cls:L, a, b=None, step=None)Class Method: Same as `range`, but returns `L`.
func
fastcore.foundation.reduce(self:L, f, initial=None)Wrapper for `functools.reduce`
func
fastcore.foundation.renumerate(self:L)Same as `renumerate`
func
fastcore.foundation.setattrs(self:L, attr, val)Call `setattr` on all items
func
fastcore.foundation.shuffle(self:L)Same as `random.shuffle`, but not inplace
func
fastcore.foundation.sorted(self:L, key=None, reverse=False, cmp=None, **kwargs)New `L` sorted by `key`, using `sort_ex`.
func
fastcore.foundation.split(cls:L, s, sep=None, maxsplit=-1)Class Method: Same as `str.split`, but returns an `L`
func
fastcore.foundation.sum(self:L)Sum of the items
func
fastcore.foundation.takewhile(self:L, f)Same as `itertools.takewhile`
func
fastcore.foundation.unique(self:L, sort=False, bidir=False, start=None)Unique items, in stable order
func
fastcore.foundation.val2idx(self:L)Dict from value to index
func
fastcore.foundation.zip(self:L, cycled=False)Create new `L` with `zip(*items)`
func
fastcore.funccall.get_schema(f:Union[callable, dict], pname='input_schema', evalable=False, skip_hidden=False, name=None) -> dictGenerate JSON schema for a class, function, or method
func
fastcore.imports.is_coll(o)Test whether `o` is a collection (i.e.
func
fastcore.imports.is_iter(o)Test whether `o` can be used in a `for` loop
func
fastcore.imports.noop(x=None, *args, **kwargs)Do nothing
func
fastcore.imports.noops(self, x=None, *args, **kwargs)Do nothing (method)
func
fastcore.imports.remove_prefix(text, prefix)Temporary until py39 is a prereq
func
fastcore.imports.remove_suffix(text, suffix)Temporary until py39 is a prereq
class
fastcore.meta.NewChkMetaMetaclass to avoid recreating object passed to constructor
func
fastcore.meta.empty2none(p)Replace `Parameter.empty` with `None`
func
fastcore.meta.method(f)Mark `f` as a method
class
fastcore.nbio.NotebookRead, query, and edit Jupyter notebooks
func
fastcore.nbio.cell2xml(cell, ids=True, incl_out=True)Convert NbCell to concise XML format
func
fastcore.nbio.deep_merge(d:dict, u:dict)Copy of `d` updated by `u`
func
fastcore.nbio.dict2nb(js=None, **kwargs)Convert dict `js` to an `AttrDict`,
func
fastcore.nbio.mk_cell(text, cell_type='code', **kwargs)Create an `NbCell` containing `text`
func
fastcore.nbio.mk_stream(name, text)Helper to create an output stream dict
func
fastcore.nbio.nb2dict(d, k=None)Convert parsed notebook to `dict`
func
fastcore.nbio.nb2str(nb)Convert `nb` to a `str`
func
fastcore.nbio.new_nb(cells=None, meta=None, nbformat=4, nbformat_minor=5)Returns an empty new notebook
func
fastcore.nbio.read_nb(path)Return notebook at `path` (expands `~`)
func
fastcore.nbio.summary(self:Notebook, maxlen=120)One `CellRow` line per cell
func
fastcore.nbio.write_nb(nb, path)Write `nb` to `path` (expands `~`)
func
fastcore.net.is_port_free(port, host='localhost')Is `port` free on `host`?
func
fastcore.net.tobytes(s:str) -> bytesConvert `s` into HTTP-ready bytes format
func
fastcore.net.urljson(url, data=None, headers=None, timeout=None)Retrieve `url` and decode json
func
fastcore.net.urlvalid(x)Test if `x` is a valid URL
func
fastcore.net.waitfor_async(f, timeout=20, msg=None)Async version of `waitfor`
func
fastcore.py2pyi.has_deco(node:Union[ast.FunctionDef, ast.AsyncFunctionDef], name:str) -> boolCheck if a function node `node` has a decorator named `name`
func
fastcore.script.args_from_prog(func, prog)Extract args from `prog`
class
fastcore.style.StyleA minimal terminal text styler.
class
fastcore.style.StyleCodeAn escape sequence for styling terminal text.
class
fastcore.test.ExceptionExpectedContext manager that tests if an exception is raised.
func
fastcore.test.is_close(a, b, eps=1e-05)Is `a` within `eps` of `b`
func
fastcore.test.nequals(a, b)Compares `a` and `b` for `not equals`
func
fastcore.tools.create_file(path:str, contents:str, overwrite:bool=False)Create a new file with contents.
func
fastcore.tools.insert_line(text:str, insert_line:int, new_str:str)Insert new_str at specified line number
func
fastcore.tools.line_hash(line:str) -> str4-char hex hash of `line`
func
fastcore.tools.lnhash(lineno:int, line:str) -> str`lineno|hash|` exhash address for `line` at `lineno`
func
fastcore.tools.lnhash_at(s:str | list | tuple, line:int) -> str`lineno|hash|` exhash address of line `line` of `s`
func
fastcore.xdg.xdg_cache_home()Path corresponding to `XDG_CACHE_HOME`
func
fastcore.xdg.xdg_config_dirs()Paths corresponding to `XDG_CONFIG_DIRS`
func
fastcore.xdg.xdg_config_home()Path corresponding to `XDG_CONFIG_HOME`
func
fastcore.xdg.xdg_data_dirs()Paths corresponding to XDG_DATA_DIRS`
func
fastcore.xdg.xdg_data_home()Path corresponding to `XDG_DATA_HOME`
func
fastcore.xdg.xdg_runtime_dir()Path corresponding to `XDG_RUNTIME_DIR`
func
fastcore.xdg.xdg_state_home()Path corresponding to `XDG_STATE_HOME`
class
fastcore.xml.FTA 'Fast Tag' structure, containing `tag`,`children`,and `attrs`
method
fastcore.xml.FT.set(*c, **kw)Set children and/or attributes (chainable)
func
fastcore.xml.Html(*doctype=True, *c, **kwargs) -> FTAn HTML tag, optionally preceeded by `!DOCTYPE HTML`
func
fastcore.xml.ft(tag:str, *void_:bool=False, *attrmap:callable=attrmap, *valmap:callable=valmap, *ft_cls=FT, *c, **kw)Create an `FT` structure for `to_xml()`
class
fastcore.xtras.CachedIterCache the result returned by an iterator
class
fastcore.xtras.ConfigReading and writing `ConfigParser` ini files
class
fastcore.xtras.EventTimerAn event timer with history of `store` items of time `span`
method
fastcore.xtras.EventTimer.add(n=1)Record `n` events
func
fastcore.xtras.asave_iter(g)Like `save_iter`, but for async iterators
func
fastcore.xtras.console_help(libname:str)Show help for all console scripts from `libname`
func
fastcore.xtras.delete(self:Path)Delete a file, symlink, or directory tree
func
fastcore.xtras.flexiclass(cls) -> dataclassConvert `cls` into a `dataclass` like `make_nullable`.
func
fastcore.xtras.get_source_link(func)Return link to `func` in source code
func
fastcore.xtras.hl_md(s, lang='html', show=True)Syntax highlight `s` using `lang`.
func
fastcore.xtras.is_namedtuple(cls)`True` if `cls` is a namedtuple type
func
fastcore.xtras.is_typeddict(cls:type) -> boolCheck if `cls` is a `TypedDict`
func
fastcore.xtras.load_mod(name, path)Load module `name` from file `path`
func
fastcore.xtras.loads(s, **kw)Same as `json.loads`, but handles `None`
func
fastcore.xtras.local2utc(dt:datetime) -> datetimeConvert `dt` from local to UTC time
func
fastcore.xtras.ls(self:Path, n_max=None, file_type=None, file_exts=None)Contents of path as a list
func
fastcore.xtras.modify_exception(e:Exception, msg:str=None, replace:bool=False) -> ExceptionModifies `e` with a custom message attached
func
fastcore.xtras.normpath(self:Path)Normalize path, eliminating double slashes, etc.
func
fastcore.xtras.parse_env(s:str=None, fn:Union[str, Path]=None) -> dictParse a shell-style environment string or file
func
fastcore.xtras.pglob(path:Path | str='.', func:callable=Path, **kwargs) -> LShortcut for `globtastic(..., call=Path)`
func
fastcore.xtras.read_json(self:Path, encoding=None, errors=None)Same as `read_text` followed by `loads`
func
fastcore.xtras.readlines(self:Path, hint=-1, encoding='utf8')Read the content of `self`
func
fastcore.xtras.rtoken_hex(nbytes:int=16) -> strGenerate a random hex string using Python's random module.
func
fastcore.xtras.shell(*args, **kwargs)Shortcut for `subprocess.run(shell=True)`
func
fastcore.xtras.ssh(host, args='', user='ubuntu', sock=None)Run SSH command with given arguments
func
fastcore.xtras.str_diff(a:str, b:str, n:int=1, names:tuple=None) -> strUnified diff of `a` and `b`
func
fastcore.xtras.stringfmt_names(s:str) -> listUnique brace-delimited names in `s`
func
fastcore.xtras.trace(f)Add `set_trace` to an existing function `f`
func
fastcore.xtras.type2str(typ:type) -> strStringify `typ`
func
fastcore.xtras.utc2local(dt:datetime) -> datetimeConvert `dt` from UTC to local time
func
fastcore.xtras.vars_pub(x)Get public non-skipped vars
func
fastcore.xtras.write_json(self:Path, data, encoding=None, errors=None, mode=511, uid=-1, gid=-1, **kw)Same as `dumps`followed by `mk_write`
この情報について
掲載しているシグネチャは AnswerDotAI/fastcore の公開ソースコードを
Python の ast モジュールで静的解析し、引数名・デフォルト値・
型注釈・戻り値型をそのまま抽出したものです。実装コードは保存していません。
詳しくは仕組みの解説をご覧ください。