Skip to content

Commit

Permalink
Let Structure inherit from ABCMeta
Browse files Browse the repository at this point in the history
  • Loading branch information
schmoelder committed Dec 6, 2024
1 parent a7ec502 commit 58576f5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions CADETProcess/dataStructure/dataStructure.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from abc import ABC
from abc import ABC, ABCMeta
from collections import OrderedDict
from inspect import Parameter, Signature
from functools import wraps
Expand Down Expand Up @@ -325,8 +325,13 @@ def __new__(cls, clsname, bases, clsdict):
return clsobj



class AbstractStructMeta(StructMeta, ABCMeta):
pass


# %% Stucture / ParameterHandler
class Structure(metaclass=StructMeta):
class Structure(metaclass=AbstractStructMeta):
"""
A class representing a structured data entity.
Expand Down Expand Up @@ -359,18 +364,17 @@ def __init__(self, *args, **kwargs):
**kwargs
Keyword arguments representing parameters.
"""
bound = self.__signature__.bind_partial(*args, **kwargs)
for name, val in bound.arguments.items():
setattr(self, name, val)

self._parameters_dict = Dict()
for param in self._parameters:
value = getattr(self, param)
if param in self._optional_parameters and value is None:
continue

self._parameters_dict[param] = value

bound = self.__signature__.bind_partial(*args, **kwargs)
for name, val in bound.arguments.items():
setattr(self, name, val)

@property
def parameters(self):
"""dict: Parameters of the instance."""
Expand Down

0 comments on commit 58576f5

Please sign in to comment.