4 examples of 'python is nan' in Python

Every line of 'python is nan' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
22def is_nan(builder, z):
23 return builder.fcmp_unordered('uno', z.real, z.imag)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

59def is_scalar_nan(x):
60 """Tests if x is NaN
61 This function is meant to overcome the issue that np.isnan does not allow
62 non-numerical types as input, and that np.nan is not np.float('nan').
63 Parameters
64 ----------
65 x : any type
66 Returns
67 -------
68 boolean
69 Examples
70 --------
71 >>> is_scalar_nan(np.nan)
72 True
73 >>> is_scalar_nan(float("nan"))
74 True
75 >>> is_scalar_nan(None)
76 False
77 >>> is_scalar_nan("")
78 False
79 >>> is_scalar_nan([np.nan])
80 False
81 """
82
83 # convert from numpy.bool_ to python bool to ensure that testing
84 # is_scalar_nan(x) is True does not fail.
85 # Redondant np.floating is needed because numbers can't match np.float32
86 # in python 2.
87 return bool(isinstance(x, (numbers.Real, np.floating)) and np.isnan(x))
82def _is_nan(log):
83 return math.isnan(log.current_row['total_gradient_norm'])
413def test_nan(sentry_init, capture_events):
414 sentry_init()
415 events = capture_events()
416
417 try:
418 nan = float("nan") # noqa
419 1 / 0
420 except Exception:
421 capture_exception()
422
423 (event,) = events
424 frames = event["exception"]["values"][0]["stacktrace"]["frames"]
425 (frame,) = frames
426 assert frame["vars"]["nan"] == "nan"

Related snippets