From bb1e7af99626c49bb4b1f78643d62812b70c280c Mon Sep 17 00:00:00 2001 From: Huoran Li Date: Wed, 28 Dec 2022 14:20:18 +0800 Subject: [PATCH 1/2] Change numpy data type; change test requirements. --- maro/cli/data_pipeline/citi_bike.py | 4 ++-- maro/rl/training/replay_memory.py | 4 ++-- maro/streamit/client/metric.py | 2 +- tests/requirements.test.txt | 2 +- tests/test_frame.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/maro/cli/data_pipeline/citi_bike.py b/maro/cli/data_pipeline/citi_bike.py index b8b18166f..7d9456213 100644 --- a/maro/cli/data_pipeline/citi_bike.py +++ b/maro/cli/data_pipeline/citi_bike.py @@ -320,7 +320,7 @@ def _process_distance(self, station_info: pd.DataFrame): 0, index=station_info["station_index"], columns=station_info["station_index"], - dtype=np.float, + dtype=float, ) look_up_df = station_info[["latitude", "longitude"]] return distance_adj.apply( @@ -617,7 +617,7 @@ def _gen_distance(self, station_init: pd.DataFrame): 0, index=station_init["station_index"], columns=station_init["station_index"], - dtype=np.float, + dtype=float, ) look_up_df = station_init[["latitude", "longitude"]] distance_df = distance_adj.apply( diff --git a/maro/rl/training/replay_memory.py b/maro/rl/training/replay_memory.py index 8d8f6e5e4..3e4f573e0 100644 --- a/maro/rl/training/replay_memory.py +++ b/maro/rl/training/replay_memory.py @@ -204,7 +204,7 @@ def __init__( self._states = np.zeros((self._capacity, self._state_dim), dtype=np.float32) self._actions = np.zeros((self._capacity, self._action_dim), dtype=np.float32) self._rewards = np.zeros(self._capacity, dtype=np.float32) - self._terminals = np.zeros(self._capacity, dtype=np.bool) + self._terminals = np.zeros(self._capacity, dtype=bool) self._next_states = np.zeros((self._capacity, self._state_dim), dtype=np.float32) self._returns = np.zeros(self._capacity, dtype=np.float32) self._advantages = np.zeros(self._capacity, dtype=np.float32) @@ -373,7 +373,7 @@ def __init__( self._actions = [np.zeros((self._capacity, action_dim), dtype=np.float32) for action_dim in self._action_dims] self._rewards = [np.zeros(self._capacity, dtype=np.float32) for _ in range(self.agent_num)] self._next_states = np.zeros((self._capacity, self._state_dim), dtype=np.float32) - self._terminals = np.zeros(self._capacity, dtype=np.bool) + self._terminals = np.zeros(self._capacity, dtype=bool) assert len(agent_states_dims) == self.agent_num self._agent_states_dims = agent_states_dims diff --git a/maro/streamit/client/metric.py b/maro/streamit/client/metric.py index 43ca9c4d7..2cdc6e7e4 100644 --- a/maro/streamit/client/metric.py +++ b/maro/streamit/client/metric.py @@ -61,7 +61,7 @@ def is_float_type(v_type: type): Returns: bool: True if an float type. """ - return v_type is float or v_type is np.float or v_type is np.float32 or v_type is np.float64 + return v_type is float or v_type is np.float16 or v_type is np.float32 or v_type is np.float64 def parse_value(value: object): diff --git a/tests/requirements.test.txt b/tests/requirements.test.txt index e44b03370..c7ac76f45 100644 --- a/tests/requirements.test.txt +++ b/tests/requirements.test.txt @@ -6,7 +6,7 @@ deepdiff>=5.7.0 geopy>=2.0.0 holidays>=0.10.3 kubernetes>=21.7.0 -numpy>=1.19.5,<1.24.0 +numpy>=1.19.5 pandas>=0.25.3 paramiko>=2.9.2 pytest>=7.1.2 diff --git a/tests/test_frame.py b/tests/test_frame.py index 2d81cce97..a06713e50 100644 --- a/tests/test_frame.py +++ b/tests/test_frame.py @@ -311,7 +311,7 @@ def test_append_nodes(self): self.assertListEqual([0.0, 0.0, 0.0, 0.0, 9.0], list(states)[0:5]) # 2 padding (NAN) in the end - self.assertTrue((states[-2:].astype(np.int) == 0).all()) + self.assertTrue((states[-2:].astype(int) == 0).all()) states = static_snapshot[1::"a3"] From 9dd725288fde3a9bcb54a0a14fc1f8cd6f0414b2 Mon Sep 17 00:00:00 2001 From: Huoran Li Date: Fri, 30 Dec 2022 13:48:42 +0800 Subject: [PATCH 2/2] Lint --- maro/cli/data_pipeline/citi_bike.py | 1 - 1 file changed, 1 deletion(-) diff --git a/maro/cli/data_pipeline/citi_bike.py b/maro/cli/data_pipeline/citi_bike.py index 7d9456213..b4b74cc51 100644 --- a/maro/cli/data_pipeline/citi_bike.py +++ b/maro/cli/data_pipeline/citi_bike.py @@ -8,7 +8,6 @@ from enum import Enum import geopy.distance -import numpy as np import pandas as pd from yaml import safe_load