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

fix: remove spaces in adjacency matrix expression #472

Merged
merged 1 commit into from
Feb 9, 2023

Conversation

wdconinc
Copy link
Contributor

@wdconinc wdconinc commented Feb 9, 2023

Briefly, what does this PR introduce?

When there are spaces in the adjacency matrix string expression's default value, JANA2 chops at the first space. This results in many warnings, i.e. https://github.com/eic/EICrecon/actions/runs/4121127389/jobs/7116665443.

The issue seems to be in the SetDefaultParameter call, since modifying u_adjacencyMatrix in the algorithm didn't have any impact. At that point the string has already been chopped.

What kind of change does this PR introduce?

  • Bug fix (issue #__)
  • New feature (issue #__)
  • Documentation update
  • Other: __

Please check if this PR fulfills the following:

  • Tests for the changes have been added
  • Documentation has been added / updated
  • Changes have been communicated to collaborators

Does this PR introduce breaking changes? What changes might users need to make to their code?

No.

Does this PR change default behavior?

No.

@wdconinc wdconinc requested a review from veprbl February 9, 2023 03:26
@wdconinc
Copy link
Contributor Author

wdconinc commented Feb 9, 2023

@faustus123 @nathanwbrei I am very surprised that JANA2 changes default values set in the C++ in a SetDefaultParameter call. Can't we even trust default values anymore?

[2023-02-08 21:29:43.387] [EcalBarrelSciGlassProtoClusters] [error] (abs(tower_1 - tower_2) + (abs((sector_1 - sector_2) * 5 + row_1 - row_2) == 1) + (abs((sector_1 - sector_2) * 5 + row_1 - row_2) == (24 * 5 - 1))) == 1
[WARN] Parameter 'BEMC:EcalBarrelSciGlassProtoClusters:adjacencyMatrix' loses equality with itself after stringification
[2023-02-08 21:29:43.387] [EcalBarrelSciGlassProtoClusters] [error] (abs(tower_1

@faustus123
Copy link
Contributor

@faustus123 @nathanwbrei I am very surprised that JANA2 changes default values set in the C++ in a SetDefaultParameter call. Can't we even trust default values anymore?

Ha! You're right. This is a bug where we need to handle strings differently than other data types. Spaces in strings are not being handled properly.

The issue is due to parameters being passed through std::stringstream to convert them into string form first and then back into the native type of the parameter (e.g. double). This is actually done on purpose so one can run a process using default values from the C++ code and have it dump the full configuration to a file. That configuration file should then be able to reproduce the job exactly. If there are round-off errors in the stringification, those will need to be included in the original run.

We will need to add a template specialization for strings types that skips the conversion using std::stringstream. We'll take care of that on the JANA2 end.

@wdconinc
Copy link
Contributor Author

wdconinc commented Feb 9, 2023

@wdconinc wdconinc enabled auto-merge February 9, 2023 15:42
Copy link
Contributor

@faustus123 faustus123 left a comment

Choose a reason for hiding this comment

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

This looks like a reasonable and simple workaround.

@AyanRoy16
Copy link

Hello @wdconinc ,
We have added a test case for JParameter to show that a c++ command that is parsed as a string remains the same after it is parsed, the white spaces are correctly parsed. Let me know if we are missing out on something.
PR: JeffersonLab/JANA2#248
cc. @faustus123 @nathanwbrei

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.

3 participants