@@ -1153,16 +1153,14 @@ def sell_prices(self):
1153
1153
1154
1154
@sell_prices .setter
1155
1155
def sell_prices (self , value : np .ndarray [Any , np .dtype [np .float64 ]]):
1156
- if value is not None and isinstance (value , np .ndarray ) and is_real_numbers (value ):
1156
+ if isinstance (value , np .ndarray ) and is_real_numbers (value ):
1157
1157
if value .shape != (YEAR_HOURS ,) and value .shape != (self ._project_hour_num ,):
1158
1158
raise ValueError (f"Prices shape should be ({ YEAR_HOURS } ,) or ({ self ._project_hour_num } , ), prices"
1159
1159
f" for each hour in a year or for each hour of every year" )
1160
1160
# compare shapes if buy prices were set
1161
- try :
1161
+ if self . _buy_prices is not None :
1162
1162
if value .shape != self ._buy_prices .shape :
1163
1163
raise ValueError ("Sell prices and buy prices should have the same shape" )
1164
- except AttributeError :
1165
- pass
1166
1164
self ._sell_prices = value
1167
1165
else :
1168
1166
raise ValueError ("Prices should be a numpy array of floats" )
@@ -1173,15 +1171,13 @@ def buy_prices(self):
1173
1171
1174
1172
@buy_prices .setter
1175
1173
def buy_prices (self , value : np .ndarray [Any , np .dtype [np .float64 ]]):
1176
- if value is not None and isinstance (value , np .ndarray ) and is_real_numbers (value ):
1174
+ if isinstance (value , np .ndarray ) and is_real_numbers (value ):
1177
1175
if value .shape != (YEAR_HOURS ,) and value .shape != (self ._project_hour_num , ):
1178
1176
raise ValueError (f"Prices shape should be ({ YEAR_HOURS } ,) or ({ self ._project_hour_num } , ), prices"
1179
1177
f" for each hour in a year or for each hour of every year" )
1180
- try :
1178
+ if self . _sell_prices is not None :
1181
1179
if value .shape != self ._sell_prices .shape :
1182
1180
raise ValueError ("Sell prices and buy prices should have the same shape" )
1183
- except AttributeError :
1184
- pass
1185
1181
self ._buy_prices = value
1186
1182
else :
1187
1183
raise ValueError ("Prices should be a numpy array of floats" )
0 commit comments