File tree 2 files changed +7
-9
lines changed 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change 63
63
Base. convert (:: Type{nlopt_algorithm} , a:: Algorithm ) = nlopt_algorithm (Int (a))
64
64
Base. convert (:: Type{Algorithm} , r:: nlopt_algorithm ) = Algorithm (Int (r))
65
65
66
- const _SYMBOL_TO_ALGORITHM = Dict (Symbol (i) => i for i in instances (Algorithm))
67
-
68
- function Algorithm (name:: Symbol )
69
- algorithm = get (_SYMBOL_TO_ALGORITHM, name, nothing )
70
- if algorithm === nothing
71
- throw (ArgumentError (" unknown algorithm $name " ))
66
+ function Algorithm (name:: Symbol ):: Algorithm
67
+ algorithm = nlopt_algorithm_from_string (" $name " )
68
+ if UInt32 (algorithm) == 0xffffffff
69
+ throw (ArgumentError (" unknown algorithm: $name " ))
72
70
end
73
- return algorithm:: Algorithm
71
+ return algorithm
74
72
end
75
73
76
74
# enum nlopt_result
Original file line number Diff line number Diff line change @@ -75,8 +75,8 @@ function test_issue_156_no_error()
75
75
end
76
76
77
77
function test_invalid_algorithms ()
78
- @test_throws ArgumentError (" unknown algorithm BILL" ) Algorithm (:BILL )
79
- @test_throws ArgumentError (" unknown algorithm BILL" ) Opt (:BILL , 420 )
78
+ @test_throws ArgumentError (" unknown algorithm: BILL" ) Algorithm (:BILL )
79
+ @test_throws ArgumentError (" unknown algorithm: BILL" ) Opt (:BILL , 420 )
80
80
return
81
81
end
82
82
You can’t perform that action at this time.
0 commit comments