diff --git a/lib/explorer/backend/lazy_series.ex b/lib/explorer/backend/lazy_series.ex index 26ee1080f..21a48c0b7 100644 --- a/lib/explorer/backend/lazy_series.ex +++ b/lib/explorer/backend/lazy_series.ex @@ -822,9 +822,7 @@ defmodule Explorer.Backend.LazySeries do when op in [:first, :last, :sum, :min, :max, :product], do: series.dtype - defp dtype_for_agg_operation(op, _) when op in [:all?, :any?], do: :boolean defp dtype_for_agg_operation(:mode, series), do: {:list, series.dtype} - defp dtype_for_agg_operation(_, _), do: {:f, 64} defp resolve_numeric_dtype(items) do @@ -1077,13 +1075,6 @@ defmodule Explorer.Backend.LazySeries do defp to_elixir_ast(other), do: other - @impl true - def size(series) do - data = new(:size, [lazy_series!(series)], {:u, 32}) - - Backend.Series.new(data, {:u, 32}) - end - @impl true def transform(_series, _fun) do raise """ diff --git a/lib/explorer/polars_backend/expression.ex b/lib/explorer/polars_backend/expression.ex index 93092fe63..ea094f527 100644 --- a/lib/explorer/polars_backend/expression.ex +++ b/lib/explorer/polars_backend/expression.ex @@ -322,7 +322,7 @@ defmodule Explorer.PolarsBackend.Expression do Native.expr_int_range(to_expr(0), size_expr, 1, {:u, 32}) end - for {op, arity} <- @all_expressions do + for {op, arity} <- @all_expressions -- @first_only_expressions do args = Macro.generate_arguments(arity, __MODULE__) updates = diff --git a/lib/explorer/series.ex b/lib/explorer/series.ex index 3b979d4ed..718f4915b 100644 --- a/lib/explorer/series.ex +++ b/lib/explorer/series.ex @@ -1143,7 +1143,7 @@ defmodule Explorer.Series do do: apply_series(series, :strftime, [format_string]) def strftime(%Series{dtype: dtype}, _format_string), - do: dtype_error("strftime/2", dtype, :datetime_like) + do: dtype_error("strftime/2", dtype, [:datetime_like]) @doc """ Clip (or clamp) the values in a series. @@ -5346,15 +5346,15 @@ defmodule Explorer.Series do float_series = case dtype(series) do - :f32 -> + {:f, 32} -> series - :f64 -> + {:f, 64} -> series _ -> try do - cast(series, :f64) + cast(series, {:f, 64}) rescue _ -> raise ArgumentError, diff --git a/notebooks/exploring_explorer.livemd b/notebooks/exploring_explorer.livemd index 1ccc6aaea..9cdb358bd 100644 --- a/notebooks/exploring_explorer.livemd +++ b/notebooks/exploring_explorer.livemd @@ -800,7 +800,7 @@ In `Explorer`, like in `dplyr`, we have five main verbs to work with dataframes: - sort - summarise -We are going to explore then in this notebook, but first we need to "require" +We are going to explore them in this notebook, but first we need to "require" the `Explorer.DataFrame` module in order to load the macros needed for these verbs. I want to take the opportunity to create a shorter alias for the `DataFrame` module, diff --git a/test/explorer/series_test.exs b/test/explorer/series_test.exs index fb121eeeb..2b3efce07 100644 --- a/test/explorer/series_test.exs +++ b/test/explorer/series_test.exs @@ -4658,7 +4658,7 @@ defmodule Explorer.SeriesTest do end describe "ewm_mean/2" do - test "returns calculated ewm values with default options used for calculation" do + test "returns calculated ewm values with default options used for integer calculation" do s1 = 1..10 |> Enum.to_list() |> Series.from_list() s2 = Series.ewm_mean(s1) @@ -4676,6 +4676,24 @@ defmodule Explorer.SeriesTest do ]) end + test "returns calculated ewm values with default options used for f64 calculation" do + s1 = Series.from_list([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]) + s2 = Series.ewm_mean(s1) + + assert all_close?(s2, [ + 1.0, + 1.6666666666666667, + 2.4285714285714284, + 3.2666666666666666, + 4.161290322580645, + 5.095238095238095, + 6.05511811023622, + 7.031372549019608, + 8.017612524461839, + 9.009775171065494 + ]) + end + test "returns calculated ewma with differernt smoothing factor if different alpha is passed" do s1 = 1..10 |> Enum.to_list() |> Series.from_list() s2 = Series.ewm_mean(s1, alpha: 0.8)