Skip to content

Address various warnings - #391

Merged
colinvwood merged 3 commits into
qiime2:devfrom
miiixi1in:remove-warnings
Jun 2, 2026
Merged

colinvwood merged 3 commits into
qiime2:devfrom
miiixi1in:remove-warnings

Conversation

@miiixi1in

Copy link
Copy Markdown
Contributor

Removed warnings regarding pandas deprecations and Phred 33-encoded data.

AI disclaimer
No AI used.

@colinvwood
colinvwood requested a review from Oddant1 May 28, 2026 23:35
@github-project-automation github-project-automation Bot moved this to Backlog in 2026.7 🐐 May 28, 2026
@colinvwood colinvwood moved this from Backlog to In Review in 2026.7 🐐 May 28, 2026
Comment on lines +114 to +118
warnings.filterwarnings(
'ignore',
message='Importing of PHRED 64 data is slow.*',
category=UserWarning
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update the data format being used by the test instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The transformers are testing transformations between the two data formats, so if we update the format, we wouldn't be testing the transformers that raise that warning.

@Oddant1 Oddant1 moved this from In Review to In Development in 2026.7 🐐 Jun 1, 2026
Comment on lines 25 to 33
# casting of columns adapted from SO post:
# https://stackoverflow.com/a/36814203/3424666
cols = df.columns
df[cols] = df[cols].apply(pd.to_numeric, errors='ignore')
for col in cols:
try:
df[col] = df[col].apply(pd.to_numeric)
except ValueError:
pass
return df

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely. Why would they do this to us...

I don't really understand why we were pulling the columns off the DataFrame in the first place. The SO post shows doing this when you want to drop specific columns and not apply to them, but we aren't doing that.

It probably should've just looked like this before:

    df = df.apply(pd.to_numeric, errors='ignore')

Now that we can't ignore errors for god knows what reason, probably something like this:

    def _to_numeric(col):
        try:
            return pd.to_numeric(col)
        except ValueError:
            return col
    df = df.apply(_to_numeric)

The way it works currently in this PR, we're iterating over the columns then calling apply on each column. If we are going to use a for loop we don't need the apply:

    for col in cols:
        try:
            df[col] = pd.to_numeric(df[col])
        except ValueError:
            pass

it is generally considered preferable to use .apply instead of your own for loop (and it's generally considered better to do vectorized operations over .apply, but I don't think we can do that here).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub is being VERY annoying about letting me actually suggest the diff I want here, but basically, delete lines 25-32 and replace them with:

    def _to_numeric(col):
        try:
            return pd.to_numeric(col)
        except ValueError:
            return col
    df = df.apply(_to_numeric)

@github-project-automation github-project-automation Bot moved this from In Development to Ready for Merge in 2026.7 🐐 Jun 2, 2026
@colinvwood
colinvwood merged commit 9fa1982 into qiime2:dev Jun 2, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for Merge to Changelog Needed in 2026.7 🐐 Jun 2, 2026
@colinvwood colinvwood moved this from Changelog Needed to Completed in 2026.7 🐐 Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Completed

Development

Successfully merging this pull request may close these issues.

5 participants