Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Issue #1492 migrate from fastcore to plum #1493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 21, 2025

Conversation

JoerivanEngelen
Copy link
Contributor

@JoerivanEngelen JoerivanEngelen commented Mar 19, 2025

Fixes #1492

Description

Replace fastcore typedispatching with plum's dispatching.
Plum is a bit stricter, which I generally think is good. When fastcore's typedispatching didn't encounter a typedispatched fallback function for type Any, for some reason things worked, but I'm not sure what it did. Plum is stricter so I had to explicitly had to add some fallback functions to either raise an error or do something.

In detail, this PR

  • Replaces @typedispatch with a plum Dispatcher instance, this also limits the scope for accidentily adding typedispatched functions in other modules
  • Separate clip_by_grid method for GridDataArray into one for xr.DataArray and xu.UgridDataArray, as plum apparently thinks this ambiguous.
  • Update some arrays in create_exchange_package to become DataArray
  • Add missing fallback functions for enforce_dim_order and is_unstructured
  • Add function for enforce_dim_order with None
  • Change fallback type from object to Any, to also support None

Checklist

  • Links to correct issue
  • Update changelog, if changes affect users
  • PR title starts with Issue #nr, e.g. Issue #737
  • Unit tests were added
  • If feature added: Added/extended example

Copy link

return _clip_by_grid_line_data(package, active)


# For some reason the plum dispatching finds "active: GridDataArray" ambiguous
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe raise an issue about this on the their board? Seems like something that should be supported

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't have time now to further investigate this. Seems somewhat related to this beartype/plum#149.

@JoerivanEngelen JoerivanEngelen merged commit 0b92a8c into master Mar 21, 2025
7 checks passed
@JoerivanEngelen JoerivanEngelen deleted the issue_#1492_import_fastcore branch March 21, 2025 08:39
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.

Error upon import with latest fastcore
2 participants