-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stubを分割 #169
Stubを分割 #169
Conversation
- name: Test if stub exists | ||
run: | | ||
echo -e "from scaluq import StateVector\nfrom.scaluq.gate import I" > /tmp/stub_sample.py | ||
mypy /tmp/stub_sample.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
全オブジェクトを列挙してmypyするテストも考えましたが、むしろ一部だけでも名前を指定したほうがそもそもなにもbindingできていない事故を検知できていいと思ったのでこうしました。
全オブジェクト列挙を手動でしておく方法は、追加忘れが起きそうなのと一部だけ生成されないケースをまだ見ていないので一旦やめました。
@@ -62,7 +62,7 @@ class ParamGateBase { | |||
} | |||
virtual ~ParamGateBase() = default; | |||
|
|||
[[nodiscard]] double param_coef() { return _pcoef; } | |||
[[nodiscard]] double param_coef() const { return _pcoef; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constがついてなかったのでつけました
.def( \ | ||
"param_coef", \ | ||
[](const PARAM_GATE_TYPE &gate) { return gate->param_coef(); }, \ | ||
"Get coefficient of parameter.") \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
param_coefがバインドされていなかったのでしました
"phi", [](const U3Gate& gate) { return gate->phi(); }, "Get `phi` property.") | ||
.def( | ||
"lambda_", [](const U3Gate& gate) { return gate->lambda(); }, "Get `lambda` property."); | ||
DEF_GATE(SwapGate, "Specific class of two-qubit swap gate."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SwapGateがバインドできてなかったのでしました(特にメンバ関数が増えるわけでもないのでそれほど必要ではないですが…)
scaluq/gate/gate.hpp
Outdated
@@ -127,7 +127,7 @@ namespace internal { | |||
class GateBase : public std::enable_shared_from_this<GateBase> { | |||
protected: | |||
std::uint64_t _target_mask, _control_mask; | |||
void check_qubit_mask_within_bounds(const StateVector& state_vector) const { | |||
void check_qubit_mask_within_bounds(const StateVector &state_vector) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
このあたりよくわかっていないんですが、これは自動でformatされないんですかね?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
自動formatの結果動いたのですが、たぶん手元Dev containerとCIそれぞれでインストールされるclang-formatのバージョンが同時に変わったため変更+CI通過起こってます…
本家みたいにclang-formatのバージョン固定したほうがいいかも
&の位置は PointerAlignment で指定はできそうですが、デフォルトが変わったんだろうか…
ベースにしているGoogle Styleでは
When referring to a pointer or reference (variable declarations or definitions, arguments, return types, template parameters, etc), you may place the space before or after the asterisk/ampersand. In the trailing-space style, the space is elided in some cases (template parameters, etc).
と書いてあるのでどちらかに規定はされてないようです。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
バージョン固定でもいいですが、一意に定まるほどconfigをキッチリするほうがきれいだと思った(+PointerAlignmentはドキュメントの例でも指定されているほどみんなが設定している項目だった)ので、configのほうを追加する方針にしました。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
対応ありがとうございます!
scaluq/circuit/circuit.hpp
Outdated
.def("copy", &Circuit::copy, "Copy circuit. All the gates inside is copied.") | ||
.def("get_inverse", | ||
&Circuit::get_inverse, | ||
"Get inverse of circuit. ALl the gates are newly created."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: ALl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OKです!
ありがとうございます。
@@ -7,3 +7,5 @@ AccessModifierOffset: -4 | |||
BinPackArguments: false | |||
BinPackParameters: false | |||
ColumnLimit: 100 | |||
DerivePointerAlignment: false | |||
PointerAlignment: Left |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format結果がブレるケースがあったので追加で指定しました。
close #166
binding.cppが長いので、各ヘッダの末尾に分割しました。
エラーでstubが生成されていないものの検知をCIに入れました。