Find a primitive version of the unit cell.

        Returns:
            A primitive cell in the input cell is searched and returned
            as an Structure object. If no primitive cell is found, None is
            returned.
973807
def find_primitive(self):
        
        lattice, scaled_positions, numbers = spglib.find_primitive(
            self._cell, symprec=self._symprec)

        species = [self._unique_species[i - 1] for i in numbers]

        return Structure(lattice, species, scaled_positions,
                         to_unit_cell=True).get_reduced_structure()
494234
def find(cls, name):
        
        try:
            return cls._member_map_[name]
        except KeyError:
            for ctype in cls._member_map_.values():
                if ctype.name == name:
                    return ctype
            raise ValueError('%s is not a valid %s' % (name, cls.__name__))
1143900
def instance_str(cell):
    
    if isinstance(cell, str):
        return 'str'
    elif isinstance(cell, int):
        return 'int'
    elif isinstance(cell, float):
        return 'float'
    else:
        return 'unknown'
752813
def getCell(self, row, width=None):
        ''
        cellval = wrapply(self.getValue, row)
        typedval = wrapply(self.type, cellval)

        if isinstance(typedval, TypedWrapper):
            if isinstance(cellval, TypedExceptionWrapper):  # calc failed
                exc = cellval.exception
                if cellval.forwarded:
                    dispval = str(cellval)  # traceback.format_exception_only(type(exc), exc)[-1].strip()
                else:
                    dispval = options.disp_error_val
                return DisplayWrapper(cellval.val, error=exc.stacktrace,
                                        display=dispval,
                                        note=options.note_getter_exc,
                                        notecolor='color_error')
            elif typedval.val is None:  # early out for strict None
                return DisplayWrapper(None, display='',  # force empty display for None
                                            note=options.disp_note_none,
                                            notecolor='color_note_type')
            elif isinstance(typedval, TypedExceptionWrapper):  # calc succeeded, type failed
                return DisplayWrapper(typedval.val, display=str(cellval),
                                            error=typedval.exception.stacktrace,
                                            note=options.note_type_exc,
                                            notecolor='color_warning')
            else:
                return DisplayWrapper(typedval.val, display=str(typedval.val),
                                            note=options.note_type_exc,
                                            notecolor='color_warning')

        elif isinstance(typedval, threading.Thread):
            return DisplayWrapper(None,
                                display=options.disp_pending,
                                note=options.note_pending,
                                notecolor='color_note_pending')

        dw = DisplayWrapper(cellval)

        try:
            dw.display = self.format(typedval) or ''

            if width and isNumeric(self):
                dw.display = dw.display.rjust(width-1)

            # annotate cells with raw value type in anytype columns, except for strings
            if self.type is anytype and type(cellval) is not str:
                typedesc = typemap.get(type(cellval), None)
                dw.note = typedesc.icon if typedesc else options.note_unknown_type
                dw.notecolor = 'color_note_type'

        except Exception as e:  # formatting failure
            e.stacktrace = stacktrace()
            dw.error = e
            try:
                dw.display = str(cellval)
            except Exception as e:
                dw.display = str(e)
            dw.note = options.note_format_exc
            dw.notecolor = 'color_warning'

        return dw
184475
def fit(self, struct1, struct2):
        
        struct1, struct2 = self._process_species([struct1, struct2])

        if not self._subset and self._comparator.get_hash(struct1.composition) \
                != self._comparator.get_hash(struct2.composition):
            return None

        struct1, struct2, fu, s1_supercell = self._preprocess(struct1, struct2)
        match = self._match(struct1, struct2, fu, s1_supercell,
                            break_on_match=True)

        if match is None:
            return False
        else:
            return match[0] <= self.stol
153425
def are_equal(self, d1, d2):
        
        possible_defect_types = (Defect, Vacancy, Substitution, Interstitial)

        if not isinstance(d1, possible_defect_types) or \
            not isinstance(d2, possible_defect_types):
            raise ValueError("Cannot use PointDefectComparator to" + \
                             " compare non-defect objects...")

        if not isinstance(d1, d2.__class__):
            return False
        elif d1.site.specie != d2.site.specie:
            return False
        elif self.check_charge and (d1.charge != d2.charge):
            return False

        sm = StructureMatcher( ltol=0.01,
                               primitive_cell=self.check_primitive_cell,
                               scale=self.check_lattice_scale)

        if not sm.fit(d1.bulk_structure, d2.bulk_structure):
            return False

        d1 = d1.copy()
        d2 = d2.copy()
        if self.check_primitive_cell or self.check_lattice_scale:
            # if allowing for base structure volume or supercell modifications,
            # then need to preprocess defect objects to allow for matching
            d1_mod_bulk_structure, d2_mod_bulk_structure, _, _ = sm._preprocess(
                d1.bulk_structure, d2.bulk_structure)
            d1_defect_site = PeriodicSite(d1.site.specie, d1.site.coords,
                                          d1_mod_bulk_structure.lattice,
                                          to_unit_cell=True,
                                          coords_are_cartesian=True)
            d2_defect_site = PeriodicSite( d2.site.specie, d2.site.coords,
                                           d2_mod_bulk_structure.lattice,
                                           to_unit_cell=True,
                                           coords_are_cartesian=True)

            d1._structure = d1_mod_bulk_structure
            d2._structure = d2_mod_bulk_structure
            d1._defect_site = d1_defect_site
            d2._defect_site = d2_defect_site

        return sm.fit(d1.generate_defect_structure(),
                      d2.generate_defect_structure())
907656
def find(self,cell_designation,cell_filter=lambda x,c: 'c' in x and x['c'] == c):
        
        res = [i for i,sc in enumerate(self.spike_containers) if cell_filter(sc.meta,cell_designation)]
        if len(res) > 0:
            return res[0]
266321
def _get_cell_type(cell_type):
    
    if isinstance(cell_type, str):
        if cell_type == 'lstm':
            return rnn.LSTMCell
        elif cell_type == 'gru':
            return rnn.GRUCell
        elif cell_type == 'relu_rnn':
            return partial(rnn.RNNCell, activation='relu')
        elif cell_type == 'tanh_rnn':
            return partial(rnn.RNNCell, activation='tanh')
        else:
            raise NotImplementedError
    else:
        return cell_type
1048831
def primitive(self):
        """"""
        primitive = copy(self.item.primitive)
        primitive.update(self.entry.primitive)
        return primitive
97
function(obj) {
    if (obj instanceof Cell) {
      return {
        inside: obj.inside
      };
    } else {
      return {
        back : serialize(obj.back),
        front : serialize(obj.front),
        plane: obj.plane,
        shp: obj.shp,
        complemented: obj.complemented,
      };
    }
  }
993186
def find(self, query):
        
        try:
            return self._finder(finditem, query)
        except StopIteration:
            raise CellNotFound(query)
829475
def cells(self):
        

        n = 0

        for (order, cells) in self:
            n += len(cells)

        return n
65874
def get_primitive_name(schema):
    
    try:
        return {
            const.COMPILED_TYPE.LITERAL: six.text_type,
            const.COMPILED_TYPE.TYPE: get_type_name,
            const.COMPILED_TYPE.ENUM: get_type_name,
            const.COMPILED_TYPE.CALLABLE: get_callable_name,
            const.COMPILED_TYPE.ITERABLE: lambda x: _(u'{type}[{content}]').format(type=get_type_name(list), content=_(u'...') if x else _(u'-')),
            const.COMPILED_TYPE.MAPPING:  lambda x: _(u'{type}[{content}]').format(type=get_type_name(dict), content=_(u'...') if x else _(u'-')),
        }[primitive_type(schema)](schema)
    except KeyError:
        return six.text_type(repr(schema))
212240
function findCell(cells, c) {
  var lo = 0
    , hi = cells.length-1
    , r  = -1
  while (lo <= hi) {
    var mid = (lo + hi) >> 1
      , s   = compareCells(cells[mid], c)
    if(s <= 0) {
      if(s === 0) {
        r = mid
      }
      lo = mid + 1
    } else if(s > 0) {
      hi = mid - 1
    }
  }
  return r
}
344895
def get_structure(atoms, cls=None):
        
        symbols = atoms.get_chemical_symbols()
        positions = atoms.get_positions()
        lattice = atoms.get_cell()

        cls = Structure if cls is None else cls
        return cls(lattice, symbols, positions,
                   coords_are_cartesian=True)
797252
def to_struct(cls, name=None):
        
        if name is None:
            name = cls.__name__
        basic_attrs = dict([(attr_name, value)
                            for attr_name, value in cls.get_attrs()
                            if isinstance(value, Column)])
        if not basic_attrs:
            return None
        src = 'struct {0} {{'.format(name)
        for attr_name, value in basic_attrs.items():
            src += '{0} {1};'.format(value.type.typename, attr_name)
        src += '};'
        if ROOT.gROOT.ProcessLine(src) != 0:
            return None
        return getattr(ROOT, name, None)
796237
def find_primitive(cell, symprec=1e-5, angle_tolerance=-1.0):
    
    _set_no_error()

    lattice, positions, numbers, _ = _expand_cell(cell)
    if lattice is None:
        return None

    num_atom_prim = spg.primitive(lattice,
                                  positions,
                                  numbers,
                                  symprec,
                                  angle_tolerance)
    _set_error_message()

    if num_atom_prim > 0:
        return (np.array(lattice.T, dtype='double', order='C'),
                np.array(positions[:num_atom_prim], dtype='double', order='C'),
                np.array(numbers[:num_atom_prim], dtype='intc'))
    else:
        return None