-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed and extended GAP <-> Julia conversions #347
Conversation
Good question. I think the reasoning was that Julia's For most "regular" text, this doesn't matter, because it is ASCII. It would matter for strings that represent binary data read from a file; but that's somewhat rare in GAP. All in all, I am open to changing this. Pure GAP chars are rarely used anyway. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks!
src/gap_to_julia.jl
Outdated
@@ -135,6 +145,19 @@ function gap_to_julia( ::Type{Array{UInt8,1}}, obj :: GapObj ) | |||
end | |||
end | |||
|
|||
## BitArrays | |||
function gap_to_julia( ::Type{BitArray{1}}, obj :: GapObj ) | |||
if ! Globals.IsBlistRep( obj ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this function doesn't use anything about the actual blist rep, could also do this:
if ! Globals.IsBlistRep( obj ) | |
if ! Globals.IsBlist( obj ) |
Of course we could also write a more efficient conversion which does exploit the actual representation at some point in the future... But it's not important right now.
@@ -243,9 +301,18 @@ function gap_to_julia(x::GapObj) | |||
elseif Globals.IsFloat(x) | |||
return gap_to_julia(Float64,x) | |||
elseif Globals.IsChar(x) | |||
#T why Cuchar not Char? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with switching this to Char
@test GAP.julia_to_gap( 4:13 ) == r | ||
@test GAP.julia_to_gap( 4:1:13 ) == r | ||
r = GAP.EvalString( "[ 1, 4 .. 10 ]" ) | ||
@test GAP.julia_to_gap( 1:3:10 ) == r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume trying to convert 1:2^62
will throw an error? Perhaps this should also be tested for?
- fixed the GAP -> Julia conversion for strings - added the GAP <-> Julia conversion for ranges - added the GAP -> Julia conversion for Blists (to BitArrays); note that the Julia -> GAP conversion to Blists happens automatically) - changed the generic GAP -> Julia conversions for GAP strings, ranges, blists - added tests for all this (Why is Cuchar and not Char the default type for the conversion of GAP characters to Julia?)
8ea3416
to
367150d
Compare
@fingolfin I have updated the pull request according to your suggestions |
note that the Julia -> GAP conversion to Blists happens automatically
(Why is Cuchar and not Char the default type for the conversion of GAP characters to Julia?)