Skip to content

Remove dead pixel_count fallback that called nonexistent .items() - #331

Merged
perrygeo merged 1 commit into
perrygeo:masterfrom
aiddata:fix-pixel-count-item
Dec 5, 2026
Merged

perrygeo merged 1 commit into
perrygeo:masterfrom
aiddata:fix-pixel-count-item

Conversation

@sgoodm

@sgoodm sgoodm commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

The except AttributeError fallback when building pixel_count called .items() on numpy scalars, which no numpy version has, so it would raise if it ever ran.

It started as an np.asscalar fallback for numpy <1.16 (71e260a), and #329 replaced np.asscalar with .items(). The fallback was never needed: np.asscalar(a) was implemented as a.item(), and .item() exists on numpy scalars in every supported version (>=1.9).

This drops the try/except and keeps the single .item() path. No behaviour change; existing tests pass.

@sgoodm

sgoodm commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Came across this while running my own checks after merging upstream into my fork.

@perrygeo

perrygeo commented Dec 5, 2026

Copy link
Copy Markdown
Owner

Good catch! I started using the ty type checker and blindly followed its recommendation to remove np.asscalar - should have looked at the surrounding code and realized the redundancy.

@perrygeo
perrygeo merged commit dd5e6ea into perrygeo:master Dec 5, 2026
4 checks passed
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