Skip to content

Commit

Permalink
Revert "faster"
Browse files Browse the repository at this point in the history
This reverts commit 97da28f.
  • Loading branch information
vovaf709 committed Apr 16, 2024
1 parent bdb4996 commit 3b9ee95
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions imops/interp1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from warnings import warn

import numpy as np
import torch
from scipy.interpolate import interp1d as scipy_interp1d

from .backend import BackendLike, resolve_backend
Expand Down Expand Up @@ -181,14 +180,14 @@ def __call__(self, x_new: np.ndarray) -> np.ndarray:
if self.backend.name == 'Numba':
set_num_threads(old_num_threads)

out = torch.from_numpy(out).to(max(torch.from_numpy(self.y).dtype, torch.from_numpy(self.x).dtype, torch.from_numpy(x_new).dtype, key=lambda x: x.itemsize)).numpy()
out = out.astype(max(self.y.dtype, self.x.dtype, x_new.dtype, key=lambda x: x.type(0).itemsize), copy=False)

if self.n_dummy:
out = out[(0,) * self.n_dummy]
if self.axis not in (-1, out.ndim - 1):
out = np.swapaxes(out, -1, self.axis)
# FIXME: fix behaviour with np.inf-s
if torch.isnan(torch.from_numpy(out)).any():
if np.isnan(out).any():
if not np.isinf(out).any():
raise RuntimeError("Can't decide how to handle nans in the output.")

Expand Down

0 comments on commit 3b9ee95

Please sign in to comment.