HajimeKawahara / exojax

🐈 Automatic differentiable spectrum modeling of exoplanets/brown dwarfs using JAX, compatible with NumPyro and JAXopt
http://secondearths.sakura.ne.jp/exojax/
MIT License
45 stars 14 forks source link

No change mdb (Exomol, HITRAN, Hitemp) from opa #515

Closed HajimeKawahara closed 1 month ago

HajimeKawahara commented 1 month ago

address the side effect raised in #510

The following is a simple test of the side effect:

tests/unittest/opa/sideeffect_test.py

def test_sideeffect_call():
    nus, wav, res = wavenumber_grid(
        22920.0, 23100.0, 20000, unit="AA", xsmode="premodit"
    )
    mdb = mock_mdbHitemp(multi_isotope=True)
    opa1 = OpaPremodit(mdb, nu_grid=nus, allow_32bit=True, auto_trange=[500.0, 1000])
    opa1_orig = copy.deepcopy(opa1)
    opa2 = OpaPremodit(
        mdb, nu_grid=nus, allow_32bit=True, auto_trange=[500.0, 1200]
    )  # used the same mdb used in opa1
    print(opa1 == opa1_orig) -> True 

Before this PR (i.e. recent develop branch), opa1 == opa1_orig gives False. This means the second call of OpaPremodit using the same mdb changes opa1.mdb. In this PR, based on the strategy described in #510, we avoid the side effect, i.e. opa does not change the internal state of mdb.

but, we need some modifications:

github-actions[bot] commented 1 month ago

Unit Test Results

177 tests  Β±0   177 :heavy_check_mark: Β±0   40s :stopwatch: Β±0s βŸβ€„βŸβ€„1 suites Β±0β€‚β€ƒβ€ƒβŸβ€„βŸβ€„0 :zzz: Β±0  βŸβ€„βŸβ€„1 files   Β±0β€‚β€ƒβ€ƒβŸβ€„βŸβ€„0 :x: Β±0 

Results for commit 04fb330d. ± Comparison against base commit d13bd3ce.

:recycle: This comment has been updated with latest results.