annoviko / annoviko/pyclustering

[C++ pyclustering] Human-readable errors to Python

未關閉
#591 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
Enhancement Good First Issue
主要語言
Python
星號
1.2k
分支
262
PR 合併指標
30 天內沒有已合併 PR

描述

**Introduction**
The current problem is following: in case of incorrect input data or due to some other reason (even unexpected) - C++ code throws exception that is not captured by anyone. As a result the client (python code) receives error code that is not readable. Here is an example of an error:
```
[WinError -529697949] Windows Error 0xe06d7363
```

The idea is to capture each exception in pyclustering interface and report about the problem to the client of the library, in this case - python pyclustering library.

**Description**
C++ pyclustering interface `ccore/include/interface/` and `ccore/src/interface/`.

The idea is to capture all exception, for example, there is a function:
```cpp
pyclustering_package * agglomerative_algorithm(const pyclustering_package * const p_sample, const size_t p_number_clusters, const size_t p_link) {
pyclustering::clst::agglomerative algorithm(p_number_clusters, (pyclustering::clst::agglomerative::type_link) p_link);

/* ... ... ... */

return package;
}
```

Wrap it by try catch block:
```cpp
pyclustering_package * agglomerative_algorithm(const pyclustering_package * const p_sample, const size_t p_number_clusters, const size_t p_link) try {
pyclustering::clst::agglomerative algorithm(p_number_clusters, (pyclustering::clst::agglomerative::type_link) p_link);

pyclustering::dataset data;
p_sample->extract(data);

pyclustering::clst::agglomerative_data result;
algorithm.process(data, result);

pyclustering_package * package = create_package(&result.clusters());

return package;
}
catch (std::exception & p_error) {
return pyclustering_pachage_from_exception(p_error);
}
```

**Useful links**
- How to prepare working copy: https://github.com/annoviko/pyclustering/wiki/Working-Copy-Preparation
- How to build C++ pyclustering: https://github.com/annoviko/pyclustering/wiki/Cpp-PyClustering
- How to run C++ unit-tests: https://github.com/annoviko/pyclustering/wiki/Unit-Testing-CCORE

**Functionality to cover**
All exported functions that return `pyclustering_package`:
- [ ] agglomerative_interface.cpp
- [ ] bsas_interface.cpp
- [x] clique_interface.cpp
- [ ] cure_interface.cpp
- [ ] dbscan_interface.cpp
- [x] elbow_interface.cpp
- [ ] fcm_interface.cpp
- [ ] gmeans_interface.cpp
- [ ] hhn_interface.cpp
- [ ] hsyncnet_interface.cpp
- [ ] kmeans_interface.cpp
- [ ] kmedoids_interface.cpp
- [ ] legion_interface.cpp
- [ ] mbsas_interface.cpp
- [ ] metric_interface.cpp
- [ ] optics_interface.cpp
- [ ] pcnn_interface.cpp
- [ ] rock_interface.cpp
- [ ] silhouette_interface.cpp
- [ ] som_interface.cpp
- [ ] sync_interface.cpp
- [ ] syncnet_interface.cpp
- [ ] syncpr_interface.cpp
- [ ] ttsas_interface.cpp
- [ ] xmeans_interface.cpp

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。