Skip to content
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

String Construction #29

Merged
merged 17 commits into from
Jan 12, 2020
Merged

String Construction #29

merged 17 commits into from
Jan 12, 2020

Conversation

mileslucas
Copy link
Member

@mileslucas mileslucas commented Nov 14, 2019

This PR adds the functionality for constructing coordinates using strings. It is driven by the new str2rad function.

str2rad

There are two base regex patterns to arbitrarily parse the string as either a degree or an hour angle. In addition there is a boolean flag to force parse the string as an hour angle. Here is a clip of the documentation I've written for it
Screen Shot 2019-11-14 at 12 51 08 PM

(If it's not clear, the other ticks that aren't quotation marks are \prime and \pprime, which are what unitful uses for its arcminutes and arcseconds).

string construction

The string construction takes all the types and adds a signature like Coord(::AbstractString, ::AbstractString). For coordinates that use RA (ICRS and FK5) the first string will be force-parsed as an hour angle. Here is an example of the usage

julia> ICRSCoords("12:0:0", "0:0:0") # 12:0:0 will be parsed as an hour angle
ICRSCoords{Float64}(3.141592653589793, 0.0)

julia> GalCoords("12:0:0", "0:0:0") # 12:0:0 will be parsed as degrees
GalCoords{Float64}(0.20943951023931956, 0.0)

version

bump to 0.5.0 to prep for release

@mileslucas mileslucas requested a review from giordano November 14, 2019 23:19
@codecov-io
Copy link

codecov-io commented Dec 5, 2019

Codecov Report

Merging #29 into master will increase coverage by 6.18%.
The diff coverage is 89.09%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #29      +/-   ##
==========================================
+ Coverage   86.36%   92.55%   +6.18%     
==========================================
  Files           2        2              
  Lines          66       94      +28     
==========================================
+ Hits           57       87      +30     
+ Misses          9        7       -2
Impacted Files Coverage Δ
src/types.jl 86.95% <82.35%> (+11.95%) ⬆️
src/SkyCoords.jl 94.36% <92.1%> (+3.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8a56a00...51eec08. Read the comment docs.

@mileslucas
Copy link
Member Author

Not sure whats causing the 1.0 failure on the most recent builds. I'll investigate it further.

@mileslucas
Copy link
Member Author

Previous failures were due to isnothing usage. Should work fine now!

@mileslucas
Copy link
Member Author

Good catch on the docstring, I forgot to test that.

@test C("12h 0.0m 0.0s", "90:0:0") == C(π, π / 2)
@test C("18h0:0", "90:0:0") == C(3π / 2, π / 2)
if C == GalCoords
@test C("12:0:0", "90:0:0") == C(0.20943951023931956, π / 2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit unfortunate that

julia> deg2rad(12)
0.20943951023931956

instead of giving

julia> pi / 15
0.20943951023931953

but there is little we can do here

@giordano giordano merged commit d957cd4 into JuliaAstro:master Jan 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants