brk-code

fastcore の API リファレンス

fastcore (AnswerDotAI/fastcore) の公開 API 187 件 —— クラス 30、関数 155、メソッド 2。実際のソースを静的解析して抽出した正確なシグネチャを掲載しています。

リポジトリ: AnswerDotAI/fastcore

種別件数
クラス30
関数155
メソッド2

API 一覧

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

収録ライブラリ一覧(全 805 件)へ戻る