MCPcopy Index your code
hub / github.com/plotly/plotly.py / encode_as_numpy

Method encode_as_numpy

_plotly_utils/utils.py:287–301  ·  view source on GitHub ↗

Attempt to convert numpy.ma.core.masked

(obj)

Source from the content-addressed store, hash-verified

285
286 @staticmethod
287 def encode_as_numpy(obj):
288 """Attempt to convert numpy.ma.core.masked"""
289 numpy = get_module("numpy", should_load=False)
290 if not numpy:
291 raise NotEncodable
292
293 if obj is numpy.ma.core.masked:
294 return float("nan")
295 elif isinstance(obj, numpy.ndarray) and obj.dtype.kind == "M":
296 try:
297 return numpy.datetime_as_string(obj).tolist()
298 except TypeError:
299 pass
300
301 raise NotEncodable
302
303 @staticmethod
304 def encode_as_datetime(obj):

Callers 1

test_encode_as_numpyMethod · 0.80

Calls 2

get_moduleFunction · 0.90
tolistMethod · 0.80

Tested by 1

test_encode_as_numpyMethod · 0.64