Skip to content

Commit

Permalink
Merge pull request #48 from Transport-for-the-North/calibrate-results…
Browse files Browse the repository at this point in the history
…-summary-fix

Calibrate results summary fix
  • Loading branch information
MattBuckley-TfN authored Nov 7, 2024
2 parents b53ca8a + 4d5c7c1 commit e407015
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/caf/distribute/gravity_model/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def plot_distributions(self, truncate_last_bin: bool = False) -> figure.Figure:
fig, ax = plt.subplots(figsize=(10, 6))

errors = []
for attr in ("max_vals", "min_vals", "avg_vals"):
for attr in ("max_vals", "min_vals"):
if set(getattr(self.cost_distribution, attr)) != set(
getattr(self.target_cost_distribution, attr)
):
Expand All @@ -134,7 +134,7 @@ def plot_distributions(self, truncate_last_bin: bool = False) -> figure.Figure:

max_bin_edge = self.cost_distribution.max_vals
min_bin_edge = self.cost_distribution.min_vals
bin_centres = self.cost_distribution.avg_vals
bin_centres = (max_bin_edge + min_bin_edge) / 2

ax.bar(
bin_centres,
Expand Down Expand Up @@ -177,6 +177,10 @@ def summary(self) -> pd.Series:
a summary of the calibration
"""

output_params = self.cost_params.copy()
output_params["convergence"] = self.cost_convergence
return pd.Series(output_params)


@dataclasses.dataclass
class GravityModelRunResults(GravityModelResults):
Expand Down
2 changes: 1 addition & 1 deletion src/caf/distribute/gravity_model/multi_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def from_pandas(
cat_tld = tld[tld[tld_cat_col] == category]

cat_cost_distribution = cost_utils.CostDistribution(
cat_tld, tld_min_col, tld_max_col, tld_avg_col, tld_trips_col, tld_avg_col
cat_tld, tld_min_col, tld_max_col, tld_avg_col, tld_trips_col
)

return cls(category, cat_cost_distribution, cat_zone_indices, func_params)
Expand Down

0 comments on commit e407015

Please sign in to comment.