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

Update dependencies and pre-commit #477

Merged
merged 9 commits into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from 8 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: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ default_language_version:

repos:
- repo: https://github.com/ambv/black
rev: 19.10b0
rev: 20.8b1
hooks:
- id: black
name: Blacken

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
rev: v3.2.0
hooks:
- id: trailing-whitespace
exclude: README.md
Expand Down
10 changes: 5 additions & 5 deletions openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@
"description": "Statistical probability of each group. It MUST have the same length as `sites_in_groups`.\nIt SHOULD sum to one.\nSee below for examples of how to specify the probability of the occurrence of a vacancy.\nThe possible reasons for the values not to sum to one are the same as already specified above for the `concentration` of each `species`."
}
},
"description": "A description of groups of sites that are statistically correlated.\n\n- **Examples** (for each entry of the assemblies list):\n - `{\"sites_in_groups\": [[0], [1]], \"group_probabilities: [0.3, 0.7]}`: the first site and the second site never occur at the same time in the unit cell.\n Statistically, 30 % of the times the first site is present, while 70 % of the times the second site is present.\n - `{\"sites_in_groups\": [[1,2], [3]], \"group_probabilities: [0.3, 0.7]}`: the second and third site are either present together or not present; they form the first group of atoms for this assembly.\n The second group is formed by the fourth site. Sites of the first group (the second and the third) are never present at the same time as the fourth site.\n 30 % of times sites 1 and 2 are present (and site 3 is absent); 70 % of times site 3 is present (and sites 1 and 2 are absent).\n\n "
"description": "A description of groups of sites that are statistically correlated.\n\n- **Examples** (for each entry of the assemblies list):\n - `{\"sites_in_groups\": [[0], [1]], \"group_probabilities: [0.3, 0.7]}`: the first site and the second site never occur at the same time in the unit cell.\n Statistically, 30 % of the times the first site is present, while 70 % of the times the second site is present.\n - `{\"sites_in_groups\": [[1,2], [3]], \"group_probabilities: [0.3, 0.7]}`: the second and third site are either present together or not present; they form the first group of atoms for this assembly.\n The second group is formed by the fourth site. Sites of the first group (the second and the third) are never present at the same time as the fourth site.\n 30 % of times sites 1 and 2 are present (and site 3 is absent); 70 % of times site 3 is present (and sites 1 and 2 are absent)."
},
"Attributes": {
"title": "Attributes",
Expand Down Expand Up @@ -1197,7 +1197,7 @@
"dictionary",
"unknown"
],
"description": "Optimade Data Types\n\nSee the section \"Data types\" in the OPTIMADE API specification for more information.\n "
"description": "Optimade Data Types\n\nSee the section \"Data types\" in the OPTIMADE API specification for more information."
},
"EntryInfoProperty": {
"title": "EntryInfoProperty",
Expand Down Expand Up @@ -2256,7 +2256,7 @@
"description": "A dictionary containing references to other entries according to the description in section Relationships encoded as [JSON API Relationships](https://jsonapi.org/format/1.0/#document-resource-object-relationships).\nThe OPTIONAL human-readable description of the relationship MAY be provided in the `description` field inside the `meta` dictionary of the JSON API resource identifier object."
}
},
"description": "The `references` entries describe bibliographic references.\nThe following properties are used to provide the bibliographic details:\n\n- **address**, **annote**, **booktitle**, **chapter**, **crossref**, **edition**, **howpublished**, **institution**, **journal**, **key**, **month**, **note**, **number**, **organization**, **pages**, **publisher**, **school**, **series**, **title**, **volume**, **year**: meanings of these properties match the [BibTeX specification](http://bibtexml.sourceforge.net/btxdoc.pdf), values are strings;\n- **bib_type**: type of the reference, corresponding to **type** property in the BibTeX specification, value is string;\n- **authors** and **editors**: lists of *person objects* which are dictionaries with the following keys:\n - **name**: Full name of the person, REQUIRED.\n - **firstname**, **lastname**: Parts of the person's name, OPTIONAL.\n- **doi** and **url**: values are strings.\n- **Requirements/Conventions**:\n - **Support**: OPTIONAL support in implementations, i.e., any of the properties MAY be `null`.\n - **Query**: Support for queries on any of these properties is OPTIONAL.\n If supported, filters MAY support only a subset of comparison operators.\n - Every references entry MUST contain at least one of the properties.\n\n "
"description": "The `references` entries describe bibliographic references.\n\nThe following properties are used to provide the bibliographic details:\n\n- **address**, **annote**, **booktitle**, **chapter**, **crossref**, **edition**, **howpublished**, **institution**, **journal**, **key**, **month**, **note**, **number**, **organization**, **pages**, **publisher**, **school**, **series**, **title**, **volume**, **year**: meanings of these properties match the [BibTeX specification](http://bibtexml.sourceforge.net/btxdoc.pdf), values are strings;\n- **bib_type**: type of the reference, corresponding to **type** property in the BibTeX specification, value is string;\n- **authors** and **editors**: lists of *person objects* which are dictionaries with the following keys:\n - **name**: Full name of the person, REQUIRED.\n - **firstname**, **lastname**: Parts of the person's name, OPTIONAL.\n- **doi** and **url**: values are strings.\n- **Requirements/Conventions**:\n - **Support**: OPTIONAL support in implementations, i.e., any of the properties MAY be `null`.\n - **Query**: Support for queries on any of these properties is OPTIONAL.\n If supported, filters MAY support only a subset of comparison operators.\n - Every references entry MUST contain at least one of the properties."
},
"ReferenceResourceAttributes": {
"title": "ReferenceResourceAttributes",
Expand Down Expand Up @@ -2416,7 +2416,7 @@
"description": "Meaning of property matches the BiBTeX specification."
}
},
"description": "Model that stores the attributes of a reference. Many properties match the\nmeaning described in the\n[BibTeX specification](http://bibtexml.sourceforge.net/btxdoc.pdf)."
"description": "Model that stores the attributes of a reference.\n\nMany properties match the meaning described in the\n[BibTeX specification](http://bibtexml.sourceforge.net/btxdoc.pdf)."
},
"ReferenceResponseMany": {
"title": "ReferenceResponseMany",
Expand Down Expand Up @@ -2873,7 +2873,7 @@
"description": "If provided MUST be a list of length 1 or more of integers indicating the number of attached atoms of the kind specified in the value of the :field:`attached` key."
}
},
"description": "A list describing the species of the sites of this structure.\nSpecies can represent pure chemical elements, virtual-crystal atoms representing a\nstatistical occupation of a given site by multiple chemical elements, and/or a\nlocation to which there are attached atoms, i.e., atoms whose precise location are\nunknown beyond that they are attached to that position (frequently used to indicate\nhydrogen atoms attached to another element, e.g., a carbon with three attached\nhydrogens might represent a methyl group, -CH3).\n\n- **Examples**:\n - `[ {\"name\": \"Ti\", \"chemical_symbols\": [\"Ti\"], \"concentration\": [1.0]} ]`: any site with this species is occupied by a Ti atom.\n - `[ {\"name\": \"Ti\", \"chemical_symbols\": [\"Ti\", \"vacancy\"], \"concentration\": [0.9, 0.1]} ]`: any site with this species is occupied by a Ti atom with 90 % probability, and has a vacancy with 10 % probability.\n - `[ {\"name\": \"BaCa\", \"chemical_symbols\": [\"vacancy\", \"Ba\", \"Ca\"], \"concentration\": [0.05, 0.45, 0.5], \"mass\": 88.5} ]`: any site with this species is occupied by a Ba atom with 45 % probability, a Ca atom with 50 % probability, and by a vacancy with 5 % probability. The mass of this site is (on average) 88.5 a.m.u.\n - `[ {\"name\": \"C12\", \"chemical_symbols\": [\"C\"], \"concentration\": [1.0], \"mass\": 12.0} ]`: any site with this species is occupied by a carbon isotope with mass 12.\n - `[ {\"name\": \"C13\", \"chemical_symbols\": [\"C\"], \"concentration\": [1.0], \"mass\": 13.0} ]`: any site with this species is occupied by a carbon isotope with mass 13.\n - `[ {\"name\": \"CH3\", \"chemical_symbols\": [\"C\"], \"concentration\": [1.0], \"attached\": [\"H\"], \"nattached\": [3]} ]`: any site with this species is occupied by a methyl group, -CH3, which is represented without specifying precise positions of the hydrogen atoms.\n\n "
"description": "A list describing the species of the sites of this structure.\n\nSpecies can represent pure chemical elements, virtual-crystal atoms representing a\nstatistical occupation of a given site by multiple chemical elements, and/or a\nlocation to which there are attached atoms, i.e., atoms whose precise location are\nunknown beyond that they are attached to that position (frequently used to indicate\nhydrogen atoms attached to another element, e.g., a carbon with three attached\nhydrogens might represent a methyl group, -CH3).\n\n- **Examples**:\n - `[ {\"name\": \"Ti\", \"chemical_symbols\": [\"Ti\"], \"concentration\": [1.0]} ]`: any site with this species is occupied by a Ti atom.\n - `[ {\"name\": \"Ti\", \"chemical_symbols\": [\"Ti\", \"vacancy\"], \"concentration\": [0.9, 0.1]} ]`: any site with this species is occupied by a Ti atom with 90 % probability, and has a vacancy with 10 % probability.\n - `[ {\"name\": \"BaCa\", \"chemical_symbols\": [\"vacancy\", \"Ba\", \"Ca\"], \"concentration\": [0.05, 0.45, 0.5], \"mass\": 88.5} ]`: any site with this species is occupied by a Ba atom with 45 % probability, a Ca atom with 50 % probability, and by a vacancy with 5 % probability. The mass of this site is (on average) 88.5 a.m.u.\n - `[ {\"name\": \"C12\", \"chemical_symbols\": [\"C\"], \"concentration\": [1.0], \"mass\": 12.0} ]`: any site with this species is occupied by a carbon isotope with mass 12.\n - `[ {\"name\": \"C13\", \"chemical_symbols\": [\"C\"], \"concentration\": [1.0], \"mass\": 13.0} ]`: any site with this species is occupied by a carbon isotope with mass 13.\n - `[ {\"name\": \"CH3\", \"chemical_symbols\": [\"C\"], \"concentration\": [1.0], \"attached\": [\"H\"], \"nattached\": [3]} ]`: any site with this species is occupied by a methyl group, -CH3, which is represented without specifying precise positions of the hydrogen atoms."
},
"StructureFeatures": {
"title": "StructureFeatures",
Expand Down
2 changes: 1 addition & 1 deletion optimade/adapters/structures/aiida.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


def get_aiida_structure_data(optimade_structure: OptimadeStructure) -> StructureData:
""" Get AiiDA `StructureData` from OPTIMADE structure.
"""Get AiiDA `StructureData` from OPTIMADE structure.

Parameters:
optimade_structure: OPTIMADE structure.
Expand Down
2 changes: 1 addition & 1 deletion optimade/adapters/structures/ase.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


def get_ase_atoms(optimade_structure: OptimadeStructure) -> Atoms:
""" Get ASE `Atoms` from OPTIMADE structure.
"""Get ASE `Atoms` from OPTIMADE structure.

Caution:
Cannot handle partial occupancies (this includes vacancies).
Expand Down
2 changes: 1 addition & 1 deletion optimade/adapters/structures/cif.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
def get_cif( # pylint: disable=too-many-locals,too-many-branches
optimade_structure: OptimadeStructure,
) -> str:
""" Get CIF file as string from OPTIMADE structure.
"""Get CIF file as string from OPTIMADE structure.

Parameters:
optimade_structure: OPTIMADE structure.
Expand Down
2 changes: 1 addition & 1 deletion optimade/adapters/structures/jarvis.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


def get_jarvis_atoms(optimade_structure: OptimadeStructure) -> Atoms:
""" Get jarvis `Atoms` from OPTIMADE structure.
"""Get jarvis `Atoms` from OPTIMADE structure.

Caution:
Cannot handle partial occupancies.
Expand Down
4 changes: 2 additions & 2 deletions optimade/adapters/structures/proteindatabank.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
def get_pdbx_mmcif( # pylint: disable=too-many-locals
optimade_structure: OptimadeStructure,
) -> str:
""" Write Protein Data Bank (PDB) structure in the PDBx/mmCIF format from OPTIMADE structure.
"""Write Protein Data Bank (PDB) structure in the PDBx/mmCIF format from OPTIMADE structure.

Warning:
The result of this function can currently not be parsed as a complete PDBx/mmCIF file.
Expand Down Expand Up @@ -199,7 +199,7 @@ def get_pdbx_mmcif( # pylint: disable=too-many-locals
def get_pdb( # pylint: disable=too-many-locals
optimade_structure: OptimadeStructure,
) -> str:
""" Write Protein Data Bank (PDB) structure in the old PDB format from OPTIMADE structure.
"""Write Protein Data Bank (PDB) structure in the old PDB format from OPTIMADE structure.

Parameters:
optimade_structure: OPTIMADE structure.
Expand Down
2 changes: 1 addition & 1 deletion optimade/adapters/structures/pymatgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


def get_pymatgen(optimade_structure: OptimadeStructure) -> Union[Structure, Molecule]:
""" Get pymatgen Structure or Molecule from OPTIMADE structure.
"""Get pymatgen `Structure` or `Molecule` from OPTIMADE structure.

This function will return either a pymatgen `Structure` or `Molecule` based
on the periodicity or periodic dimensionality of OPTIMADE structure.
Expand Down
5 changes: 4 additions & 1 deletion optimade/adapters/structures/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,8 @@ def pad_cell(

"""
return _pad_iter_of_iters(
iterable=lattice_vectors, padding=padding, outer=tuple, inner=tuple,
iterable=lattice_vectors,
padding=padding,
outer=tuple,
inner=tuple,
)
8 changes: 4 additions & 4 deletions optimade/filtertransformers/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@


class Quantity:
""" Class to provide information about available quantities to the transformer.
"""Class to provide information about available quantities to the transformer.

The elasticsearch transformer will :class:`Quantity`s to (a) do some semantic checks,
The elasticsearch transformer will use `Quantity`s to (a) do some semantic checks,
(b) map quantities to the underlying elastic index.

Attributes:
Expand Down Expand Up @@ -66,9 +66,9 @@ def __repr__(self):


class Transformer(lark.Transformer):
""" Transformer that transforms ``v0.10.0`` grammer parse trees into queries.
"""Transformer that transforms ``v0.10.0`` grammer parse trees into queries.

Uses elasticsearch_dsl and will produce a :class:`Q` instance.
Uses elasticsearch_dsl and will produce a `Q` instance.
"""

def __init__(self, quantities: List[Quantity]):
Expand Down
28 changes: 15 additions & 13 deletions optimade/filtertransformers/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MongoTransformer(Transformer):
}

def __init__(self, mapper: BaseResourceMapper = None):
""" Initialise the object, optionally loading in a
"""Initialise the object, optionally loading in a
resource mapper for use when post-processing.

"""
Expand Down Expand Up @@ -71,7 +71,7 @@ def non_string_value(self, value):

@v_args(inline=True)
def not_implemented_string(self, value):
""" not_implemented_string: value
"""not_implemented_string: value

Raise NotImplementedError.
For further information, see Materials-Consortia/OPTIMADE issue 157:
Expand Down Expand Up @@ -231,8 +231,8 @@ def __default__(self, data, children, meta):
)

def _recursive_expression_phrase(self, arg):
""" Helper function for parsing `expression_phrase`. Recursively sorts out
the correct precedence for $and, $or and $nor.
"""Helper function for parsing `expression_phrase`. Recursively sorts out
the correct precedence for `$and`, `$or` and `$nor`.

"""
if len(arg) == 1:
Expand All @@ -258,7 +258,7 @@ def _recursive_expression_phrase(self, arg):
return {prop: {"$not": expr} for prop, expr in arg[1].items()}

def _apply_length_aliases(self, filter_: dict) -> dict:
""" Recursively search query for any $size calls, and check
"""Recursively search query for any `$size` operations, and check
if the property can be replaced with its corresponding length
alias.

Expand All @@ -283,7 +283,7 @@ def replace_with_length_alias(subdict, prop, expr):
)

def _apply_aliases(self, filter_: dict) -> dict:
""" Check whether any fields in the filter have aliases so
"""Check whether any fields in the filter have aliases so
that they can be renamed for the Mongo query.

"""
Expand All @@ -307,7 +307,7 @@ def apply_alias(subdict, prop, expr):
return recursive_postprocessing(filter_, check_for_alias, apply_alias)

def _apply_length_operators(self, filter_: dict) -> dict:
""" Check for any invalid pymongo queries that involve
"""Check for any invalid pymongo queries that involve
applying an operator to the length of a field, and transform
them into a test for existence of the relevant entry, e.g.
"list LENGTH > 3" becomes "does the 4th list entry exist?".
Expand Down Expand Up @@ -348,11 +348,13 @@ def apply_length_op(subdict, prop, expr):
return subdict

return recursive_postprocessing(
filter_, check_for_length_op_filter, apply_length_op,
filter_,
check_for_length_op_filter,
apply_length_op,
)

def _apply_relationship_filtering(self, filter_: dict) -> dict:
""" Check query for property names that match the entry
"""Check query for property names that match the entry
types, and transform them as relationship filters rather than
property filters.

Expand Down Expand Up @@ -394,14 +396,14 @@ def replace_with_relationship(subdict, prop, expr):
)

def _apply_unknown_or_null_filter(self, filter_: dict) -> dict:
""" This method loops through the query and replaces the check for
"""This method loops through the query and replaces the check for
KNOWN with a check for existence and a check for not null, and the
inverse for UNKNOWN.

"""

def check_for_known_filter(_, expr):
""" Find cases where the query dict looks like
"""Find cases where the query dict looks like
`{"field": {"#known": T/F}}` or
`{"field": "$not": {"#known": T/F}}`, which is a magic word
for KNOWN/UNKNOWN filters in this transformer.
Expand All @@ -412,7 +414,7 @@ def check_for_known_filter(_, expr):
)

def replace_known_filter_with_or(subdict, prop, expr):
""" Replace #known and $not->#known parsed filters with the appropriate
"""Replace #known and $not->#known parsed filters with the appropriate
CasperWA marked this conversation as resolved.
Show resolved Hide resolved
combination of $exists and/or $eq/$ne null.

"""
Expand Down Expand Up @@ -444,7 +446,7 @@ def replace_known_filter_with_or(subdict, prop, expr):


def recursive_postprocessing(filter_, condition, replacement):
""" Recursively descend into the query, checking each dictionary
"""Recursively descend into the query, checking each dictionary
(contained in a list, or as an entry in another dictionary) for
the condition passed. If the condition is true, apply the
replacement to the dictionary.
Expand Down
Loading