Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Upgrading

<!-- Here goes notes on how to upgrade from previous versions, including deprecations and what they should be replaced with -->
* Includes a major update of the numpy dependency to v2.x.

## New Features

Expand Down
18 changes: 9 additions & 9 deletions benchmarks/timeseries/periodic_feature_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ async def init_feature_extractor(

def _calculate_avg_window(
feature_extractor: PeriodicFeatureExtractor,
window: NDArray[np.float_],
window: NDArray[np.float64],
window_size: int,
) -> NDArray[np.float_]:
) -> NDArray[np.float64]:
"""
Reshapes the window and calculates the average.

Expand All @@ -77,10 +77,10 @@ def _calculate_avg_window(

def _calculate_avg_window_py(
feature_extractor: PeriodicFeatureExtractor,
window: NDArray[np.float_],
window: NDArray[np.float64],
window_size: int,
weights: list[float] | None = None,
) -> NDArray[np.float_]:
) -> NDArray[np.float64]:
"""
Plain python version of the average calculator.

Expand All @@ -100,7 +100,7 @@ def _calculate_avg_window_py(
"""

def _num_windows(
window: NDArray[np.float_] | MovingWindow, window_size: int, period: int
window: NDArray[np.float64] | MovingWindow, window_size: int, period: int
) -> int:
"""
Get the number of windows that are fully contained in the MovingWindow.
Expand All @@ -118,7 +118,7 @@ def _num_windows(
The number of windows that are fully contained in the MovingWindow.
"""

def length(window: NDArray[np.float_] | MovingWindow) -> int:
def length(window: NDArray[np.float64] | MovingWindow) -> int:
return (
window.count_valid()
if isinstance(window, MovingWindow)
Expand Down Expand Up @@ -159,14 +159,14 @@ def length(window: NDArray[np.float_] | MovingWindow) -> int:


def run_benchmark(
array: NDArray[np.float_],
array: NDArray[np.float64],
window_size: int,
feature_extractor: PeriodicFeatureExtractor,
) -> None:
"""Run the benchmark for the given ndarray and window size."""

def run_avg_np(
array: NDArray[np.float_],
array: NDArray[np.float64],
window_size: int,
feature_extractor: PeriodicFeatureExtractor,
) -> None:
Expand All @@ -183,7 +183,7 @@ def run_avg_np(
_calculate_avg_window(feature_extractor, array, window_size)

def run_avg_py(
array: NDArray[np.float_],
array: NDArray[np.float64],
window_size: int,
feature_extractor: PeriodicFeatureExtractor,
) -> None:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies = [
"frequenz-channels >= 1.6.0, < 2.0.0",
"frequenz-quantities[marshmallow] >= 1.0.0, < 2.0.0",
"networkx >= 2.8, < 4",
"numpy >= 1.26.4, < 2",
"numpy >= 2, < 3",
"typing_extensions >= 4.6.1, < 5",
"marshmallow >= 3.19.0, < 5",
"marshmallow_dataclass >= 8.7.1, < 9",
Expand Down
8 changes: 4 additions & 4 deletions src/frequenz/sdk/timeseries/_periodic_feature_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ def _timestamp_to_rel_index(self, timestamp: datetime) -> int:
return dist_to_oldest

def _reshape_np_array(
self, array: NDArray[np.float_], window_size: int
) -> NDArray[np.float_]:
self, array: NDArray[np.float64], window_size: int
) -> NDArray[np.float64]:
"""
Reshape a numpy array to a 2D array where each row represents a window.

Expand Down Expand Up @@ -361,7 +361,7 @@ def _get_buffer_bounds(

def _get_reshaped_np_array(
self, start: datetime, end: datetime
) -> tuple[NDArray[np.float_], int]:
) -> tuple[NDArray[np.float64], int]:
"""
Create a reshaped numpy array from the MovingWindow.

Expand Down Expand Up @@ -392,7 +392,7 @@ def _get_reshaped_np_array(

def avg(
self, start: datetime, end: datetime, weights: list[float] | None = None
) -> NDArray[np.float_]:
) -> NDArray[np.float64]:
"""
Create the average window out of the window defined by `start` and `end`.

Expand Down
Loading