Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ファイルからロードした後に新しい結果を書き込めない #52

Closed
k-kitai opened this issue May 31, 2023 · 3 comments
Closed

Comments

@k-kitai
Copy link
Contributor

k-kitai commented May 31, 2023

historyクラスの内容をsaveメソッドでnpzファイルに保存しておいたものをloadメソッドで読み込み、複数のアクションの結果を書き込もうとするとエラーになります。再現コードは以下のとおりです。

from physbo.search.discrete import history
his = history()
his.write(t=[3.14], action=[0])
his.save("history.npz")
his.load("history.npz")
his.write(t=[2.18, 1.618], action=[1, 2]) # ValueError: could not broadcast input array from shape (2,) into shape (0,)

原因はhistoryクラスのint型のインスタンス変数であるnum_runstotal_num_search が、npzファイルに保存した際にnumpy.ndarray型に変化してしまい、その値を別の変数に格納するときに参照渡しになっているからのようです。loadメソッドでこれらの値を読み出した時に、キャストで明示的にint型に戻してはいかがでしょうか。

@k-yoshimi
Copy link
Contributor

@k-kitai
バグ報告と解決方法のご提案をありがとうございます。
修正対応後にIssueにその旨を記載するようにします。

@yomichi
Copy link
Contributor

yomichi commented Aug 20, 2024

@k-kitai
すみません、大変遅くなりましたが修正しました。(#59)
develop ブランチにありますが、他の修正と合わせてなるべく早く新しいバージョンを出します

@yomichi
Copy link
Contributor

yomichi commented Dec 23, 2024

2024/8に出したv2.0.1に入っているのでclose

@yomichi yomichi closed this as completed Dec 23, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants