Skip to content

Commit

Permalink
Simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
dachengx committed Jul 31, 2024
1 parent ce202ca commit 6221acd
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 53 deletions.
22 changes: 9 additions & 13 deletions appletree/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,20 +579,16 @@ def lineage(self):
"bins_type": self.bins_type,
}
return {
**{
"rate_name": self.rate_name,
"norm_type": self.norm_type,
"code": self.code,
**bins_dict,
},
**{
"instances": dict(
zip(
self.instances,
[_cached_functions[self.llh_name][p].lineage for p in self.instances],
)
"rate_name": self.rate_name,
"norm_type": self.norm_type,
"code": self.code,
"instances": dict(
zip(
self.instances,
[_cached_functions[self.llh_name][p].lineage for p in self.instances],
)
},
),
**bins_dict,
}


Expand Down
4 changes: 2 additions & 2 deletions appletree/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,14 @@ def update_parameter_config(self, likelihoods):
def lineage(self):
return {
**self.instruct,
**{"par_config": self.par_config},
**{
"par_config": self.par_config,
"likelihoods": dict(
zip(
self.likelihoods.keys(),
[v.lineage for v in self.likelihoods.values()],
)
)
),
},
}

Expand Down
44 changes: 18 additions & 26 deletions appletree/likelihood.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,23 +415,19 @@ def print_likelihood_summary(self, indent: str = " " * 4, short: bool = True):
@property
def lineage(self):
return {
**{
"config": self._config,
"file_path": (
os.path.basename(self._data_file_name)
if not utils.FULL_PATH_LINEAGE
else get_file_path(self._data_file_name)
),
"sha256": calculate_sha256(get_file_path(self._data_file_name)),
},
**{
"components": dict(
zip(
self.components.keys(),
[v.lineage for v in self.components.values()],
)
"config": self._config,
"file_path": (
os.path.basename(self._data_file_name)
if not utils.FULL_PATH_LINEAGE
else get_file_path(self._data_file_name)
),
"sha256": calculate_sha256(get_file_path(self._data_file_name)),
"components": dict(
zip(
self.components.keys(),
[v.lineage for v in self.components.values()],
)
},
),
}

@property
Expand Down Expand Up @@ -591,15 +587,11 @@ def print_likelihood_summary(self, indent: str = " " * 4, short: bool = True):
@property
def lineage(self):
return {
**{
"config": self._config,
},
**{
"components": dict(
zip(
self.components.keys(),
[v.lineage_hash for v in self.components.values()],
)
"config": self._config,
"components": dict(
zip(
self.components.keys(),
[v.lineage_hash for v in self.components.values()],
)
},
),
}
20 changes: 8 additions & 12 deletions appletree/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,15 @@ def sanity_check(self):
@property
def lineage(self):
return {
**{
"depends_on": self.depends_on,
"provides": self.provides,
"parameters": self.parameters,
},
**{
"takes_config": dict(
zip(
self.takes_config.keys(),
[v.lineage for v in self.takes_config.values()],
)
"depends_on": self.depends_on,
"provides": self.provides,
"parameters": self.parameters,
"takes_config": dict(
zip(
self.takes_config.keys(),
[v.lineage for v in self.takes_config.values()],
)
},
),
}

@property
Expand Down

0 comments on commit 6221acd

Please sign in to comment.