imports
is_iter
def is_iter(
o
):
Test whether o can be used in a for loop
is_coll
def is_coll(
o
):
Test whether o is a collection (i.e. has a usable len)
all_equal
def all_equal(
a, b
):
Compares whether a and b are the same length and have the same contents
noop
def noop(
x=None, *args, **kwargs
):
Do nothing
noops
def noops(
x=None, *args, **kwargs
):
Do nothing (method)
any_is_instance
def any_is_instance(
t, *args
):
isinstance_str
def isinstance_str(
x, cls_name
):
Like isinstance, except takes a type name instead of a type
array_equal
def array_equal(
a, b
):
df_equal
def df_equal(
a, b
):
equals
def equals(
a, b
):
Compares a and b for equality; supports sublists, tensors and arrays too
ipython_shell
def ipython_shell():
Same as get_ipython but returns False if not in IPython
in_ipython
def in_ipython():
Check if code is running in some kind of IPython environment
in_colab
def in_colab():
Check if the code is running in Google Colaboratory
in_jupyter
def in_jupyter():
Check if the code is running in a jupyter notebook
in_notebook
def in_notebook():
Check if the code is running in a jupyter notebook
remove_prefix
def remove_prefix(
text, prefix
):
Temporary until py39 is a prereq
remove_suffix
def remove_suffix(
text, suffix
):
Temporary until py39 is a prereq
is_usable_tool
def is_usable_tool(
func:<built-in function callable>
):
True if the function has a docstring and all parameters have types, meaning that it can be used as an LLM tool.
llmtool
def llmtool(
f=None, **tmpls
):
Decorator to mark a function as an LLM tool. Pass **tmpls to format the docstring.