Skip to content
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

Series.cast/2 with type error when used with across/1 and summarise/2 #1038

Closed
viniciussbs opened this issue Dec 10, 2024 · 1 comment · Fixed by #1041
Closed

Series.cast/2 with type error when used with across/1 and summarise/2 #1038

viniciussbs opened this issue Dec 10, 2024 · 1 comment · Fixed by #1041

Comments

@viniciussbs
Copy link
Contributor

Hey! I guess we have another typespec issue.

This is working:

grouped_df
|> DF.summarise(
  for col <- across(~r/^group_\d+_price$/) do
    {col.name, Series.cast(mean(col), :integer)}
  end
)

But Dialyzer is complaining about Explorer.Series.cast/2:

The function call will not succeed.

Explorer.Series.cast(:infinity | :nan | :neg_infinity | nil | float(), :integer)

will never return since the success typing is:
(%Explorer.Series{:dtype => _, _ => _}, any()) :: any()

and the contract is
(series :: t(), dtype :: dtype() | dtype_alias()) :: t()
@philss
Copy link
Member

philss commented Dec 10, 2024

@viniciussbs That's because mean may return a lazy series in the context of a Query. If you want to send a PR, please take a look the specs from the size/1 function (inside the Series module) - we want to do the same: @spec mean(series :: Series.t()) :: float() | non_finite() | nil | lazy_t().

philss added a commit that referenced this issue Dec 16, 2024
This is valid for most of the series operations that can return a scalar
value (in general a float). Inside the context of a query - like in
`mutate` -, this will return a lazy series before being collected.

Closes #1038
philss added a commit that referenced this issue Dec 16, 2024
This is valid for most of the series operations that can return a scalar
value (in general a float). Inside the context of a query - like in
`mutate` -, this will return a lazy series before being collected.

Closes #1038
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 a pull request may close this issue.

2 participants