Skip to content

Commit

Permalink
Small optimization.
Browse files Browse the repository at this point in the history
  • Loading branch information
vnmabus committed Mar 30, 2023
1 parent 546f360 commit 53dfa29
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion skfda/_utils/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,11 @@ def map_function(

def _int_to_real(array: Union[NDArrayInt, NDArrayFloat]) -> NDArrayFloat:
"""Convert integer arrays to floating point."""
return array + 0.0
if np.issubdtype(array.dtype, np.integer):
return array.astype(np.float64)

assert np.issubdtype(array.dtype, np.floating)
return cast(NDArrayFloat, array)


def _check_array_key(array: NDArrayAny, key: Any) -> Any:
Expand Down
2 changes: 1 addition & 1 deletion skfda/representation/basis/_fdatabasis.py
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ def _mul_scalar(
) -> T:
"""Multiplication by scalar."""
try:
vector = np.atleast_1d(other)
vector = _int_to_real(np.atleast_1d(other))
except Exception:
return NotImplemented

Expand Down

0 comments on commit 53dfa29

Please sign in to comment.