Skip to content

Fix PSAR series assignment to use .iloc consistently - #368

Open
saket3395 wants to merge 1 commit into
bukosabino:masterfrom
saket3395:fix/psar-iloc-setitem
Open

saket3395 wants to merge 1 commit into
bukosabino:masterfrom
saket3395:fix/psar-iloc-setitem

Conversation

@saket3395

Copy link
Copy Markdown

Summary

Fixes #354, #357, #339, #348 — all four report the same root cause independently.

In PSARIndicator._run (ta/trend.py), one line uses bare positional indexing:

if high2 > self._psar.iloc[i]:
    self._psar[i] = high2          # inconsistent / deprecated
elif high1 > self._psar.iloc[i]:
    self._psar.iloc[i] = high1     # already correct

Every other read/write of self._psar in this method already goes through .iloc[i]. The one exception triggers pandas' FutureWarning: Series.__setitem__ treating keys as positions is deprecated (reported in #357, #339, #348) and was also flagged directly as an indexing inconsistency in #354, which includes the exact proposed fix.

Change

self._psar[i] = high2

self._psar.iloc[i] = high2

One line, no behavior change — .iloc[i] and positional [i] currently resolve to the same element for this integer-indexed Series; the fix only removes the deprecated code path and makes the method internally consistent.

Test plan

  • Confirmed via source inspection that this is the only remaining bare-positional assignment on self._psar in the method — all other accesses already use .iloc.
  • Change matches the fix proposed in Bug Report - Incorrect Series Indexing in trend.py (Line 1030) #354 exactly.
  • Not run through the project's test suite locally — flagging for maintainer/CI verification.

…nal setitem

Fixes bukosabino#354, bukosabino#357, bukosabino#339, bukosabino#348. In PSARIndicator._run, one assignment
(self._psar[i] = high2) used bare positional __setitem__ while the
surrounding code already used .iloc[i] consistently. This triggers
pandas' FutureWarning for Series.__setitem__ positional indexing and
is inconsistent with the rest of the method, as reported independently
across four issues.

Changed to self._psar.iloc[i] = high2 to match the rest of the method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Report - Incorrect Series Indexing in trend.py (Line 1030)

1 participant