Skip to content

Commit

Permalink
KData 增加不等判断,引出相等与不等判断至python
Browse files Browse the repository at this point in the history
  • Loading branch information
fasiondog committed Oct 29, 2023
1 parent e51f2bf commit 000ba7e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hikyuu_cpp/hikyuu/KData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ KData::KData(const Stock& stock, const KQuery& query) {
}
}

bool KData::operator==(const KData& thr) {
bool KData::operator==(const KData& thr) const {
return this == &thr || m_imp == thr.m_imp ||
(getStock() == thr.getStock() && getQuery() == thr.getQuery());
}
Expand Down
7 changes: 6 additions & 1 deletion hikyuu_cpp/hikyuu/KData.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class HKU_API KData {
size_t size() const;
bool empty() const;

bool operator==(const KData&);
bool operator==(const KData&) const;
bool operator!=(const KData&) const;

DatetimeList getDatetimeList() const;

Expand Down Expand Up @@ -217,6 +218,10 @@ inline size_t KData::lastPos() const {
return m_imp ? m_imp->lastPos() : 0;
}

inline bool KData::operator!=(const KData& other) const {
return !(*this == other);
}

} /* namespace hku */

#if FMT_VERSION >= 90000
Expand Down
4 changes: 4 additions & 0 deletions hikyuu_pywrap/_KData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ void export_KData() {
:param str filename: 指定保存的文件名称)")

.def("__len__", &KData::size)

.def(self == self)
.def(self != self)

#if HKU_PYTHON_SUPPORT_PICKLE
.def_pickle(normal_pickle_suite<KData>())
#endif
Expand Down

0 comments on commit 000ba7e

Please sign in to comment.