@@ -104,65 +104,101 @@ def test_more_kwargs(self):
104
104
105
105
class TestOHLC (TestCase ):
106
106
107
- def test_unequal_o_h_l_c_length (self ):
107
+ def test_unequal_ohlc_length (self ):
108
108
109
- # check: PlotlyError if op, hi, lo, cl are not the same length for
110
- # TraceFactory.ohlc_increase and TraceFactory.ohlc_decrease
109
+ # check: PlotlyError if open, high, low, close are not the same length
110
+ # for TraceFactory.ohlc_increase and TraceFactory.ohlc_decrease
111
111
112
- kwargs = {'op ' : [1 ], 'hi ' : [1 , 3 ], 'lo ' : [1 , 2 ], 'cl ' : [1 , 2 ]}
112
+ kwargs = {'open ' : [1 ], 'high ' : [1 , 3 ], 'low ' : [1 , 2 ], 'close ' : [1 , 2 ]}
113
113
self .assertRaises (PlotlyError , tls .TraceFactory .create_ohlc_increase ,
114
114
** kwargs )
115
115
116
- kwargs = {'op' : [1 , 2 ], 'hi' : [1 , 2 , 3 ], 'lo' : [1 , 2 ], 'cl' : [1 , 2 ]}
116
+ kwargs = {'open' : [1 , 2 ], 'high' : [1 , 2 , 3 ], 'low' : [1 , 2 ],
117
+ 'close' : [1 , 2 ]}
117
118
self .assertRaises (PlotlyError , tls .TraceFactory .create_ohlc_increase ,
118
119
** kwargs )
119
120
120
- kwargs = {'op ' : [1 ], 'hi ' : [1 , 3 ], 'lo ' : [1 , 2 ], 'cl ' : [2 ]}
121
+ kwargs = {'open ' : [1 ], 'high ' : [1 , 3 ], 'low ' : [1 , 2 ], 'close ' : [2 ]}
121
122
self .assertRaises (PlotlyError , tls .TraceFactory .create_ohlc_decrease ,
122
123
** kwargs )
123
124
124
- kwargs = {'op' : [1 , 2 ], 'hi' : [1 , 2 ], 'lo' : [1 , 2 , .5 ], 'cl' : [1 , 2 ]}
125
+ kwargs = {'open' : [1 , 2 ], 'high' : [1 , 2 ],
126
+ 'low' : [1 , 2 , .5 ], 'close' : [1 , 2 ]}
125
127
self .assertRaises (PlotlyError , tls .TraceFactory .create_ohlc_decrease ,
126
128
** kwargs )
127
129
128
- def test_hi_highest_value (self ):
130
+ def test_high_highest_value (self ):
129
131
130
- # check: PlotlyError if the "hi " value is less than the corresponding
131
- # op, lo , or cl value because if the "high" value is not the highest
132
- # (or equal) then the data may have been entered incorrectly.
132
+ # check: PlotlyError if the "high " value is less than the corresponding
133
+ # open, low , or close value because if the "high" value is not the
134
+ # highest (or equal) then the data may have been entered incorrectly.
133
135
134
136
# create_ohlc_increase
135
- kwargs = {'op' : [2 , 3 ], 'hi' : [4 , 2 ], 'lo' : [1 , 1 ], 'cl' : [1 , 2 ]}
136
- self .assertRaises (PlotlyError , tls .TraceFactory .create_ohlc_increase ,
137
- ** kwargs )
137
+ kwargs = {'open' : [2 , 3 ], 'high' : [4 , 2 ],
138
+ 'low' : [1 , 1 ], 'close' : [1 , 2 ]}
139
+ self .assertRaisesRegexp (PlotlyError , "Oops! Looks like some of "
140
+ "your high values are less "
141
+ "the corresponding open, "
142
+ "low, or close values. "
143
+ "Double check that your data "
144
+ "is entered in O-H-L-C order" ,
145
+ tls .TraceFactory .create_ohlc_increase ,
146
+ ** kwargs )
138
147
139
148
# create_ohlc_decrease
140
- kwargs = {'op' : [2 , 3 ], 'hi' : [4 , 3 ], 'lo' : [1 , 1 ], 'cl' : [1 , 6 ]}
141
- self .assertRaises (PlotlyError , tls .TraceFactory .create_ohlc_decrease ,
142
- ** kwargs )
143
-
144
- def test_lo_lowest_value (self ):
145
-
146
- # check: PlotlyError if the "lo" value is greater than the
147
- # corresponding op, hi, or cl value because if the "lo" value is not
148
- # the lowest (or equal) then the data may have been entered incorrectly
149
+ kwargs = {'open' : [2 , 3 ], 'high' : [4 , 3 ],
150
+ 'low' : [1 , 1 ], 'close' : [1 , 6 ]}
151
+ self .assertRaisesRegexp (PlotlyError ,
152
+ "Oops! Looks like some of "
153
+ "your high values are less "
154
+ "the corresponding open, "
155
+ "low, or close values. "
156
+ "Double check that your data "
157
+ "is entered in O-H-L-C order" ,
158
+ tls .TraceFactory .create_ohlc_decrease ,
159
+ ** kwargs )
160
+
161
+ def test_low_lowest_value (self ):
162
+
163
+ # check: PlotlyError if the "low" value is greater than the
164
+ # corresponding open, high, or close value because if the "low" value
165
+ # is not the lowest (or equal) then the data may have been entered
166
+ # incorrectly
149
167
150
168
# create_ohlc_increase
151
- kwargs = {'op' : [2 , 3 ], 'hi' : [4 , 6 ], 'lo' : [3 , 1 ], 'cl' : [1 , 2 ]}
152
- self .assertRaises (PlotlyError , tls .TraceFactory .create_ohlc_increase ,
153
- ** kwargs )
169
+ kwargs = {'open' : [2 , 3 ], 'high' : [4 , 6 ],
170
+ 'low' : [3 , 1 ], 'close' : [1 , 2 ]}
171
+ self .assertRaisesRegexp (PlotlyError ,
172
+ "Oops! Looks like some of "
173
+ "your low values are greater "
174
+ "than the corresponding high"
175
+ ", open, or close values. "
176
+ "Double check that your data "
177
+ "is entered in O-H-L-C order" ,
178
+ tls .TraceFactory .create_ohlc_increase ,
179
+ ** kwargs )
154
180
155
181
# create_ohlc_decrease
156
- kwargs = {'op' : [2 , 3 ], 'hi' : [4 , 6 ], 'lo' : [1 , 5 ], 'cl' : [1 , 6 ]}
157
- self .assertRaises (PlotlyError , tls .TraceFactory .create_ohlc_decrease ,
158
- ** kwargs )
182
+ kwargs = {'open' : [2 , 3 ], 'high' : [4 , 6 ],
183
+ 'low' : [1 , 5 ], 'close' : [1 , 6 ]}
184
+ self .assertRaisesRegexp (PlotlyError ,
185
+ "Oops! Looks like some of "
186
+ "your low values are greater "
187
+ "than the corresponding high"
188
+ ", open, or close values. "
189
+ "Double check that your data "
190
+ "is entered in O-H-L-C order" ,
191
+ tls .TraceFactory .create_ohlc_decrease ,
192
+ ** kwargs )
159
193
160
194
def test_one_ohlc_increase (self ):
161
195
162
196
# This should create one "increase" (i.e. close > open) ohlc stick
163
197
164
- ohlc_incr = tls .TraceFactory .create_ohlc_increase (op = [33.0 ], hi = [33.2 ],
165
- lo = [32.7 ], cl = [33.1 ])
198
+ ohlc_incr = tls .TraceFactory .create_ohlc_increase (open = [33.0 ],
199
+ high = [33.2 ],
200
+ low = [32.7 ],
201
+ close = [33.1 ])
166
202
167
203
expected_ohlc_incr = {
168
204
'mode' : 'lines' ,
@@ -179,8 +215,10 @@ def test_ohlc_increase_with_kwargs(self):
179
215
# This should create one "increase" (i.e. close > open) ohlc stick
180
216
# and change the name to "POSITIVE!!"
181
217
182
- ohlc_incr = tls .TraceFactory .create_ohlc_increase (op = [1.5 ], hi = [30 ],
183
- lo = [1 ], cl = [25 ],
218
+ ohlc_incr = tls .TraceFactory .create_ohlc_increase (open = [1.5 ],
219
+ high = [30 ],
220
+ low = [1 ],
221
+ close = [25 ],
184
222
name = "POSITIVE!!" )
185
223
186
224
expected_ohlc_incr = {
@@ -198,8 +236,10 @@ def test_one_ohlc_decrease(self):
198
236
199
237
# This should create one "decrease" (i.e. close < open) ohlc stick
200
238
201
- ohlc_decr = tls .TraceFactory .create_ohlc_decrease (op = [33.3 ], hi = [33.3 ],
202
- lo = [32.7 ], cl = [32.9 ])
239
+ ohlc_decr = tls .TraceFactory .create_ohlc_decrease (open = [33.3 ],
240
+ high = [33.3 ],
241
+ low = [32.7 ],
242
+ close = [32.9 ])
203
243
204
244
expected_ohlc_decr = {
205
245
'mode' : 'lines' ,
@@ -216,8 +256,8 @@ def test_ohlc_decrease_with_kwargs(self):
216
256
# This should create one "decrease" (i.e. close < open) ohlc stick
217
257
# and change the line width to 4
218
258
219
- ohlc_decr = tls .TraceFactory .create_ohlc_decrease (op = [15 ], hi = [30 ],
220
- lo = [1 ], cl = [5 ],
259
+ ohlc_decr = tls .TraceFactory .create_ohlc_decrease (open = [15 ], high = [30 ],
260
+ low = [1 ], close = [5 ],
221
261
line = Line (
222
262
color = 'rgb(214, 39, 40)' ,
223
263
width = 4 ))
0 commit comments