Skip to content

Commit

Permalink
Fixed minor PEP 257 style issues using pydocstyle.
Browse files Browse the repository at this point in the history
  • Loading branch information
dyoung11 committed May 22, 2020
1 parent aec74d9 commit c518d27
Show file tree
Hide file tree
Showing 34 changed files with 119 additions and 123 deletions.
2 changes: 1 addition & 1 deletion Jupyter/README.md
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions fedelemflowlist/add_uuid_to_flowmapping.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Add docstring."""
import pandas as pd
from fedelemflowlist.globals import flowmappingpath,outputpath,list_version_no

Expand Down
7 changes: 3 additions & 4 deletions fedelemflowlist/analysis/flow_list_analysis.py
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
6 changes: 4 additions & 2 deletions fedelemflowlist/contexts.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 6 additions & 3 deletions fedelemflowlist/flowlist.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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'
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fedelemflowlist/globals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Set common variables for use in package"""
"""Set common variables for use in package."""
import sys
import os
import json
Expand Down
13 changes: 5 additions & 8 deletions fedelemflowlist/jsonld.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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):

Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions fedelemflowlist/uuid_generators.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion format specs/Contexts.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
6 changes: 3 additions & 3 deletions format specs/FlowList.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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.
for discussion of preferred flows.
14 changes: 7 additions & 7 deletions format specs/FlowMapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion format specs/FlowableAltUnits.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion format specs/FlowablePrimaryContexts.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
4 changes: 2 additions & 2 deletions format specs/Flowables.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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.
for discussion of preferred flowables.
7 changes: 4 additions & 3 deletions format specs/README.md
Original file line number Diff line number Diff line change
@@ -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.

for an explanation of how the input files in these formats are used to create the flow list.
5 changes: 2 additions & 3 deletions format specs/SecondaryContextMembership.md
Original file line number Diff line number Diff line change
@@ -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). |
Expand All @@ -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.
for discussion of preferred secondary contexts.
9 changes: 5 additions & 4 deletions scripts/add_conversion_to_flowmapping.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions scripts/add_uuid_to_flowmapping.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 4 additions & 3 deletions scripts/build_recipe_mapping.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 4 additions & 3 deletions scripts/build_traci2.1_mapping.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions scripts/compare_old_flowlist.py
Original file line number Diff line number Diff line change
@@ -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.
"""
Expand Down
6 changes: 4 additions & 2 deletions scripts/determine_unused_flowables_formapping.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 5 additions & 4 deletions scripts/extract_flow_data_from_Excel.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 5 additions & 3 deletions scripts/extract_mapping_data_from_Excel.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions scripts/get_all_mappings.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions scripts/summarize_flowlist.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions scripts/write_all_flows.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 1 addition & 3 deletions scripts/write_flows_and_mappings.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions scripts/write_preferred_flows.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Loading

0 comments on commit c518d27

Please sign in to comment.