Skip to content

Commit e2e4e83

Browse files
authored
Merge pull request #46 from timbernat/release-cleanup
Release cleanup
2 parents 4e06cec + 966bfab commit e2e4e83

44 files changed

Lines changed: 5670 additions & 886 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

devtools/conda-envs/release-build.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ dependencies:
3939

4040
# MD engines
4141
- openmm
42-
# - lammps # NOTE: this grinds the conda/libmamba env solver to a halt, so we install it via pip instead
42+
- lammps # DEV: keep an eye on this as updates roll out - 2024.08.29 is latest STABLE version at time of writing this comment (08/18/25)
4343
- mdtraj
4444
- pint # for units in case OpenFF is not installed
4545

@@ -57,5 +57,4 @@ dependencies:
5757
- pubchempy
5858

5959
# pip installs
60-
- pip:
61-
- lammps>=2024 # NOTE: see above - conda version of lammps exists, but makes env solve prohibitively slow
60+
# - pip:

devtools/conda-envs/test-env.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies:
2626

2727
# MD engines
2828
- openmm
29-
# - lammps # NOTE: this grinds the conda/libmamba env solver to a halt, so we install it via pip instead
29+
- lammps # DEV: keep an eye on this as updates roll out - 2024.08.29 is latest STABLE version at time of writing this comment (08/18/25)
3030
- mdtraj
3131
- pint # for units in case OpenFF is not installed
3232

@@ -44,5 +44,4 @@ dependencies:
4444
- pubchempy
4545

4646
# pip installs
47-
- pip:
48-
- lammps>=2024 # NOTE: see above - conda version of lammps exists, but makes env solve prohibitively slow
47+
# - pip:

polymerist/analysis/__init__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

polymerist/analysis/calculation.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

polymerist/analysis/mdtrajutils.py

Lines changed: 0 additions & 148 deletions
This file was deleted.

polymerist/genutils/decorators/signatures.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,23 @@
55

66
from inspect import Parameter, Signature
77

8-
POSITIONAL_PARAMETER_TYPES = [
8+
POSITIONAL_PARAMETER_TYPES = (
99
Parameter.POSITIONAL_ONLY,
1010
Parameter.POSITIONAL_OR_KEYWORD,
1111
Parameter.VAR_POSITIONAL
12-
]
12+
)
13+
KEYWORD_PARAMETER_TYPES = (
14+
Parameter.KEYWORD_ONLY,
15+
Parameter.VAR_KEYWORD
16+
)
1317

1418
def get_index_after_positionals(sig : Signature) -> int:
1519
'''Get the first Parameter index which follows all positional Parameters'''
1620
for i, param in enumerate(sig.parameters.values()):
17-
if param.kind not in POSITIONAL_PARAMETER_TYPES:
18-
return i + 1 # return index immediately after first non-positional argument
19-
else:
20-
return len(sig.parameters)
21+
if param.kind in KEYWORD_PARAMETER_TYPES:
22+
return i
23+
else:
24+
return len(sig.parameters)
2125

2226
def insert_parameter_at_index(sig : Signature, new_param : Parameter, index : int) -> Signature:
2327
'''Insert a new Parameter into a Signature at a given position'''

polymerist/genutils/fileutils/jsonio/jsonify.py

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@
33
__author__ = 'Timotej Bernat'
44
__email__ = 'timotej.bernat@colorado.edu'
55

6-
from typing import Any, Callable, ClassVar, Optional, Type, TypeVar, Union
6+
from typing import (
7+
Any,
8+
ClassVar,
9+
Optional,
10+
Type,
11+
TypeVar,
12+
Union,
13+
get_origin,
14+
get_args,
15+
)
716
C = TypeVar('C') # generic type for classes
817

918
from dataclasses import dataclass, is_dataclass
10-
from functools import update_wrapper, wraps
19+
from functools import wraps
1120
from inspect import signature, isclass
1221

1322
import json
@@ -68,12 +77,30 @@ def jsonifiable_factory(cls : C) -> C:
6877

6978
# check if any of the init fields of the dataclass are also JSONifiable, register respective serializers if they are
7079
for init_param in signature(cls).parameters.values(): # TODO: find a way to have this recognize serializable classes in default containers (e.g. list[JSONifiable])
71-
if isclass(init_param.annotation) and issubclass(init_param.annotation, JSONifiable): # check if the init field is itself a JSONifiable class
72-
multi_serializer.add_type_serializer(init_param.annotation.serializer)
80+
if get_origin(init_param.annotation) == Union:
81+
init_param_types : tuple[Type] = get_args(init_param.annotation)
82+
else:
83+
init_param_types : tuple[Type] = (init_param.annotation,)
84+
85+
for init_param_type in init_param_types: # scrape sub-TypeSerializers from annotated init argument types
86+
if isclass(init_param_type) and issubclass(init_param_type, JSONifiable):
87+
multi_serializer.add_type_serializer(init_param_type.serializer)
7388

7489
# generate serializable wrapper class
75-
@wraps(cls, updated=()) # copy over docstring, module, etc; set updated to empty so as to not attempt __dict__updates (classes don;t have these)
7690
@dataclass
91+
@wraps(
92+
cls,
93+
assigned=(
94+
'__module__',
95+
'__name__',
96+
'__qualname__',
97+
'__doc__',
98+
# '__annotations__',
99+
## DEVNOTE: NEED to have __annotations__ suppressed for wrapped functions to have correct signature on missing argument TypeError
100+
## Before you say it, NO, "wraps" can't just be placed before (i.e. around) the @dataclass call - that's what screws up the names in the first place
101+
),
102+
updated=(), # DEVNOTE: set updated to empty so as to not attempt __dict__updates (classes don't have these)
103+
) # copy over docstring, module, etc;
77104
class WrappedClass(cls, JSONifiable):
78105
'''Class which inherits from modified class and adds JSON serialization capability'''
79106
serializer : ClassVar[MultiTypeSerializer] = multi_serializer
@@ -87,7 +114,7 @@ def to_file(self, save_path : Path) -> None:
87114

88115
@classmethod
89116
@allow_string_paths
90-
def from_file(cls, load_path : Path) -> cls.__class__:
117+
def from_file(cls, load_path : Path) -> cls:
91118
assert(load_path.suffix == '.json')
92119
with load_path.open('r') as loadfile:
93120
return json.load(loadfile, object_hook=cls.serializer.decoder_hook)

0 commit comments

Comments
 (0)