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

WIP: Base version of Landau pdf #563

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft

Conversation

mmaehring
Copy link

@mmaehring mmaehring commented May 1, 2024

Comes with basic documentation and a skeleton for a test suite. Bug in PDF implementation.

I had some problems with installing the environments for dev. When running pip install -e . "[alldev]", it says that there is a conflict between the zfit version some required packages. I run the same commands as described in the "CONTRIBUTING.rst" file but I can add the errors I get in a comment if that would help.

Fixes #

Proposed Changes

  • I need to debug the class implementation

Tests added

Skeleton for:

  • non-nan
  • non-negativity
  • accuracy (with pylandau as reference)

Checklist

  • change approved
  • implementation finished
  • docs updated
  • correct namespace imported
  • tests added
  • CHANGELOG updated
  • (if new public method/class) docs in rst file updated?
  • (if large change) tutorial added/updated?

@mmaehring mmaehring marked this pull request as draft May 1, 2024 13:14
@mmaehring mmaehring changed the title Base version of Landau pdf WIP: Base version of Landau pdf May 1, 2024
@jonas-eschle
Copy link
Contributor

jonas-eschle commented May 1, 2024

Thanks for opening the PR, that looks like a good start and about what I had in mind, too! About the PDF, a crucial part are the "if" statements: to be able to use the jit compilation of the underlying backend, the incoming arrays are replaced by "symbolic" arrays. That means, the arrays/tensors don't have an actual value, and therefore, one cannot use Python conditional statements (is the symbolic expression "X > 5" true? Neither, it depends on the X, but as it's symbolic at the moment of jit compilation, it's neither). That means that the if statements have to be vectorized properly using where (sidenote: instead of z.exp etc, use znp.exp), such as znp.where.

EDIT: here is also a guide to help better understand what is going on with jitting, conditionals etc

There is an additional difficulty probably with the gradient, but just to keep an eye out for "where", where one of the cases creates invalid inputs (feel free to make a comment). Example would be something like znp.where(x>0, log(x), log(-x)) -> there will we NaN in the first and second array (not in the final after the where, but intermediate). Just mark if you think there can be issues.

I had some problems with installing the environments for dev. When running pip install -e . "[alldev]", it says that there is a conflict between the zfit version some required packages. I run the same commands as described in the "CONTRIBUTING.rst" file but I can add the errors I get in a comment if that would help.

yes, can you please post it here? I just tried to install it with Python 3.9 on Linux and it works, which OS are you using? And which Python version & virtualization (virtualenv, conda?)

Also, there seem to be a few conflicts, just minor, as the JohnsonSU was meanwhile added. Can you resolve them (Github interface should work) and pull again?

Besides, are you familiar with git, github, conda environments etc? If you need any help, have any questions or are just unsure if something is right, just let us know and we can assist/explain all steps.

@mmaehring
Copy link
Author

mmaehring commented May 1, 2024

Hi, good to hear that it's going in the right direction. To summarize the things you addressed:

  • Good to know about the jitting, I'll make sure to read through the tutorial for further information
  • I'll change everything to znp again
  • I am on macOS 14.4.1 and I tried building with python 3.11.9, conda 23.11.0 (build version 3.28.2). I'll try rebuilding the env with conda again in the coming days and post if anything fails
  • I resolved the merge conflicts

I have middling-to-ok amounts of experience with all the tools, but mostly on an "individualistic" level, i.e. I know how to use the tools, but only when I'm the only one working on the project. I would say I know conda, but especially with git and GitHub, my knowledge is average at best. I'll make sure to ask if something is unclear!

@jonas-eschle
Copy link
Contributor

Sounds good! For the installation, you should also be able to just install [dev] instead of [alldev], maybe that helps

@ikrommyd
Copy link
Contributor

ikrommyd commented May 6, 2024

I just went over this. It's heading towards the right direction. Apart from the if statements that should be avoided like Jonas said, it's going really well. Please include pylandau in the test requirements so your tests can be ran by the ci jobs. You can also add tests against ROOT if you'd like but add a pytest.importorskip because ROOT is not included in the ci. One example of testing against root is done here in zfit-physics.

@mmaehring
Copy link
Author

Hey everyone, a small update.
I've started porting the code to using an alternative proposed in the zfit documentation, but I have some other projects which are currently taking priority. I'll push some new changes in the coming week or two.

Regarding the testing, I'll make sure to add pylandau as a test requirement and write a basic ROOT-based test.

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.

None yet

3 participants