Skip to content

Commit

Permalink
MAINT: Use loc instead of deprecated ix
Browse files Browse the repository at this point in the history
  • Loading branch information
richafrank committed Aug 14, 2020
1 parent 7e97198 commit 2fd244d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 46 deletions.
68 changes: 23 additions & 45 deletions tests/metrics/test_metrics.py
@@ -1,5 +1,4 @@
import unittest
import warnings

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -117,11 +116,7 @@ def init_class_fixtures(cls):
cls.closes.name = None

def test_nop(self):
# Filter out pandas `ix` DeprecationWarning causing tests to fail
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)

perf = self.run_algorithm()
perf = self.run_algorithm()

zeros = pd.Series(0.0, index=self.closes)
all_zero_fields = [
Expand Down Expand Up @@ -451,13 +446,10 @@ def handle_data(context, data):
check_portfolio(context)
context.bar_count += 1

# Filter out pandas `ix` DeprecationWarning causing tests to fail
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
perf = self.run_algorithm(
initialize=initialize,
handle_data=handle_data,
)
perf = self.run_algorithm(
initialize=initialize,
handle_data=handle_data,
)

first_day_returns = -(
abs(per_fill_commission.sum()) / self.SIM_PARAMS_CAPITAL_BASE
Expand Down Expand Up @@ -608,13 +600,10 @@ def handle_data(context, data):
# the portfolio on the bar of the order, only the following bars
check_portfolio(context, first_bar)

# Filter out pandas `ix` DeprecationWarning causing tests to fail
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
perf = self.run_algorithm(
initialize=initialize,
handle_data=handle_data,
)
perf = self.run_algorithm(
initialize=initialize,
handle_data=handle_data,
)

zeros = pd.Series(0.0, index=self.closes)
all_zero_fields = [
Expand Down Expand Up @@ -1026,13 +1015,10 @@ def handle_data(context, data):
# the portfolio on the bar of the order, only the following bars
check_portfolio(context, first_bar)

# Filter out pandas `ix` DeprecationWarning causing tests to fail
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
perf = self.run_algorithm(
initialize=initialize,
handle_data=handle_data,
)
perf = self.run_algorithm(
initialize=initialize,
handle_data=handle_data,
)

zeros = pd.Series(0.0, index=self.closes)
all_zero_fields = [
Expand Down Expand Up @@ -1585,14 +1571,10 @@ def handle_data(context, data):
# the portfolio on the bar of the order, only the following bars
check_portfolio(data, context, first_bar)

# Filter out pandas `ix` DeprecationWarning causing tests to fail
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)

perf = self.run_algorithm(
initialize=initialize,
handle_data=handle_data,
)
perf = self.run_algorithm(
initialize=initialize,
handle_data=handle_data,
)

zeros = pd.Series(0.0, index=self.equity_closes)
all_zero_fields = [
Expand Down Expand Up @@ -2006,16 +1988,12 @@ def handle_data(context, data):
# the portfolio on the bar of the order, only the following bars
check_portfolio(data, context, first_bar)

# Filter out pandas `ix` DeprecationWarning causing tests to fail
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)

perf = self.run_algorithm(
initialize=initialize,
handle_data=handle_data,
trading_calendar=self.trading_calendars[Future],
data_portal=self.futures_data_portal,
)
perf = self.run_algorithm(
initialize=initialize,
handle_data=handle_data,
trading_calendar=self.trading_calendars[Future],
data_portal=self.futures_data_portal,
)

zeros = pd.Series(0.0, index=self.future_closes)
all_zero_fields = [
Expand Down
2 changes: 1 addition & 1 deletion zipline/algorithm.py
Expand Up @@ -490,7 +490,7 @@ def _create_clock(self):
"""
If the clock property is not set, then create one based on frequency.
"""
trading_o_and_c = self.trading_calendar.schedule.ix[
trading_o_and_c = self.trading_calendar.schedule.loc[
self.sim_params.sessions]
market_closes = trading_o_and_c['market_close']
minutely_emission = False
Expand Down

0 comments on commit 2fd244d

Please sign in to comment.