Skip to content

Commit

Permalink
Raise instead of logging
Browse files Browse the repository at this point in the history
  • Loading branch information
philss committed Apr 21, 2024
1 parent c708f46 commit 1ae1ddd
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions lib/explorer/backend/lazy_series.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ defmodule Explorer.Backend.LazySeries do
"""
alias Explorer.Series
alias Explorer.Backend
require Logger

@behaviour Explorer.Backend.Series

Expand Down Expand Up @@ -1197,25 +1196,17 @@ defmodule Explorer.Backend.LazySeries do
def re_named_captures(series, pattern) do
lazy_s = lazy_series!(series)

target_dtype = get_backend(lazy_s).re_dtype(pattern)
backend = get_backend(lazy_s, "re_named_captures/2")
target_dtype = backend.re_dtype(pattern)

data = new(:re_named_captures, [lazy_s, pattern], target_dtype)

Backend.Series.new(data, target_dtype)
end

defp get_backend(%__MODULE__{} = lazy_series) do
lazy_series.backend || warning_with_default_backend()
end

defp warning_with_default_backend do
backend = Explorer.Backend.get()

Logger.warning(
"cannot get backend from LazySeries. Using the default one: #{inspect(backend)}"
)

:"#{backend}.DataFrame"
defp get_backend(%__MODULE__{} = lazy_series, function) do
lazy_series.backend ||
raise "cannot get backend from Explorer.Backend.LazySeries for `#{function}`"
end

@remaining_non_lazy_operations [
Expand Down

0 comments on commit 1ae1ddd

Please sign in to comment.