-
Notifications
You must be signed in to change notification settings - Fork 27
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
ENH: singledispatch in centrography to natively support geopandas objects #149
base: main
Are you sure you want to change the base?
Conversation
Yes, I think that's the case. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #149 +/- ##
=======================================
+ Coverage 69.7% 74.5% +4.8%
=======================================
Files 12 12
Lines 1775 1904 +129
=======================================
+ Hits 1237 1419 +182
+ Misses 538 485 -53
|
They even have examples of types within collections like the one below but I failed to make it work with numpy arrays. I'd say that is something for a potential follow-up :). @fun.register(list)
def _(arg: list[int], verbose=False):
if verbose:
print("Enumerate this:")
for i, elem in enumerate(arg):
print(i, elem) |
Would be interested in your thoughts about the design pattern generally... |
i know they're interested over in spreg as well |
When you need different output types for different input types, it is kind of neat. Especially when you have a primary implementation either directly as one of the functions (e.g. for Let's see how messy the docstrings will become. |
Super! Imho it's very clean, and helps simplify a lot of the "from_x" usage patterns, since you can easily keep output types consistent with input types (as we have examined in the past!). I use it always now in my private consulting code. |
@ljwolf do you have any recommendation on how to deal with docstrings with conditional input and output types? I've been looking for some examples with little to no luck. Everyone talks about code but how to deal with possibly messy docstrings is not covered anywhere. |
Very much WIP as I just wanted to see how this actually works. Will continue at some point later on this.
One thing I wanted to figure out was to ensure that we also support numpy arrays of shapely objects and return a shapely object but it seems that singledispatch typing is a bit limited in this sense and there's no way of distinguishing between
np.ndarray[np.float64]
andnp.ndarray[shapely.Geometry]
. At least none of the attempts I made worked.xref #135
TODO: