Skip to content

Commit 7fa2457

Browse files
fix some coding style issues
1 parent fec3380 commit 7fa2457

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

optibess_algorithm/output_calculator.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -1153,16 +1153,14 @@ def sell_prices(self):
11531153

11541154
@sell_prices.setter
11551155
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):
11571157
if value.shape != (YEAR_HOURS,) and value.shape != (self._project_hour_num,):
11581158
raise ValueError(f"Prices shape should be ({YEAR_HOURS},) or ({self._project_hour_num}, ), prices"
11591159
f" for each hour in a year or for each hour of every year")
11601160
# compare shapes if buy prices were set
1161-
try:
1161+
if self._buy_prices is not None:
11621162
if value.shape != self._buy_prices.shape:
11631163
raise ValueError("Sell prices and buy prices should have the same shape")
1164-
except AttributeError:
1165-
pass
11661164
self._sell_prices = value
11671165
else:
11681166
raise ValueError("Prices should be a numpy array of floats")
@@ -1173,15 +1171,13 @@ def buy_prices(self):
11731171

11741172
@buy_prices.setter
11751173
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):
11771175
if value.shape != (YEAR_HOURS,) and value.shape != (self._project_hour_num, ):
11781176
raise ValueError(f"Prices shape should be ({YEAR_HOURS},) or ({self._project_hour_num}, ), prices"
11791177
f" for each hour in a year or for each hour of every year")
1180-
try:
1178+
if self._sell_prices is not None:
11811179
if value.shape != self._sell_prices.shape:
11821180
raise ValueError("Sell prices and buy prices should have the same shape")
1183-
except AttributeError:
1184-
pass
11851181
self._buy_prices = value
11861182
else:
11871183
raise ValueError("Prices should be a numpy array of floats")

0 commit comments

Comments
 (0)