Skip to content

Commit

Permalink
Merge pull request #225 from hjkgrp/fix_rtd
Browse files Browse the repository at this point in the history
Fix documentation
  • Loading branch information
ralf-meyer committed Apr 22, 2024
2 parents 7a938be + 5a05bf0 commit 47b7ba9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/source/Classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mol3D Class
Mol2D Class
--------------------------------

.. automodule:: molSimplify.Classes.mol3D
.. automodule:: molSimplify.Classes.mol2D
:members:
:undoc-members:
:show-inheritance:
Expand Down
31 changes: 19 additions & 12 deletions molSimplify/Classes/mol2D.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import networkx as nx
import numpy as np
from typing import List
from typing import List, Union
from packaging import version
from molSimplify.Classes.globalvars import globalvars

Expand Down Expand Up @@ -28,7 +28,7 @@ def __repr__(self):
return f"Mol2D({formula})"

@classmethod
def from_smiles(cls, smiles):
def from_smiles(cls, smiles: str):
"""Create a Mol2D object from a SMILES string.
Parameters
Expand All @@ -44,6 +44,7 @@ def from_smiles(cls, smiles):
Examples
--------
Create a furan molecule from SMILES:
>>> mol = Mol2D.from_smiles("o1cccc1")
>>> mol
Mol2D(O1C4H4)
Expand Down Expand Up @@ -121,7 +122,7 @@ def from_mol_file(cls, filename):

return mol

def graph_hash(self):
def graph_hash(self) -> str:
"""Calculates the node attributed graph hash of the molecule.
Returns
Expand All @@ -132,9 +133,11 @@ def graph_hash(self):
Examples
--------
Create a furan molecule from SMILES:
>>> mol = Mol2D.from_smiles("o1cccc1")
and calculate its graph hash:
and calculate the node attributed graph hash:
>>> mol.graph_hash()
'f6090276d7369c0c0a535113ec1d97cf'
"""
Expand All @@ -144,7 +147,7 @@ def graph_hash(self):
assert version.parse(nx.__version__) >= version.parse("2.7")
return nx.weisfeiler_lehman_graph_hash(self, node_attr="symbol")

def graph_hash_edge_attr(self):
def graph_hash_edge_attr(self) -> str:
"""Calculates the edge attributed graph hash of the molecule.
Returns
Expand All @@ -155,9 +158,11 @@ def graph_hash_edge_attr(self):
Examples
--------
Create a furan molecule from SMILES:
>>> mol = Mol2D.from_smiles("o1cccc1")
and calculate its graph hash:
and calculate the edge attributed graph hash:
>>> mol.graph_hash_edge_attr()
'a9b6fbc7b5f53613546d5e91a7544ed6'
"""
Expand All @@ -174,7 +179,7 @@ def graph_hash_edge_attr(self):

return nx.weisfeiler_lehman_graph_hash(G, edge_attr="label")

def graph_determinant(self, return_string=True):
def graph_determinant(self, return_string: bool = True) -> Union[str, float]:
"""Calculates the molecular graph determinant.
Parameters
Expand All @@ -184,15 +189,17 @@ def graph_determinant(self, return_string=True):
Returns
-------
str
edge attributed graph hash
str | float
graph determinant
Examples
--------
Create a furan molecule from SMILES:
>>> mol = Mol2D.from_smiles("o1cccc1")
and calculate its graph hash:
and calculate the graph determinant:
>>> mol.graph_determinant()
'-19404698740'
"""
Expand Down Expand Up @@ -224,7 +231,7 @@ def graph_determinant(self, return_string=True):

def find_metal(self, transition_metals_only: bool = True) -> List[int]:
"""
Find metal(s) in a Mol2D class.
Find indices of metal(s) in a Mol2D class.
Parameters
----------
Expand All @@ -239,8 +246,8 @@ def find_metal(self, transition_metals_only: bool = True) -> List[int]:
Examples
--------
Build Vanadyl acetylacetonate from SMILES:
>>> mol = Mol2D.from_smiles("CC(=[O+]1)C=C(C)O[V-3]12(#[O+])OC(C)=CC(C)=[O+]2")
>>> mol = Mol2D.from_smiles("CC(=[O+]1)C=C(C)O[V-3]12(#[O+])OC(C)=CC(C)=[O+]2")
>>> mol.find_metal()
[7]
"""
Expand Down

0 comments on commit 47b7ba9

Please sign in to comment.