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

refactor!: generalize data generation interface #392

Merged
merged 33 commits into from
Jan 3, 2022

Conversation

redeboer
Copy link
Member

@redeboer redeboer commented Jan 3, 2022

Large refactoring of the data module with the aim to generalize its hit-and-miss mechanisms to general domain DataSample types.

Interface changes

  • Removed generate_data() and generate_phsp() façade functions. The new way to generate phase space and hit-and-miss data samples is:
    from tensorwaves.data import IntensityDistributionGenerator
    from tensorwaves.data.phasespace import TFPhaseSpaceGenerator
    from tensorwaves.data.rng import TFUniformRealNumberGenerator
    
    # intensity: Function
    # helicity_transformer: SympyDataTransformer
    rng = TFUniformRealNumberGenerator(seed=0)
    phsp_generator = TFPhaseSpaceGenerator(
        initial_state_mass=3.0969,
        final_state_masses={0: 0.0, 1: 0.135, 2: 0.135},
    )
    data_generator = IntensityDistributionGenerator(
        domain_generator=phsp_generator,
        domain_transformer=helicity_transformer,
        function=intensity,
    )
    phsp = phsp_generator.generate(100_000, rng)
    data = data_generator.generate(10_000, rng)
  • UniformRealNumberGenerator -> RealNumberGenerator
  • PhaseSpaceGenerator -> DataGenerator
  • PhaseSpaceGenerator.setup() has been merged into the constructor (DataGenerator.__init__()) and removed from the interface.
  • Split old TFPhaseSpaceGenerator into an unweighted TFPhaseSpaceGenerator (implements DataGenerator) and a TFWeightedPhaseSpaceGenerator (implements WeightedDataGenerator). TFPhaseSpaceGenerator can be used instead of the old generate_phsp() function.
  • Collected RNGs under a new sub-module data.rng

New features

  • New interface: DataGenerator, which does not generate weights as opposed to FourMomentumGenerator.
  • IntensityDistributionGenerator, which should be used instead of generate_data()
  • IdentityTransformer, which is just the identity implementation of a DataTransformer.
  • NumpyUniformRNG

@redeboer redeboer added 📝 Docs Improvements or additions to documentation ⚠️ Interface Breaking changes to the API labels Jan 3, 2022
@redeboer redeboer added this to the 0.4.0 milestone Jan 3, 2022
@redeboer redeboer self-assigned this Jan 3, 2022
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Hit-and-miss samples are now generated with an unweighted phsp sample, so this results in different numbers (but a same distribution)
@redeboer redeboer marked this pull request as ready for review January 3, 2022 15:22
@redeboer redeboer merged commit bc065b7 into ComPWA:main Jan 3, 2022
@redeboer redeboer deleted the generalize-data-interface branch January 3, 2022 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📝 Docs Improvements or additions to documentation ⚠️ Interface Breaking changes to the API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant