diff --git a/Jupyter/README.md b/Jupyter/README.md index 7f596213..85e4d093 100644 --- a/Jupyter/README.md +++ b/Jupyter/README.md @@ -1,3 +1,3 @@ -Create a mapping file for use in openLCA through Binder: +# Create a mapping file for use in openLCA through Binder [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/bl-young/Federal-LCA-Commons-Elementary-Flow-List/Binder?filepath=Jupyter%2Frun_mappings.ipynb) diff --git a/fedelemflowlist/add_uuid_to_flowmapping.py b/fedelemflowlist/add_uuid_to_flowmapping.py index 85dc92c7..3791301f 100644 --- a/fedelemflowlist/add_uuid_to_flowmapping.py +++ b/fedelemflowlist/add_uuid_to_flowmapping.py @@ -1,3 +1,4 @@ +"""Add docstring.""" import pandas as pd from fedelemflowlist.globals import flowmappingpath,outputpath,list_version_no diff --git a/fedelemflowlist/analysis/flow_list_analysis.py b/fedelemflowlist/analysis/flow_list_analysis.py index 7851d4fe..944290a7 100644 --- a/fedelemflowlist/analysis/flow_list_analysis.py +++ b/fedelemflowlist/analysis/flow_list_analysis.py @@ -1,11 +1,10 @@ -""" -Functions to perform analysis of a flow list -""" +"""Functions to perform analysis of a flow list.""" import pandas as pd def count_flows_by_class(flowlist): - """Counts all and preferred flows by class + """ + Counts all and preferred flows by class. :param flowlist: A FlowList in standard format :return: pandas df with 'Class','No. of Flows','No. of Preferred Flows' diff --git a/fedelemflowlist/contexts.py b/fedelemflowlist/contexts.py index e91bf335..3ce07304 100644 --- a/fedelemflowlist/contexts.py +++ b/fedelemflowlist/contexts.py @@ -1,6 +1,8 @@ """ -Provides a pandas dataframe of all contexts as paths and as a pattern of context classes -Used by flowlist.py +Provides a pandas dataframe. + +Of all contexts as paths and as a pattern of context classes. Used by +flowlist.py. """ import pandas as pd diff --git a/fedelemflowlist/flowlist.py b/fedelemflowlist/flowlist.py index 12d82a53..b330951b 100644 --- a/fedelemflowlist/flowlist.py +++ b/fedelemflowlist/flowlist.py @@ -1,6 +1,7 @@ """ -Generate the elementary flow master list as a pandas dataframe from input files -Write it to the output folder +Generate the elementary flow master list. + +As a pandas dataframe from input files. Write it to the output folder. """ import pandas as pd @@ -14,7 +15,8 @@ altunits_data_types = {'Conversion Factor': flow_list_fields['AltUnitConversionFactor'][0]['dtype']} #AltUnitConversionFactor def read_in_flowclass_file(flowclass, flowclasstype): - """Declare data types for select variables in flow class input files + """ + Declare data types for select variables in flow class input files. :param flowclass: One of the flow class names :param flowclasstype: either 'Flowables','FlowablePrimaryContexts',or 'FlowableAltUnits' @@ -30,6 +32,7 @@ def read_in_flowclass_file(flowclass, flowclasstype): return flowclassfile def import_secondary_context_membership(): + """Add docstring.""" log.info('Read in secondary context membership') SecondaryContextMembership = pd.read_csv(inputpath + 'SecondaryContextMembership.csv') return SecondaryContextMembership diff --git a/fedelemflowlist/globals.py b/fedelemflowlist/globals.py index 09fe69bb..14cc6893 100644 --- a/fedelemflowlist/globals.py +++ b/fedelemflowlist/globals.py @@ -1,4 +1,4 @@ -"""Set common variables for use in package""" +"""Set common variables for use in package.""" import sys import os import json diff --git a/fedelemflowlist/jsonld.py b/fedelemflowlist/jsonld.py index 781d7a4d..1c65ea3a 100644 --- a/fedelemflowlist/jsonld.py +++ b/fedelemflowlist/jsonld.py @@ -1,5 +1,4 @@ -"""Writes flow list and mapping files to a JSON-LD zip archive using olca library -""" +"""Writes flow list and mapping files to a JSON-LD zip archive using olca library.""" import datetime import logging as log import math @@ -36,9 +35,7 @@ def _isnum(val) -> bool: def _s(val) -> Optional[str]: - """Returns the string value of the given value or None if the value is - `None`, `NaN`, or `""`. - """ + """Returns the string value of the given value or None if the value is `None`, `NaN`, or `""`.""" if _isnil(val): return None return str(val).strip() @@ -81,7 +78,7 @@ def to_json(self) -> dict: class _MapEntry(object): - """ Describes a mapping entry in the Fed.LCA flow list. """ + """Describes a mapping entry in the Fed.LCA flow list.""" def __init__(self, row): @@ -122,8 +119,8 @@ def to_json(self) -> dict: class Writer(object): - """Class for writing flows and mappings to json - """ + """Class for writing flows and mappings to json.""" + def __init__(self, flow_list: pd.DataFrame, flow_mapping: pd.DataFrame = None): self.flow_list = flow_list diff --git a/fedelemflowlist/uuid_generators.py b/fedelemflowlist/uuid_generators.py index 4c792b06..d2af5e87 100644 --- a/fedelemflowlist/uuid_generators.py +++ b/fedelemflowlist/uuid_generators.py @@ -1,6 +1,8 @@ """ -Methods for UUID generation for flows, contexts -Uses UUID3 function from UUID package to generate IDs from strings +Methods for UUID generation. + +For flows, contexts, uses UUID3 function from UUID package to generate IDs from +strings. """ import uuid diff --git a/format specs/Contexts.md b/format specs/Contexts.md index 7307d0b8..4df699dc 100644 --- a/format specs/Contexts.md +++ b/format specs/Contexts.md @@ -1,4 +1,4 @@ -## Contexts Input File Format +# Contexts Input File Format The context input file is in the form of CSV data with the following fields. diff --git a/format specs/FlowList.md b/format specs/FlowList.md index 5e7dfac0..39601dd4 100644 --- a/format specs/FlowList.md +++ b/format specs/FlowList.md @@ -1,4 +1,4 @@ -## Flow List format +# Flow List format A Flow List is in the form of a pandas data frame with the following fields. @@ -15,7 +15,7 @@ A Flow List is in the form of a pandas data frame with the following fields. Context | string | Y | A path-like set of context compartments in the form of directionality/environmental media/environmental compartment... e.g. `emission/air/tropophere`| Flow UUID | string | Y | Unique hexadecimal ID for the flow | AltUnit | string | N | Alternate unit for the flow | - AltUnitConversionFactor | float | N | Conversion factor in the form of alternate units/reference unit | + AltUnitConversionFactor | float | N | Conversion factor in the form of alternate units/reference unit | \* See the [EPA Report](https://cfpub.epa.gov/si/si_public_search_results.cfm?simpleSearch=0&showCriteria=2&searchAll=elementary+flows&TIMSType=Published+Report&dateBeginPublishedPresented=07%2F31%2F2019) - for discussion of preferred flows. \ No newline at end of file + for discussion of preferred flows. diff --git a/format specs/FlowMapping.md b/format specs/FlowMapping.md index 57fe58e2..f30abfac 100644 --- a/format specs/FlowMapping.md +++ b/format specs/FlowMapping.md @@ -2,21 +2,21 @@ Flow mapping data is in the form of a pandas dataframe with the following fields. -Field | Type | Required? | Note | +Field | Type | Required? | Note | ----- | ---- | -------- | ----------- | SourceListName | string | Y | Name and version of the source flowlist, e.g. `openLCA1.7` or `TRACI2.1` | -SourceFlowName | string | Y | Name of the source flow | -SourceFlowUUID | string | N | If no UUID present, UUID generated based on olca algorithm| +SourceFlowName | string | Y | Name of the source flow | +SourceFlowUUID | string | N | If no UUID present, UUID generated based on olca algorithm| SourceFlowContext | string | Y | Compartments separated by `/`, like `emission/air`| SourceUnit | string | Y | A unit abbreviation, like `kg`| MatchCondition | string | N |Single character. `=`, `>`,`<`,`~`. Meaning 'equal to','a superset of', 'a subset of', 'a proxy for'. Assumes `=` if not present | -ConversionFactor | float | N | Value for multiplying with source flow to equal target flow. Assumes `1` if not present | +ConversionFactor | float | N | Value for multiplying with source flow to equal target flow. Assumes `1` if not present | TargetFlowName | string | Y | Name of the Fed Commons flowable | -TargetFlowUUID | string| Y| UUID for Fed Commons flow | +TargetFlowUUID | string| Y| UUID for Fed Commons flow | TargetFlowContext | string | Y | Fed commons context, in form like `emission/air` | TargetUnit | string | Y | A unit abbreviation, like `kg`| -Mapper | string | N | Person creating the mapping | -Verifier | string | N | Person verifying the mapping | +Mapper | string | N | Person creating the mapping | +Verifier | string | N | Person verifying the mapping | LastUpdated | datetime | N | Date mapping last updated | Note that TargetList is not present, because the Fed LCA Commons Elementary Flow List diff --git a/format specs/FlowableAltUnits.md b/format specs/FlowableAltUnits.md index 74f8e7b3..5ba8efd1 100644 --- a/format specs/FlowableAltUnits.md +++ b/format specs/FlowableAltUnits.md @@ -1,4 +1,4 @@ -## Flowable Alternate Units Input File Format +# Flowable Alternate Units Input File Format The flowable alternate units input files are in the form of CSV data with the following fields. diff --git a/format specs/FlowablePrimaryContexts.md b/format specs/FlowablePrimaryContexts.md index 763c1f32..67128aa4 100644 --- a/format specs/FlowablePrimaryContexts.md +++ b/format specs/FlowablePrimaryContexts.md @@ -1,4 +1,4 @@ -## Flowable Primary Context Input File Format +# Flowable Primary Context Input File Format Flowable primary context input files are the form of CSV data with the following fields. diff --git a/format specs/Flowables.md b/format specs/Flowables.md index 58fe8823..3b06665a 100644 --- a/format specs/Flowables.md +++ b/format specs/Flowables.md @@ -1,4 +1,4 @@ -## Flowables Input File Format +# Flowables Input File Format Flowable input files are the form of CSV data with the following fields. @@ -13,4 +13,4 @@ Flowable input files are the form of CSV data with the following fields. Flowable Preferred | int | Y | Indicates whether or not flowable is preferred.* `1` for preferred, `0` for non-preferred | \* See the [EPA Report](https://cfpub.epa.gov/si/si_public_search_results.cfm?simpleSearch=0&showCriteria=2&searchAll=elementary+flows&TIMSType=Published+Report&dateBeginPublishedPresented=07%2F31%2F2019) - for discussion of preferred flowables. \ No newline at end of file + for discussion of preferred flowables. diff --git a/format specs/README.md b/format specs/README.md index d8d41860..a7ecaf06 100644 --- a/format specs/README.md +++ b/format specs/README.md @@ -1,6 +1,7 @@ -Format specifications for input files, [Flowables](Flowables.md), [FlowablePrimaryContexts](FlowablePrimaryContexts.md), +# Format specifications for input files + +[Flowables](Flowables.md), [FlowablePrimaryContexts](FlowablePrimaryContexts.md), [FlowableAltUnits](FlowableAltUnits.md), [Contexts](Contexts.md), and [SecondaryContextMembership](SecondaryContextMembership.md) as well as the formats provided and used by `fedelemflowlist`, [FlowList](FlowList.md) and [FlowMapping](FlowMapping.md). See the EPA report linked to in the main [README](https://github.com/USEPA/Federal-LCA-Commons-Elementary-Flow-List/) - for an explanation of how the input files in these formats are used to create the flow list. - \ No newline at end of file + for an explanation of how the input files in these formats are used to create the flow list. diff --git a/format specs/SecondaryContextMembership.md b/format specs/SecondaryContextMembership.md index 1bcc8531..a63f72bc 100644 --- a/format specs/SecondaryContextMembership.md +++ b/format specs/SecondaryContextMembership.md @@ -1,11 +1,10 @@ -## Secondary Context Membership Input File Format +# Secondary Context Membership Input File Format The secondary context membership input file is in the form of CSV data with the following fields. Secondary context membership indicates whether or not secondary contexts (see [Contexts](Contexts.md) for class definitions) should be associated with flows from this FlowClass with listed primary contexts (Directionality and Environmental Media). - Field | Type | Required | Note | ----------- | ---- | ---------| ----- | FlowClass | string | Y | The flow class. Same as 'Class' in [FlowList](FlowList.md). | @@ -22,4 +21,4 @@ for class definitions) should be associated with flows from this FlowClass with ContextPreferred* | int | Y | `1` for included and `0` for excluded. See note. | \* See the [EPA Report]((https://cfpub.epa.gov/si/si_public_search_results.cfm?simpleSearch=0&showCriteria=2&searchAll=elementary+flows&TIMSType=Published+Report&dateBeginPublishedPresented=07%2F31%2F2019)) - for discussion of preferred secondary contexts. \ No newline at end of file + for discussion of preferred secondary contexts. diff --git a/scripts/add_conversion_to_flowmapping.py b/scripts/add_conversion_to_flowmapping.py index 0d2df02b..9aec930e 100644 --- a/scripts/add_conversion_to_flowmapping.py +++ b/scripts/add_conversion_to_flowmapping.py @@ -1,8 +1,9 @@ """ -Adds conversion factor to mapping files if source unit is an alternate unit -Requires target unit to be the primary unit -Existing conversion factor must be set to 1 to avoid replacing manual conversion factors -Mapping file must already conform to mapping format +Adds conversion factor to mapping files if source unit is an alternate unit. + +Requires target unit to be the primary unit. Existing conversion factor must be +set to 1 to avoid replacing manual conversion factors. Mapping file must already +conform to mapping format. """ import pandas as pd import fedelemflowlist diff --git a/scripts/add_uuid_to_flowmapping.py b/scripts/add_uuid_to_flowmapping.py index 411bfb24..7371638f 100644 --- a/scripts/add_uuid_to_flowmapping.py +++ b/scripts/add_uuid_to_flowmapping.py @@ -1,6 +1,8 @@ """ -Gets Fed Commons Flow UUID from mapping list and adds it to mapping file(s). -Mapping file must already conform to mapping format +Gets Fed Commons Flow UUID. + +From mapping list and adds it to mapping file(s). Mapping file must already +conform to mapping format. """ import pandas as pd import fedelemflowlist diff --git a/scripts/build_recipe_mapping.py b/scripts/build_recipe_mapping.py index 99a3169f..28ef0cb0 100644 --- a/scripts/build_recipe_mapping.py +++ b/scripts/build_recipe_mapping.py @@ -1,8 +1,9 @@ """ -Builds the mapping file for ReCiPe using input flowable and context mappings, -and recipe from the lcia_formatter +Builds the mapping file for ReCiPe. + +Using input flowable and context mappings, and recipe from the lcia_formatter Requires lciafmt from lcia_formatter (https://github.com/USEPA/lciaformatter) -BEWARE this will replace the existing mapping file if it exists in /flowmapping +BEWARE this will replace the existing mapping file if it exists in /flowmapping. """ import pandas as pd diff --git a/scripts/build_traci2.1_mapping.py b/scripts/build_traci2.1_mapping.py index 1f458827..e2fd3220 100644 --- a/scripts/build_traci2.1_mapping.py +++ b/scripts/build_traci2.1_mapping.py @@ -1,8 +1,9 @@ """ -Builds the mapping file for TRACI2.1 using input flowable and context mappings, -and TRACI2.1 from the lcia_formatter +Builds the mapping file for TRACI2.1. + +Using input flowable and context mappings, and TRACI2.1 from the lcia_formatter Requires lciafmt from lcia_formatter (https://github.com/USEPA/lciaformatter) -BEWARE this will replace the existing mapping file if it exists in /flowmapping +BEWARE this will replace the existing mapping file if it exists in /flowmapping. """ import pandas as pd diff --git a/scripts/compare_old_flowlist.py b/scripts/compare_old_flowlist.py index 5f50a645..4510e824 100644 --- a/scripts/compare_old_flowlist.py +++ b/scripts/compare_old_flowlist.py @@ -1,5 +1,6 @@ """ Use an archived flowlist parquet file to load in and compare with the current list. + Write csvs of the new flows and expired flows in csv format, write new flows to JSON-LD Currently compares only by UUID. """ diff --git a/scripts/determine_unused_flowables_formapping.py b/scripts/determine_unused_flowables_formapping.py index 0db53f5c..ad247bde 100644 --- a/scripts/determine_unused_flowables_formapping.py +++ b/scripts/determine_unused_flowables_formapping.py @@ -1,6 +1,8 @@ """ -Determines FEDEFL flowables not used in a mapping and exports those flowables to csv -output: csv with columns 'Class','Flowable','CAS No','Formula','Synonyms' +Determines FEDEFL flowables not used in a mapping and exports. + +Those flowables to csv output: csv with columns 'Class','Flowable','CAS No', +'Formula','Synonyms'. """ import fedelemflowlist diff --git a/scripts/extract_flow_data_from_Excel.py b/scripts/extract_flow_data_from_Excel.py index 0f9b636d..88e17431 100644 --- a/scripts/extract_flow_data_from_Excel.py +++ b/scripts/extract_flow_data_from_Excel.py @@ -1,8 +1,9 @@ """ -Flow data were originally developed in Excel. This script extracts those data -and writes them to csv files. -WARNING: This will replace the existing input files -The flow class files should match the class names in the flowlistspecs +Flow data were originally developed in Excel. + +This script extracts those data and writes them to csv files. WARNING: This will +replace the existing input files The flow class files should match the class +names in the flowlistspecs. """ import pandas as pd diff --git a/scripts/extract_mapping_data_from_Excel.py b/scripts/extract_mapping_data_from_Excel.py index 730c723a..2f3f51b7 100644 --- a/scripts/extract_mapping_data_from_Excel.py +++ b/scripts/extract_mapping_data_from_Excel.py @@ -1,7 +1,9 @@ """ -For mapping data were originally developed in Excel where flowables. This was developed specifically -for the USLCI mapping. This script extracts those data and writes them to csv files. -WARNING: This will replace the existing input files +For mapping data were originally developed in Excel where flowables. + +This was developed specifically for the USLCI mapping. This script extracts +those data and writes them to csv files. WARNING: This will replace the existing +input files. """ import pandas as pd diff --git a/scripts/get_all_mappings.py b/scripts/get_all_mappings.py index ef93d639..47d635e4 100644 --- a/scripts/get_all_mappings.py +++ b/scripts/get_all_mappings.py @@ -1,6 +1,8 @@ """ -Combines all mapping files to help maintain consistency in future future mappings -output: xlsx in the mapping format +Combines all mapping files. + +To help maintain consistency in future future mappings +output: xlsx in the mapping format. """ import fedelemflowlist diff --git a/scripts/summarize_flowlist.py b/scripts/summarize_flowlist.py index c977b3c0..c41da9c8 100644 --- a/scripts/summarize_flowlist.py +++ b/scripts/summarize_flowlist.py @@ -1,6 +1,4 @@ -""" -Uses fedelemflowlist analysis functions to perform and export basic analysis -""" +"""Uses fedelemflowlist analysis functions to perform and export basic analysis.""" import fedelemflowlist from fedelemflowlist.analysis.flow_list_analysis import count_flows_by_class,\ count_flowables_by_class, list_contexts diff --git a/scripts/write_all_flows.py b/scripts/write_all_flows.py index 27dc2fd8..9f5e0c74 100644 --- a/scripts/write_all_flows.py +++ b/scripts/write_all_flows.py @@ -1,6 +1,4 @@ -""" -Writes preferred flows to a JSON-LD archive in the output folder -""" +"""Writes preferred flows to a JSON-LD archive in the output folder.""" import fedelemflowlist from fedelemflowlist.globals import outputpath,flow_list_specs diff --git a/scripts/write_flows_and_mappings.py b/scripts/write_flows_and_mappings.py index cd66b784..c7fa99e1 100644 --- a/scripts/write_flows_and_mappings.py +++ b/scripts/write_flows_and_mappings.py @@ -1,6 +1,4 @@ -""" -Exports flows and flowmappings for a selecting mapping file -""" +"""Exports flows and flowmappings for a selecting mapping file.""" import fedelemflowlist import pandas as pd from fedelemflowlist.globals import outputpath diff --git a/scripts/write_preferred_flows.py b/scripts/write_preferred_flows.py index 52d7b4f3..3718711f 100644 --- a/scripts/write_preferred_flows.py +++ b/scripts/write_preferred_flows.py @@ -1,6 +1,4 @@ -""" -Writes preferred flows to a JSON-LD archive in the output folder -""" +"""Writes preferred flows to a JSON-LD archive in the output folder.""" import fedelemflowlist from fedelemflowlist.globals import outputpath, flow_list_specs diff --git a/tests/test_flow_list.py b/tests/test_flow_list.py index f5db7f9b..dd8ce5fd 100644 --- a/tests/test_flow_list.py +++ b/tests/test_flow_list.py @@ -1,6 +1,4 @@ -""" -Tests the stored flow list to provide quality assurance -""" +"""Tests the stored flow list to provide quality assurance.""" import unittest import pandas as pd import fedelemflowlist @@ -49,7 +47,9 @@ existing_flow_sample = pd.DataFrame(existing_flow_list_sample) def get_required_flowlist_fields(): - """Gets required field names for Flow List + """ + Gets required field names for Flow List. + :return:list of required fields """ from fedelemflowlist.globals import flow_list_fields @@ -60,16 +60,15 @@ def get_required_flowlist_fields(): return required_fields class TestFlowList(unittest.TestCase): + """Add docstring.""" def setUp(self): - """Get flowlist used for all tests - """ + """Get flowlist used for all tests.""" self.flowlist = fedelemflowlist.get_flows() def test_UUID_stability(self): - """Checks that UUIDs in currently served list are identical to old UUIDs - """ + """Checks that UUIDs in currently served list are identical to old UUIDs.""" merge_new_and_existing = pd.merge(existing_flow_sample, self.flowlist, on=['Flowable', 'Context', 'Unit']) self.assertEqual(set(merge_new_and_existing['Flow UUID_x']), @@ -77,16 +76,14 @@ def test_UUID_stability(self): def test_no_nas_in_required_fields(self): - """Checks that no flows have na values in required fields - """ + """Checks that no flows have na values in required fields.""" required_fields = get_required_flowlist_fields() flowlist_w_required = self.flowlist[required_fields] nas_in_required = flowlist_w_required.dropna() self.assertEqual(len(flowlist_w_required), len(nas_in_required)) def test_for_duplicate_uuids(self): - """Checks for duplicate uuids in list - """ + """Checks for duplicate uuids in list.""" fl_g = self.flowlist.groupby(['Flowable', 'Context', 'Unit'])['Flow UUID'].count().reset_index() duplicate_uuids = fl_g[fl_g['Flow UUID'] > 1] len_duplicate_uuids = len(duplicate_uuids) @@ -96,8 +93,7 @@ def test_for_duplicate_uuids(self): self.assertEqual(len_duplicate_uuids,0) def test_preferred_flows_exist_for_all_classes(self): - """Checks for each flow class in specs, preferred flows exist in list - """ + """Checks for each flow class in specs, preferred flows exist in list.""" flowclasses_in_list = set(pd.unique(self.flowlist['Class'])) flowclasses_in_specs = set(flow_list_specs['flow_classes']) self.assertEqual(flowclasses_in_list, flowclasses_in_specs) diff --git a/tests/test_flow_mappings.py b/tests/test_flow_mappings.py index fab733ee..755e8fc3 100644 --- a/tests/test_flow_mappings.py +++ b/tests/test_flow_mappings.py @@ -1,14 +1,10 @@ -""" -Tests the stored flow mappings to provide quality assurance -""" +"""Tests the stored flow mappings to provide quality assurance.""" import unittest import pandas as pd import fedelemflowlist def get_required_flowmapping_fields(): - """Gets required field names for Flow Mappingt - :return:list of required fields - """ + """Gets required field names for Flow Mappingt:return:list of required fields.""" from fedelemflowlist.globals import flowmapping_fields required_fields = [] for k, v in flowmapping_fields.items(): @@ -17,24 +13,22 @@ def get_required_flowmapping_fields(): return required_fields class TestFlowMappings(unittest.TestCase): + """Add doctring.""" def setUp(self): - """Get flowlist used for all tests - """ + """Get flowlist used for all tests.""" self.flowmappings = fedelemflowlist.get_flowmapping() self.flowlist = self.flowlist = fedelemflowlist.get_flows() def test_no_nas_in_required_fields(self): - """Checks that no flows have na values in required fields - """ + """Checks that no flows have na values in required fields.""" required_fields = get_required_flowmapping_fields() flowmappings_w_required = self.flowmappings[required_fields] nas_in_required = flowmappings_w_required.dropna() self.assertEqual(len(flowmappings_w_required), len(nas_in_required)) def test_targetflowinfo_matches_flows_in_list(self): - """Checks that target flow information in the mapping files matches a flow in the flowlist - """ + """Checks that target flow information in the mapping files matches a flow in the flowlist.""" flowmapping_targetinfo = self.flowmappings[['TargetFlowName', 'TargetFlowUUID', 'TargetFlowContext']] flowmapping_targetinfo.columns = ['Flowable', 'Flow UUID', 'Context'] diff --git a/tests/test_input_files.py b/tests/test_input_files.py index 3fb86db8..a87c1a4d 100644 --- a/tests/test_input_files.py +++ b/tests/test_input_files.py @@ -1,6 +1,4 @@ -""" -Tests for input files used to build flow list to provide quality assurance -""" +"""Tests for input files used to build flow list to provide quality assurance.""" import unittest import pandas as pd from fedelemflowlist.flowlist import read_in_flowclass_file, import_secondary_context_membership @@ -8,10 +6,12 @@ from fedelemflowlist.contexts import contexts, compartment_classes class TestInputFiles(unittest.TestCase): + """Add docstring.""" def test_flowables_match_primary_context_flowables(self): - """For each flow class, tests that flowables in Flowables match those - in FlowablePrimaryContexts + """ + For each flow class, tests that flowables in Flowables match those in + FlowablePrimaryContexts. """ for c_ in flow_list_specs["flow_classes"]: flowables = read_in_flowclass_file(c_, "Flowables") @@ -21,8 +21,7 @@ def test_flowables_match_primary_context_flowables(self): self.assertEqual(flowables_in_flowables, flowables_in_primary_contexts) def test_duplicate_flowables(self): - """For each flow class, tests for duplicate flowable names - """ + """For each flow class, tests for duplicate flowable names.""" duplicates = 0 for c_ in flow_list_specs["flow_classes"]: flowables = read_in_flowclass_file(c_, "Flowables") @@ -34,8 +33,7 @@ def test_duplicate_flowables(self): self.assertTrue(duplicates==0,'Duplicate flowables') def test_altunit_files_match_flowables(self): - """For each flow class, test flowables in AltUnits are defined in Flowables - """ + """For each flow class, test flowables in AltUnits are defined in Flowables.""" for c_ in flow_list_specs["flow_classes"]: flowables = read_in_flowclass_file(c_, "Flowables") flowables_w_unit = flowables[['Flowable','Unit']] @@ -55,9 +53,9 @@ def test_altunit_files_match_flowables(self): altunits_for_class = None def test_units_are_olcaunits(self): + """Test that units are openlca reference units.""" import olca.units as olcaunits - """ Test that units are openlca reference units - """ + for c_ in flow_list_specs["flow_classes"]: flowables = read_in_flowclass_file(c_, "Flowables") # Get units and test that they are olca ref units @@ -82,8 +80,9 @@ def test_units_are_olcaunits(self): def test_compartment_classes_match(self): - """Test that compartment classes in Contexts and Secondary Context - Membership match those in flow list specs + """ + Test that compartment classes in Contexts and Secondary Context + Membership match those in flow list specs. """ context_classes = set(contexts.columns) flowlistspecs_classes = set(compartment_classes) @@ -96,9 +95,7 @@ def test_compartment_classes_match(self): self.assertEqual(flowlistspecs_classes, secondary_membership_classes) def test_synonyms_in_flowables(self): - """ - Checks synonyms for bad characters - """ + """Checks synonyms for bad characters.""" for c_ in flow_list_specs["flow_classes"]: flowables = read_in_flowclass_file(c_, "Flowables") synonyms = list(flowables['Synonyms'].dropna()) diff --git a/tests/test_writing_jsonld.py b/tests/test_writing_jsonld.py index 02e04eeb..ff7c5c7c 100644 --- a/tests/test_writing_jsonld.py +++ b/tests/test_writing_jsonld.py @@ -1,5 +1,5 @@ """ -Tests for that flows and mappings are written as expected to JSON-LD archives +Tests for that flows and mappings are written as expected to JSON-LD archives. """ import unittest import fedelemflowlist @@ -8,10 +8,10 @@ import os class TestWritingJSONLD(unittest.TestCase): + """Add docstring.""" def test_writing_flows(self): - """Test that first 100 flows are written to 100 files in JSON_LD archive - """ + """Test that first 100 flows are written to 100 files in JSON_LD archive.""" flowlist = fedelemflowlist.get_flows(preferred_only=False) #Test first 100 flowlist = flowlist.iloc[0:100] diff --git a/wiki/readme.md b/wiki/readme.md index bcd7f369..f779d533 100644 --- a/wiki/readme.md +++ b/wiki/readme.md @@ -1 +1 @@ -Resources for mapping datasets and assets used in the wiki. +# Resources for mapping datasets and assets used in the wiki.