Skip to content

Commit eb46696

Browse files
committed
Fix and test rational exponent to_std output
1 parent 7a37de1 commit eb46696

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/stdstr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function to_std_str(arg::Real)
4242
end
4343

4444
function to_std_str(arg::Rational)
45-
out = string(arg)
45+
out = string(arg.num) * "/" * string(arg.den)
4646

4747
return "(" * out * ")"
4848
end

test/StdTest.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,13 @@ end
276276
@test to_std(dc.UnaryOperation{dc.Abs}(mul(A, x))) == "abs(Ax)"
277277
end
278278

279+
@testset "to_std output is correct with rational exponent" begin
280+
x = Variable("x", Upper(1))
281+
282+
@test to_std(dc.Power(2, 1//3)) == "2^(1/3)"
283+
@test to_std(dc.Power(x, 1//3)) == "x^(1/3)"
284+
end
285+
279286
@testset "to_std output is correct with sgn" begin
280287
x = Variable("x", Upper(2))
281288
A = Variable("A", Upper(1), Lower(2))

0 commit comments

Comments
 (0)