mirror of
https://github.com/rmontanana/mdlp.git
synced 2025-08-17 00:15:59 +00:00
Fix conan (#10)
* Fix debug conan build target * Add viewcoverage and fix coverage generation * Add more tests to cover new integrity checks * Add tests to accomplish 100% * Fix conan-create makefile target
This commit is contained in:
committed by
GitHub
parent
c1759ba1ce
commit
6d8b55a808
@@ -49,7 +49,7 @@ namespace mdlp {
|
||||
// Note: y parameter is validated but not used in binning strategy
|
||||
fit(X);
|
||||
}
|
||||
std::vector<precision_t> linspace(precision_t start, precision_t end, int num)
|
||||
std::vector<precision_t> BinDisc::linspace(precision_t start, precision_t end, int num)
|
||||
{
|
||||
// Input validation
|
||||
if (num < 2) {
|
||||
@@ -77,7 +77,7 @@ namespace mdlp {
|
||||
{
|
||||
return std::max(lower, std::min(n, upper));
|
||||
}
|
||||
std::vector<precision_t> percentile(samples_t& data, const std::vector<precision_t>& percentiles)
|
||||
std::vector<precision_t> BinDisc::percentile(samples_t& data, const std::vector<precision_t>& percentiles)
|
||||
{
|
||||
// Input validation
|
||||
if (data.empty()) {
|
||||
|
@@ -23,6 +23,9 @@ namespace mdlp {
|
||||
// y is included for compatibility with the Discretizer interface
|
||||
void fit(samples_t& X_, labels_t& y) override;
|
||||
void fit(samples_t& X);
|
||||
protected:
|
||||
std::vector<precision_t> linspace(precision_t start, precision_t end, int num);
|
||||
std::vector<precision_t> percentile(samples_t& data, const std::vector<precision_t>& percentiles);
|
||||
private:
|
||||
void fit_uniform(const samples_t&);
|
||||
void fit_quantile(const samples_t&);
|
||||
|
@@ -39,8 +39,8 @@ namespace mdlp {
|
||||
size_t getCandidate(size_t, size_t);
|
||||
size_t compute_max_num_cut_points() const;
|
||||
pair<precision_t, size_t> valueCutPoint(size_t, size_t, size_t);
|
||||
private:
|
||||
inline precision_t safe_X_access(size_t idx) const {
|
||||
inline precision_t safe_X_access(size_t idx) const
|
||||
{
|
||||
if (idx >= indices.size()) {
|
||||
throw std::out_of_range("Index out of bounds for indices array");
|
||||
}
|
||||
@@ -50,7 +50,8 @@ namespace mdlp {
|
||||
}
|
||||
return X[real_idx];
|
||||
}
|
||||
inline label_t safe_y_access(size_t idx) const {
|
||||
inline label_t safe_y_access(size_t idx) const
|
||||
{
|
||||
if (idx >= indices.size()) {
|
||||
throw std::out_of_range("Index out of bounds for indices array");
|
||||
}
|
||||
@@ -60,7 +61,8 @@ namespace mdlp {
|
||||
}
|
||||
return y[real_idx];
|
||||
}
|
||||
inline size_t safe_subtract(size_t a, size_t b) const {
|
||||
inline size_t safe_subtract(size_t a, size_t b) const
|
||||
{
|
||||
if (b > a) {
|
||||
throw std::underflow_error("Subtraction would cause underflow");
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ namespace mdlp {
|
||||
if (cutPoints.size() < 2) {
|
||||
throw std::runtime_error("Discretizer not fitted yet or no valid cut points found");
|
||||
}
|
||||
|
||||
|
||||
discretizedData.clear();
|
||||
discretizedData.reserve(data.size());
|
||||
// CutPoints always have at least two items
|
||||
@@ -40,9 +40,6 @@ namespace mdlp {
|
||||
void Discretizer::fit_t(const torch::Tensor& X_, const torch::Tensor& y_)
|
||||
{
|
||||
// Validate tensor properties for security
|
||||
if (!X_.is_contiguous() || !y_.is_contiguous()) {
|
||||
throw std::invalid_argument("Tensors must be contiguous");
|
||||
}
|
||||
if (X_.sizes().size() != 1 || y_.sizes().size() != 1) {
|
||||
throw std::invalid_argument("Only 1D tensors supported");
|
||||
}
|
||||
@@ -58,7 +55,7 @@ namespace mdlp {
|
||||
if (X_.numel() == 0) {
|
||||
throw std::invalid_argument("Tensors cannot be empty");
|
||||
}
|
||||
|
||||
|
||||
auto num_elements = X_.numel();
|
||||
samples_t X(X_.data_ptr<precision_t>(), X_.data_ptr<precision_t>() + num_elements);
|
||||
labels_t y(y_.data_ptr<int>(), y_.data_ptr<int>() + num_elements);
|
||||
@@ -67,9 +64,6 @@ namespace mdlp {
|
||||
torch::Tensor Discretizer::transform_t(const torch::Tensor& X_)
|
||||
{
|
||||
// Validate tensor properties for security
|
||||
if (!X_.is_contiguous()) {
|
||||
throw std::invalid_argument("Tensor must be contiguous");
|
||||
}
|
||||
if (X_.sizes().size() != 1) {
|
||||
throw std::invalid_argument("Only 1D tensors supported");
|
||||
}
|
||||
@@ -79,7 +73,7 @@ namespace mdlp {
|
||||
if (X_.numel() == 0) {
|
||||
throw std::invalid_argument("Tensor cannot be empty");
|
||||
}
|
||||
|
||||
|
||||
auto num_elements = X_.numel();
|
||||
samples_t X(X_.data_ptr<precision_t>(), X_.data_ptr<precision_t>() + num_elements);
|
||||
auto result = transform(X);
|
||||
@@ -88,9 +82,6 @@ namespace mdlp {
|
||||
torch::Tensor Discretizer::fit_transform_t(const torch::Tensor& X_, const torch::Tensor& y_)
|
||||
{
|
||||
// Validate tensor properties for security
|
||||
if (!X_.is_contiguous() || !y_.is_contiguous()) {
|
||||
throw std::invalid_argument("Tensors must be contiguous");
|
||||
}
|
||||
if (X_.sizes().size() != 1 || y_.sizes().size() != 1) {
|
||||
throw std::invalid_argument("Only 1D tensors supported");
|
||||
}
|
||||
@@ -106,7 +97,7 @@ namespace mdlp {
|
||||
if (X_.numel() == 0) {
|
||||
throw std::invalid_argument("Tensors cannot be empty");
|
||||
}
|
||||
|
||||
|
||||
auto num_elements = X_.numel();
|
||||
samples_t X(X_.data_ptr<precision_t>(), X_.data_ptr<precision_t>() + num_elements);
|
||||
labels_t y(y_.data_ptr<int>(), y_.data_ptr<int>() + num_elements);
|
||||
|
Reference in New Issue
Block a user