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

Upgrade config #824

Merged
merged 10 commits into from
May 19, 2023
Merged

Upgrade config #824

merged 10 commits into from
May 19, 2023

Conversation

gonzaponte
Copy link
Collaborator

@gonzaponte gonzaponte commented Jul 18, 2022

This PR forces every city to be fully-annotate its input arguments. Hopefully, this will help new users to understand what parameters they need to provide to a city and slightly improve the self-documentation of the cities.
The types of input arguments are checked before running the city. Inner functions can also be fully-annotated and type-checked by using the provided decorator, check_annotations.

@gonzaponte gonzaponte force-pushed the upgrade-config branch 2 times, most recently from 5054001 to 359bb37 Compare August 24, 2022 10:13
@gonzaponte gonzaponte marked this pull request as ready for review August 24, 2022 10:33
@gonzaponte gonzaponte changed the title [Draft] Upgrade config Upgrade config Aug 24, 2022
Copy link
Collaborator

@jacg jacg left a comment

Choose a reason for hiding this comment

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

Improves automatic verification of cities' parameters, resulting in better, enforced documentation and checking of configurations. An important step forward in long-term usability and mainainability of the code.

NB: this sits on top of #816, which needs merging first. #816 has already been approved.

@@ -401,3 +416,240 @@ def test_configure_numpy(config_tmpdir):
conf_ns = configure(argv).as_namespace
assert hasattr(conf_ns, "a_numpy_array")
assert conf_ns.a_numpy_array.tolist() == [0, 0.5, 1]


@mark.parametrize( "value type".split()
Copy link
Collaborator

Choose a reason for hiding this comment

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

While these tests are important, let's just take a few seconds to observe that we have over 100 lines of boilerplate that we get for free in a (strong! C++ doesn't cut the mustard) static type system!

Comment on lines +75 to +81
diffusion : Optional[Tuple[float, float, float]]=(1., 1., 0.3),
energy_type : Optional[HitEnergy]=HitEnergy.Ec,
deconv_mode : Optional[DeconvolutionMode]=DeconvolutionMode.joint,
n_dim : Optional[int]=2,
cut_type : Optional[CutType]=CutType.abs,
inter_method : Optional[InterpolationMethod]=InterpolationMethod.cubic,
n_iterations_g : Optional[int]=0):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor point: this does not conform to the IC alignment style. There are a few more instances of this in the code.

Comment on lines +75 to +83
, s1_nmin : int, s1_nmax : int
, s1_emin : float, s1_emax : float
, s1_wmin : float, s1_wmax : float
, s1_hmin : float, s1_hmax : float
, s1_ethr : float
, s2_nmin : int, s2_nmax : int
, s2_emin : float, s2_emax : float
, s2_wmin : float, s2_wmax : float
, s2_hmin : float, s2_hmax : float
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find the spatial proximity of the type of the earlier parameter to the name of the next parameter, a bit confusing to read. That is to say, in something like

, s1_nmin          : float, s1_emax          :float

the natural inclination is to see the float, s1_emax as belonging together.

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'm planning a PR applying a more uniform style everywhere, all these cosmetic changes will fit in there naturally.

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