original_docstring: Build a ``AtomicData`` from an ``ase.Atoms`` object.
  
          Respects ``atoms``'s ``pbc`` and ``cell``.
  
          First tries to extract energies and forces from a single-point calculator associated with the ``Atoms`` if one is present and has those fields.
          If either is not found, the method will look for ``energy``/``energies`` and ``force``/``forces`` in ``atoms.arrays``.
  
          `get_atomic_numbers()` will be stored as the atomic_numbers attribute.
  
          Args:
              atoms (ase.Atoms): the input.
              r_max (float): neighbor cutoff radius.
              features (torch.Tensor shape [N, M], optional): per-atom M-dimensional feature vectors. If ``None`` (the
               default), uses a one-hot encoding of the species present in ``atoms``.
              include_keys (list): list of additional keys to include in AtomicData aside from the ones defined in
                   ase.calculators.calculator.all_properties. Optional
              key_mapping (dict): rename ase property name to a new string name. Optional
              **kwargs (optional): other arguments for the ``AtomicData`` constructor.
  
          Returns:
              A ``AtomicData``.
          
docstring: 
  
  First tries to extract energies and forces from a single-point calculator associated with the ``Atoms`` if one is present and has those fields.
  
  `get_atomic_numbers()` will be stored as the atomic_numbers attribute.
docstring_tokens: First tries to extract energies and forces from a single - point calculator associated with the ` ` Atoms ` ` if one is present and has those fields . ` get_atomic_numbers () ` will be stored as the atomic_numbers attribute .
code: def from_ase(
          cls,
          atoms,
          r_max,
          key_mapping: Optional[Dict[str, str]] = {},
          include_keys: Optional[list] = [],
          **kwargs,
      ):
          """Build a ``AtomicData`` from an ``ase.Atoms`` object.
  
          Respects ``atoms``'s ``pbc`` and ``cell``.
  
          First tries to extract energies and forces from a single-point calculator associated with the ``Atoms`` if one is present and has those fields.
          If either is not found, the method will look for ``energy``/``energies`` and ``force``/``forces`` in ``atoms.arrays``.
  
          `get_atomic_numbers()` will be stored as the atomic_numbers attribute.
  
          Args:
              atoms (ase.Atoms): the input.
              r_max (float): neighbor cutoff radius.
              features (torch.Tensor shape [N, M], optional): per-atom M-dimensional feature vectors. If ``None`` (the
               default), uses a one-hot encoding of the species present in ``atoms``.
              include_keys (list): list of additional keys to include in AtomicData aside from the ones defined in
                   ase.calculators.calculator.all_properties. Optional
              key_mapping (dict): rename ase property name to a new string name. Optional
              **kwargs (optional): other arguments for the ``AtomicData`` constructor.
  
          Returns:
              A ``AtomicData``.
          """
          from nequip.ase import NequIPCalculator
  
          assert "pos" not in kwargs
  
          default_args = set(
              [
                  "numbers",
                  "positions",
              ]  # ase internal names for position and atomic_numbers
              + ["pbc", "cell", "pos", "r_max"]  # arguments for from_points method
              + list(kwargs.keys())
          )
          # the keys that are duplicated in kwargs are removed from the include_keys
          include_keys = list(set(include_keys + ase_all_properties) - default_args)
  
          km = {
              "forces": AtomicDataDict.FORCE_KEY,
              "energy": AtomicDataDict.TOTAL_ENERGY_KEY,
          }
          km.update(key_mapping)
          key_mapping = km
  
          add_fields = {}
  
          # Get info from atoms.arrays; lowest priority. copy first
          add_fields = {
              key_mapping.get(k, k): v
              for k, v in atoms.arrays.items()
              if k in include_keys
          }
  
          # Get info from atoms.info; second lowest priority.
          add_fields.update(
              {
                  key_mapping.get(k, k): v
                  for k, v in atoms.info.items()
                  if k in include_keys
              }
          )
  
          if atoms.calc is not None:
  
              if isinstance(
                  atoms.calc, (SinglePointCalculator, SinglePointDFTCalculator)
              ):
                  add_fields.update(
                      {
                          key_mapping.get(k, k): deepcopy(v)
                          for k, v in atoms.calc.results.items()
                          if k in include_keys
                      }
                  )
              elif isinstance(atoms.calc, NequIPCalculator):
                  pass  # otherwise the calculator breaks
              else:
                  raise NotImplementedError(
                      f"`from_ase` does not support calculator {atoms.calc}"
                  )
  
          add_fields[AtomicDataDict.ATOMIC_NUMBERS_KEY] = atoms.get_atomic_numbers()
  
          # cell and pbc in kwargs can override the ones stored in atoms
          cell = kwargs.pop("cell", atoms.get_cell())
          pbc = kwargs.pop("pbc", atoms.pbc)
  
          return cls.from_points(
              pos=atoms.positions,
              r_max=r_max,
              cell=cell,
              pbc=pbc,
              **kwargs,
              **add_fields,
          )
code_tokens: def from_ase ( cls , atoms , r_max , key_mapping : Optional [ Dict [ str , str ] ] = { } , include_keys : Optional [ list ] = [ ] , ** kwargs , ) : from nequip . ase import NequIPCalculator assert "pos" not in kwargs default_args = set ( [ "numbers" , "positions" , ] + [ "pbc" , "cell" , "pos" , "r_max" ] + list ( kwargs . keys ( ) ) ) include_keys = list ( set ( include_keys + ase_all_properties ) - default_args ) km = { "forces" : AtomicDataDict . FORCE_KEY , "energy" : AtomicDataDict . TOTAL_ENERGY_KEY , } km . update ( key_mapping ) key_mapping = km add_fields = { } add_fields = { key_mapping . get ( k , k ) : v for k , v in atoms . arrays . items ( ) if k in include_keys } add_fields . update ( { key_mapping . get ( k , k ) : v for k , v in atoms . info . items ( ) if k in include_keys } ) if atoms . calc is not None : if isinstance ( atoms . calc , ( SinglePointCalculator , SinglePointDFTCalculator ) ) : add_fields . update ( { key_mapping . get ( k , k ) : deepcopy ( v ) for k , v in atoms . calc . results . items ( ) if k in include_keys } ) elif isinstance ( atoms . calc , NequIPCalculator ) : pass else : raise NotImplementedError ( f"`from_ase` does not support calculator {atoms.calc}" ) add_fields [ AtomicDataDict . ATOMIC_NUMBERS_KEY ] = atoms . get_atomic_numbers ( ) cell = kwargs . pop ( "cell" , atoms . get_cell ( ) ) pbc = kwargs . pop ( "pbc" , atoms . pbc ) return cls . from_points ( pos = atoms . positions , r_max = r_max , cell = cell , pbc = pbc , ** kwargs , ** add_fields , )
short_docstring: Build a ``AtomicData`` from an ``ase.Atoms`` object.
short_docstring_tokens: Build a ` ` AtomicData ` ` from an ` ` ase . Atoms ` ` object .
comment: """Build a ``AtomicData`` from an ``ase.Atoms`` object.
  
          Respects ``atoms``'s ``pbc`` and ``cell``.
  
          First tries to extract energies and forces from a single-point calculator associated with the ``Atoms`` if one is present and has those fields.
          If either is not found, the method will look for ``energy``/``energies`` and ``force``/``forces`` in ``atoms.arrays``.
  
          `get_atomic_numbers()` will be stored as the atomic_numbers attribute.
  
          Args:
              atoms (ase.Atoms): the input.
              r_max (float): neighbor cutoff radius.
              features (torch.Tensor shape [N, M], optional): per-atom M-dimensional feature vectors. If ``None`` (the
               default), uses a one-hot encoding of the species present in ``atoms``.
              include_keys (list): list of additional keys to include in AtomicData aside from the ones defined in
                   ase.calculators.calculator.all_properties. Optional
              key_mapping (dict): rename ase property name to a new string name. Optional
              **kwargs (optional): other arguments for the ``AtomicData`` constructor.
  
          Returns:
              A ``AtomicData``.
          """$SEP$# ase internal names for position and atomic_numbers$SEP$# arguments for from_points method$SEP$# the keys that are duplicated in kwargs are removed from the include_keys$SEP$# Get info from atoms.arrays; lowest priority. copy first$SEP$# Get info from atoms.info; second lowest priority.$SEP$# otherwise the calculator breaks$SEP$# cell and pbc in kwargs can override the ones stored in atoms