Skip to content
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
2 changes: 1 addition & 1 deletion talib/_abstract.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ class Function(object):
This is a shortcut to the outputs property that also allows setting
the input_arrays dict.
"""
if input_arrays:
if input_arrays is not None:
self.set_input_arrays(input_arrays)
self.__call_function()
return self.outputs
Expand Down
32 changes: 16 additions & 16 deletions talib/_ta_lib.c

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions tests/test_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,3 +444,18 @@ def worker(i):

with ThreadPoolExecutor(4) as pool:
list(pool.map(worker, range(4)))


@pytest.mark.parametrize("frame_type", ["pandas", "polars"])
@pytest.mark.parametrize("empty", [False, True])
def test_run_with_dataframe(frame_type, empty):
module = pytest.importorskip(frame_type)
values = np.array([] if empty else [2.0, 4.0, 6.0, 8.0])
frame = module.DataFrame({"close": values})
indicator = abstract.Function('SMA', timeperiod=2)
result = indicator.run(frame)
assert isinstance(result, module.Series)
assert_array_equal(result.to_numpy(), talib.SMA(values, timeperiod=2))
if frame_type == 'pandas':
assert result.index.equals(frame.index)
assert_array_equal(indicator.run().to_numpy(), result.to_numpy())