parameters: (wfn_data: Union[str, Dict, Path])
return_statement: return wfn
docstring: r"""Build Wavefunction from data.
  
      Parameters
      ----------
      wfn_data
          If a dict, use data directly. Otherwise, path-like passed to :py:func:`numpy.load`
          to read from disk.
  
      Returns
      -------
      Wavefunction
          A deserialized Wavefunction object
docstring_summary: r"""Build Wavefunction from data.
docstring_tokens: r Build Wavefunction from data .
function: def _core_wavefunction_from_file(wfn_data: Union[str, Dict, Path]) -> core.Wavefunction:
      r"""Build Wavefunction from data.
  
      Parameters
      ----------
      wfn_data
          If a dict, use data directly. Otherwise, path-like passed to :py:func:`numpy.load`
          to read from disk.
  
      Returns
      -------
      Wavefunction
          A deserialized Wavefunction object
  
      """
      # load the wavefunction from file
      if isinstance(wfn_data, dict):
          pass
      elif isinstance(wfn_data, str):
          if not wfn_data.endswith(".npy"):
              wfn_data = wfn_data + ".npy"
          wfn_data = np.load(wfn_data, allow_pickle=True).item()
      else:
          # Could be path-like or file-like, let `np.load` handle it
          wfn_data = np.load(wfn_data, allow_pickle=True).item()
  
      # variable type specific dictionaries to be passed into C++ constructor
      wfn_matrix = wfn_data['matrix']
      wfn_vector = wfn_data['vector']
      wfn_dimension = wfn_data['dimension']
      wfn_int = wfn_data['int']
      wfn_string = wfn_data['string']
      wfn_boolean = wfn_data['boolean']
      wfn_float = wfn_data['float']
      wfn_floatvar = wfn_data['floatvar']
      wfn_matrixarr = wfn_data['matrixarr']
  
      # reconstruct molecule from dictionary representation
      wfn_molecule = wfn_data['molecule']
      molecule = core.Molecule.from_dict(wfn_molecule)
  
      # get basis set name and spherical harmonics boolean
      basis_name = wfn_string['basisname']
      if ".gbs" in basis_name:
          basis_name = basis_name.split('/')[-1].replace('.gbs', '')
  
      basis_puream = wfn_boolean['basispuream']
      basisset = core.BasisSet.build(molecule, 'ORBITAL', basis_name, puream=basis_puream)
  
      # change some variables to psi4 specific data types (Matrix, Vector, Dimension)
      for label in wfn_matrix:
          array = wfn_matrix[label]
          wfn_matrix[label] = core.Matrix.from_array(array, name=label) if array is not None else None
  
      for label in wfn_vector:
          array = wfn_vector[label]
          wfn_vector[label] = core.Vector.from_array(array, name=label) if array is not None else None
  
      for label in wfn_dimension:
          tup = wfn_dimension[label]
          wfn_dimension[label] = core.Dimension.from_list(tup, name=label) if tup is not None else None
  
      for label in wfn_matrixarr:
          array = wfn_matrixarr[label]
          wfn_matrixarr[label] = core.Matrix.from_array(array, name=label) if array is not None else None
  
      # make the wavefunction
      wfn = core.Wavefunction(molecule, basisset, wfn_matrix, wfn_vector, wfn_dimension, wfn_int, wfn_string,
                              wfn_boolean, wfn_float)
  
      # some of the wavefunction's variables can be changed directly
      for k, v in wfn_floatvar.items():
          wfn.set_variable(k, v)
      for k, v in wfn_matrixarr.items():
          wfn.set_variable(k, v)
  
      return wfn
function_tokens: def _core_wavefunction_from_file ( wfn_data : Union [ str , Dict , Path ] ) -> core . Wavefunction : # load the wavefunction from file if isinstance ( wfn_data , dict ) : pass elif isinstance ( wfn_data , str ) : if not wfn_data . endswith ( ".npy" ) : wfn_data = wfn_data + ".npy" wfn_data = np . load ( wfn_data , allow_pickle = True ) . item ( ) else : # Could be path-like or file-like, let `np.load` handle it wfn_data = np . load ( wfn_data , allow_pickle = True ) . item ( ) # variable type specific dictionaries to be passed into C++ constructor wfn_matrix = wfn_data [ 'matrix' ] wfn_vector = wfn_data [ 'vector' ] wfn_dimension = wfn_data [ 'dimension' ] wfn_int = wfn_data [ 'int' ] wfn_string = wfn_data [ 'string' ] wfn_boolean = wfn_data [ 'boolean' ] wfn_float = wfn_data [ 'float' ] wfn_floatvar = wfn_data [ 'floatvar' ] wfn_matrixarr = wfn_data [ 'matrixarr' ] # reconstruct molecule from dictionary representation wfn_molecule = wfn_data [ 'molecule' ] molecule = core . Molecule . from_dict ( wfn_molecule ) # get basis set name and spherical harmonics boolean basis_name = wfn_string [ 'basisname' ] if ".gbs" in basis_name : basis_name = basis_name . split ( '/' ) [ - 1 ] . replace ( '.gbs' , '' ) basis_puream = wfn_boolean [ 'basispuream' ] basisset = core . BasisSet . build ( molecule , 'ORBITAL' , basis_name , puream = basis_puream ) # change some variables to psi4 specific data types (Matrix, Vector, Dimension) for label in wfn_matrix : array = wfn_matrix [ label ] wfn_matrix [ label ] = core . Matrix . from_array ( array , name = label ) if array is not None else None for label in wfn_vector : array = wfn_vector [ label ] wfn_vector [ label ] = core . Vector . from_array ( array , name = label ) if array is not None else None for label in wfn_dimension : tup = wfn_dimension [ label ] wfn_dimension [ label ] = core . Dimension . from_list ( tup , name = label ) if tup is not None else None for label in wfn_matrixarr : array = wfn_matrixarr [ label ] wfn_matrixarr [ label ] = core . Matrix . from_array ( array , name = label ) if array is not None else None # make the wavefunction wfn = core . Wavefunction ( molecule , basisset , wfn_matrix , wfn_vector , wfn_dimension , wfn_int , wfn_string , wfn_boolean , wfn_float ) # some of the wavefunction's variables can be changed directly for k , v in wfn_floatvar . items ( ) : wfn . set_variable ( k , v ) for k , v in wfn_matrixarr . items ( ) : wfn . set_variable ( k , v ) return wfn