Skip to content

Commit bc0f860

Browse files
committed
Remove redundent checks
1 parent 721b4f9 commit bc0f860

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

ocf_data_sampler/numpy_sample/datetime_features.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,33 +48,22 @@ def get_t0_embedding(
4848
"""
4949
features = []
5050

51-
if len(periods)!=len(embeddings):
52-
raise ValueError("`periods` and `embeddings` must be the same length")
53-
5451
for period_str, embedding in zip(periods, embeddings, strict=True):
5552

5653
if period_str.endswith("h"):
5754
period_hours = int(period_str.removesuffix("h"))
58-
if not (1<=period_hours<=24):
59-
raise ValueError("The period in hours must be in interval [1, 24]")
6055
frac = (t0.hour + t0.minute / 60) / period_hours
6156

6257
elif period_str.endswith("y"):
6358
period_years = int(period_str.removesuffix("y"))
64-
if not period_years > 0:
65-
raise ValueError("The period in years must be >0")
6659
days_in_year = 366 if t0.is_leap_year else 365
6760
frac = (((t0.dayofyear-1) / days_in_year) + t0.year % period_years) / period_years
6861

69-
else:
70-
raise ValueError(f"Invalid period format: {period_str}")
71-
7262
if embedding=="cyclic":
7363
radians = 2 * np.pi * frac
7464
features.extend([np.sin(radians), np.cos(radians)])
65+
7566
elif embedding=="linear":
7667
features.append(frac)
77-
else:
78-
raise ValueError(f"embedding option {embedding} not recognised")
7968

8069
return {"t0_embedding": np.array(features, dtype=np.float32)}

0 commit comments

Comments
 (0)