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

fixes for numpy2 #259

Closed
wants to merge 1 commit into from
Closed
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 pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies = [
'multipledispatch >=0.6.0',
'networkx >=2.0',
'numexpr >=2.6.1',
'numpy >=1.14.5,<2.0.0',
'numpy >=1.14.5',
'pandas >=1.3',
'patsy >=0.4.0',
'python-dateutil >=2.4.2',
Expand Down
6 changes: 3 additions & 3 deletions src/zipline/data/data_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def _get_fetcher_value(self, asset, field, dt):
try:
return self._augmented_sources_map[field][asset].loc[day, field]
except KeyError:
return np.NaN
return nan

def _get_single_asset_value(self, session_label, asset, field, dt, data_frequency):
if self._is_extra_source(asset, field, self._augmented_sources_map):
Expand All @@ -427,7 +427,7 @@ def _get_single_asset_value(self, session_label, asset, field, dt, data_frequenc
elif field == "contract":
return None
elif field != "last_traded":
return np.NaN
return nan

if data_frequency == "daily":
if field == "contract":
Expand Down Expand Up @@ -1033,7 +1033,7 @@ def _get_daily_window_data(self, assets, field, days_in_window, extra_slot=True)
if field != "volume":
# volumes default to 0, so we don't need to put NaNs in the array
return_array = return_array.astype(float64)
return_array[:] = np.NAN
return_array[:] = nan

if bar_count != 0:
data = self._history_loader.history(
Expand Down
2 changes: 1 addition & 1 deletion src/zipline/data/hdf5_daily_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def _make_sid_selector(self, assets):
"""
assets = np.array(assets)
sid_selector = self.sids.searchsorted(assets)
unknown = np.in1d(assets, self.sids, invert=True)
unknown = np.isin(assets, self.sids, invert=True)
sid_selector[unknown] = -1
return sid_selector

Expand Down
10 changes: 5 additions & 5 deletions src/zipline/data/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def opens(self, assets, dt):

for asset in assets:
if not asset.is_alive_for_session(session_label):
opens.append(np.NaN)
opens.append(np.nan)
continue

if prev_dt is None:
Expand Down Expand Up @@ -250,7 +250,7 @@ def highs(self, assets, dt):

for asset in assets:
if not asset.is_alive_for_session(session_label):
highs.append(np.NaN)
highs.append(np.nan)
continue

if prev_dt is None:
Expand Down Expand Up @@ -318,7 +318,7 @@ def lows(self, assets, dt):

for asset in assets:
if not asset.is_alive_for_session(session_label):
lows.append(np.NaN)
lows.append(np.nan)
continue

if prev_dt is None:
Expand Down Expand Up @@ -396,11 +396,11 @@ def _get_filled_close(asset):
try:
return window[~np.isnan(window)][-1]
except IndexError:
return np.NaN
return np.nan

for asset in assets:
if not asset.is_alive_for_session(session_label):
closes.append(np.NaN)
closes.append(np.nan)
continue

if prev_dt is None:
Expand Down
2 changes: 1 addition & 1 deletion src/zipline/finance/slippage.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ def _get_window_data(self, data, asset, window_length):
except HistoryWindowStartsBeforeData:
# If there is not enough data to do a full history call, return
# values as if there was no data.
return 0, np.NaN
return 0, np.nan

# Exclude the first value of the percent change array because it is
# always just NaN.
Expand Down
2 changes: 1 addition & 1 deletion src/zipline/pipeline/factors/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class MaxDrawdown(SingleInputMixin, CustomFactor):

def compute(self, today, assets, out, data):
drawdowns = fmax.accumulate(data, axis=0) - data
drawdowns[isnan(drawdowns)] = NINF
drawdowns[isnan(drawdowns)] = -np.inf
drawdown_ends = nanargmax(drawdowns, axis=0)

# TODO: Accelerate this loop in Cython or Numba.
Expand Down
Loading