Skip to content

Commit

Permalink
add Irreps.is_scalar
Browse files Browse the repository at this point in the history
  • Loading branch information
mariogeiger committed Sep 27, 2022
1 parent 84bbe98 commit b631e3e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `e3nn.IrrepsArray.filtered(keep: List[Irrep])`
- `e3nn.reduced_tensor_product_basis(formula_or_irreps_list: Union[str, List[e3nn.Irreps]], ...)`
- `IrrepsArray.at[i].set(v)` and `IrrepsArray.at[i].add(v)`
- add `Irreps.is_scalar`

## [0.9.0] - 2022-09-04
### Added
Expand Down
14 changes: 14 additions & 0 deletions e3nn_jax/_src/irreps.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,20 @@ def count(self, ir: IntoIrrep) -> int:
ir = Irrep(ir)
return sum(mul for mul, irrep in self if ir == irrep)

def is_scalar(self) -> bool:
r"""Check if the representation is scalar.
Returns:
`bool`: ``True`` if the representation is scalar
Examples:
>>> Irreps("2x0e + 3x1o").is_scalar()
False
>>> Irreps("2x0e + 2x0e").is_scalar()
True
"""
return {ir for _, ir in self} == {Irrep("0e")}

def index(self, _object): # noqa: D102
raise NotImplementedError

Expand Down

0 comments on commit b631e3e

Please sign in to comment.