-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Refactor Bicubic class to use interpolation factory
- Loading branch information
Showing
2 changed files
with
25 additions
and
17 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/pyinterp/core/include/pyinterp/detail/interpolation/factory_2d.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
#include <stdexcept> | ||
|
||
#include "pyinterp/detail/interpolation/bicubic.hpp" | ||
#include "pyinterp/detail/interpolation/bilinear.hpp" | ||
|
||
namespace pyinterp::detail::interpolation { | ||
|
||
template <typename T> | ||
static inline auto factory_2d(const std::string &kind) | ||
-> std::unique_ptr<Interpolator2D<T>> { | ||
if (kind == "bilinear") { | ||
return std::make_unique<Bilinear<T>>(); | ||
} | ||
if (kind == "bicubic") { | ||
return std::make_unique<Bicubic<T>>(); | ||
} | ||
throw std::invalid_argument("Invalid bicubic type: " + kind); | ||
} | ||
|
||
} // namespace pyinterp::detail::interpolation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters