Coder Social home page Coder Social logo

Comments (20)

timj avatar timj commented on July 17, 2024

Fine with me if this is done automatically during import from SOFA.

from erfa.

eteq avatar eteq commented on July 17, 2024

While I agree this would be better, I'm concerned that it generates a substantive incompatibility with SOFA. That is, instead of a global find-and-replace from "iau" to "era", this requires actually changing code that uses SOFA to add prefixes when they weren't present before.

If we do want to go ahead with it, though, I agree with @timj that it absolutely has to be automatic.

from erfa.

sergiopasra avatar sergiopasra commented on July 17, 2024

This shell script does the job amazingly well.

for i in $(awk '/#define/ {print $2}' erfam.h); do
    sed "s/\b$i\b/ERFA_$i/g" -i *.c *.h
  done

I have to tweak it a little bit because:

  • It doesn't work with the macros with arguments
  • It adds ERFA_ to ERFAMHDEF

But it's a good starting point

from erfa.

sergiopasra avatar sergiopasra commented on July 17, 2024

By the way, SOFA should do the same in sofam.h

from erfa.

eteq avatar eteq commented on July 17, 2024

I'm not saying it's not possible/reasonably easy to make the change, but rather than it takes us a step further from SOFA, which we've said we're trying to avoid beyond what we've been required to do by the SOFA board. But perhaps we should hear from some of the parties that plan on switching from SOFA to ERFA...

And @sergiopasra - I agree it would be better if SOFA did this, but I highly doubt that will happen as they are highly conservative when it comes to any changes in SOFA (@scottransom might know better, though?)

from erfa.

sergiopasra avatar sergiopasra commented on July 17, 2024

What I'm proposing is basically the same than renaming the functions from iau to era. This is not altering the algorithms in any way and improves the library (seriously, #define DC?).

You say that SOFA ks very conservative (I would use a different word here) but that doesn't mean that we have to be conservative. We wouldn't have this library, or astropy, if we were conservative.

from erfa.

sergiopasra avatar sergiopasra commented on July 17, 2024
# Translate all the macros except ERFAMHDEF
# Macros with arguments will not match the sed pattern
for i in $(awk '$0~/#define/ && $0!~/ERFAMHDEF/ {print $2}' erfam.h); do
  sed "s/\b$i\b/ERFA_$i/g" -i *.c *.h
done

# The macros with arguments are upper-cased
for i in dint dnint dsign; do
  sed "s/\b\($i\)\b/ERFA_\U\1/g" -i *.c *.h
done

from erfa.

timj avatar timj commented on July 17, 2024

@eteq I am on the fence about this. I've used these macros for years and years and never actually had a problem. On the other hand it does seem wrong to not have a prefix. When AST adopted the macros it did add a prefix (so you will see AST__DR2D). I tentatively am in favor of doing it with automation. It does mean that people will not be confused if they add sofam.h and erfam.h at the same time...(well, they will be confused, but the compiler won't get upset).

I guarantee that SOFA will never add a prefix. I may even have asked back in 2008 but I can't dig it out of email now. SLALIB has done this since the late 1990s and SOFA are not going to break their public interface by adding a prefix.

from erfa.

eteq avatar eteq commented on July 17, 2024

Hmm, I do see your points @sergiopasra and @timj. And it's probably true that it only really has to be done once when some package switches from SOFA to ERFA and never again, really.

@taldcroft, @olebole, or @astrofrog, do you have any opinions here? We probably should decide on this before we release v1.0, as it would require a v2.0 shortly afterwards if we change it...

from erfa.

olebole avatar olebole commented on July 17, 2024

I'd add a prefix in ERFA.

In my opinion, we should not care too much about SOFA here (as long as ERFA can be created programmatically from their sources): I see now SOFA more a reference implementation of IAU algorithms without a use for the end user: once ERFA is out, there is no longer the need to use SOFA at all.

from erfa.

taldcroft avatar taldcroft commented on July 17, 2024

I don't have any objections to this PR since it sets a bit of precedent for other enhancements. 😄

from erfa.

sergiopasra avatar sergiopasra commented on July 17, 2024

Just in case...

from erfa.

scottransom avatar scottransom commented on July 17, 2024

@olebole you are correct that basically the sole purpsose of SOFA is as a reference implementation of IAU algorithms. I has a lot of discussion with the other board members about this when I became a member (because I don't really agree with it). I think the most important thing for ERFA is that new versions of SOFA (and there will be another one soon with some bug fixes) can be auto-magically (or semi-) incorporated to become new versions of ERFA.

from erfa.

eteq avatar eteq commented on July 17, 2024

Alright, sounds like the consensus is that we should include the prefixes, so let's do it. (we can close this issue once erfa-fetch has been updated and the changes propogated to the main erfa repo).

from erfa.

timj avatar timj commented on July 17, 2024

Yes, in #13 we have to decide how we are doing it though. Localized to erfam.h or changes to every C file.

from erfa.

eteq avatar eteq commented on July 17, 2024

@timj - right, but I just closed that given that it needs to be done in erfa-fetch first (as you said). I'm just leaving the note hear so we know when it's safe to close this issue.

from erfa.

timj avatar timj commented on July 17, 2024

@eteq Sorry. I hadn't seen your follow up to #13 when I responded.

from erfa.

eteq avatar eteq commented on July 17, 2024

Ah - simultaneous posting, I think :)

from erfa.

eteq avatar eteq commented on July 17, 2024

Were you planning on implementing the autogeneration scheme in liberfa/erfa-fetch, @sergiopasra? Once we have that I think we are ready for release. Or are we still waiting for resolution on erfam.h macros vs. every C file, @timj or @sergiopasra? Either way seems fine to me (whichever is easier to implement in erfa-fetch...)

from erfa.

sergiopasra avatar sergiopasra commented on July 17, 2024

Let me try a little

from erfa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.