utils
Utility functions for the figure_resampler submodule.
is_figure(figure)
¶
Check if the figure is a plotly go.Figure or a FigureResampler.
Note
This method does not use isinstance(figure, go.Figure) as this will not work
when go.Figure is decorated (after executing the
register_plotly_resampler
function).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
figure |
Any
|
The figure to check. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the figure is a plotly go.Figure or a FigureResampler. |
Source code in plotly_resampler/figure_resampler/utils.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
is_figurewidget(figure)
¶
Check if the figure is a plotly go.FigureWidget or a FigureWidgetResampler.
Note
This method does not use isinstance(figure, go.FigureWidget) as this will not
work when go.FigureWidget is decorated (after executing the
register_plotly_resampler
function).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
figure |
Any
|
The figure to check. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the figure is a plotly go.FigureWidget or a FigureWidgetResampler. |
Source code in plotly_resampler/figure_resampler/utils.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
is_fr(figure)
¶
Check if the figure is a FigureResampler.
Note
This method will not return True if the figure is a plotly go.Figure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
figure |
Any
|
The figure to check. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the figure is a FigureResampler. |
Source code in plotly_resampler/figure_resampler/utils.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
is_fwr(figure)
¶
Check if the figure is a FigureWidgetResampler.
Note
This method will not return True if the figure is a plotly go.FigureWidget.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
figure |
Any
|
The figure to check. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the figure is a FigureWidgetResampler. |
Source code in plotly_resampler/figure_resampler/utils.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
round_number_str(number)
¶
Round a number to the nearest unit and convert to a string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
number |
float
|
The number to round. |
required |
Returns:
Type | Description |
---|---|
str
|
The rounded number as a string. If the number is == 0, None is returned. |
Source code in plotly_resampler/figure_resampler/utils.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
round_td_str(td)
¶
Round a timedelta to the nearest unit and convert to a string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
td |
pd.Timedelta
|
The timedelta to round. |
required |
Returns:
Type | Description |
---|---|
str
|
The rounded timedelta as a string. If the timedelta is == 0, None is returned. |
See Also
Source code in plotly_resampler/figure_resampler/utils.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
timedelta_to_str(td)
¶
Construct a tight string representation for the given timedelta arg.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
td |
pd.Timedelta
|
The timedelta for which the string representation is constructed |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The tight string bounds of format ‘$d-$h$m$s.$ms’. If the timedelta is negative, the string starts with ‘NEG’. |
Source code in plotly_resampler/figure_resampler/utils.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|