Comments (1)
For orbital:
def merge(self, other) -> Orbital:
""" Merges two orbitals into one, with a preference of `self` """
cls = self.__class__
s = self.__getstate__()
o = other.__getstate__()
def inst_merge(typ, op):
for k, v in s.items():
if isinstance(v, typ):
s[k] = op(v, o[k])
def key_merge(key, op):
for k, v in s.items():
if k == key:
s[k] = op(v, o[k])
if isinstance(other, cls):
inst_merge(float, max)
# tag is defined for this orbital, no change
key_merge("tag", lambda s, o: v if v else o)
return cls(**s)
for atom
def merge(self, other: Atom) -> Atom:
"""Merges two atoms into a single one, the calling atom will have precedence
When merging there will be a couple of rules that will apply:
1. When in doubt, the calling atom will have precedence.
2. If the two atoms have the same `Z` value, they can be merged,
otherwise, `self` will be returned *as-is*.
3. The tag is only overwritten if not set.
4. There is no way to decide which mass to choose. It will *always*
take `self`.
5. The orbitals requires explicit handling, the order will prefer
`self`, but if there is more information in `other` those will
be copied over.
Parameters
----------
other : Atom
the other atom to merge into a single one
"""
if self.Z != other.Z:
return self
mass = self.mass
tag = self._tag or other._tag
orbs = []
for sorb in self:
oorb = other[sorb.name()]
if oorb is None:
orbs.append(sorb)
continue
if isinstance(sorb, type(oorb)):
# same type, now only check
from sisl.
Related Issues (20)
- `translate2uc` should use boundary conditions (?) HOT 7
- Transport routines within the kubo approach HOT 16
- Disentangle overlap matrix and *other matrices*
- eigenvalues from hamiltonian in presence of magnetic field HOT 2
- Listify breaks documentation HOT 8
- Custom colormaps for 3D plots HOT 3
- numpy 2.0 released -- need to bump stuff HOT 1
- sisl release policy HOT 6
- Docs formatting issue: Missing argument for `\mathbf` HOT 2
- sisl.viz.FatBandsPlot error in fatbands_mode = 'line/scatter' HOT 16
- #496 seems broken on 3.12 HOT 3
- Allow `State.degenerate_decouple`
- Writing Hamiltonian to netcdf HOT 32
- In ORCA 6 `_property.txt` -> `.property.txt` HOT 2
- lorbit10 files not tested? HOT 5
- Minor terms missing for off-diagonal derivative calculations
- Don't remove `Atoms.specie` HOT 3
- Allow a caching object that can cache specific entries HOT 6
- Generalized `Operators` HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sisl.