elixir-explorer / explorer

Series (one-dimensional) and dataframes (two-dimensional) for fast and elegant data exploration in Elixir
https://hexdocs.pm/explorer
MIT License
1.12k stars 123 forks source link

Fix issue 976 #980

Closed billylanchantin closed 2 months ago

billylanchantin commented 2 months ago

Description

Fixes an issue with DF.new where a well placed nil could result in a panic.

Basically, the work was being done by Native.s_from_list_of_series/2 which attempted to do following:

But because s_from_list_of_series/2 didn't have the final dtype information up front, it was possible for two elements of the intermediate list to have incompatible dtypes. When this happened, the final creation would panic.

Changes

This PR makes the dtype a required argument for:

(Those two seemed like a pair so I made them the same.)

Links

Discussion

I think there's an opportunity for optimization since we're now passing the expected dtype, but I didn't explore it.