Determine the structure from the output
192213
def get_output_structure(self):
        ''''''
        bohr_to_angstrom = 0.529177249

        # determine the number of atoms
        natoms = int(float(self._get_line('number of atoms/cell', self.outputf).split('=')[-1]))

        # determine the initial lattice parameter
        alat = float(self._get_line('lattice parameter (alat)', self.outputf).split('=')[-1].split()[0])

        # find the initial unit cell
        unit_cell = []
        with open(self.outputf, 'r') as fp:
            for line in fp:
                if "crystal axes:" in line:
                    for i in range(3):
                        unit_cell.append([float(j)*alat*bohr_to_angstrom for j in next(fp).split('(')[-1].split(')')[0].split()])
                    break
            if len(unit_cell) == 0: raise Exception('Cannot find the initial unit cell')

        # find the initial atomic coordinates
        coords = [] ; atom_symbols = []
        with open(self.outputf, 'r') as fp:
            for line in fp:
                if "site n." in line and "atom" in line and "positions" in line and "alat units" in line:
                    for i in range(natoms):
                        coordline = next(fp)
                        atom_symbols.append(''.join([i for i in coordline.split()[1] if not i.isdigit()]))
                        coord_conv_factor = alat*bohr_to_angstrom
                        coords.append([float(j)*coord_conv_factor for j in coordline.rstrip().split('=')[-1].split('(')[-1].split(')')[0].split()])
                    break
            if len(coords) == 0: raise Exception('Cannot find the initial atomic coordinates')

        if type(self.is_relaxed()) == type(None):
            # static run: create, populate, and return the initial structure
            structure = Atoms(symbols=atom_symbols, cell=unit_cell, pbc=True)
            structure.set_positions(coords)
            return structure
        else:
            # relaxation run: update with the final structure
            with open(self.outputf) as fp:
                for line in fp:
                    if "Begin final coordinates" in line:
                        if 'new unit-cell volume' in next(fp):
                            # unit cell allowed to change
                            next(fp) # blank line
                            # get the final unit cell
                            unit_cell = []
                            cellheader = next(fp)
                            if 'bohr' in cellheader.lower():
                                cell_conv_factor = bohr_to_angstrom
                            elif 'angstrom' in cellheader.lower():
                                cell_conv_factor = 1.0
                            else:
                                alat = float(cellheader.split('alat=')[-1].replace(')', ''))
                                cell_conv_factor = alat*bohr_to_angstrom
                            for i in range(3):
                                unit_cell.append([float(j)*cell_conv_factor for j in next(fp).split()])
                            next(fp) # blank line

                        # get the final atomic coordinates
                        coordtype = next(fp).split()[-1].replace('(', '').replace(')', '')
                        if coordtype == 'bohr':
                            coord_conv_factor = bohr_to_angstrom
                        elif coordtype == 'angstrom' or coordtype == 'crystal':
                            coord_conv_factor = 1.0
                        else:
                            coord_conv_factor = alat*bohr_to_angstrom
                        coords = [] # reinitialize the coords
                        for i in range(natoms):
                            coordline = next(fp).split()
                            coords.append([float(j)*coord_conv_factor for j in coordline[1:4]])

                        # create, populate, and return the final structure
                        structure = Atoms(symbols=atom_symbols, cell=unit_cell, pbc=True)
                        if coordtype == 'crystal':
                            structure.set_scaled_positions(coords) # direct coord
                        else:
                            structure.set_positions(coords) # cartesian coord
                        return structure
                raise Exception('Cannot find the final coordinates')
1248045
def check_structure(self, keys):
        
        """
        return set(keys) <= set([self.__options['attrkey'], self.__options['valuekey']])
370753
def compute_output(self, o, output_shape=None):
    
    if self.combine_dims:
      o = mtf.transpose(o, o.shape - self.o_dims + self.o_dims)
      o = mtf.replace_dimensions(o, self.o_dims, self.wo.shape.dims[0])
      reduced_dims = [self.wo.shape.dims[0]]
    else:
      reduced_dims = self.o_dims
    return mtf.einsum(
        [o, self.wo], output_shape=output_shape, reduced_dims=reduced_dims)
666667
def get_band_structure(self):
        """"""

        kpath = HighSymmKpath(self.data.structure)
        kpt_line = [Kpoint(k, self.data.structure.lattice) for k
                    in
                    kpath.get_kpoints(coords_are_cartesian=False)[
                        0]]
        kpoints = np.array(
            [kp.frac_coords for kp in kpt_line])

        labels_dict = {l: k for k, l in zip(
            *kpath.get_kpoints(coords_are_cartesian=False)) if l}

        lattvec = self.data.get_lattvec()
        egrid, vgrid = fite.getBands(kpoints, self.equivalences, lattvec, self.coeffs)

        bands_dict = {Spin.up: (egrid / units.eV)}

        sbs = BandStructureSymmLine(kpoints, bands_dict,
                                    self.data.structure.lattice.reciprocal_lattice,
                                    self.efermi / units.eV,
                                    labels_dict=labels_dict)
        return sbs
772752
def block_structure(self):
        
        n, m = self.shape
        if n != m:
            raise AttributeError("block_structure only defined for square "
                                 "matrices")
        for k in range(1, n):
            if ((self.matrix[:k, k:] == 0).all() and
                    (self.matrix[k:, :k] == 0).all()):
                return (k,) + self[k:, k:].block_structure
        return n,
294801
def complex_out_dtype(self):
        """"""
        if self.__complex_out_dtype is None:
            raise AttributeError(
                'no complex variant of output dtype {} defined'
                ''.format(dtype_repr(self.scalar_out_dtype)))
        else:
            return self.__complex_out_dtype
157875
def calculate_reshape_output_shapes(operator):
    '''
    
    '''
    check_input_and_output_numbers(operator, input_count_range=1, output_count_range=1)
    check_input_and_output_types(operator, good_input_types=[FloatTensorType])

    params = operator.raw_operator.reshape

    output_shape = list(int(i) for i in params.targetShape)

    if len(output_shape) == 3:
        output_shape = [operator.inputs[0].type.shape[0]] + output_shape

    operator.outputs[0].type.shape = output_shape
1145490
def _get_block(self):
    """"""
    b = self._fh.read(4) # get block size bytes
    #print self._fh.tell()
    if not b: raise StopIteration
    block_size = struct.unpack('<i',b)[0]
    return self._fh.read(block_size)
267236
def calculate_slice_output_shapes(operator):
    '''
    
    '''
    check_input_and_output_numbers(operator, input_count_range=1, output_count_range=1)
    check_input_and_output_types(operator, good_input_types=[FloatTensorType])

    output_shape = copy.deepcopy(operator.inputs[0].type.shape)

    params = operator.raw_operator.slice

    from coremltools.proto.NeuralNetwork_pb2 import SliceLayerParams as Params
    axis_map = {Params.CHANNEL_AXIS: 1, Params.HEIGHT_AXIS: 2, Params.WIDTH_AXIS: 3}

    if params.startIndex >= 0:
        output_shape[axis_map[Params.CHANNEL_AXIS]] = params.endIndex - params.startIndex
    else:
        output_shape[axis_map[Params.CHANNEL_AXIS]] += 1 + params.endIndex - params.startIndex

    operator.outputs[0].type = FloatTensorType(output_shape, doc_string=operator.outputs[0].type.doc_string)
605150
private void logUnexpectedStructure()
   {
      if (m_log != null)
      {
         m_log.println("ABORTED COLUMN - unexpected structure: " + m_currentColumn.getClass().getSimpleName() + " " + m_currentColumn.getName());
      }
   }
971096
def get_conv_struct(structure):
    
    output = run_aconvasp_command(["aconvasp", "--std_conv"], structure)
    if "ERROR" in output[1]:
        raise AconvaspError(output[1])
    tmp = Poscar.from_string(output[0])
    return {'struct': tmp.structure, 'comm': tmp.comment}
701468
def calculate_split_output_shapes(operator):
    '''
    
    '''
    check_input_and_output_numbers(operator, input_count_range=1, output_count_range=[1, None])
    check_input_and_output_types(operator, good_input_types=[FloatTensorType])

    output_shape = copy.deepcopy(operator.inputs[0].type.shape)

    divided = output_shape[1] / operator.raw_operator.split.nOutputs
    if divided != int(divided):
        raise RuntimeError('Variable dimension along C-axis must be divisible by partition number')

    output_shape[1] = int(divided)

    for i in range(len(operator.outputs)):
        operator.outputs[i].type.shape = copy.deepcopy(output_shape)
918966
def _check_structure(self):
        '''
        
        '''
        # Collect all variable names and operator names
        unused_variables = set()
        unused_operators = set()
        for variable in self.unordered_variable_iterator():
            unused_variables.add(variable.full_name)
        for operator in self.unordered_operator_iterator():
            unused_operators.add(operator.full_name)

        for operator in self.unordered_operator_iterator():
            for variable in operator.inputs:
                # A variable is used by an operator, so we remove the variable from the unused-variable list.
                unused_variables.discard(variable.full_name)
                # A operator has an input, so we remove the operator from the unused-operator list.
                unused_operators.discard(operator.full_name)
            for variable in operator.outputs:
                # A variable is used by an operator, so we remove the variable from the unused-variable list.
                unused_variables.discard(variable.full_name)
                # A operator has an output, so we remove the operator from the unused-operator list.
                unused_operators.discard(operator.full_name)

        if len(unused_variables) > 0:
            raise RuntimeError('Isolated variables exist: %s' % unused_variables)

        if len(unused_operators) > 0:
            raise RuntimeError('Isolated operators exist: %s' % unused_operators)
421934
def assemble(self):
        """"""
        first_block = ray.get(self.objectids[(0, ) * self.ndim])
        dtype = first_block.dtype
        result = np.zeros(self.shape, dtype=dtype)
        for index in np.ndindex(*self.num_blocks):
            lower = DistArray.compute_block_lower(index, self.shape)
            upper = DistArray.compute_block_upper(index, self.shape)
            result[[slice(l, u) for (l, u) in zip(lower, upper)]] = ray.get(
                self.objectids[index])
        return result
96513
def find_structure(self, filename_or_structure):
        
        try:
            if isinstance(filename_or_structure, str):
                s = Structure.from_file(filename_or_structure)
            elif isinstance(filename_or_structure, Structure):
                s = filename_or_structure
            else:
                raise MPRestError("Provide filename or Structure object.")
            payload = {'structure': json.dumps(s.as_dict(), cls=MontyEncoder)}
            response = self.session.post(
                '{}/find_structure'.format(self.preamble), data=payload
            )
            if response.status_code in [200, 400]:
                resp = json.loads(response.text, cls=MontyDecoder)
                if resp['valid_response']:
                    return resp['response']
                else:
                    raise MPRestError(resp["error"])
            raise MPRestError("REST error with status code {} and error {}"
                              .format(response.status_code, response.text))
        except Exception as ex:
            raise MPRestError(str(ex))
379785
def context_structure(self):
        
        instructions = []
        last_context = Context()
        for instr in self.structure:
            instruction_type = instr['instruction']
            if instruction_type == "FROM":  # reset per stage
                last_context = Context()

            context = Context(envs=dict(last_context.envs),
                              labels=dict(last_context.labels))

            if instruction_type in ["ENV", "LABEL"]:
                val = get_key_val_dictionary(instruction_value=instr['value'],
                                             env_replace=self.env_replace,
                                             envs=last_context.envs)
                context.set_line_value(context_type=instruction_type, value=val)

            instructions.append(context)
            last_context = context
        return instructions
888691
def struct(self):
        
        data = {}
        for var, fmap in self._def.items():
            if hasattr(self, var):
                data.update(fmap.get_outputs(getattr(self, var)))
        return data