@@ -71,7 +71,11 @@ def __init__(self, *, material=None, process=None, mass_fraction=None,
7171 @property
7272 def name (self ):
7373 """Get name."""
74- return super ().name
74+ from gemd .entity .object .ingredient_spec import IngredientSpec
75+ if isinstance (self .spec , IngredientSpec ):
76+ return self .spec .name
77+ else :
78+ return super ().name
7579
7680 @name .setter
7781 def name (self , name ):
@@ -90,7 +94,11 @@ def _name_setter(cls, obj, name):
9094 @property
9195 def labels (self ):
9296 """Get labels."""
93- return self ._labels
97+ from gemd .entity .object .ingredient_spec import IngredientSpec
98+ if isinstance (self .spec , IngredientSpec ):
99+ return self .spec .labels
100+ else :
101+ return self ._labels
94102
95103 @labels .setter
96104 @deprecation .deprecated (deprecated_in = "0.12" , removed_in = "0.13" ,
@@ -155,13 +163,15 @@ def spec(self):
155163 def spec (self , spec ):
156164 from gemd .entity .object .ingredient_spec import IngredientSpec
157165 from gemd .entity .link_by_uid import LinkByUID
166+
167+ if isinstance (self ._spec , IngredientSpec ): # Store values if you had them
168+ self .__class__ ._labels_setter (self , self .spec .labels )
169+ self .__class__ ._name_setter (self , self .spec .name )
170+
158171 if spec is None :
159172 self ._spec = None
160173 elif isinstance (spec , (IngredientSpec , LinkByUID )):
161174 self ._spec = spec
162- if isinstance (spec , IngredientSpec ):
163- self .__class__ ._labels_setter (self , spec .labels )
164- self .__class__ ._name_setter (self , spec .name )
165175 else :
166176 raise TypeError ("spec must be a IngredientSpec or LinkByUID: {}" .format (spec ))
167177
0 commit comments