Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions lib/explorer/backend/lazy_series.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Dead code, afaik.

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
Expand Down Expand Up @@ -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

Comment on lines -1080 to -1086

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Dead code as well.

@impl true
def transform(_series, _fun) do
raise """
Expand Down
2 changes: 1 addition & 1 deletion lib/explorer/polars_backend/expression.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Dead code too, because line 280 already defines the relevant code.

args = Macro.generate_arguments(arity, __MODULE__)

updates =
Expand Down
8 changes: 4 additions & 4 deletions lib/explorer/series.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion notebooks/exploring_explorer.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 19 additions & 1 deletion test/explorer/series_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down
Loading