MCPcopy Index your code
hub / github.com/bqplot/bqplot / validate

Method validate

bqplot/traits.py:69–83  ·  view source on GitHub ↗
(self, obj, value)

Source from the content-addressed store, hash-verified

67 """
68
69 def validate(self, obj, value):
70 try:
71 if isinstance(value, dt.datetime):
72 return value
73 if isinstance(value, dt.date):
74 return dt.datetime(value.year, value.month, value.day)
75 if np.issubdtype(np.dtype(value), np.datetime64):
76 # TODO: Fix this. Right now, we have to limit the precision
77 # of time to microseconds because np.datetime64.astype(datetime)
78 # returns date values only for precision <= 'us'
79 value_truncated = np.datetime64(value, 'us')
80 return value_truncated.astype(dt.datetime)
81 except Exception:
82 self.error(obj, value)
83 self.error(obj, value)
84
85 def __init__(self, default_value=dt.datetime.today(), **kwargs):
86 super(Date, self).__init__(default_value=default_value, **kwargs)

Callers 1

_draw_markFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected