Check whether object is a number or not, include numpy number, etc.
(obj)
| 46 | |
| 47 | |
| 48 | def is_numeric(obj): |
| 49 | """Check whether object is a number or not, include numpy number, etc.""" |
| 50 | try: |
| 51 | float(obj) |
| 52 | return True |
| 53 | except (TypeError, ValueError): |
| 54 | # TypeError: obj is not a string or a number |
| 55 | # ValueError: invalid literal |
| 56 | return False |
| 57 | |
| 58 | |
| 59 | def is_numpy_1d_array(data): |
no outgoing calls
no test coverage detected