amusecode / amuse

Astrophysical Multipurpose Software Environment. This is the main repository for AMUSE
http://www.amusecode.org
Apache License 2.0
154 stars 98 forks source link

Tests fail: cannot set value of a DerivedAttribute #957

Closed rieder closed 1 year ago

rieder commented 1 year ago

After merging #947, tests fail with cannot set value of a DerivedAttribute:

=========================== short test summary info ============================
[209](https://github.com/amusecode/amuse/actions/runs/4958183044/jobs/8870747119?pr=956#step:17:210)
FAILED src/amuse/test/suite/codes_tests/test_sse.py::TestSSE::test18 - amuse.support.exceptions.AmuseException: cannot set value of a DerivedAttribute
[210](https://github.com/amusecode/amuse/actions/runs/4958183044/jobs/8870747119?pr=956#step:17:211)
================== 1 failed, 26 passed, 2 warnings in 15.00s ===================

Need to fix the tests to account for this.

rieder commented 1 year ago

The relevant lines are:

        evolved_star = instance.particles.copy()[0]
        evolved_star.temperature = instance.particles[0].temperature

So this should not result in an error - evolved_star.temperature should not be a DerivedAttribute.

rieder commented 1 year ago

Ah but it is - it seems the copy of the SSE star now works exactly like a Particle of SSE instead of a standard AMUSE particle with all attributes of the SSE star copied to it as before. So the solution is to remove the second line above.

It's unexpected that printing the copied evolved_star doesn't show the temperature property, though it is still available with print(evolved_star.particle):

> print(evolved_star)
Particle(13167421731397204142, set=<4694462320>
    , CO_core_mass=0.566294538385 MSun
    , age=7000.0 Myr
    , convective_envelope_mass=1e-10 MSun
    , convective_envelope_radius=1e-10 RSun
    , core_mass=0.566294538385 MSun
    , core_radius=0.0132436589837 RSun
    , end_time=7000.0 Myr
    , epoch=3727.22312388 Myr
    , initial_mass=0.566294538385 1.98892e+30 * kg
    , luminosity=9.59615023773e-05 LSun
    , main_sequence_lifetime=10000000000.0 Myr
    , mass=0.566294538385 MSun
    , radius=0.0132436589837 RSun
    , spin=4.79426850652e-06 yr**-1
    , stellar_type=Carbon/Oxygen White Dwarf)
> print(evolved_star.temperature)
4968.44327548 K