Commit Graph

2227 Commits

Author SHA1 Message Date
Don Cross
bdb28eee2e Kotlin demo: rise/set/culmination
Added Kotlin demo to search for rise/set/culmination
of the Sun and Moon.

Enhanced the Time class to allow it to be
directly compared and sorted.
2022-05-03 21:09:56 -04:00
Don Cross
f32a922ddb Demo for Kotlin, Java: constellation 2022-05-03 16:50:11 -04:00
Don Cross
984ebf6a07 Merge pull request #214 from ebraminio/kotlin
jvm: Upgrade Java language version to 11
2022-05-03 13:37:36 -04:00
Ebrahim Byagowi
c24d49f742 jvm: Upgrade Java language version to 11 2022-05-03 21:57:57 +04:30
Don Cross
c9f2228827 Cannot use Optional<T>.isEmpty() in Java 1.8.
Our GitHub Actions tests were using a Java 11
function `Optional<T>.isEmpty()`, but it runs using
Java 1.8. Replaced `isEmpty` with `!isPresent`.
2022-05-02 20:34:29 -04:00
Don Cross
a66fa24def Merge branch 'ebraminio-kotlin' into kotlin 2022-05-02 19:14:38 -04:00
Ebrahim Byagowi
6c55d15778 jvm demos: Simplify main function
Also makes the two more similar.
2022-05-03 01:41:06 +04:30
Ebrahim Byagowi
612f2ef3f4 jvm demos: Apply IDE provided suggestions 2022-05-03 01:27:05 +04:30
Don Cross
1e84f4940f Demo jupiter_moons for Kotlin, Java.
Added Kotlin and Java demos for calculating Jupiter's moons.
Illustrates correcting for light travel time.
I added named getters for the 4 moons in `JupiterMoonsInfo`,
because in Java it was really ugly to write
`jm.getMoon()[0]`, etc.
2022-05-02 15:45:10 -04:00
Don Cross
f670ae2127 Added Kotlin demo: jupiter_moons.
I had to add a new method `Vector.withTime` to work around
the error checking that throws an exception if vectors
from different times are added.

Also made Kotlin constants public:

    MINUTES_PER_DAY
    SECONDS_PER_DAY
    MILLISECONDS_PER_DAY
2022-05-02 14:57:16 -04:00
Don Cross
5df9b03e7c Added comments to Java demos. 2022-05-02 13:38:31 -04:00
Don Cross
90aa6ed369 Cleaned up GitHub Actions configuration.
Deleted the do-nothing placeholders for installing
the Kotlin Native compiler. We are not going to support
Kotlin Native for now.

Removed redundant installation of pylint from the
Windows commit_hook.bat.

Other batch file cleanup, now that I know "||" works in Windows.
2022-05-02 12:30:23 -04:00
Don Cross
e11cb1721b Simplified demotest scripts for C, C#, JS, PY.
I made the scripts for testing the demos for
C, C#, JavaScript, and Python follow the improved
pattern used for Java and Kotlin: much smaller
and easier to maintain thanks to bash functions.
2022-05-02 12:27:19 -04:00
Don Cross
cd5f254b86 Merge branch 'matrix_workflow' into kotlin 2022-05-02 11:28:49 -04:00
Don Cross
237bc42084 Added Kotlin demo: positions.
I also reworked how the Java and Kotlin demos
process errors in the command line arguments.
Using exceptions that are caught by main() rather
than directly exiting the process where the errors
are detected.
2022-05-02 11:28:16 -04:00
Don Cross
551ce7a249 Simplified Java/Kotlin demo tests.
I found that it is possible to use the "||" operator
in Windows batch files, and it works the same as the
"||" operator in bash scripts.

This inspired me to rework the bash scripts and
Windows batch files for running the Java/Kotlin demo
tests to be much more compact using functions/subroutines.

The best part is, the new approach will make it much
easier to add more demo tests in the future.

Removed the "now" test from Java demos, because it
does not follow the same pattern as the other demos,
plus it is not really demonstrating astronomy calculations.

Starting working on the Positions.kt demo; but not finished yet.
2022-05-02 10:21:23 -04:00
Don Cross
60c6286422 Merge branch 'kotlin' of https://github.com/HrBDev/astronomy into matrix_workflow 2022-05-01 21:46:46 -04:00
Don Cross
190cc5b534 Java: added positions demo. 2022-05-01 21:12:57 -04:00
Don Cross
eac8582418 Test Kotlin demos in Windows. 2022-05-01 19:48:18 -04:00
Don Cross
b03171ac3a Added code comments for the Kotlin demos. 2022-05-01 16:45:57 -04:00
Don Cross
5cb273ceed Starting to add Kotlin demos.
Just like we have Java demos that use the Kotlin
version of Astronomy Engine, I want equivalent
demos in Kotlin.
2022-05-01 16:39:14 -04:00
Hamidreza Bayat
0a2fdbfd8d Use conditions & matrix for workflow 2022-05-01 20:12:42 +04:30
Don Cross
6064bf1d94 Updated README.md for the Java demo suite.
Added link and description of Seasons.java.
Mention `rundemo` script.
2022-05-01 09:40:50 -04:00
Don Cross
99d1aecba7 Minor cleanup to Java demos. 2022-04-30 21:38:32 -04:00
Don Cross
f98f64b9ef Removed the stub Android demo. 2022-04-30 21:38:03 -04:00
Don Cross
303bebdff5 Added Java demo for calculating seasons. 2022-04-30 21:20:33 -04:00
Don Cross
efc59ae6fc Refactored demo tests.
I refactored the unit tests for all the demo programs
to follow a different pattern that makes it simpler
to add more demo tests in the future.

The main thing is that correct output and generated
output are now in separate directories `correct` and `test`.
I have moved the test scripts from `test/test` to `./demotest`
in all the langauge demo directories.

This makes it simpler to clean up any stale generated
files before each test run by `rm -f test/*.txt`.

I stumbled across this while making the Java demo tests,
and it was a better solution, so now all the other languages
are consistent with the Java demo tests.

In the C demo tests, I also decided to compile all the
binary executables into a subdirectory `bin` that can
be cleaned out before each run, to make sure there are
no stale executables from an earlier run.
2022-04-30 21:01:11 -04:00
Don Cross
7c74730d8e Java demos: print error message for unknown verb. 2022-04-30 17:46:15 -04:00
Don Cross
b3d42fc6d5 Java demos: reworked as table-driven.
As I add more Java demos, it will make the code more
compact to factor out argument count checking, etc.
Reworked as a table-driven model instead of using `switch`,
so that I will be able to add new demos more concisely.
2022-04-30 12:20:28 -04:00
Don Cross
8f5f8940bc Java demo: eliminate use of Date. 2022-04-30 11:31:32 -04:00
Don Cross
3ff72cc715 Merge branch 'ebraminio-kotlin' into kotlin 2022-04-30 11:16:07 -04:00
Don Cross
e81a566d1e Kotlin: was not running Java demo tests.
Run the Java demo unit test as part of the automated test suite.
If the test fails, print the xml test results to the screen,
so if it happens in GitHub Actions, we can see what went wrong
and diagnose the problem.
2022-04-30 11:14:01 -04:00
Ebrahim Byagowi
13f6e98866 Kotlin: Use Instant.parse instead a custom date parser
Also fixes the demo which had the same code.
2022-04-30 12:14:46 +04:30
Don Cross
3ca64f1ab2 Kotlin: fixed Java demo test for Windows.
I forgot to update the Windows batch file
for testing Java demo programs. Now it works
and correctly verifies the output of the
Java demo `MoonPhase`.
2022-04-28 21:52:33 -04:00
Don Cross
05684bafdb Kotlin: added Java demo: moonphase.
This is the first substantial demo of using
the Kotlin version of Astronomy Engine from
a Java program.

Structured the README.md so I can keep adding more and
more demos as separate Java class files.
The `demotest` script builds the code and will run
each demo one at a time, verifying each one's output.
2022-04-28 21:04:54 -04:00
Don Cross
79597c2e9c Merge branch 'ebraminio-kotlin' into kotlin 2022-04-28 11:29:42 -04:00
Ebrahim Byagowi
962b9c7c9c kotlin: Revert and use arrayOf directly
Direct use of arrayOf can be a bit more efficient than calling map and toTypedArray.

It could be faster if JupiterMoonsInfo was holding a list but better to use direct
typed array initializer for more efficiency.
2022-04-28 19:10:35 +04:30
Ebrahim Byagowi
abd48a3e2b kotlin: Use hashMapOf instead mutableMapOf
mutableMapOf guarantees order of insertion and hashMapOf don't and
as it doesn't matter here let's use that instead.
2022-04-28 18:58:39 +04:30
Don Cross
5d704f438c Merge branch 'ebraminio-kotlin' into kotlin.
Merged ebraminio's changes, but reverted `sumOf` changes
that caused inaccurate calculations.
2022-04-27 21:19:32 -04:00
Don Cross
462f172e6d Kotlin: restored original series calculations.
Changing series calculations to use `sumOf` caused
test failures for Jupiter's moons, compared to the other
languages. I don't understand why, but it is losing about
5 decimal places of accuracy:

    First  file: temp/c_check.txt
    Second file: temp/k_check.txt
    Tolerance = 6.700e-15

                lnum                 a_value                 b_value     factor       diff  name
      OK       59558 -3.7992709399390907e-04 -3.7992709399390658e-04  411.52263  1.026e-15  helio_x
      OK       70088 -1.2672603312645981e-03 -1.2672603312646005e-03  411.52263  9.816e-16  helio_y
      OK      122819  1.0937502621531685e-04  1.0937502621531790e-04  411.52263  4.294e-16  helio_z
      OK        2427  2.0269124415104024e+01  2.0269124415104031e+01    0.01730  1.229e-16  sky_j2000_ra
      OK       96711 -1.3269907232295576e+01 -1.3269907232295552e+01    0.00556  1.382e-16  sky_j2000_dec
      OK      321094  1.9426425943521761e+00  1.9426425943521755e+00    2.61780  1.744e-15  sky_j2000_dist
      OK      302748  3.5388201408771312e+02  3.5388201408771533e+02    0.00275  6.086e-15  sky_hor_az
      OK      121119 -2.2454039277279009e+01 -2.2454039277279151e+01    0.00556  7.895e-16  sky_hor_alt
    FAIL      462886  3.2838700693197847e-05  3.2838701021405780e-05  354.60993  1.164e-10  jm_x
    FAIL       18898  4.1298198258838197e-05  4.1298197961707834e-05  354.60993  1.054e-10  jm_y
    FAIL       18898  6.5401658638156675e-05  6.5401658496812707e-05  354.60993  5.012e-11  jm_z
    FAIL       18898 -1.9369714715980919e-04 -1.9369714599049137e-04  100.00000  1.169e-10  jm_vx
    FAIL      462886  2.0741129523130840e-04  2.0741129628185288e-04  100.00000  1.051e-10  jm_vy
    FAIL      462886 -7.0200557604537683e-05 -7.0200557103467577e-05  100.00000  5.011e-11  jm_vz

    Score = 1.169e-10
    ctest(Diff): EXCEEDED ERROR TOLERANCE.

Restored the original loop logic and now it is back within tolerance:

    First  file: temp/c_check.txt
    Second file: temp/k_check.txt
    Tolerance = 6.700e-15

                lnum                 a_value                 b_value     factor       diff  name
      OK       59558 -3.7992709399390907e-04 -3.7992709399390658e-04  411.52263  1.026e-15  helio_x
      OK       70088 -1.2672603312645981e-03 -1.2672603312646005e-03  411.52263  9.816e-16  helio_y
      OK      122819  1.0937502621531685e-04  1.0937502621531790e-04  411.52263  4.294e-16  helio_z
      OK        2427  2.0269124415104024e+01  2.0269124415104031e+01    0.01730  1.229e-16  sky_j2000_ra
      OK       96711 -1.3269907232295576e+01 -1.3269907232295552e+01    0.00556  1.382e-16  sky_j2000_dec
      OK      321094  1.9426425943521761e+00  1.9426425943521755e+00    2.61780  1.744e-15  sky_j2000_dist
      OK      302748  3.5388201408771312e+02  3.5388201408771533e+02    0.00275  6.086e-15  sky_hor_az
      OK      121119 -2.2454039277279009e+01 -2.2454039277279151e+01    0.00556  7.895e-16  sky_hor_alt
      OK       92717  4.1268347083494783e-03  4.1268347083494774e-03  223.21429  1.936e-16  jm_x
      OK       45091 -8.0149190392649894e-03 -8.0149190392649929e-03   79.42812  2.756e-16  jm_y
      OK      135377  1.5470777280065808e-03  1.5470777280065804e-03  223.21429  9.680e-17  jm_z
      OK      216836  4.5725777238332412e-03  4.5725777238332394e-03  126.58228  2.196e-16  jm_vx
      OK      351647  5.1351566793199944e-03  5.1351566793199962e-03  126.58228  2.196e-16  jm_vy
      OK      351647  2.5217607180929289e-03  2.5217607180929298e-03  126.58228  1.098e-16  jm_vz

    Score = 6.086e-15
2022-04-27 21:18:29 -04:00
Ebrahim Byagowi
7ab343e7d4 kotlin: Avoide code duplication in jupiterMoons by using map 2022-04-28 03:42:01 +04:30
Ebrahim Byagowi
474cffccac kotlin: Use sumOf where possible
As sumOf is inline in Kotlin it supposed to have the same performance.
2022-04-28 02:42:23 +04:30
Ebrahim Byagowi
6789c64343 kotlin: Use idiomatic way to create mutable objects 2022-04-28 01:57:38 +04:30
Ebrahim Byagowi
2fe4c8abf4 kotlin: Use single format instead multiple calls 2022-04-28 01:37:35 +04:30
Ebrahim Byagowi
d2485392c3 kotlin: Use getOrPut to facilitate use of cache 2022-04-28 01:19:36 +04:30
Don Cross
53f5540f09 Kotlin: cleanup of code and documentation.
Used IntelliJ IDEA's linter to perform code cleanup.
There were unused variables, `var` that could be replaced with `val`,
and other minor code style issues.

While doing this, I also discovered that a lot of documentation
links were broken. The fix is to stop intenting the text after
a `@param`.
2022-04-27 14:04:42 -04:00
Don Cross
b93719146b Set version numbers to 2.1.0.
In anticipation of releasing the Kotlin version,
I set the version numbers for the following to 2.1.0:

    Kotlin
    Node.js / npm
    Python / pip

The intention is to keep matching releases of
Astronomy Engine at a common version number.
2022-04-26 15:58:27 -04:00
Don Cross
565bac127a Kotlin docs: link to body enum values.
When documentation refers to a Body value, e.g. Body.Earth,
link to its information page. I'm not sure this is super helpful,
but it is an attempt to provide better linking.

Added more explanatory text about the SSB and EMB values.
I found that a blank line splits the extra text onto the
dedicated pages for SSB and EMB, while leaving the "brief"
description on the list of all Body enum values. That is nice.
2022-04-25 20:43:41 -04:00
Don Cross
4c34245c01 Kotlin doc cleanup: removed more 'jvm' tags.
I found that there were a bunch of lingering 'jvm'
tags in the generated markdown documentation.
Got rid of them with another change to format_kotlin_doc.py.
2022-04-25 17:16:46 -04:00
Don Cross
d130405d13 Kotlin docs: more enum cleanup.
I missed a couple of places where I want to remove
private constructor calls from enum members.
Also, discard [name] and [ordinal] links while preserving
other properties that are intentionally exposed.
2022-04-25 16:51:25 -04:00