Skip to content

Commit

Permalink
Black reformating
Browse files Browse the repository at this point in the history
  • Loading branch information
romainsacchi committed Mar 22, 2024
1 parent 7d11606 commit ab2f30d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
6 changes: 3 additions & 3 deletions pathways/lca.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import csv
from pathlib import Path
from typing import Dict, Tuple, List, Any
from typing import Any, Dict, List, Tuple

import bw_processing as bwp
import numpy as np
import sparse as sp
from bw_processing import Datapackage
from numpy import ndarray, dtype
from numpy import dtype, ndarray
from scipy import sparse
from scipy.sparse import csr_matrix
import sparse as sp

from .lcia import get_lcia_methods

Expand Down
16 changes: 11 additions & 5 deletions pathways/pathways.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,22 @@

from .data_validation import validate_datapackage
from .filesystem_constants import DATA_DIR, DIR_CACHED_DB
from .lca import get_lca_matrices, remove_double_counting, fill_characterization_factors_matrices
from .lca import (
fill_characterization_factors_matrices,
get_lca_matrices,
remove_double_counting,
)
from .lcia import get_lcia_method_names
from .utils import (
_get_activity_indices,
clean_cache_directory,
create_lca_results_array,
display_results,
get_unit_conversion_factors,
harmonize_units,
load_classifications,
load_numpy_array_from_disk,
load_units_conversion,
clean_cache_directory
)

warnings.filterwarnings("ignore")
Expand Down Expand Up @@ -254,7 +258,7 @@ def process_region(data: Tuple) -> dict[str, ndarray[Any, dtype[Any]] | list[int
location_to_index,
rev_A_index,
lca,
characterization_matrix
characterization_matrix,
) = data

FU = []
Expand Down Expand Up @@ -415,7 +419,9 @@ def _calculate_year(args):
)
lca.lci(factorize=True)

characterization_matrix = fill_characterization_factors_matrices(biosphere_indices, methods, lca.dicts.biosphere)
characterization_matrix = fill_characterization_factors_matrices(
biosphere_indices, methods, lca.dicts.biosphere
)

bar = pyprind.ProgBar(len(regions))
for region in regions:
Expand All @@ -442,7 +448,7 @@ def _calculate_year(args):
location_to_index,
reverse_technosphere_index,
lca,
characterization_matrix
characterization_matrix,
)
)

Expand Down
4 changes: 3 additions & 1 deletion pathways/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from pathlib import Path
from typing import Any, Dict, List, Tuple, Union

import numpy as np
import xarray as xr
import yaml
from pathlib import Path

from .filesystem_constants import DATA_DIR, DIR_CACHED_DB

Expand Down Expand Up @@ -277,9 +277,11 @@ def load_numpy_array_from_disk(filepath):

return np.load(filepath, allow_pickle=True)


def get_visible_files(path):
return [file for file in Path(path).iterdir() if not file.name.startswith(".")]


def clean_cache_directory():
# clean up the cache directory
for file in get_visible_files(DIR_CACHED_DB):
Expand Down

0 comments on commit ab2f30d

Please sign in to comment.