ICplxTrans' `to_bytes` and `from_bytes` use different primitive data types (int on write, float on read)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 70/100
調査の方向性
バグは src/db/db/dbBinarySerialize.h の446~463行目付近のリーダーにあり、ICplxTrans の変位が R (double) として読み込まれる一方で D (int) として書き込まれています。まず issue にある Python のラウンドトリップを再現し、from_bytes の後の変位を確認してください。ICplxTrans(Trans(x=10000, y=-2000)) が to_bytes/from_bytes を経ても変わらず、既存のバイナリ形式も引き続き動作すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Hi Matthias,
I found an asymmetry in ICplxTrans.to_bytes() and ICPlxTrans.from_bytes (a clanker helped me analyze the precise error which seems to come from klayout).
Small clanker analysis bleow:
In KLayout 0.30.13, an ICplxTrans with a displacement does not survive a to_bytes() / from_bytes() round trip.
import klayout.db as kdb
original = kdb.ICplxTrans(kdb.Trans(x=10000, y=-2000))
restored = kdb.ICplxTrans.from_bytes(original.to_bytes())
print(original) # r0 *1 10000,-2000
print(restored) # r0 *1 0,nan
assert restored == original # fails
The displacement is present in the serialized bytes. In dbBinarySerialize.h (https://github.com/KLayout/klayout/blob/v0.30.13/src/db/db/dbBinarySerialize.h#L446-L463), the writer stores it using the output coordinate type D, but the reader reads it using the internal representation type R. For ICplxTrans, those are integer and double respectively, so the coordinate bytes are interpreted as floating point values.
Suggested minimal fix for the reader:
- db::vector<R> d;
+ db::vector<D> d;
read_binary (s, d);
double asin, acos, mag;
s >> asin >> acos >> mag;
- t = db::complex_trans<C, D, R> (d, asin, acos, mag);
+ t = db::complex_trans<C, D, R> (db::vector<R> (d), asin, acos, mag);
This keeps the existing binary format and reads its displacement using the type with which it was written.
- 主要言語
- C++
- スター
- 1.2k
- フォーク
- 305
- 平均マージ
- 3日 2時間
- マージ済み PR(30日)
- 11
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
KLayout/klayout のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
KLayout/klayout#2412 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
DRC functions not working properly with clip in place対応中かも @klayoutmatthias が今日担当しました。 オープンbug
KLayout/klayout#2553 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 50/100
メンテナーはふだん 1 日以内に返信
-
Deep DRC can miss violations when a cell has many shapes再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
KLayout/klayout#2546 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
-
Python API: edge neighborhood nodes retain visitors after leaving scope対応中かも @klayoutmatthias が 4 日前に担当しました。 オープンbug
KLayout/klayout#2542 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
KLayout/klayout の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
LaneDibello/Kotor-Patch-Manager#375 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信