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

Define context to fit based on different datasets #14

Merged
merged 4 commits into from
Oct 2, 2022
Merged

Conversation

dachengx
Copy link
Collaborator

@dachengx dachengx commented Oct 2, 2022

No description provided.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

pep8

appletree/context.py|73 col 1| D102 Missing docstring in public method
appletree/context.py|73 col 27| W291 trailing whitespace
appletree/context.py|74 col 38| W291 trailing whitespace
appletree/context.py|75 col 37| W291 trailing whitespace
appletree/context.py|76 col 33| B008 Do not perform function calls in argument defaults. The call is performed only once at function definition time. All calls to your function will reuse the result of that definition-time function call. If this is intended, assign the function call to a module-level variable and use that variable as a default value.
appletree/context.py|76 col 33| WPS404 Found complex default value
appletree/context.py|76 col 42| W291 trailing whitespace
appletree/context.py|81 col 23| WPS219 Found too deep access level: 5 > 4
appletree/context.py|82 col 17| W291 trailing whitespace
appletree/context.py|88 col 1| D200 One-line docstring should fit on one line with quotes
appletree/context.py|88 col 1| D204 1 blank line required after class docstring
appletree/context.py|91 col 1| D107 Missing docstring in init
appletree/context.py|99 col 21| C408 Unnecessary dict call - rewrite as a literal.
appletree/context.py|101 col 26| W291 trailing whitespace
appletree/context.py|102 col 85| C812 missing trailing comma
appletree/context.py|103 col 15| W291 trailing whitespace
appletree/context.py|112 col 21| C408 Unnecessary dict call - rewrite as a literal.
appletree/context.py|114 col 26| W291 trailing whitespace
appletree/context.py|115 col 100| C812 missing trailing comma
appletree/context.py|116 col 15| W291 trailing whitespace
appletree/context.py|125 col 46| F405 'AC' may be undefined, or defined from star imports: appletree.components
appletree/context.py|126 col 46| F405 'ERBand' may be undefined, or defined from star imports: appletree.components
appletree/context.py|127 col 45| F405 'ERPeak' may be undefined, or defined from star imports: appletree.components
appletree/init.py|33 col 1| F401 '.context' imported but unused
appletree/init.py|34 col 1| F401 '.context.*' imported but unused
appletree/init.py|34 col 1| WPS347 Found vague import that may cause confusion: *
appletree/init.py|34 col 1| WPS458 Found imports collision: context
appletree/plugins/common.py|14 col 1| D101 Missing docstring in public class
appletree/plugins/common.py|31 col 1| D101 Missing docstring in public class
appletree/plugins/common.py|35 col 1| D107 Missing docstring in init
appletree/plugins/common.py|35 col 35| E231 missing whitespace after ':'
appletree/plugins/common.py|35 col 41| E252 missing whitespace around parameter equals
appletree/plugins/common.py|35 col 42| E252 missing whitespace around parameter equals
appletree/plugins/common.py|41 col 1| D102 Missing docstring in public method
appletree/components/er.py|2 col 1| WPS458 Found imports collision: appletree.plugins
appletree/components/er.py|2 col 1| WPS458 Found imports collision: appletree.plugins
appletree/components/er.py|10 col 1| D107 Missing docstring in init
appletree/components/er.py|17 col 1| D101 Missing docstring in public class

@@ -49,11 +48,16 @@ def __init__(self, **config):
def sanity_check(self):
assert len(self.bins_on) == len(self.bins), 'Length of bins must be the same as length of bins_on!'

def register_component(self, component_cls, component_name):
def register_component(self,
Copy link

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method

@@ -49,11 +48,16 @@ def __init__(self, **config):
def sanity_check(self):
assert len(self.bins_on) == len(self.bins), 'Length of bins must be the same as length of bins_on!'

def register_component(self, component_cls, component_name):
def register_component(self,
Copy link

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

@@ -49,11 +48,16 @@ def __init__(self, **config):
def sanity_check(self):
assert len(self.bins_on) == len(self.bins), 'Length of bins must be the same as length of bins_on!'

def register_component(self, component_cls, component_name):
def register_component(self,
component_cls,
Copy link

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

def register_component(self, component_cls, component_name):
def register_component(self,
component_cls,
component_name,
Copy link

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

@@ -38,6 +39,12 @@ def load_data(file_name:str):
raise ValueError(f'unsupported file format {fmt}!')
return data

@export
Copy link

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
E302 expected 2 blank lines, found 1

likelihood.print_likelihood_summary(short=short)
print('\n'+'='*80)

def log_posterior(self, pars, batch_size=int(1e6)):
Copy link

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
WPS404 Found complex default value

key = randgen.get_key()
log_posterior = 0
for likelihood in self.likelihoods.values():
key, log_likelihood_i = likelihood.get_log_likelihood(key, batch_size, self.par_manager.get_all_parameter())
Copy link

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 (120 > 100 characters)


return log_posterior

def fitting(self, nwalkers=200, steps=500):
Copy link

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method


_ = self.sampler.run_mcmc(p0, steps, progress=True)

def get_post_parameters(self):
Copy link

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method


def get_post_parameters(self):
# TODO: how many iteration is burning
self.par_manager.set_parameter_fit_from_array(self.sampler.get_chain()[-1].mean(axis=0))
Copy link

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: 16 > 14

Add manual continue fitting between different context
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

pep8

appletree/context.py|140 col 15| W291 trailing whitespace
appletree/context.py|148 col 46| F405 'ERBand' may be undefined, or defined from star imports: appletree.components
appletree/context.py|149 col 46| F405 'AC' may be undefined, or defined from star imports: appletree.components
appletree/context.py|153 col 1| D200 One-line docstring should fit on one line with quotes
appletree/context.py|153 col 1| D204 1 blank line required after class docstring
appletree/context.py|156 col 1| D107 Missing docstring in init
appletree/context.py|156 col 5| WPS213 Found too many expressions: 11 > 9
appletree/context.py|166 col 21| C408 Unnecessary dict call - rewrite as a literal.
appletree/context.py|168 col 26| W291 trailing whitespace
appletree/context.py|169 col 85| C812 missing trailing comma
appletree/context.py|170 col 15| W291 trailing whitespace
appletree/context.py|178 col 46| F405 'ERBand' may be undefined, or defined from star imports: appletree.components
appletree/context.py|179 col 46| F405 'AC' may be undefined, or defined from star imports: appletree.components
appletree/context.py|181 col 21| C408 Unnecessary dict call - rewrite as a literal.
appletree/context.py|183 col 26| W291 trailing whitespace
appletree/context.py|184 col 100| C812 missing trailing comma
appletree/context.py|185 col 15| W291 trailing whitespace
appletree/context.py|193 col 45| F405 'ERPeak' may be undefined, or defined from star imports: appletree.components
appletree/init.py|33 col 1| F401 '.context' imported but unused
appletree/init.py|34 col 1| F401 '.context.*' imported but unused
appletree/init.py|34 col 1| WPS347 Found vague import that may cause confusion: *
appletree/init.py|34 col 1| WPS458 Found imports collision: context
appletree/component.py|31 col 13| WPS221 Found line with high Jones Complexity: 15 > 14
appletree/parameter.py|8 col 1| D101 Missing docstring in public class
appletree/parameter.py|8 col 1| WPS214 Found too many methods: 12 > 7
appletree/plugins/common.py|4 col 1| WPS301 Found dotted raw import: jax.numpy
appletree/plugins/common.py|14 col 1| D101 Missing docstring in public class
appletree/plugins/common.py|31 col 1| D101 Missing docstring in public class
appletree/plugins/common.py|36 col 1| D107 Missing docstring in init
appletree/plugins/common.py|36 col 35| E231 missing whitespace after ':'
appletree/plugins/common.py|36 col 41| E252 missing whitespace around parameter equals
appletree/plugins/common.py|36 col 42| E252 missing whitespace around parameter equals
appletree/plugins/common.py|42 col 1| D102 Missing docstring in public method
appletree/components/er.py|2 col 1| WPS458 Found imports collision: appletree.plugins
appletree/components/er.py|2 col 1| WPS458 Found imports collision: appletree.plugins
appletree/components/er.py|10 col 1| D107 Missing docstring in init
appletree/components/er.py|17 col 1| D101 Missing docstring in public class

import numpy as np
import jax.numpy as jnp
Copy link

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
WPS301 Found dotted raw import: jax.numpy


class Likelihood:
Copy link

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
D101 Missing docstring in public class


class Likelihood:
Copy link

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
WPS230 Found too many public instance attributes: 10 > 6

@@ -46,14 +52,22 @@ def __init__(self, **config):
weights=jnp.ones(len(self.data))
)

def __getitem__(self, keys):
Copy link

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
D105 Missing docstring in magic method

from appletree.components import *


class Context():
Copy link

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
WPS214 Found too many methods: 11 > 7



class ContextRn220(Context):
"""
Copy link

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
D204 1 blank line required after class docstring

"""
A specified context for ER response by Rn220 fit
"""
def __init__(self):
Copy link

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
D107 Missing docstring in init

par_config.pop('er_rate')
super().__init__(par_config)

rn_config = dict(
Copy link

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
C408 Unnecessary dict call - rewrite as a literal.


rn_config = dict(
data_file_name = os.path.join(
DATAPATH,
Copy link

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

rn_config = dict(
data_file_name = os.path.join(
DATAPATH,
'data_XENONnT_Rn220_v8_strax_v1.2.2_straxen_v1.7.1_cutax_v1.9.0.csv'
Copy link

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
C812 missing trailing comma

@dachengx dachengx merged commit bc5bad0 into master Oct 2, 2022
@dachengx dachengx mentioned this pull request Oct 2, 2022
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.

1 participant