tardis icon indicating copy to clipboard operation
tardis copied to clipboard

made the timo_0 in decay framework required

Open Soumya624 opened this issue 2 years ago • 16 comments

:pencil: Description

Type: :beetle: bugfix | :rocket: feature

Changed the current init method in line 11 of "\tardis\io\decay.py" file, to resolve the issue. Here is a snippet of the modified version of the init method that includes a check to ensure that the time_0 parameter is specified by the user:

Screenshot 2022-12-29 011009

This modified version first checks if the time_0 parameter is included in the kwargs dictionary. If it is not, it raises a ValueError to inform the user that the time_0 parameter must be specified. If the time_0 parameter is present, it is extracted from the kwargs dictionary and assigned to the time_0 variable. The time_0 key is then removed from the kwargs dictionary before calling the parent class's init method. Finally, the value of time_0 is assigned to the time_0 attribute of the IsotopeAbundance instance.

Also, link issues affected by this pull request by using the keywords: close, closes, closed, fix, fixes, fixed, resolve, resolves or resolved.

:pushpin: Resources

Examples, notebooks and links to useful references.

:vertical_traffic_light: Testing

How did you test these changes?

  • [ ] Testing Locally

Screenshot 2022-12-29 012543

:ballot_box_with_check: Checklist

  • [ ] I requested two reviewers for this pull request
  • [ ] I updated the documentation according to my changes
  • [ ] I built the documentation by applying the build_docs label

Note: If you are not allowed to perform any of these actions, ping (@) a contributor.

Soumya624 avatar Dec 29 '22 07:12 Soumya624

*beep* *bop*

Hi, human.

I'm the @tardis-bot and couldn't find your records in my database. I think we don't know each other, or you changed your credentials recently.

Please add your name and email to .mailmap in your current branch and push the changes to this pull request.

In case you need to map an existing alias, follow this example.

tardis-bot avatar Dec 29 '22 07:12 tardis-bot

This seems to break the tests.

Rodot- avatar Feb 01 '23 16:02 Rodot-

This seems to break the tests.

The tests probably assume that the "default value" is set to 0, as it was in previously. @Soumya624 , can you look into that?

sonachitchyan avatar Feb 01 '23 16:02 sonachitchyan

Yeah sure!

Soumya624 avatar Feb 11 '23 22:02 Soumya624

@Soumya624 do you plan to address the currently failing checks soon?

andrewfullard avatar Feb 20 '23 15:02 andrewfullard

@Soumya624 Are you still working on resolving this? If not, please let me know if I can take it forward from here.

AyushiDaksh avatar Feb 27 '23 11:02 AyushiDaksh

The tests probably assume that the "default value" is set to 0, as it was in previously

@andrewfullard I was going through the entire repository and i found that any test cases that create an instance of the IsotopeAbundance class without explicitly specifying the time_0 parameter are likely to fail.

So, I searched the test cases and found that if we can modify 'tardis/io/tests/test_decay.py' and 'tardis/model/tests/test_base.py', then we can omit these.

To modify the simple_abundance_model() fixture in tardis/io/tests/test_decay.py to avoid the failure due to the time_0 parameter not being specified, we can add an explicit time_0 parameter with a default value of 0 to the function definition and pass this default value to the constructor of IsotopeAbundances.

@pytest.fixture
def simple_abundance_model(time_0=0):
    index = pd.MultiIndex.from_tuples(
        [(28, 56)], names=["atomic_number", "mass_number"]
    )
    return IsotopeAbundances([[1.0, 1.0]], index=index, time_0=time_0)

And to modify the simple_isotope_abundance() function in tardis/model/tests/test_base.py, we can add a similar explicit time_0 parameter with a default value of 0 to the function definition and pass this default value to the constructor of IsotopeAbundances.

def simple_isotope_abundance(time_0=0):
    index = pd.MultiIndex.from_tuples(
        [(6, 14), (12, 28)], names=["atomic_number", "mass_number"]
    )
    abundance = [[0.2] * 20] * 2
    return IsotopeAbundances(abundance, index=index, time_0=time_0)

Please let me know if this approach is correct. I will made the PR!

Soumya624 avatar Feb 28 '23 19:02 Soumya624

@Soumya624 Are you still working on resolving this? If not, please let me know if I can take it forward from here.

@AyushiDaksh Yeah i'm about to make a PR. With the necessary changes in the test cases!

Soumya624 avatar Feb 28 '23 19:02 Soumya624

Sorry for the late response. I think your solution is sensible, please commit it to this PR.

andrewfullard avatar Mar 15 '23 14:03 andrewfullard

@Soumya624 Are you still working on this?

@andrewfullard If @Soumya624 is not actively working on this, then I'll take this up. In that case, would I have to make a new PR or append my changes to this PR?

AyushiDaksh avatar Mar 27 '23 05:03 AyushiDaksh

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Hi @andrewfullard, Please have a look at this now. Updated the changes!

Thanks

Soumya624 avatar Mar 27 '23 06:03 Soumya624

@Soumya624 Are you still working on this? Yeah. think rn it's passing the tests. Thanks for reminding!

Soumya624 avatar Mar 27 '23 07:03 Soumya624

Please resolve the merge conflict

andrewfullard avatar Mar 27 '23 16:03 andrewfullard

Hi @andrewfullard ,

Thanks for your review regarding the variable name. Please have a look at this now!

Soumya624 avatar Apr 10 '23 17:04 Soumya624

@wkerzendorf do we want to require "time_0" now that we are changing how the model is set up?

andrewfullard avatar Aug 18 '23 13:08 andrewfullard

Closing this in favour of later configuration restructure

andrewfullard avatar Apr 12 '24 14:04 andrewfullard