class_docstr: A trait that accepts either a numpy array, or an NDArrayWidget reference.
  
  Also constrains the use of 64-bit arrays, as this is not supported by WebGL.
class_docstr_tok: ["A","trait","that","accepts","either","a","numpy","array",",","or","an","NDArrayWidget","reference",".","Also","constrains","the","use","of","64-bit","arrays",",","as","this","is","not","supported","by","WebGL","."]
code: def validate(self, obj, value):
      was_original_array = isinstance(value, np.ndarray)
      value = super(WebGLDataUnion, self).validate(obj, value)
      array = value.array if isinstance(value, NDArrayWidget) else value
  
      dtype_str = str(array.dtype) if array is not Undefined else ""
      if dtype_str == "float64" or dtype_str.endswith("int64"):
          if isinstance(value, NDArrayWidget):
              raise TraitError(
                  "Cannot use a %s data widget as a WebGL source."
                  % (dtype_str,)
              )
          else:
              # 64-bit not supported, coerce to 32-bit
              # If original was another array, warn about casting,
              # as it might otherwise silently increase memory usage:
              if was_original_array:
                  warnings.warn(
                      "64-bit data types not supported for WebGL "
                      "data, casting to 32-bit."
                  )
              value = value.astype(dtype_str.replace("64", "32"))
      return value
  
imports: from collections import namedtuple
  from collections.abc import Sequence
  import numbers
  import math
  import re
  import warnings
  from traitlets import Unicode, Int, CInt, Instance, Enum, List, Dict, Float, CFloat, Bool, Tuple, Undefined, TraitError, Union, TraitType, CaselessStrEnum
  from ipywidgets import widget_serialization
  from ipydatawidgets import DataUnion, NDArrayWidget, shape_constraints
  import numpy
label_desc: Use image node_id 1 for calling the WebGLDataUnion obj's underlying member method code with example usage: obj.validate(obj, value) and returns: value