Skip to content

fix: filter non-float columns in check_for_np_inf#184

Merged
jacobdadams merged 3 commits intomainfrom
copilot/fix-check-for-np-inf-error
Feb 17, 2026
Merged

fix: filter non-float columns in check_for_np_inf#184
jacobdadams merged 3 commits intomainfrom
copilot/fix-check-for-np-inf-error

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

FieldChecker.check_for_np_inf raises TypeError when checking text or non-numeric columns because np.isinf() only supports float dtypes.

Changes

  • Add pd.api.types.is_float_dtype() check before calling np.isinf() to skip non-float columns
  • Add test coverage for mixed-dtype dataframes with text, int, and float columns

Example

# Previously failed with TypeError on text_field
df = pd.DataFrame({
    'text_field': ['a', 'b', 'c'],
    'float_field': [1.0, np.inf, 3.0]
})
checker.check_for_np_inf()  # Now only checks float_field

Integer and text columns cannot contain inf values, so checking only float dtypes is both correct and necessary.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • naciscdn.org
    • Triggering command: /usr/bin/python python -m pytest tests/ -x (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>check_for_np_inf raising error on non-float fields</issue_title>
<issue_description>FieldChecker.check_for_np_inf is raising TypeError: ufunc 'isinf' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe'' when being run against text columns.

This check should only be run against columns whose dtype allows np.inf values.

stacktrace:

  File "C:\gis\git\nfhl-skid\src\nfhl\main.py", line 218, in _load_layer
    features_loaded = feature_layer.truncate_and_load(layer_df, save_old=False)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jdadams\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\nfhl3\Lib\site-packages\palletjack\load.py", line 235, in truncate_and_load       
    utils.FieldChecker.check_fields(self.service.properties, dataframe, fields, add_oid=False)
  File "C:\Users\jdadams\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\nfhl3\Lib\site-packages\palletjack\utils.py", line 486, in check_fields
    field_checker.check_for_np_inf()
  File "C:\Users\jdadams\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\nfhl3\Lib\site-packages\palletjack\utils.py", line 811, in check_for_np_inf       
    if np.isinf(self.new_dataframe[column]).any():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jdadams\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\nfhl3\Lib\site-packages\pandas\core\generic.py", line 2102, in __array_ufunc__    
    return arraylike.array_ufunc(self, ufunc, method, *inputs, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jdadams\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\nfhl3\Lib\site-packages\pandas\core\arraylike.py", line 396, in array_ufunc       
    result = getattr(ufunc, method)(*inputs, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jdadams\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\nfhl3\Lib\site-packages\pandas\core\arrays\numpy_.py", line 194, in __array_ufunc__
    result = getattr(ufunc, method)(*inputs, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jdadams\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\nfhl3\Lib\site-packages\pandas\core\arrays\numpy_.py", line 194, in __array_ufunc__
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jdadams\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\nfhl3\Lib\site-packages\pandas\core\arrays\numpy_.py", line 194, in __array_ufunc__
    result = getattr(ufunc, method)(*inputs, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ufunc 'isinf' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Modified check_for_np_inf to only check columns with float dtypes, as np.isinf
only works with float types. This prevents TypeError when checking text or other
non-numeric columns.

Added tests to verify text columns don't cause errors and that the check still
works correctly for float columns with inf values.

Co-authored-by: jacobdadams <38168030+jacobdadams@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix check_for_np_inf raising error on non-float fields fix: filter non-float columns in check_for_np_inf Feb 17, 2026
Copilot AI requested a review from jacobdadams February 17, 2026 16:52
@jacobdadams jacobdadams requested a review from stdavis February 17, 2026 17:13
@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.69%. Comparing base (f87f4c5) to head (926be5a).
⚠️ Report is 133 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #184      +/-   ##
==========================================
+ Coverage   94.52%   95.69%   +1.16%     
==========================================
  Files           7        7              
  Lines        1133     1255     +122     
  Branches      148      148              
==========================================
+ Hits         1071     1201     +130     
+ Misses         52       44       -8     
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jacobdadams jacobdadams marked this pull request as ready for review February 17, 2026 17:14
@jacobdadams jacobdadams self-requested a review February 17, 2026 17:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes FieldChecker.check_for_np_inf raising TypeError on non-numeric columns by restricting the np.isinf check to float-typed columns, and adds regression coverage for mixed-dtype DataFrames.

Changes:

  • Skip non-float columns when scanning for np.inf/-np.inf in FieldChecker.check_for_np_inf.
  • Add tests ensuring mixed text/int/float DataFrames don’t raise, and still warn when a float column contains np.inf.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/palletjack/utils.py Adds a float-dtype guard before calling np.isinf to prevent errors on text/non-numeric columns.
tests/test_utils.py Adds tests covering mixed-dtype DataFrames and warning behavior for np.inf in float columns.

stdavis
stdavis previously approved these changes Feb 17, 2026
Copy link
Member

@stdavis stdavis left a comment

Choose a reason for hiding this comment

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

This looks good to me. It's up to you if you want to update the comments as recommended by copilot.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jacobdadams jacobdadams merged commit 5796569 into main Feb 17, 2026
5 checks passed
@jacobdadams jacobdadams deleted the copilot/fix-check-for-np-inf-error branch February 17, 2026 20:43
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.

check_for_np_inf raising error on non-float fields

3 participants

Comments