Skip to content

Commit

Permalink
Robustness of tests against different hash implementations, documenta…
Browse files Browse the repository at this point in the history
…tion update
  • Loading branch information
Matthias Koefferlein committed Nov 26, 2024
1 parent 0f438cd commit ce4dc08
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
5 changes: 4 additions & 1 deletion src/db/db/gsiDeclDbEdgeNeighborhood.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ Class<gsi::EdgeNeighborhoodVisitorImpl> decl_EdgeNeighborhoodVisitorImpl (decl_E
gsi::callback ("begin_polygon", &EdgeNeighborhoodVisitorImpl::issue_begin_polygon, &EdgeNeighborhoodVisitorImpl::f_begin_polygon, gsi::arg ("layout"), gsi::arg ("cell"), gsi::arg ("polygon"),
"@brief Is called for each new polygon\n"
"This event announces a new primary polygon. After this event, the edges of the polygon are reported via \\on_edge, "
"followed by a call of \\end_polygon."
"followed by a call of \\end_polygon.\n"
"\n"
"Note, that the polygon object is a temporary reference to a C++ object and it is only valid during the execution of this "
"callback. If you like to keep the polygon object, create a copy of it using the 'dup' method."
) +
gsi::callback ("end_polygon", &EdgeNeighborhoodVisitorImpl::issue_end_polygon, &EdgeNeighborhoodVisitorImpl::f_end_polygon,
"@brief Is called after the polygon\n"
Expand Down
33 changes: 19 additions & 14 deletions testdata/ruby/dbEdgeNeighborhood.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,35 @@
class MyVisitor < RBA::EdgeNeighborhoodVisitor

def initialize
@log = ""
@log = {}
@current_log = nil
end

def log
@log
@log.keys.sort { |a,b| a < b ? -1 : (a == b ? 0 : 1) }.collect { |k| @log[k].join("") }.join("")
end

def begin_polygon(layout, cell, polygon)
polygon = polygon.dup
output(polygon)
@log += "Polygon: #{polygon}\n"
@log[polygon] ||= []
@current_log = @log[polygon]
@current_log << "Polygon: #{polygon}\n"
end

def end_polygon
@log += "/Polygon\n"
@current_log << "/Polygon\n"
@current_log = nil
end

def on_edge(layout, cell, edge, neighborhood)
@log += "edge = #{edge}\n"
@current_log << "edge = #{edge}\n"
neighborhood.each do |n|
x1, x2 = n[0]
polygons = n[1]
polygons.each do |inp, poly|
poly_str = poly.collect { |p| p.to_s }.join("/")
@log += " #{x1},#{x2} -> #{inp}: #{poly_str}\n"
@current_log << " #{x1},#{x2} -> #{inp}: #{poly_str}\n"
end
end
end
Expand All @@ -68,7 +73,7 @@ def on_edge(layout, cell, edge, neighborhood)
polygons.each do |inp, poly|
poly.each do |p|
bbox = p.bbox
t = self.to_original_trans(edge)
t = RBA::EdgeNeighborhoodVisitor.to_original_trans(edge)
ep = RBA::EdgePair::new(edge, t * RBA::Edge::new(bbox.p1, RBA::Point::new(bbox.right, bbox.bottom)))
output(ep)
end
Expand Down Expand Up @@ -111,19 +116,19 @@ def test_1
res = prim.complex_op(node)

assert_equal(visitor.log,
"Polygon: (0,0;0,1000;1000,1000;1000,0)\n" +
"edge = (0,0;0,1000)\n" +
" 0.0,1000.0 -> 0: (0,100;0,101;1000,101;1000,100)\n" +
"edge = (0,1000;1000,1000)\n" +
"edge = (1000,1000;1000,0)\n" +
"edge = (1000,0;0,0)\n" +
"/Polygon\n" +
"Polygon: (-1100,0;-1100,1000;-100,1000;-100,0)\n" +
"edge = (-1100,0;-1100,1000)\n" +
"edge = (-1100,1000;-100,1000)\n" +
"edge = (-100,1000;-100,0)\n" +
" 0.0,1000.0 -> 0: (0,100;0,101;1000,101;1000,100)\n" +
"edge = (-100,0;-1100,0)\n" +
"/Polygon\n" +
"Polygon: (0,0;0,1000;1000,1000;1000,0)\n" +
"edge = (0,0;0,1000)\n" +
" 0.0,1000.0 -> 0: (0,100;0,101;1000,101;1000,100)\n" +
"edge = (0,1000;1000,1000)\n" +
"edge = (1000,1000;1000,0)\n" +
"edge = (1000,0;0,0)\n" +
"/Polygon\n"
)

Expand Down

0 comments on commit ce4dc08

Please sign in to comment.