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

fix(textile): distribution step had no inland road transports added. #761

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ jobs:
uses: actions/cache@v4
with:
path: ~/.local/share/virtualenvs
key: ${{ runner.os }}-${{ matrix.python-version }}-pipenv-${{ hashFiles('Pipfile.lock') }}
restore-keys: |
${{ runner.os }}-pipenv-
key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-pipenv-${{ hashFiles('Pipfile.lock') }}

- name: Install Node dependencies
run: npm ci --prefer-offline --no-audit
Expand Down
14 changes: 5 additions & 9 deletions src/Data/Textile/Step.elm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import Data.Transport as Transport exposing (Transport)
import Data.Unit as Unit
import Energy exposing (Energy)
import Json.Encode as Encode
import Length
import Mass exposing (Mass)
import Quantity
import Static.Db exposing (Db)
Expand Down Expand Up @@ -221,15 +222,14 @@ computeTransportImpacts impacts { airTransport, seaTransport } roadProcess mass
computeTransportSummary : Step -> Transport -> Transport
computeTransportSummary step transport =
let
( noTransports, defaultInland ) =
( Transport.default step.transport.impacts
, Transport.default step.transport.impacts
)
noTransports =
Transport.default step.transport.impacts
in
case step.label of
Label.Distribution ->
-- Product Distribution leverages no transports
-- Add default road transport to materialize transport to/from a warehouse
noTransports
|> Transport.add { noTransports | road = Length.kilometers 500 }

Label.EndOfLife ->
-- End of life leverages no transports
Expand All @@ -239,10 +239,6 @@ computeTransportSummary step transport =
-- Air transport only applies between the Making and the Distribution steps
transport
|> Formula.transportRatio step.airTransportRatio
-- Added intermediary inland transport distances to materialize
-- transport to the "distribution" step
-- Also ensure we don't add unnecessary air transport
|> Transport.add { defaultInland | air = Quantity.zero }

Label.Use ->
-- Product Use leverages no transports
Expand Down
4 changes: 2 additions & 2 deletions tests/Data/Textile/LifeCycleTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ suite =
|> Result.andThen (lifeCycleToTransports db tShirtCotonFrance)
|> Result.map LifeCycle.computeTotalTransportImpacts
|> Result.map (\{ road, sea } -> ( Length.inKilometers road, Length.inKilometers sea ))
|> Expect.equal (Ok ( 2000, 21549 ))
|> Expect.equal (Ok ( 2500, 21549 ))
|> asTest "should compute default distances"
, let
tShirtCotonEnnoblementIndia =
Expand All @@ -46,7 +46,7 @@ suite =
|> Result.andThen (lifeCycleToTransports db tShirtCotonEnnoblementIndia)
|> Result.map LifeCycle.computeTotalTransportImpacts
|> Result.map (\{ road, sea } -> ( Length.inKilometers road, Length.inKilometers sea ))
|> Expect.equal (Ok ( 1000, 45471 ))
|> Expect.equal (Ok ( 1500, 45471 ))
|> asTest "should compute custom distances"
]
]
Expand Down
2 changes: 1 addition & 1 deletion tests/Data/Textile/SimulatorTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ suite =
[ { tShirtCotonFrance
| countrySpinning = Nothing
}
|> expectImpact db ecs 1469.1531378179673
|> expectImpact db ecs 1471.1431913678628
|> asTest "should compute a simulation ecs impact"
, describe "disabled steps"
[ { tShirtCotonFrance | disabledSteps = [ Label.Ennobling ] }
Expand Down
Loading