@@ -16,6 +16,9 @@ DENSITYPLOT_Y = DENSITYPLOT_FIXTURE_JSON["y"].as_a.map(&.as_f)
1616SPY_FIXTURE_PATH = File .join(__DIR__, " fixtures" , " julia_spy_data.json" )
1717SPY_FIXTURE_JSON = JSON .parse(File .read(SPY_FIXTURE_PATH ))
1818
19+ POLARPLOT_FIXTURE_PATH = File .join(__DIR__, " fixtures" , " julia_polarplot_data.json" )
20+ POLARPLOT_FIXTURE_JSON = JSON .parse(File .read(POLARPLOT_FIXTURE_PATH ))
21+
1922# Returns a matrix fixture by key ("60x60", "10x10", "10x11").
2023# The parsed matrix is cached because multiple examples reuse the same payload.
2124def heatmap_fixture_matrix (key : String ) : Array (Array (Float64 ))
@@ -74,6 +77,14 @@ def spy_flip_matrix : Array(Array(Float64))
7477 a
7578end
7679
80+ def polarplot_fixture_linspace (case_key : String , axis : String ) : Array (Float64 )
81+ entry = POLARPLOT_FIXTURE_JSON [case_key][axis]
82+ start_v = entry[" start" ].as_f
83+ stop_v = entry[" stop" ].as_f
84+ length = entry[" length" ].as_i
85+ linspace(start_v, stop_v, length)
86+ end
87+
7788def linspace (start_v : Float64 , end_v : Float64 , length : Int32 ) : Array (Float64 )
7889 return [] of Float64 if length <= 0
7990 return [start_v] if length == 1
@@ -1239,4 +1250,46 @@ describe "Julia reference output compatibility" do
12391250 end
12401251 end
12411252 end
1253+
1254+ describe " polarplot" do
1255+ it " matches polarplot/simple" do
1256+ theta = polarplot_fixture_linspace(" simple" , " theta" )
1257+ r = polarplot_fixture_linspace(" simple" , " r" )
1258+ p = UnicodePlot .polarplot(theta, r)
1259+ test_ref(" polarplot/simple.txt" , p)
1260+ end
1261+
1262+ it " matches polarplot/simple_with_rlim" do
1263+ theta = polarplot_fixture_linspace(" simple_with_rlim" , " theta" )
1264+ r = polarplot_fixture_linspace(" simple_with_rlim" , " r" )
1265+ rlim_json = POLARPLOT_FIXTURE_JSON [" simple_with_rlim" ][" rlim" ].as_a
1266+ rlim = {rlim_json[0 ].as_f, rlim_json[1 ].as_f}
1267+ p = UnicodePlot .polarplot(theta, r, rlim: rlim)
1268+ test_ref(" polarplot/simple_with_rlim.txt" , p)
1269+ end
1270+
1271+ it " matches polarplot/callable" do
1272+ theta = polarplot_fixture_linspace(" callable" , " theta" )
1273+ p = UnicodePlot .polarplot(theta, - > (angle : Float64 ) { angle / (2.0 * Math ::PI ) })
1274+ test_ref(" polarplot/callable.txt" , p)
1275+ end
1276+
1277+ it " matches polarplot/kwargs" do
1278+ scale = POLARPLOT_FIXTURE_JSON [" kwargs" ][" size_scale" ].as_f
1279+ h = (UnicodePlot .default_height * scale).round.to_i
1280+ w = (UnicodePlot .default_width * scale).round.to_i
1281+ theta = polarplot_fixture_linspace(" kwargs" , " theta" )
1282+ r = polarplot_fixture_linspace(" kwargs" , " r" )
1283+ p = UnicodePlot .polarplot(
1284+ theta,
1285+ r,
1286+ lines: false ,
1287+ border: :solid ,
1288+ color: :red ,
1289+ height: h,
1290+ width: w,
1291+ )
1292+ test_ref(" polarplot/kwargs.txt" , p)
1293+ end
1294+ end
12421295end
0 commit comments