Skip to content

Commit

Permalink
formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
wsprague-nu committed May 8, 2024
1 parent 15b2827 commit fb88a59
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 91 deletions.
1 change: 0 additions & 1 deletion doranet/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
"""A streamlined, generic rewrite of Pickaxe."""


from doranet.engine import create_engine # noqa:F401
54 changes: 19 additions & 35 deletions doranet/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ def __init__(
molecule: typing.Union[rdkit.Chem.rdchem.Mol, str],
sanitize: bool = True,
neutralize: bool = False,
) -> None:
...
) -> None: ...

@property
@abc.abstractmethod
Expand Down Expand Up @@ -450,8 +449,7 @@ def __init__(
engine: "NetworkEngine",
kekulize: bool = False,
drop_errors: bool = False,
) -> None:
...
) -> None: ...

@classmethod
def from_bytes(
Expand All @@ -478,9 +476,9 @@ def from_bytes(
pickaxe_generic.interfaces.OpDatRDKit
Operator returned from processing bytestring.
"""
unpacked: tuple[
rdkit.Chem.rdChemReactions.ChemicalReaction, bool
] = pickle.loads(data)
unpacked: tuple[rdkit.Chem.rdChemReactions.ChemicalReaction, bool] = (
pickle.loads(data)
)
operator, kekulize = unpacked
return engine.op.rdkit(operator, kekulize)

Expand Down Expand Up @@ -1624,8 +1622,7 @@ class _max_atoms_from_num(typing.Protocol):
@abc.abstractmethod
def __call__(
cls, max_atoms: int, proton_number: typing.Optional[int] = None
) -> "filters.ReactionFilterMaxAtoms":
...
) -> "filters.ReactionFilterMaxAtoms": ...


@typing.final
Expand Down Expand Up @@ -1884,13 +1881,11 @@ def __contains__(self, item: typing.Union[Identifier, T_data]) -> bool:

@abc.abstractmethod
@typing.overload
def __getitem__(self, item: slice) -> collections.abc.Sequence[T_data]:
...
def __getitem__(self, item: slice) -> collections.abc.Sequence[T_data]: ...

@abc.abstractmethod
@typing.overload
def __getitem__(self, item: typing.Union[T_int, Identifier]) -> T_data:
...
def __getitem__(self, item: typing.Union[T_int, Identifier]) -> T_data: ...

@abc.abstractmethod
def i(self, uid: Identifier) -> T_int:
Expand Down Expand Up @@ -1927,8 +1922,7 @@ def meta(
keys: typing.Optional[
collections.abc.Iterable[collections.abc.Hashable]
] = None,
) -> collections.abc.Mapping[typing.Hashable, typing.Any]:
...
) -> collections.abc.Mapping[typing.Hashable, typing.Any]: ...

@abc.abstractmethod
@typing.overload
Expand All @@ -1940,8 +1934,7 @@ def meta(
] = None,
) -> collections.abc.Iterable[
collections.abc.Mapping[typing.Hashable, typing.Any]
]:
...
]: ...

@abc.abstractmethod
def meta(
Expand Down Expand Up @@ -2055,13 +2048,11 @@ class ValueQueryAssoc(typing.Protocol[T_id, T_int]):

@typing.overload
@abc.abstractmethod
def __getitem__(self, item: slice) -> collections.abc.Sequence[T_id]:
...
def __getitem__(self, item: slice) -> collections.abc.Sequence[T_id]: ...

@typing.overload
@abc.abstractmethod
def __getitem__(self, item: T_int) -> T_id:
...
def __getitem__(self, item: T_int) -> T_id: ...

@abc.abstractmethod
def i(self, item: T_id) -> T_int:
Expand All @@ -2087,8 +2078,7 @@ def meta(
keys: typing.Optional[
collections.abc.Iterable[collections.abc.Hashable]
] = None,
) -> collections.abc.Mapping:
...
) -> collections.abc.Mapping: ...

@typing.overload
@abc.abstractmethod
Expand All @@ -2098,8 +2088,7 @@ def meta(
keys: typing.Optional[
collections.abc.Iterable[collections.abc.Hashable]
] = None,
) -> collections.abc.Iterable[collections.abc.Mapping]:
...
) -> collections.abc.Iterable[collections.abc.Mapping]: ...

@abc.abstractmethod
def meta(
Expand Down Expand Up @@ -2201,8 +2190,7 @@ class ChemNetwork(abc.ABC):
__slots__ = ()

@abc.abstractmethod
def __init__(self) -> None:
...
def __init__(self) -> None: ...

@property
@abc.abstractmethod
Expand Down Expand Up @@ -2679,8 +2667,7 @@ class PriorityQueueStrategy(abc.ABC):
def __init__(
self,
network: ChemNetwork,
) -> None:
...
) -> None: ...

@abc.abstractmethod
def expand(
Expand Down Expand Up @@ -2862,13 +2849,11 @@ class MetaDataCalculatorLocal(typing.Protocol):
@abc.abstractmethod
def __call__(
self, unit: typing.Union[ReactionExplicit, RecipeExplicit]
) -> None:
...
) -> None: ...

@property
@abc.abstractmethod
def meta_required(self) -> MetaKeyPacket:
...
def meta_required(self) -> MetaKeyPacket: ...


class MetaDataUpdate(typing.Protocol):
Expand All @@ -2882,5 +2867,4 @@ def __call__(
],
None,
None,
]:
...
]: ...
55 changes: 20 additions & 35 deletions doranet/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ class MetaSink(typing.Protocol):

@property
@abc.abstractmethod
def meta_required(self) -> interfaces.MetaKeyPacket:
...
def meta_required(self) -> interfaces.MetaKeyPacket: ...


_T = typing.TypeVar("_T")
Expand All @@ -31,18 +30,15 @@ def TrivialMetaDataResolverFunc(a: _T, b: _T) -> _T:
class LocalPropertyCalc(abc.ABC, typing.Generic[_T]):
@property
@abc.abstractmethod
def key(self) -> collections.abc.Hashable:
...
def key(self) -> collections.abc.Hashable: ...

@property
@abc.abstractmethod
def meta_required(self) -> interfaces.MetaKeyPacket:
...
def meta_required(self) -> interfaces.MetaKeyPacket: ...

@property
@abc.abstractmethod
def resolver(self) -> MetaDataResolverFunc[_T]:
...
def resolver(self) -> MetaDataResolverFunc[_T]: ...

@typing.final
def __and__(
Expand Down Expand Up @@ -121,8 +117,7 @@ def __call__(
self,
data: interfaces.DataPacketE[interfaces.MolDatBase],
prev_value: typing.Optional[_T] = None,
) -> typing.Optional[_T]:
...
) -> typing.Optional[_T]: ...


class MolPropertyFromRxnCalc(LocalPropertyCalc[_T]):
Expand All @@ -132,8 +127,7 @@ def __call__(
data: interfaces.DataPacketE[interfaces.MolDatBase],
rxn: interfaces.ReactionExplicit,
prev_value: typing.Optional[_T] = None,
) -> typing.Optional[_T]:
...
) -> typing.Optional[_T]: ...


class OpPropertyCalc(LocalPropertyCalc[_T]):
Expand All @@ -142,8 +136,7 @@ def __call__(
self,
data: interfaces.DataPacketE[interfaces.OpDatBase],
prev_value: typing.Optional[_T] = None,
) -> typing.Optional[_T]:
...
) -> typing.Optional[_T]: ...


class OpPropertyFromRxnCalc(LocalPropertyCalc[_T]):
Expand All @@ -153,8 +146,7 @@ def __call__(
data: interfaces.DataPacketE[interfaces.OpDatBase],
rxn: interfaces.ReactionExplicit,
prev_value: typing.Optional[_T] = None,
) -> typing.Optional[_T]:
...
) -> typing.Optional[_T]: ...


class RxnPropertyCalc(LocalPropertyCalc[_T]):
Expand All @@ -163,8 +155,7 @@ def __call__(
self,
data: interfaces.ReactionExplicit,
prev_value: typing.Optional[_T] = None,
) -> typing.Optional[_T]:
...
) -> typing.Optional[_T]: ...


@dataclasses.dataclass(frozen=True)
Expand Down Expand Up @@ -209,8 +200,7 @@ class ReactionFilterBase(abc.ABC):
__slots__ = ()

@abc.abstractmethod
def __call__(self, recipe: interfaces.ReactionExplicit) -> bool:
...
def __call__(self, recipe: interfaces.ReactionExplicit) -> bool: ...

@property
def meta_required(self) -> interfaces.MetaKeyPacket:
Expand Down Expand Up @@ -303,13 +293,13 @@ def meta_required(self) -> interfaces.MetaKeyPacket:

class PropertyCompositor(abc.ABC):
@abc.abstractmethod
def __call__(self, rxn: interfaces.ReactionExplicit) -> "MetaPropertyState":
...
def __call__(
self, rxn: interfaces.ReactionExplicit
) -> "MetaPropertyState": ...

@property
@abc.abstractmethod
def keys(self) -> KeyOutput:
...
def keys(self) -> KeyOutput: ...

@typing.final
def __and__(
Expand Down Expand Up @@ -371,13 +361,11 @@ def __rshift__(

@property
@abc.abstractmethod
def meta_required(self) -> interfaces.MetaKeyPacket:
...
def meta_required(self) -> interfaces.MetaKeyPacket: ...

@property
@abc.abstractmethod
def resolver(self) -> "MetaUpdateResolver":
...
def resolver(self) -> "MetaUpdateResolver": ...


class MergePropertyCompositor(PropertyCompositor):
Expand Down Expand Up @@ -723,8 +711,7 @@ def execute(
rxns: collections.abc.Iterable[
tuple[interfaces.ReactionExplicit, bool]
],
) -> collections.abc.Iterable[tuple[interfaces.ReactionExplicit, bool]]:
...
) -> collections.abc.Iterable[tuple[interfaces.ReactionExplicit, bool]]: ...

@typing.final
def __rshift__(
Expand All @@ -744,13 +731,11 @@ def __rshift__(

@property
@abc.abstractmethod
def meta_required(self) -> interfaces.MetaKeyPacket:
...
def meta_required(self) -> interfaces.MetaKeyPacket: ...

@property
@abc.abstractmethod
def resolver(self) -> "MetaUpdateResolver":
...
def resolver(self) -> "MetaUpdateResolver": ...


@dataclasses.dataclass(frozen=True)
Expand Down Expand Up @@ -918,7 +903,7 @@ def resolver(self) -> "MetaUpdateResolver":


def _as_property_compositor(
arg: typing.Union[PropertyCompositor, LocalPropertyCalc]
arg: typing.Union[PropertyCompositor, LocalPropertyCalc],
) -> PropertyCompositor:
if isinstance(arg, PropertyCompositor):
return arg
Expand Down
24 changes: 8 additions & 16 deletions doranet/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,12 @@ def __contains__(
@typing.overload
def __getitem__(
self, item: slice
) -> collections.abc.Sequence[interfaces.T_data]:
...
) -> collections.abc.Sequence[interfaces.T_data]: ...

@typing.overload
def __getitem__(
self, item: typing.Union[interfaces.T_int, interfaces.Identifier]
) -> interfaces.T_data:
...
) -> interfaces.T_data: ...

def __getitem__(
self, item: typing.Union[slice, interfaces.T_int, interfaces.Identifier]
Expand All @@ -86,8 +84,7 @@ def meta(
keys: typing.Optional[
collections.abc.Iterable[collections.abc.Hashable]
] = None,
) -> collections.abc.Mapping[collections.abc.Hashable, typing.Any]:
...
) -> collections.abc.Mapping[collections.abc.Hashable, typing.Any]: ...

@typing.overload
def meta(
Expand All @@ -100,8 +97,7 @@ def meta(
] = None,
) -> collections.abc.Iterable[
collections.abc.Mapping[collections.abc.Hashable, typing.Any]
]:
...
]: ...

def meta(
self,
Expand Down Expand Up @@ -165,12 +161,10 @@ class _ValueQueryAssoc(typing.Generic[interfaces.T_id, interfaces.T_int]):
@typing.overload
def __getitem__(
self, item: slice
) -> collections.abc.Sequence[interfaces.T_id]:
...
) -> collections.abc.Sequence[interfaces.T_id]: ...

@typing.overload
def __getitem__(self, item: interfaces.T_int) -> interfaces.T_id:
...
def __getitem__(self, item: interfaces.T_int) -> interfaces.T_id: ...

def __getitem__(self, item: typing.Union[slice, interfaces.T_int]):
if isinstance(item, slice):
Expand All @@ -187,8 +181,7 @@ def meta(
keys: typing.Optional[
collections.abc.Iterable[collections.abc.Hashable]
] = None,
) -> collections.abc.Mapping[collections.abc.Hashable, typing.Any]:
...
) -> collections.abc.Mapping[collections.abc.Hashable, typing.Any]: ...

@typing.overload
def meta(
Expand All @@ -201,8 +194,7 @@ def meta(
] = None,
) -> collections.abc.Iterable[
collections.abc.Mapping[collections.abc.Hashable, typing.Any]
]:
...
]: ...

def meta(
self,
Expand Down
Loading

0 comments on commit fb88a59

Please sign in to comment.