Skip to content

Conversation

@google-labs-jules
Copy link
Contributor

This change resolves a pandas FutureWarning in the zscore method of the FeaturesConcatDataset class. The warning was triggered by an incompatible dtype assignment. The fix involves explicitly casting the result of the normalization to float32 before assigning it back to the DataFrame. A targeted unit test has been added to verify the fix and prevent future regressions.


PR created automatically by Jules for task 355021486991017514

Resolves a pandas FutureWarning that occurs when assigning a
float64 result to a float32 DataFrame column.

The `zscore` method in `eegdash/features/datasets.py` was
performing a calculation that resulted in a float64 dtype.
When this was assigned back to the DataFrame, which has a
float32 dtype, a FutureWarning was raised.

This change explicitly casts the result of the z-score
calculation to `float32` before assignment, ensuring dtype
compatibility and silencing the warning.

A new test was added to `tests/test_features.py` to verify
that the `zscore` method correctly maintains the float32 dtype.
@google-labs-jules
Copy link
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

@bruAristimunha bruAristimunha marked this pull request as ready for review October 5, 2025 00:57
@bruAristimunha
Copy link
Collaborator

The feature module doesn't work with Python 3.10, but we support Python 3.10. It is mainly because of this type of attribution:

==================================== ERRORS ====================================
___________________ ERROR collecting tests/test_features.py ____________________
.venv/lib/python3.10/site-packages/_pytest/python.py:498: in importtestmodule
mod = import_path(
.venv/lib/python3.10/site-packages/_pytest/pathlib.py:587: in import_path
importlib.import_module(module_name)
../../../.local/share/uv/python/cpython-3.10.18-linux-x86_64-gnu/lib/python3.10/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
.venv/lib/python3.10/site-packages/_pytest/assertion/rewrite.py:186: in exec_module
exec(co, module.dict)
tests/test_features.py:4: in
from eegdash.features.datasets import FeaturesDataset, FeaturesConcatDataset
eegdash/features/init.py:17: in
from .feature_bank import ( # Complexity; Connectivity; CSP; Dimensionality; Signal; Spectral
eegdash/features/feature_bank/init.py:8: in
from .complexity import (
E File "/home/runner/work/EEGDash/EEGDash/eegdash/features/feature_bank/complexity.py", line 39
E counts_m[*i, :] = _channel_app_samp_entropy_counts(x[i], m, rr[i], l)
E ^
E SyntaxError: invalid syntax

@google-labs-jules
Copy link
Contributor Author

The feature module doesn't work with Python 3.10, but we support Python 3.10. It is mainly because of this type of attribution:

==================================== ERRORS ====================================
___________________ ERROR collecting tests/test_features.py ____________________
.venv/lib/python3.10/site-packages/_pytest/python.py:498: in importtestmodule
mod = import_path(
.venv/lib/python3.10/site-packages/_pytest/pathlib.py:587: in import_path
importlib.import_module(module_name)
../../../.local/share/uv/python/cpython-3.10.18-linux-x86_64-gnu/lib/python3.10/importlib/init.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
:1050: in _gcd_import
???
:1027: in _find_and_load
???
:1006: in _find_and_load_unlocked
???
:688: in _load_unlocked
???
.venv/lib/python3.10/site-packages/_pytest/assertion/rewrite.py:186: in exec_module
exec(co, module.dict)
tests/test_features.py:4: in
from eegdash.features.datasets import FeaturesDataset, FeaturesConcatDataset
eegdash/features/init.py:17: in
from .feature_bank import ( # Complexity; Connectivity; CSP; Dimensionality; Signal; Spectral
eegdash/features/feature_bank/init.py:8: in
from .complexity import (
E File "/home/runner/work/EEGDash/EEGDash/eegdash/features/feature_bank/complexity.py", line 39
E counts_m[*i, :] = _channel_app_samp_entropy_counts(x[i], m, rr[i], l)
E ^
E SyntaxError: invalid syntax

Thank you for catching this! You are correct, the syntax was not compatible with Python 3.10. I have now updated the code to use a backward-compatible indexing method. This should resolve the SyntaxError.

This commit addresses two separate issues:

1. Resolves a pandas FutureWarning in the `zscore` method by
   explicitly casting the result of the z-score calculation
   to `float32` before assignment. This ensures dtype
   compatibility and silences the warning. A new test was
   added to verify this fix.

2. Fixes a `SyntaxError` in `eegdash/features/feature_bank/complexity.py`
   that occurred in Python 3.10. The indexing syntax was updated
   to be backward-compatible, ensuring the feature module works
   correctly on all supported Python versions.
@bruAristimunha bruAristimunha deleted the fix-pandas-futurewarning branch October 5, 2025 22:52
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.

2 participants