samuelrince commited on
Commit
636212b
1 Parent(s): db0320d

fix: display magnitude to remove dimensionless

Browse files
Files changed (2) hide show
  1. app.py +3 -3
  2. src/utils.py +3 -3
app.py CHANGED
@@ -239,21 +239,21 @@ with gr.Blocks(css=custom_css) as demo:
239
  name = "Wind turbines"
240
  with gr.Column(scale=1, min_width=300):
241
  gr.Markdown(f"""
242
- <h2 align="center">{emoji} $$ \Large {count:.0f} $$ {name} <span style="font-size: 12px">(yearly)</span></h2>
243
  <p align="center"><i>Based on electricity consumption<i></p><br>
244
  """, latex_delimiters=[{"left": "$$", "right": "$$", "display": False}])
245
 
246
  ireland_count = format_energy_eq_electricity_consumption_ireland(impacts.energy)
247
  with gr.Column(scale=1, min_width=300):
248
  gr.Markdown(f"""
249
- <h2 align="center">🇮🇪 $$ \Large {ireland_count:.2g} $$ x Ireland <span style="font-size: 12px">(yearly ⚡️ cons.)</span></h2>
250
  <p align="center"><i>Based on electricity consumption<i></p><br>
251
  """, latex_delimiters=[{"left": "$$", "right": "$$", "display": False}])
252
 
253
  paris_nyc_airplane = format_gwp_eq_airplane_paris_nyc(impacts.gwp)
254
  with gr.Column(scale=1, min_width=300):
255
  gr.Markdown(f"""
256
- <h2 align="center">✈️ $$ \Large {paris_nyc_airplane:,.0f} $$ Paris ↔ NYC </h2>
257
  <p align="center"><i>Based on GHG emissions<i></p><br>
258
  """, latex_delimiters=[{"left": "$$", "right": "$$", "display": False}])
259
 
 
239
  name = "Wind turbines"
240
  with gr.Column(scale=1, min_width=300):
241
  gr.Markdown(f"""
242
+ <h2 align="center">{emoji} $$ \Large {count.magnitude:.0f} $$ {name} <span style="font-size: 12px">(yearly)</span></h2>
243
  <p align="center"><i>Based on electricity consumption<i></p><br>
244
  """, latex_delimiters=[{"left": "$$", "right": "$$", "display": False}])
245
 
246
  ireland_count = format_energy_eq_electricity_consumption_ireland(impacts.energy)
247
  with gr.Column(scale=1, min_width=300):
248
  gr.Markdown(f"""
249
+ <h2 align="center">🇮🇪 $$ \Large {ireland_count.magnitude:.2g} $$ x Ireland <span style="font-size: 12px">(yearly ⚡️ cons.)</span></h2>
250
  <p align="center"><i>Based on electricity consumption<i></p><br>
251
  """, latex_delimiters=[{"left": "$$", "right": "$$", "display": False}])
252
 
253
  paris_nyc_airplane = format_gwp_eq_airplane_paris_nyc(impacts.gwp)
254
  with gr.Column(scale=1, min_width=300):
255
  gr.Markdown(f"""
256
+ <h2 align="center">✈️ $$ \Large {paris_nyc_airplane.magnitude:,.0f} $$ Paris ↔ NYC </h2>
257
  <p align="center"><i>Based on GHG emissions<i></p><br>
258
  """, latex_delimiters=[{"left": "$$", "right": "$$", "display": False}])
259
 
src/utils.py CHANGED
@@ -148,7 +148,7 @@ def format_gwp_eq_streaming(gwp: Quantity) -> Quantity:
148
  return streaming_eq
149
 
150
 
151
- def format_energy_eq_electricity_production(energy: Quantity) -> tuple[EnergyProduction, float]:
152
  electricity_eq = energy * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
153
  electricity_eq = electricity_eq.to("TWh")
154
  if electricity_eq > YEARLY_NUCLEAR_ENERGY_EQ:
@@ -157,13 +157,13 @@ def format_energy_eq_electricity_production(energy: Quantity) -> tuple[EnergyPro
157
  return EnergyProduction.WIND, electricity_eq / YEARLY_WIND_ENERGY_EQ
158
 
159
 
160
- def format_energy_eq_electricity_consumption_ireland(energy: Quantity) -> float:
161
  electricity_eq = energy * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
162
  electricity_eq = electricity_eq.to("TWh")
163
  return electricity_eq / YEARLY_IRELAND_ELECTRICITY_CONSUMPTION
164
 
165
 
166
- def format_gwp_eq_airplane_paris_nyc(gwp: Quantity) -> float:
167
  gwp_eq = gwp * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
168
  gwp_eq = gwp_eq.to("kgCO2eq")
169
  return gwp_eq / AIRPLANE_PARIS_NYC_GWP_EQ
 
148
  return streaming_eq
149
 
150
 
151
+ def format_energy_eq_electricity_production(energy: Quantity) -> tuple[EnergyProduction, Quantity]:
152
  electricity_eq = energy * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
153
  electricity_eq = electricity_eq.to("TWh")
154
  if electricity_eq > YEARLY_NUCLEAR_ENERGY_EQ:
 
157
  return EnergyProduction.WIND, electricity_eq / YEARLY_WIND_ENERGY_EQ
158
 
159
 
160
+ def format_energy_eq_electricity_consumption_ireland(energy: Quantity) -> Quantity:
161
  electricity_eq = energy * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
162
  electricity_eq = electricity_eq.to("TWh")
163
  return electricity_eq / YEARLY_IRELAND_ELECTRICITY_CONSUMPTION
164
 
165
 
166
+ def format_gwp_eq_airplane_paris_nyc(gwp: Quantity) -> Quantity:
167
  gwp_eq = gwp * ONE_PERCENT_WORLD_POPULATION * DAYS_IN_YEAR
168
  gwp_eq = gwp_eq.to("kgCO2eq")
169
  return gwp_eq / AIRPLANE_PARIS_NYC_GWP_EQ