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

Use specific config for certain llh #78

Merged
merged 10 commits into from
Jan 25, 2023
Merged

Use specific config for certain llh #78

merged 10 commits into from
Jan 25, 2023

Conversation

dachengx
Copy link
Collaborator

@dachengx dachengx commented Jan 23, 2023

Sometimes we do need to combine two likelihoods, but they can have different maps (s). In this PR, we specify the name of llh for Map.build, so that we do not need to write many similar plugins.

Finally, we recover Rn220 & Ar37 combined fit.

Also add map_interpolator_regular_binning_1d performing 1D KNN with regular binning.

Recover Rn220 & Ar37 combine fit
self.value = _cached_configs[self.name]
value = _cached_configs[self.name]
if isinstance(value, dict):
self.value = value[llh_name]

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
WPS601 Found shadowed class attribute: value

if isinstance(value, dict):
self.value = value[llh_name]
else:
self.value = value

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
WPS601 Found shadowed class attribute: value

@@ -289,7 +291,7 @@ def flush_source_code(self,
# initialize new instances
for work in self.worksheet:
instance = work[0] + '_' + self.name
code += f'{instance} = {work[0]}()\n'
code += f"{instance} = {work[0]}('{self.llh_name}')\n"

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
WPS221 Found line with high Jones Complexity: 15 > 14

@coveralls
Copy link

coveralls commented Jan 23, 2023

Pull Request Test Coverage Report for Build 4002889673

  • 35 of 74 (47.3%) changed or added relevant lines in 6 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.06%) to 77.514%

Changes Missing Coverage Covered Lines Changed/Added Lines %
appletree/plugin.py 8 10 80.0%
appletree/component.py 13 16 81.25%
appletree/interpolation.py 3 6 50.0%
appletree/share.py 0 8 0.0%
appletree/utils.py 2 11 18.18%
appletree/config.py 9 23 39.13%
Files with Coverage Reduction New Missed Lines %
appletree/utils.py 2 36.63%
Totals Coverage Status
Change from base Build 3983747327: 0.06%
Covered Lines: 1372
Relevant Lines: 1770

💛 - Coveralls

@@ -27,8 +27,10 @@ class Plugin():
# Set using the takes_config decorator
takes_config = immutabledict()

def __init__(self):
def __init__(self, llh_name):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if this is a good idea to require llh_name in the class lower than likelihood. Maybe give some default value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is a good idea.

value = _cached_configs[self.name]
if isinstance(value, dict):
try:
self.value = value[llh_name]

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
WPS601 Found shadowed class attribute: value

if isinstance(value, dict):
try:
self.value = value[llh_name]
except:

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
B001 Do not use bare except:, it also catches unexpected events like memory errors, interrupts, system exit, and so on. Prefer except Exception:. If you're sure what you're doing, be explicit and write except BaseException:.

if isinstance(value, dict):
try:
self.value = value[llh_name]
except:

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
E722 do not use bare 'except'

if isinstance(file_path, dict):
try:
self.file_path = file_path[llh_name]
except:

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
B001 Do not use bare except:, it also catches unexpected events like memory errors, interrupts, system exit, and so on. Prefer except Exception:. If you're sure what you're doing, be explicit and write except BaseException:.

if isinstance(file_path, dict):
try:
self.file_path = file_path[llh_name]
except:

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
E722 do not use bare 'except'

Otherwise the following initialization of components will overwrite map

self.sanity_check()

# Do not set configurations as

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
W291 trailing whitespace

@@ -117,7 +122,7 @@ def get_normalization(self, hist, parameters, batch_size=None):
if self._use_mcinput:
bootstrap_name = self._plugin_class_registry['energy'].__name__
bootstrap_name = bootstrap_name + '_' + self.name
n_events_selected = _cached_functions[bootstrap_name].g4.n_events_selected
n_events_selected = _cached_functions[self.llh_name][bootstrap_name].g4.n_events_selected

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
E501 line too long (105 > 100 characters)

@@ -75,6 +75,23 @@ def curve_interpolator(pos, ref_pos, ref_val):
return val


@export
@jit
def map_interpolator_regular_binning_1d(pos, ref_pos_lowers, ref_pos_uppers, ref_val):

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
WPS114 Found underscored number name pattern: map_interpolator_regular_binning_1d

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 guess this is tolerable.

@dachengx dachengx merged commit 2fc0a8d into master Jan 25, 2023
@dachengx dachengx deleted the configs_llh branch January 25, 2023 15:54
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