docstr: Initialize WrapStruct from binary data block
  
  Parameters
  ----------
  binaryblock : {None, string} optional
      binary block to set into object.  By default, None, in
      which case we insert the default empty block
  endianness : {None, '<','>', other endian code} string, optional
      endianness of the binaryblock.  If None, guess endianness
      from the data.
  check : bool, optional
      Whether to check content of binary data in initialization.
      Default is True.
  
  Examples
  --------
  >>> wstr1 = WrapStruct() # a default structure
  >>> wstr1.endianness == native_code
  True
  >>> wstr1['integer']
  array(0, dtype=int16)
  >>> wstr1['integer'] = 1
  >>> wstr1['integer']
  array(1, dtype=int16)
docstr_tok: ["Initialize","WrapStruct","from","binary","data","block","Parameters","--","--","--","--","--","binaryblock",":","{","None",",","string","}","optional","binary","block","to","set","into","object",".","By","default",",","None",",","in","which","case","we","insert","the","default","empty","block","endianness",":","{","None",",","'","<","'",",","'",">","'",",","other","endian","code","}","string",",","optional","endianness","of","the","binaryblock",".","If","None",",","guess","endianness","from","the","data",".","check",":","bool",",","optional","Whether","to","check","content","of","binary","data","in","initialization",".","Default","is","True",".","Examples","--","--","--","--",">",">",">","wstr1","=","WrapStruct","(",")","#","a","default","structure",">",">",">","wstr1.endianness","==","native_code","True",">",">",">","wstr1","[","'integer","'","]","array","(","0",",","dtype=int16",")",">",">",">","wstr1","[","'integer","'","]","=","1",">",">",">","wstr1","[","'integer","'","]","array","(","1",",","dtype=int16",")"]
code: def __init__(self, binaryblock=None, endianness=None, check=True):
      """Initialize WrapStruct from binary data block
  
      Parameters
      ----------
      binaryblock : {None, string} optional
          binary block to set into object.  By default, None, in
          which case we insert the default empty block
      endianness : {None, '<','>', other endian code} string, optional
          endianness of the binaryblock.  If None, guess endianness
          from the data.
      check : bool, optional
          Whether to check content of binary data in initialization.
          Default is True.
  
      Examples
      --------
      >>> wstr1 = WrapStruct() # a default structure
      >>> wstr1.endianness == native_code
      True
      >>> wstr1['integer']
      array(0, dtype=int16)
      >>> wstr1['integer'] = 1
      >>> wstr1['integer']
      array(1, dtype=int16)
      """
      if binaryblock is None:
          self._structarr = self.__class__.default_structarr(endianness)
          return
      # check size
      if len(binaryblock) != self.template_dtype.itemsize:
          raise WrapStructError("Binary block is wrong size")
      wstr = np.ndarray(
          shape=(), dtype=self.template_dtype, buffer=binaryblock
      )
      if endianness is None:
          endianness = self.__class__.guessed_endian(wstr)
      else:
          endianness = endian_codes[endianness]
      if endianness != native_code:
          dt = self.template_dtype.newbyteorder(endianness)
          wstr = np.ndarray(shape=(), dtype=dt, buffer=binaryblock)
      self._structarr = wstr.copy()
      if check:
          self.check_fix()
  
imports: from __future__ import annotations
  import numpy
  from .None import imageglobals
  from .batteryrunners import BatteryRunner
  from .volumeutils import Recoder, endian_codes, native_code, pretty_mapping, swapped_code
label_desc: Use image node_id 1 to create a new WrapStruct object  with example: obj = WrapStruct(binaryblock, endianness, check)