diff --git a/dace/properties.py b/dace/properties.py index 5fc9b8dcbe..d4a66476b2 100644 --- a/dace/properties.py +++ b/dace/properties.py @@ -24,35 +24,6 @@ ############################################################################### -def set_property_from_string(prop, obj, string, sdfg=None, from_json=False): - """ Interface function that guarantees that a property will always be - correctly set, if possible, by accepting all possible input arguments to - from_string. """ - - # If the property is a string (property name), obtain it from the object - if isinstance(prop, str): - prop = type(obj).__properties__[prop] - - if isinstance(prop, CodeProperty): - if from_json: - val = prop.from_json(string) - else: - val = prop.from_string(string, obj.language) - elif isinstance(prop, (ReferenceProperty, DataProperty)): - if sdfg is None: - raise ValueError("You cannot pass sdfg=None when editing a ReferenceProperty!") - if from_json: - val = prop.from_json(string, sdfg) - else: - val = prop.from_string(string, sdfg) - else: - if from_json: - val = prop.from_json(string, sdfg) - else: - val = prop.from_string(string) - setattr(obj, prop.attr_name, val) - - ############################################################################### # Property base implementation ############################################################################### @@ -74,8 +45,6 @@ def __init__( setter=None, dtype: Type[T] = None, default=None, - from_string=None, - to_string=None, from_json=None, to_json=None, meta_to_json=None, @@ -114,35 +83,8 @@ def __init__( if not isinstance(choice, dtype): raise TypeError("All choices must be an instance of dtype") - if from_string is not None: - self._from_string = from_string - elif choices is not None: - self._from_string = lambda s: choices[s] - else: - self._from_string = self.dtype - - if to_string is not None: - self._to_string = to_string - elif choices is not None: - self._to_string = lambda val: val.__name__ - else: - self._to_string = str - if from_json is None: - if self._from_string is not None: - - def fs(obj, *args, **kwargs): - if isinstance(obj, str): - # The serializer does not know about this property, so if - # we can convert using our to_string method, do that here - return self._from_string(obj) - # Otherwise ship off to the serializer, telling it which type - # it's dealing with as a sanity check - return dace.serialize.from_json(obj, *args, known_type=dtype, **kwargs) - - self._from_json = fs - else: - self._from_json = lambda *args, **kwargs: dace.serialize.from_json(*args, known_type=dtype, **kwargs) + self._from_json = lambda *args, **kwargs: dace.serialize.from_json(*args, known_type=dtype, **kwargs) else: self._from_json = from_json if self.from_json != from_json: @@ -226,7 +168,6 @@ def __set__(self, obj, val): if (self.dtype is not None and not isinstance(val, self.dtype) and not (val is None and self.allow_none)): if isinstance(val, str): raise TypeError("Received str for property {} of type {}. Use " - "dace.properties.set_property_from_string or the " "from_string method of the property.".format(self.attr_name, self.dtype)) raise TypeError("Invalid type \"{}\" for property {}: expected {}".format( type(val).__name__, self.attr_name, self.dtype.__name__)) @@ -296,14 +237,6 @@ def allow_none(self): def desc(self): return self._desc - @property - def from_string(self): - return self._from_string - - @property - def to_string(self): - return self._to_string - @property def from_json(self): return self._from_json @@ -853,8 +786,6 @@ def __init__( getter=None, setter=None, default=None, - from_string=None, - to_string=None, from_json=None, to_json=None, unmapped=False, # Don't enforce 1:1 mapping with a member variable @@ -867,8 +798,6 @@ def __init__( setter=setter, dtype=set, default=default, - from_string=from_string, - to_string=to_string, from_json=from_json, to_json=to_json, choices=None, diff --git a/dace/sdfg/sdfg.py b/dace/sdfg/sdfg.py index f2f30d06a4..adcaacaf27 100644 --- a/dace/sdfg/sdfg.py +++ b/dace/sdfg/sdfg.py @@ -122,25 +122,6 @@ def _replace_dict_values(d, old, new): d[k] = new -def _assignments_from_string(astr): - """ Returns a dictionary of assignments from a semicolon-delimited - string of expressions. """ - - result = {} - for aitem in astr.split(';'): - aitem = aitem.strip() - m = re.search(r'([^=\s]+)\s*=\s*([^=]+)', aitem) - result[m.group(1)] = m.group(2) - - return result - - -def _assignments_to_string(assdict): - """ Returns a semicolon-delimited string from a dictionary of assignment - expressions. """ - return '; '.join(['%s=%s' % (k, v) for k, v in assdict.items()]) - - def memlets_in_ast(node: ast.AST, arrays: Dict[str, dt.Data]) -> List[mm.Memlet]: """ Generates a list of memlets from each of the subscripts that appear in the Python AST. @@ -199,9 +180,7 @@ class InterstateEdge(object): """ assignments = Property(dtype=dict, - desc="Assignments to perform upon transition (e.g., 'x=x+1; y = 0')", - from_string=_assignments_from_string, - to_string=_assignments_to_string) + desc="Assignments to perform upon transition (e.g., 'x=x+1; y = 0')") condition = CodeProperty(desc="Transition condition", default=CodeBlock("1")) def __init__(self, condition: CodeBlock = None, assignments=None):