Skip to content

Commit

Permalink
Merge pull request #22 from syngenta/ci/apply-isort-check-for-all-files
Browse files Browse the repository at this point in the history
ci: apply isort check for all files
  • Loading branch information
MartaPasquini authored Mar 24, 2023
2 parents f43ddf1 + 1d742a5 commit fab36d3
Show file tree
Hide file tree
Showing 21 changed files with 140 additions and 78 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
rev: 5.12.0
hooks:
- id: isort
files: '^src/.*\.pyi?$'
files: '.*\.pyi?$'
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from setuptools import setup

setup()
14 changes: 8 additions & 6 deletions tests/cgu/test_convert.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from linchemin.cgu.convert import converter
from linchemin.cgu.translate import translator
from linchemin.cgu.syngraph import (SynGraph, BipartiteSynGraph, MonopartiteReacSynGraph)

import pytest
import json
from pathlib import Path
import os
from pathlib import Path

import pytest

from linchemin.cgu.convert import converter
from linchemin.cgu.syngraph import (BipartiteSynGraph, MonopartiteReacSynGraph,
SynGraph)
from linchemin.cgu.translate import translator


def test_strategy_structure(ibm1_path):
Expand Down
5 changes: 3 additions & 2 deletions tests/cgu/test_discgraph.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import pytest

from linchemin.cgu.discgraph import DisconnectionGraph, MissingAtomMapping
from linchemin.cheminfo.constructors import ChemicalEquationConstructor
from linchemin.cgu.syngraph import MonopartiteReacSynGraph
import pytest
from linchemin.cheminfo.constructors import ChemicalEquationConstructor

mapped_reactions = {'r1': 'CN(C)C=O.F[c:5]1[n:6][cH:7][cH:8][cH:9][c:10]1[F:11].O=C([O-])[O-].[CH3:1][CH:2]([CH3:3])['
'SH:4].[K+].[K+]>>[CH3:1][CH:2]([CH3:3])[S:4][c:5]1[n:6][cH:7][cH:8][cH:9][c:10]1[F:11]'}
Expand Down
2 changes: 1 addition & 1 deletion tests/cgu/test_iron.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from linchemin.cgu.iron import Node, Edge, Direction, Iron
from linchemin.cgu.iron import Direction, Edge, Iron, Node


def test_direction():
Expand Down
13 changes: 9 additions & 4 deletions tests/cgu/test_syngraph.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
from linchemin.cgu.syngraph import (BipartiteSynGraph, MonopartiteReacSynGraph, MonopartiteMolSynGraph, merge_syngraph,
extract_reactions_from_syngraph)
from linchemin.cgu.translate import translator
from linchemin.cheminfo.constructors import ChemicalEquationConstructor, MoleculeConstructor
import json

import pytest

from linchemin.cgu.syngraph import (BipartiteSynGraph, MonopartiteMolSynGraph,
MonopartiteReacSynGraph,
extract_reactions_from_syngraph,
merge_syngraph)
from linchemin.cgu.translate import translator
from linchemin.cheminfo.constructors import (ChemicalEquationConstructor,
MoleculeConstructor)


def test_bipartite_syngraph_instance(az_path):
""" To test that a BipartiteSynGraph instance is correctly generated. """
Expand Down
23 changes: 14 additions & 9 deletions tests/cgu/test_translate.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
from linchemin.cgu.iron import Iron, Node, Edge, Direction
from linchemin.cgu.translate import (translator, ibm_dict_to_iron, get_available_formats, az_dict_to_iron,
get_available_data_models, get_output_formats, get_input_formats, TranslationError)
from linchemin.cgu.syngraph import BipartiteSynGraph, MonopartiteReacSynGraph
from linchemin.cheminfo.models import ChemicalEquation
import json
import pydot
import networkx as nx
import pytest
import logging
import os
import unittest.mock
import logging

import networkx as nx
import pydot
import pytest

from linchemin.cgu.iron import Direction, Edge, Iron, Node
from linchemin.cgu.syngraph import BipartiteSynGraph, MonopartiteReacSynGraph
from linchemin.cgu.translate import (TranslationError, az_dict_to_iron,
get_available_data_models,
get_available_formats, get_input_formats,
get_output_formats, ibm_dict_to_iron,
translator)
from linchemin.cheminfo.models import ChemicalEquation


def generate_iron_test_graph():
Expand Down
15 changes: 10 additions & 5 deletions tests/cheminfo/test_atom_mapping.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from linchemin.cheminfo.atom_mapping import pipeline_atom_mapping, perform_atom_mapping, get_available_mappers
from linchemin.cgu.syngraph import extract_reactions_from_syngraph, MonopartiteReacSynGraph, merge_syngraph
from linchemin.cgu.translate import translator

import pytest
import json
import unittest.mock

import pytest

from linchemin.cgu.syngraph import (MonopartiteReacSynGraph,
extract_reactions_from_syngraph,
merge_syngraph)
from linchemin.cgu.translate import translator
from linchemin.cheminfo.atom_mapping import (get_available_mappers,
perform_atom_mapping,
pipeline_atom_mapping)


def test_basic_factory(capfd):
with pytest.raises(KeyError) as ke:
Expand Down
9 changes: 5 additions & 4 deletions tests/cheminfo/test_chemical_similarity.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import linchemin.cheminfo.functions as cif
from linchemin.cheminfo.chemical_similarity import (compute_reaction_fingerprint, compute_similarity,
compute_mol_fingerprint)
import pytest
from rdkit.Chem import rdChemReactions, DataStructs
from rdkit.Chem import DataStructs, rdChemReactions

import linchemin.cheminfo.functions as cif
from linchemin.cheminfo.chemical_similarity import (
compute_mol_fingerprint, compute_reaction_fingerprint, compute_similarity)


def test_rdkit_reaction_fingerprints_basics_non_mapped_molecules():
Expand Down
25 changes: 16 additions & 9 deletions tests/cheminfo/test_constructors.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import unittest
from itertools import combinations
from linchemin.cheminfo.constructors import (MoleculeConstructor, ChemicalEquationConstructor, RatamConstructor,
BadMapping, PatternConstructor, TemplateConstructor,
DisconnectionConstructor, calculate_molecular_hash_values,
UnavailableMolIdentifier)
from linchemin.cheminfo.models import Template
from linchemin.utilities import create_hash

import pytest

import linchemin.cheminfo.depiction as cid
import linchemin.cheminfo.functions as cif
from linchemin.cheminfo.constructors import (BadMapping,
ChemicalEquationConstructor,
DisconnectionConstructor,
MoleculeConstructor,
PatternConstructor,
RatamConstructor,
TemplateConstructor,
UnavailableMolIdentifier,
calculate_molecular_hash_values)
from linchemin.cheminfo.models import Template
from linchemin.IO import io as lio
import linchemin.cheminfo.depiction as cid
import unittest
import pytest
from linchemin.utilities import create_hash


# Molecule tests
Expand Down
27 changes: 20 additions & 7 deletions tests/cheminfo/test_functions.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
import unittest

import pytest
from rdkit import Chem
from rdkit.Chem import DataStructs, rdChemReactions
import unittest

from linchemin.cheminfo.constructors import ChemicalEquationConstructor, MoleculeConstructor
from linchemin.cheminfo.constructors import (ChemicalEquationConstructor,
MoleculeConstructor)
from linchemin.cheminfo.functions import (bstr_to_rdmol,
canonicalize_mapped_rdmol,
canonicalize_rdmol,
canonicalize_rdmol_lite,
compute_oxidation_numbers,
get_canonical_order,
has_mapped_products,
is_mapped_molecule,
mapping_diagnosis,
rdchiral_extract_template)
from linchemin.cheminfo.functions import rdkit as rdkit
from linchemin.cheminfo.functions import canonicalize_rdmol, get_canonical_order, rdmol_from_string, \
rdrxn_to_string, rdrxn_from_string, rdmol_to_bstr, bstr_to_rdmol, \
rdrxn_from_string, is_mapped_molecule, has_mapped_products, canonicalize_rdmol_lite,\
compute_oxidation_numbers, rdrxn_role_reassignment, rdrxn_to_rxn_mol_catalog, \
remove_rdmol_atom_mapping, rdchiral_extract_template, canonicalize_mapped_rdmol, mapping_diagnosis
from linchemin.cheminfo.functions import (rdmol_from_string, rdmol_to_bstr,
rdrxn_from_string,
rdrxn_role_reassignment,
rdrxn_to_rxn_mol_catalog,
rdrxn_to_string,
remove_rdmol_atom_mapping)


def test_build_rdrxn_from_smiles():
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path

import pytest


Expand Down
2 changes: 1 addition & 1 deletion tests/interfaces/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import unittest.mock
import os
import unittest.mock


def test_cli_basic(capfd, cli):
Expand Down
13 changes: 7 additions & 6 deletions tests/interfaces/test_facade.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from linchemin.interfaces.facade import facade, facade_helper
from linchemin.cgu.syngraph import MonopartiteReacSynGraph, BipartiteSynGraph
from rdkit.Chem import rdChemReactions
import json
import unittest
import unittest.mock

import pandas as pd
from rdkit.Chem import rdChemReactions

import unittest.mock
import unittest
import json
from linchemin.cgu.syngraph import BipartiteSynGraph, MonopartiteReacSynGraph
from linchemin.interfaces.facade import facade, facade_helper


def test_translate(ibm2_path):
Expand Down
7 changes: 4 additions & 3 deletions tests/interfaces/test_workflows.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from linchemin.interfaces.workflows import process_routes, get_workflow_options
from linchemin.interfaces.facade import facade
import unittest.mock

import pytest
import unittest.mock

from linchemin.interfaces.facade import facade
from linchemin.interfaces.workflows import get_workflow_options, process_routes


@unittest.mock.patch('linchemin.IO.io.write_json')
Expand Down
1 change: 1 addition & 0 deletions tests/io/test_io_functions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

from linchemin.IO import io as lio


Expand Down
8 changes: 6 additions & 2 deletions tests/rem/test_clustering.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from linchemin.rem.clustering import (clusterer, get_available_clustering, get_clustered_routes_metrics, ClusteringError)
from linchemin.cgu.translate import translator
import json

import pytest

from linchemin.cgu.translate import translator
from linchemin.rem.clustering import (ClusteringError, clusterer,
get_available_clustering,
get_clustered_routes_metrics)


def test_clusterer(az_path):
graph = json.loads(open(az_path).read())
Expand Down
22 changes: 14 additions & 8 deletions tests/rem/test_graph_distance.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
from linchemin.rem.graph_distance import (graph_distance_factory, compute_nodes_fingerprints, build_similarity_matrix,
get_available_ged_algorithms, get_ged_default_parameters,
compute_distance_matrix, get_ged_parameters, GraphDistanceError)
from linchemin.cgu.translate import translator
from linchemin.cgu.convert import converter

import json
import pytest

import networkx as nx
import pandas as pd
import numpy as np
import pandas as pd
import pytest
from rdkit.Chem import rdChemReactions

from linchemin.cgu.convert import converter
from linchemin.cgu.translate import translator
from linchemin.rem.graph_distance import (GraphDistanceError,
build_similarity_matrix,
compute_distance_matrix,
compute_nodes_fingerprints,
get_available_ged_algorithms,
get_ged_default_parameters,
get_ged_parameters,
graph_distance_factory)


def test_similarity_factory(az_path):
# Test similarity with oneself with monopartite syngraphs and factory workflow
Expand Down
5 changes: 3 additions & 2 deletions tests/rem/test_node_metrics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from linchemin.rem.node_metrics import node_score_calculator, reaction_mapping
from linchemin.cheminfo.constructors import ChemicalEquationConstructor
import pytest

from linchemin.cheminfo.constructors import ChemicalEquationConstructor
from linchemin.rem.node_metrics import node_score_calculator, reaction_mapping


def test_factory():
smile1 = 'CC(O)=O.CN>>CNC(C)=O'
Expand Down
16 changes: 11 additions & 5 deletions tests/rem/test_route_descriptors.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
from linchemin.cgu.convert import converter
from linchemin.rem.route_descriptors import (find_path, descriptor_calculator, is_subset, find_duplicates,
get_nodes_consensus, get_available_descriptors, DescriptorError)
from linchemin.cgu.syngraph import SynGraph, merge_syngraph, MonopartiteReacSynGraph
import json
from linchemin.cgu.translate import translator

import pytest

from linchemin.cgu.convert import converter
from linchemin.cgu.syngraph import (MonopartiteReacSynGraph, SynGraph,
merge_syngraph)
from linchemin.cgu.translate import translator
from linchemin.rem.route_descriptors import (DescriptorError,
descriptor_calculator,
find_duplicates, find_path,
get_available_descriptors,
get_nodes_consensus, is_subset)


def test_unavailable_metrics(ibm1_path):
""" To test that a KeyError is raised if an unavailable metrics is requested. """
Expand Down
7 changes: 4 additions & 3 deletions tests/rem/test_route_scoring.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from linchemin.rem.route_scoring import route_scorer
from linchemin.cgu.translate import translator
import json

import pytest
import json

from linchemin.cgu.translate import translator
from linchemin.rem.route_scoring import route_scorer


def test_scoring_factory(ibm1_path):
Expand Down

0 comments on commit fab36d3

Please sign in to comment.