Type | Default | Details | |
---|---|---|---|
precision | int | 3 | Digits after . |
threshold_max | int | 3 | .abs() larger than 1e3 -> Sci mode |
threshold_min | int | -4 | .abs() smaller that 1e-4 -> Sci mode |
sci_mode | NoneType | None | Sci mode (2.3e4). None=auto |
show_mem_above | int | 1024 | Show memory usage in b/Kb/Mb/Gb if itβs larger than this |
indent | int | 2 | Indent for .deeper() |
color | bool | True | ANSI colors in text |
deeper_width | int | 9 | For .deeper, width per level |
plt_seed | int | 42 | Sampling seed for plot |
fig_close | bool | True | Close matplotlib Figure |
fig_show | bool | False | Call plt.show() for .plt , .chans and .rgb |
π€ Config
Defaults:
set_config
set_config (precision:Union[~Default,int,NoneType]=Ignore, threshold_min:Union[~Default,int,NoneType]=Ignore, threshold_max:Union[~Default,int,NoneType]=Ignore, sci_mode:Union[~Default,bool,NoneType]=Ignore, show_mem_above:Union[~Default,bool,NoneType]=Ignore, indent:Union[~Default,bool,NoneType]=Ignore, color:Union[~Default,bool,NoneType]=Ignore, deeper_width:Union[~Default,int,NoneType]=Ignore, repr:Union[~Default,Callable,NoneType]=Ignore, str:Union[~Default,Callable,NoneType]=Ignore, plt_seed:Union[~Default,int,NoneType]=Ignore, fig_close:Union[~Default,bool,NoneType]=Ignore, fig_show:Union[~Default,bool,NoneType]=Ignore)
Set config variables
get_config
get_config ()
Get a copy of config variables
config
config (precision:Union[~Default,int,NoneType]=Ignore, threshold_min:Union[~Default,int,NoneType]=Ignore, threshold_max:Union[~Default,int,NoneType]=Ignore, sci_mode:Union[~Default,bool,NoneType]=Ignore, show_mem_above:Union[~Default,bool,NoneType]=Ignore, indent:Union[~Default,bool,NoneType]=Ignore, color:Union[~Default,bool,NoneType]=Ignore, deeper_width:Union[~Default,int,NoneType]=Ignore, repr:Union[~Default,Callable,NoneType]=Ignore, str:Union[~Default,Callable,NoneType]=Ignore, plt_seed:Union[~Default,int,NoneType]=Ignore, fig_close:Union[~Default,bool,NoneType]=Ignore, fig_show:Union[~Default,bool,NoneType]=Ignore)
Context manager for temporarily setting config options
Examples
from lovely_numpy import lo, lovely, set_config, get_config, config
Precision
=5)
set_config(precision1., 2, 3])) lo(np.array([
array[3] xβ[1.00000, 3.00000] ΞΌ=2.00000 Ο=0.81650 [1.00000, 2.00000, 3.00000]
Scientific mode
=True) # Force always on
set_config(sci_mode1., 2, 3])) lo(np.array([
array[3] xβ[1.00000e+00, 3.00000e+00] ΞΌ=2.00000e+00 Ο=8.16497e-01 [1.00000e+00, 2.00000e+00, 3.00000e+00]
Color on/off
=False) # Force always off
set_config(color lo(np.array(np.nan))
array NaN! nan
In-memory size of data
=1024)
set_config(show_mem_above100)))) lo(np.array(np.ones((
array[100] xβ[1.00000e+00, 1.00000e+00] ΞΌ=1.00000e+00 Ο=0.
Reser to defaults
=None, sci_mode=None, color=None) set_config(precision
1., 2, np.nan])) lo(np.array([
array[3] ΞΌ=1.500 Ο=0.500 NaN! [1.000, 2.000, nan]
1,2]) np.array([
array([1, 2])
Context manager
with config(sci_mode=True):
print(lo(np.array([1., 2, 3])))
array[3] xβ[1.000e+00, 3.000e+00] ΞΌ=2.000e+00 Ο=8.165e-01 [1.000e+00, 2.000e+00, 3.000e+00]
1., 2, 3])) lo(np.array([
array[3] xβ[1.000, 3.000] ΞΌ=2.000 Ο=0.816 [1.000, 2.000, 3.000]
Matplotlib and seed
= np.random.default_rng(seed=1).normal(size=1000) a
= lo(a).plt() # The figure was closed, it will not be displayed _
=False)
set_config(fig_close= lo(a).plt() # figure was not closed. All figures that are not closed are displayed after the cell runs. _
For performance reasons, .plt
will randomly sample up tp max_s
elements from the data (10k be default).
You can change the seed used for this sampling (42 by default):
=1)
set_config(plt_seed=100) lo(a).plt(max_s
=2)
set_config(plt_seed=100) lo(a).plt(max_s
More details in matplotlib