Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chronos: fix type deprecations in numpy 1.24 #7600

Merged
merged 2 commits into from
Feb 20, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def get_roll_start_idx(df, id_col, window_size):
id_start_idxes = df.index[df[id_col] != df[id_col].shift(1)].tolist() + [len(df.index)]
roll_start_idx_iter = ((range(id_start_idxes[i], id_start_idxes[i+1] - window_size + 1))
for i in range(len(id_start_idxes) - 1))
roll_start_idxes = np.fromiter(itertools.chain.from_iterable(roll_start_idx_iter), np.int)
roll_start_idxes = np.fromiter(itertools.chain.from_iterable(roll_start_idx_iter), np.int32)
return roll_start_idxes


Expand Down
16 changes: 8 additions & 8 deletions python/chronos/src/bigdl/chronos/model/tcmf/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,45 +59,45 @@ def __init__(self, start_date, num_ts=100, freq="H", normalized=True):
self.dti = pd.date_range(self.start_date, periods=self.num_ts, freq=self.freq)

def _minute_of_hour(self):
minutes = np.array(self.dti.minute, dtype=np.float)
minutes = np.array(self.dti.minute, dtype=np.float32)
if self.normalized:
minutes = minutes / 59.0 - 0.5
return minutes

def _hour_of_day(self):
hours = np.array(self.dti.hour, dtype=np.float)
hours = np.array(self.dti.hour, dtype=np.float32)
if self.normalized:
hours = hours / 23.0 - 0.5
return hours

def _day_of_week(self):
dayWeek = np.array(self.dti.dayofweek, dtype=np.float)
dayWeek = np.array(self.dti.dayofweek, dtype=np.float32)
if self.normalized:
dayWeek = dayWeek / 6.0 - 0.5
return dayWeek

def _day_of_month(self):
dayMonth = np.array(self.dti.day, dtype=np.float)
dayMonth = np.array(self.dti.day, dtype=np.float32)
if self.normalized:
dayMonth = dayMonth / 30.0 - 0.5
return dayMonth

def _day_of_year(self):
dayYear = np.array(self.dti.dayofyear, dtype=np.float)
dayYear = np.array(self.dti.dayofyear, dtype=np.float32)
if self.normalized:
dayYear = dayYear / 364.0 - 0.5
return dayYear

def _month_of_year(self):
monthYear = np.array(self.dti.month, dtype=np.float)
monthYear = np.array(self.dti.month, dtype=np.float32)
if self.normalized:
monthYear = monthYear / 11.0 - 0.5
return monthYear

def _week_of_year(self):
weekYear = np.array(pd.Int64Index(self.dti.isocalendar().week), dtype=np.float) if\
weekYear = np.array(pd.Int64Index(self.dti.isocalendar().week), dtype=np.float32) if\
version.parse(pd.__version__) >= version.parse("1.1.0") else\
np.array(self.dti.weekofyear, dtype=np.float)
np.array(self.dti.weekofyear, dtype=np.float32)
if self.normalized:
weekYear = weekYear / 51.0 - 0.5
return weekYear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _check_config(self, **config):
f"{lstm_name} should be int or an list/tuple of ints. "
f"Got {config[lstm_name]}")
if dropout_name in config:
if not check_iter_type(config[dropout_name], (float, np.float)):
if not check_iter_type(config[dropout_name], (float, np.float32)):
invalidInputError(False,
f"{dropout_name} should be float or a list/tuple of floats. "
f"Got {config[dropout_name]}")
Expand Down
2 changes: 1 addition & 1 deletion python/chronos/src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def setup_package():
url='https://github.com/intel-analytics/BigDL',
packages=get_bigdl_packages(),
install_requires=['pandas>=1.0.5, <=1.3.5', 'scikit-learn>=0.22.0, <=1.0.2',
'bigdl-nano==' + VERSION, 'numpy<=1.23.5'],
'bigdl-nano==' + VERSION],
extras_require={'pytorch': ['bigdl-nano[pytorch]==' + VERSION],
'tensorflow': ['bigdl-nano[tensorflow_27]=='+VERSION],
'automl': ['optuna<=2.10.1', 'configspace<=0.5.0', 'SQLAlchemy<=1.4.27'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def generate_spark_df():
spark = SparkSession(sc)
rdd = sc.range(0, 100)
from pyspark.ml.linalg import DenseVector
df = rdd.map(lambda x: (DenseVector(np.random.randn(1, ).astype(np.float)),
df = rdd.map(lambda x: (DenseVector(np.random.randn(1, ).astype(np.float32)),
int(np.random.randint(0, 2, size=())),
int(x))).toDF(["feature", "id", "date"])
return df
Expand Down