ICplxTrans' `to_bytes` and `from_bytes` use different primitive data types (int on write, float on read)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 70/100
Línea de trabajo
El error está en el lector de src/db/db/dbBinarySerialize.h alrededor de las líneas 446-463, donde el desplazamiento de ICplxTrans se lee como R (double) pero se escribe como D (int). Empieza reproduciendo el ida y vuelta en Python del issue y comprueba el desplazamiento después de from_bytes. Está terminado cuando ICplxTrans(Trans(x=10000, y=-2000)) sobrevive a to_bytes/from_bytes sin cambios y el formato binario existente sigue funcionando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C++
- Estrellas
- 1.2k
- Forks
- 305
- Merge medio
- 3 d 2 h
- PR fusionados (30 d)
- 11
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de KLayout/klayout
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
KLayout/klayout#2412 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
DRC functions not working properly with clip in placePosiblemente ocupada @klayoutmatthias la tomó hoy. Abiertobug
KLayout/klayout#2553 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 50/100
Los mantenedores suelen responder en 1 día
-
Deep DRC can miss violations when a cell has many shapesQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
KLayout/klayout#2546 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
Python API: edge neighborhood nodes retain visitors after leaving scopePosiblemente ocupada @klayoutmatthias la tomó hace 4 días. Abiertobug
KLayout/klayout#2542 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de KLayout/klayout
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Integer underflow and buffer overrun in detail::count_rows on disconnected distance matricesAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
LaneDibello/Kotor-Patch-Manager#375 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día