# Path: guacamol/utils/descriptors.py
# def num_atoms(mol: Mol) -> int:
#     """
#     Returns the total number of atoms, H included
#     """
#     mol = Chem.AddHs(mol)
#     return mol.GetNumAtoms()
# 
# class AtomCounter:
# 
#     def __init__(self, element: str) -> None:
#         """
#         Args:
#             element: element to count within a molecule
#         """
#         self.element = element
# 
#     def __call__(self, mol: Mol) -> int:
#         """
#         Count the number of atoms of a given type.
# 
#         Args:
#             mol: molecule
# 
#         Returns:
#             The number of atoms of the given type.
#         """
#         # if the molecule contains H atoms, they may be implicit, so add them
#         if self.element == 'H':
#             mol = Chem.AddHs(mol)
# 
#         return sum(1 for a in mol.GetAtoms() if a.GetSymbol() == self.element)


from rdkit import Chem
from guacamol.utils.descriptors import num_atoms, AtomCounter
    mol = Chem.MolFromSmiles(smiles)
    assert num_atoms(mol) == 21


def test_num_atoms_does_not_change_mol_instance():
    smiles = 'CCOC(CCC)'
    mol = Chem.MolFromSmiles(smiles)

    assert mol.GetNumAtoms() == 7
    num_atoms(mol)
    assert mol.GetNumAtoms() == 7


def test_count_c_atoms():
    smiles = 'CCOC(CCC)'
    mol = Chem.MolFromSmiles(smiles)
    assert AtomCounter('C')(mol) == 6


def test_count_h_atoms():
    smiles = 'CCOC(CCC)'
    mol = Chem.MolFromSmiles(smiles)
    assert AtomCounter('H')(mol) == 14


def test_count_h_atoms_does_not_change_mol_instance():
    smiles = 'CCOC(CCC)'
    mol = Chem.MolFromSmiles(smiles)

    assert mol.GetNumAtoms() == 7

# Path: guacamol/utils/descriptors.py
# def num_atoms(mol: Mol) -> int:
#     """
#     Returns the total number of atoms, H included
#     """
#     mol = Chem.AddHs(mol)
#     return mol.GetNumAtoms()
# 
# class AtomCounter:
# 
#     def __init__(self, element: str) -> None:
#         """
#         Args:
#             element: element to count within a molecule
#         """
#         self.element = element
# 
#     def __call__(self, mol: Mol) -> int:
#         """
#         Count the number of atoms of a given type.
# 
#         Args:
#             mol: molecule
# 
#         Returns:
#             The number of atoms of the given type.
#         """
#         # if the molecule contains H atoms, they may be implicit, so add them
#         if self.element == 'H':
#             mol = Chem.AddHs(mol)
# 
#         return sum(1 for a in mol.GetAtoms() if a.GetSymbol() == self.element)


# Path: tests/utils/test_descriptors.py
from rdkit import Chem
from guacamol.utils.descriptors import num_atoms, AtomCounter

    mol = Chem.MolFromSmiles(smiles)
    assert num_atoms(mol) == 21


def test_num_atoms_does_not_change_mol_instance():
    smiles = 'CCOC(CCC)'
    mol = Chem.MolFromSmiles(smiles)

    assert mol.GetNumAtoms() == 7
    num_atoms(mol)
    assert mol.GetNumAtoms() == 7


def test_count_c_atoms():
    smiles = 'CCOC(CCC)'
    mol = Chem.MolFromSmiles(smiles)
    assert AtomCounter('C')(mol) == 6


def test_count_h_atoms():
    smiles = 'CCOC(CCC)'
    mol = Chem.MolFromSmiles(smiles)
    assert AtomCounter('H')(mol) == 14


def test_count_h_atoms_does_not_change_mol_instance():
    smiles = 'CCOC(CCC)'
    mol = Chem.MolFromSmiles(smiles)

    assert mol.GetNumAtoms() == 7

    AtomCounter('H')(mol)