Skip to content

Commit

Permalink
Fix Typos
Browse files Browse the repository at this point in the history
  • Loading branch information
janssenhenning committed Jan 22, 2021
1 parent 01aadb2 commit 278e14f
Showing 1 changed file with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
"cells": [
{
"cell_type": "markdown",
"id": "accredited-pierce",
"id": "enclosed-shakespeare",
"metadata": {},
"source": [
"## Using the parsing functions in the `schema_dict_util` module\n",
"\n",
"The output parser uses a set of functions to perform the actual parsing. But even outside the output parser they can be very useful."
"The output parser uses a small set of functions to perform the actual parsing. But even outside the output parser they can be very useful."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "opponent-andorra",
"id": "fantastic-essex",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -22,16 +22,16 @@
},
{
"cell_type": "markdown",
"id": "sealed-occupation",
"id": "exempt-reliance",
"metadata": {},
"source": [
"This module contains a lot of different small functions, which make use of the schema dictionary. For example the `get_tag_xpath` and `get_attrib_xpath` functions from tutorial 3 are defined here. Then there is `read_constants`, which determines the mathemtical constants which can be used in the input file. The rest of the functions make s use of `get_tag_xpath` or `get_attrib_xpath` to gain easy access to parsing small parts of the xml files"
"This module contains a lot of different small functions, which make use of the schema dictionary. For example the `get_tag_xpath` and `get_attrib_xpath` functions from tutorial 3 are defined here. Then there is `read_constants`, which determines the mathematical constants which can be used in the input file. The rest of the functions make use of `get_tag_xpath` or `get_attrib_xpath` to gain easy access to small parts of the xml files"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "herbal-symbol",
"id": "married-journalism",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -40,39 +40,40 @@
},
{
"cell_type": "markdown",
"id": "designed-poker",
"id": "considerable-uncle",
"metadata": {},
"source": [
"To use these functions, we need to get the root of the xml file and the right schema_dict. For functions actually converting attribute values we also need to read in the defined constants (In additiona to defined constants there is also a default set)"
"To use these functions, we need to get the root of the xml file and the right schema_dict. For functions actually converting attribute values we also need to read in the defined constants (In addition to defined constants in the `inp.xml` there is also a default set)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "exceptional-chancellor",
"id": "immediate-visitor",
"metadata": {},
"outputs": [],
"source": [
"from lxml import etree\n",
"from masci_tools.io.parsers.fleur.fleur_schema import load_inpschema\n",
"from masci_tools.util.schema_dict_util import read_constants\n",
"\n",
"root = etree.parse('./files/Fe_Example_input.xml').getroot()\n",
"schema_dict = load_inpschema(root.xpath('//@fleurInputVersion')[0])\n",
"constants = read_constants(root, schema_dict)"
]
},
{
"cell_type": "markdown",
"id": "efficient-championship",
"id": "lovely-photography",
"metadata": {},
"source": [
"All parsing functions have the same interface. Let's start with tag_exists. This will tell us if a certain tag is present in the input file"
"All parsing functions have the same interface. Let's start with `tag_exists`. This will tell us if a certain tag is present in the file"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "incident-premiere",
"id": "accompanied-myanmar",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -83,7 +84,7 @@
},
{
"cell_type": "markdown",
"id": "waiting-lucas",
"id": "hindu-engineering",
"metadata": {},
"source": [
"These functions also take the same arguments as `get_tag_xpath` for specifying the concrete path"
Expand All @@ -92,7 +93,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "seventh-testing",
"id": "strange-refrigerator",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -103,7 +104,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "shaped-oxford",
"id": "third-pendant",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -112,7 +113,7 @@
},
{
"cell_type": "markdown",
"id": "unlimited-engagement",
"id": "super-deadline",
"metadata": {},
"source": [
"The function `evaluate_attribute` also allows to directly specify the tag, where the attribute should be parsed. This makes specifying attributes with common names a lot easier (like `units` in the output file for example)"
Expand All @@ -121,7 +122,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "governing-dodge",
"id": "based-little",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -131,7 +132,7 @@
},
{
"cell_type": "markdown",
"id": "meaningful-disorder",
"id": "southern-complexity",
"metadata": {},
"source": [
"Another option for specifying, which path is supposed to be parsed is using a Element of the xml tree, that is not the root. For example if we would want to parse the `mtSphere` tag for the atom species the naive approch would throw an error since all tags in the atoms section can occur in `species` or `atomGroup`."
Expand All @@ -140,7 +141,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "foster-image",
"id": "hydraulic-reducing",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -150,19 +151,19 @@
},
{
"cell_type": "markdown",
"id": "residential-progress",
"id": "acceptable-intake",
"metadata": {},
"source": [
"One easy way to circumvent this, is to first get the `species` element via the `eval_simple_xpath` function and then performing the same call as before on the `species` element.\n",
"If any of these parsing functions sees a element different from the root element it will constrain the path to contain the tag of that element. Subsequently the absolute path is converted into a relative path starting at the given element.\n",
"\n",
"The alternative is to add `contains=species` but if there are sections with lots of calls for species attributes Then this approach will definitely be less cumbersome."
"The alternative is to add `contains=species` but if there are sections with lots of calls for species attributes the above approach will definitely be less cumbersome."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "exterior-cricket",
"id": "postal-partition",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -173,7 +174,7 @@
},
{
"cell_type": "markdown",
"id": "vertical-contest",
"id": "acoustic-harvey",
"metadata": {},
"source": []
}
Expand Down

0 comments on commit 278e14f

Please sign in to comment.