docstr: Create a HBInfo instance from a file object containing a matrix in the
  HB format.
  
  Parameters
  ----------
  fid : file-like matrix
      File or file-like object containing a matrix in the HB format.
  
  Returns
  -------
  hb_info : HBInfo instance
docstr_tok: ["Create","a","HBInfo","instance","from","a","file","object","containing","a","matrix","in","the","HB","format",".","Parameters","--","--","--","--","--","fid",":","file-like","matrix","File","or","file-like","object","containing","a","matrix","in","the","HB","format",".","Returns","--","--","--","-","hb_info",":","HBInfo","instance"]
code: def from_file(cls, fid):
      """Create a HBInfo instance from a file object containing a matrix in the
      HB format.
  
      Parameters
      ----------
      fid : file-like matrix
          File or file-like object containing a matrix in the HB format.
  
      Returns
      -------
      hb_info : HBInfo instance
      """
      # First line
      line = fid.readline().strip("\n")
      if not len(line) > 72:
          raise ValueError(
              "Expected at least 72 characters for first line, "
              "got: \n%s" % line
          )
      title = line[:72]
      key = line[72:]
  
      # Second line
      line = fid.readline().strip("\n")
      if not len(line.rstrip()) >= 56:
          raise ValueError(
              "Expected at least 56 characters for second line, "
              "got: \n%s" % line
          )
      total_nlines = _expect_int(line[:14])
      pointer_nlines = _expect_int(line[14:28])
      indices_nlines = _expect_int(line[28:42])
      values_nlines = _expect_int(line[42:56])
  
      rhs_nlines = line[56:72].strip()
      if rhs_nlines == "":
          rhs_nlines = 0
      else:
          rhs_nlines = _expect_int(rhs_nlines)
      if not rhs_nlines == 0:
          raise ValueError(
              "Only files without right hand side supported for " "now."
          )
  
      # Third line
      line = fid.readline().strip("\n")
      if not len(line) >= 70:
          raise ValueError(
              "Expected at least 72 character for third line, got:\n"
              "%s" % line
          )
  
      mxtype_s = line[:3].upper()
      if not len(mxtype_s) == 3:
          raise ValueError("mxtype expected to be 3 characters long")
  
      mxtype = HBMatrixType.from_fortran(mxtype_s)
      if mxtype.value_type not in ["real", "integer"]:
          raise ValueError(
              "Only real or integer matrices supported for "
              "now (detected %s)" % mxtype
          )
      if not mxtype.structure == "unsymmetric":
          raise ValueError(
              "Only unsymmetric matrices supported for "
              "now (detected %s)" % mxtype
          )
      if not mxtype.storage == "assembled":
          raise ValueError("Only assembled matrices supported for now")
  
      if not line[3:14] == " " * 11:
          raise ValueError("Malformed data for third line: %s" % line)
  
      nrows = _expect_int(line[14:28])
      ncols = _expect_int(line[28:42])
      nnon_zeros = _expect_int(line[42:56])
      nelementals = _expect_int(line[56:70])
      if not nelementals == 0:
          raise ValueError(
              "Unexpected value %d for nltvl (last entry of line 3)"
              % nelementals
          )
  
      # Fourth line
      line = fid.readline().strip("\n")
  
      ct = line.split()
      if not len(ct) == 3:
          raise ValueError("Expected 3 formats, got %s" % ct)
  
      return cls(
          title,
          key,
          total_nlines,
          pointer_nlines,
          indices_nlines,
          values_nlines,
          mxtype,
          nrows,
          ncols,
          nnon_zeros,
          ct[0],
          ct[1],
          ct[2],
          rhs_nlines,
          nelementals,
      )
  
imports: from __future__ import division, print_function, absolute_import
  import warnings
  import numpy
  from scipy.sparse import csc_matrix
  from scipy.io.harwell_boeing._fortran_format_parser import FortranFormatParser, IntFormat, ExpFormat
label_desc: Use image node_id 2 for calling the HBInfo obj's underlying member method code with example usage: obj.from_file(cls, fid) and returns: cls