>>> ensure_float(None) 0.0 >>> ensure_float(False) 0.0 >>> ensure_float(12) 12.0 >>> ensure_float("72") 72.0
(n)
| 2805 | |
| 2806 | |
| 2807 | def ensure_float(n): |
| 2808 | """ |
| 2809 | >>> ensure_float(None) |
| 2810 | 0.0 |
| 2811 | >>> ensure_float(False) |
| 2812 | 0.0 |
| 2813 | >>> ensure_float(12) |
| 2814 | 12.0 |
| 2815 | >>> ensure_float("72") |
| 2816 | 72.0 |
| 2817 | """ |
| 2818 | if not n: |
| 2819 | return 0.0 |
| 2820 | return float(n) |
| 2821 | |
| 2822 | |
| 2823 | def import_cls(cls_info): |