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

Improve the free parameter info messages #284

Merged
merged 2 commits into from
Apr 9, 2024

Conversation

andlaus
Copy link
Collaborator

@andlaus andlaus commented Apr 4, 2024

With this, the parameter_info() function handles more parameter types, deals with more DOP types and handles complex DOPs (structures) properly. Also, I tried to make the results more consistent, but IMO this is not too important, because the result of this function is intended to be informal and for human consumption.

Besides this I found a fixed a small mistake in the handling of case limits in the multiplexer code.

Andreas Lauser <andreas.lauser@mercedes-benz.com>, on behalf of MBition GmbH.
Provider Information

With this the `parameter_info()` functions handles more parameter
types, deals with more DOPs type and handles complex DOPs (structures)
properly. Also, I tried to make the results more consistent, but IMO
this is not too important here, because the result of this function is
supposed to be informal and for human consumption.

Signed-off-by: Andreas Lauser <andreas.lauser@mbition.io>
Signed-off-by: Michael Hahn <michael.hahn@mbition.io>
since limits are now complex objects, they cannot directly be used for
arithmetics anymore.

Signed-off-by: Andreas Lauser <andreas.lauser@mbition.io>
Signed-off-by: Michael Hahn <michael.hahn@mbition.io>
@andlaus andlaus requested a review from kayoub5 April 4, 2024 13:54
of.write(f": int")
else:
of.write(f": <unknown type>")

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be better to move this logic to the __str__ of the physical datatype class

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I prefer to leave it here, because str(bdt) would need to include the bit sizes of the numeric types (uint32, float64, etc.) which are not really relevant here. (arguably they are even wrong in this context because most DOPs specify a smaller bit size than what the base type is capable of.)

ul_str = "inf)"
else:
ul_delim = ']' if ul.interval_type == IntervalType.CLOSED else ')'
ul_delim = ')' if ul.interval_type == IntervalType.OPEN else ']'
Copy link
Collaborator

@kayoub5 kayoub5 Apr 5, 2024

Choose a reason for hiding this comment

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

this logic is better off being in the __str__ of the class

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this does not work because limit objects on their own do not know if they are upper or lower limits...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not in the limit class, but in its container

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you mean in CompuMethod? I'd rather leave its __str__() method auto-generated by dataclass. This way it is guaranteed to be complete...

@@ -305,20 +305,20 @@ def test_free_param_info(self) -> None:
stdout = StringIO()
with patch("sys.stdout", stdout):
request.print_free_parameters_info()
expected_output = "forward_soberness_check: uint8\nnum_flips: uint8\n"
expected_output = "forward_soberness_check: uint\nnum_flips: uint\n"
Copy link
Collaborator

Choose a reason for hiding this comment

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

no size info?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

adding a size lead to quite unexpected results like float16. I think the sizes should be removed here anyway, as this function is concerned with the physical types of the parameters and in the physical space, the bit sizes of the internal representation of an object should not matter (only the valid range does).

@andlaus
Copy link
Collaborator Author

andlaus commented Apr 8, 2024

@kayoub5: Do you still see any issues that should be fixed here?

@andlaus andlaus merged commit db5a2a8 into mercedes-benz:main Apr 9, 2024
7 checks passed
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

2 participants