Skip to content

Commit

Permalink
chore: improve doc-strings
Browse files Browse the repository at this point in the history
  • Loading branch information
MrtinoRG committed Jan 20, 2025
1 parent 26f6ec5 commit 3df5571
Showing 1 changed file with 8 additions and 31 deletions.
39 changes: 8 additions & 31 deletions src/chemenv/tools/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,14 @@ class _Name2Smiles:
Raises:
ValueError: If the name cannot be URL-encoded or contains invalid characters.
"""

def __init__(self, name: str, timeout: int):
"""Initialize converter with chemical name.
Args:
name (str): Chemical compound name to convert
timeout (int): Timeout for API requests in seconds
Raises:
ValueError: If name cannot be URL-encoded
Example:
Example:
# Basic usage with IUPAC name
>>> converter = Name2Smiles("2-propanone")
>>> await converter.get_smiles()
'CC(=O)C'
"""
"""

def __init__(self, name: str, timeout: int):
try:
self.name = quote(name)
except Exception as e:
Expand Down Expand Up @@ -203,27 +193,14 @@ class _Smiles2Name:
Raises:
ValueError: If the SMILES string is invalid or cannot be encoded.
"""
def __init__(self, smiles: str, timeout: int):
"""Initialize Name2Smiles converter with a chemical compound name.
Takes a chemical compound name and prepares it for API queries by URL-encoding.
Sets default timeout for API requests to 10 seconds.
Args:
name (str): Chemical compound name to convert to SMILES notation.
Should be a valid IUPAC or common chemical name.
timeout (int): Timeout for API requests in seconds.
Raises:
ValueError: If the name cannot be URL-encoded or contains invalid characters.
Example:
Example:
>>> converter = Name2Smiles("ethanol")
>>> await converter.get_smiles()
'CCO'
"""
"""

def __init__(self, smiles: str, timeout: int):
mol = Chem.MolFromSmiles(smiles.strip())
if mol is None:
raise ValueError(f"Invalid SMILES: {smiles}")
Expand Down

0 comments on commit 3df5571

Please sign in to comment.