Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

98 moving naming tracking into jim class from prior class #108

Merged

Conversation

kazewong
Copy link
Owner

This PR is a rework of the naming system in Jim, such that transformations between variables are more flexible and composable. Here are some of the key features of this PR:

  1. Transforms of variables are now isolated from the prior class, which are now separately contained in transforms.py. These are basically just functions one can use to transform distribution, with the capability to interface with the naming system in Jim.
  2. The prior class is now reworked. Instead of defining an entire prior, the users should be able to use connectors such as SequentialTransform and Combine to compose priors and transform them to make more complex priors. Ultimately, the base of the prior should be a logistics distribution whenever possible.
  3. Jim now carries the naming of parameters, which should signify what parameters are to be sampled.

@kazewong kazewong self-assigned this Jul 25, 2024

def __init__(
self,
name_mapping: tuple[list[str], list[str]],
Copy link
Collaborator

@ThibeauWouters ThibeauWouters Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the, let's call them "pre-made" transformations such as the masses transforms for which the transforms are already in the source code, the name_mapping argument is not needed and could be removed from the __init__ altogether. This would also avoid having to check the assertions, which could reduce the number of errors made in the code and make the code less confusing. Practically speaking, I think this would imply that name_mapping should become an optional argument of transform or we change the __init__ of the "pre-made" transformations to something like

super.__init__(name_mapping = (["m_1", "m_2"], ["M_c", "q"]))
self.transform_func = ...

although that is in conflict with the signature of the init function...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ThibeauWouters Sorry for the late reply. I also thought of the implementation you mentioned. Maybe we can discuss this in the Monday call and see which implementation people like more. I think the benefit of the current implementation is that user can keep track of the naming when they are setting the sample_transforms.

sample_transforms = [
    ComponentMassesToChirpMassMassRatioTransform(name_mapping=[["m_1", "m_2"], ["M_c", "q"]]),
    BoundToUnbound(name_mapping = [["M_c"], ["M_c_unbounded"]], original_lower_bound=M_c_min, original_upper_bound=M_c_max),
    BoundToUnbound(name_mapping = [["q"], ["q_unbounded"]], original_lower_bound=q_min, original_upper_bound=q_max),
    ...

Users can see that m_1 and m_2 are transformed to M_c_unbounded and q_unbounded in this case.

I also thought of another way that is to make __init__ taking four arguments, each specifying a name. Users can keep the freedom to set any name in that case.

def __init__(m1_name, m2_name, Mc_name, q_name):
    ...

@kazewong kazewong merged commit d2c0416 into jim-dev Sep 2, 2024
4 of 6 checks passed
@kazewong kazewong deleted the 98-moving-naming-tracking-into-jim-class-from-prior-class branch October 16, 2024 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants