element

A module containing the Element class.

Summary

Classes:

CustomElement

A class representing a custom element it inherits from the Element class.

Element

A class representing an element.

Reference

class CustomElement(
symbol: str,
atomic_number: int,
mass: Real,
)[source]

Bases: Element

A class representing a custom element it inherits from the Element class.

Parameters:
  • symbol (str) – the custom atomic symbol

  • atomic_number (int) – the custom atomic number

  • mass (Real) – the custom atomic mass

property symbol: str | None

The symbol of the Element.

Type:

str | None

class Element(element_id: int | str | None = None)[source]

Bases: object

A class representing an element.

An Element can be initialized in three ways:

  1. By giving the atomic number of the element (e.g. 6).

  2. By giving the symbol of the element (e.g. ‘C’).

  3. By giving None.

Examples

>>> element = Element(6)
>>> (element.symbol, element.atomic_number, element.mass)
('c', 6, 12.0107)
>>> element = Element('C')
>>> (element.symbol, element.atomic_number, element.mass)
('c', 6, 12.0107)
>>> element = Element()
>>> (element.symbol, element.atomic_number, element.mass)
(None, None, None)

Initializes the Element with the given parameters.

Parameters:

element_id (int | str | None, optional) – The identifier of the element. If an integer is given, it is interpreted as the atomic number. If a string is given, it is interpreted as the symbol of the element. If None is given, the symbol, atomic number and mass are set to None, by default None

Raises:

ElementNotFoundError – If the given id is not a valid element identifier.

__eq__(other: Any) bool[source]

Checks whether the Element is equal to another Element.

Parameters:

other (Any) – The other Element to check for equality.

Returns:

True if the Element is equal to the other Element, False otherwise.

Return type:

bool

__repr__() str[source]

Returns a representation of the Element.

Returns:

A representation of the Element.

Return type:

str

__str__() str[source]

Returns a string representation of the Element.

Returns:

A string representation of the Element.

Return type:

str

property atomic_number: int | None

The atomic number of the Element.

Type:

int | None

logger = <CustomLogger PQAnalysis.Element (INFO)>
property mass: Real | None

The mass of the Element.

Type:

Real | None

property symbol: str | None

The symbol of the Element.

Type:

str | None

class Elements

A type hint for a list of elements

alias of Annotated[list, Is[lambda list: all((isinstance(element, Element) for element in list))]]