Skip to content

Fix/transformer component definition#596

Merged
smartie2076 merged 13 commits intodevfrom
fix/transformer_component_definition
Nov 5, 2020
Merged

Fix/transformer component definition#596
smartie2076 merged 13 commits intodevfrom
fix/transformer_component_definition

Conversation

@SabineHaas
Copy link
Copy Markdown
Contributor

@SabineHaas SabineHaas commented Oct 8, 2020

Fix #333
Fix #389
Fix #246

Changes proposed in this pull request:

  • All variable_costs, efficiency and nominal_value of transformers on output flows
  • Add and fix tests

The following steps were realized, as well (if applies):

  • Use in-line comments to explain your code
  • Write docstrings to your code (example docstring)
  • ❌ For new functionalities: Explain in readthedocs
  • Write test(s) for your new patch of code (pytests, assertion debug messages)
  • Update the CHANGELOG.md
  • Apply black (black . --exclude docs/)
  • Check if benchmark tests pass locally (EXECUTE_TESTS_ON=master pytest)

Please mark above checkboxes as following:

  • Open
  • Done

❌ Check not applicable to this PR

For more information on how to contribute check the CONTRIBUTING.md.

@SabineHaas SabineHaas requested a review from smartie2076 October 8, 2020 08:57
@SabineHaas SabineHaas self-assigned this Oct 8, 2020
@SabineHaas
Copy link
Copy Markdown
Contributor Author

I've just realized that in the documentation there's an example for an electrolyzer that works differently.. maybe it's worth to talk about it. Let me know when you have time @smartie2076

@SabineHaas
Copy link
Copy Markdown
Contributor Author

I've just realized that in the documentation there's an example for an electrolyzer that works differently.. maybe it's worth to talk about it. Let me know when you have time @smartie2076

moved to issue #599
So, this PR is ready for review.

Copy link
Copy Markdown
Collaborator

@smartie2076 smartie2076 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did go commit by commit now to ease the process, but I am not sure how comments are presented when you afterwards changed the specific parts of code I commented on. There may be outdated comments.

Commit ebece71 was a bit big to be reviewed.

What do you mean with "cry for benchmark tests" in b292bd4?

Can you add more info on how transformers are modeled and what the parameters mean in the RTD? Both in Modell_Assumptions.rst and in the parameter description for efficiency as a specific case. Do you have knowledge to share how to use multilple in/outputs?

"value": 10
}
},
"transformer_optimize_multiple_output_busses": {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment to this file: I like to define this dict directly in the pytest files, because then we do not need to check if the stuff around it is important. Not sure if that works for you, though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the beginning I defined only needed data in the json file, which was already a lot, which is why I didn't define the dictionaries in the python file. You have added the information around once (was necessary for other tests / completeness of input data.... I don't remember well). So, now I'm a bit confused - I thought the stuff around was necessary - would you remove it again?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bachibouzouk correct me if I am wrong, but I think if it is a json file, then the json must be a complete input file with all parameters. If you define it in the pytest directly, then it does not have to be complete. If all of that is needed for the test/it is too much to define in the py file, then we should leave it as is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all of it is needed, but also before entries were added to make the json complete it was too much to define in the py file, to my mind. So, I would leave it as it is.

@smartie2076
Copy link
Copy Markdown
Collaborator

Ah, and in the D1.transfomer functions (and the subsequent ones), can you add under Notes in the docstrings, with which pytests the function is tested?

@smartie2076
Copy link
Copy Markdown
Collaborator

Executing all pytests locally results in an error:

[...]

======================================================================== FAILURES =========================================================================
________________________________ test_input_folder_json_file_have_required_parameters[d:\\pycharmprojects\\mvs_eland\\in] _________________________________

input_folder = 'd:\\pycharmprojects\\mvs_eland\\in'

    @pytest.mark.parametrize("input_folder", TEST_JSON_INPUT_FOLDERS)
    def test_input_folder_json_file_have_required_parameters(input_folder):
        """
        Browse all folders which contains a {CSV_ELEMENTS} folder and a {JSON_FNAME} json file
        (defined as json input folders) and verify that this json file have all required
        parameters
        """
        if os.path.exists(os.path.join(input_folder, JSON_FNAME)):
>           comparison = compare_input_parameters_with_reference(input_folder, ext=JSON_EXT)

tests\test_input_folder_parameters.py:72:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src\multi_vector_simulator\utils\__init__.py:111: in compare_input_parameters_with_reference
    main_parameters = json.load(fp)
win_venv\lib\json\__init__.py:296: in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
win_venv\lib\json\__init__.py:348: in loads
    return _default_decoder.decode(s)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <json.decoder.JSONDecoder object at 0x00000285F077FD08>
s = '{\n    "constraints": {\n        "minimal_renewable_share": {\n            "unit": "factor",\n            "value": 0....e": false\n        },\n\t\t"tim
estep": {\n            "unit": "minutes",\n            "value": 60\n        }\n    }\n}'
_w = <built-in method match of re.Pattern object at 0x00000285F0742C30>

    def decode(self, s, _w=WHITESPACE.match):
        """Return the Python representation of ``s`` (a ``str`` instance
        containing a JSON document).

        """
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
        end = _w(s, end).end()
        if end != len(s):
>           raise JSONDecodeError("Extra data", s, end)
E           json.decoder.JSONDecodeError: Extra data: line 219 column 10 (char 7483)

win_venv\lib\json\decoder.py:340: JSONDecodeError

[...]

================================================================= short test summary info =================================================================
FAILED tests/test_input_folder_parameters.py::test_input_folder_json_file_have_required_parameters[d:\\pycharmprojects\\mvs_eland\\in] - json.decoder.JSO...

============================================ 1 failed, 276 passed, 2 skipped, 15 warnings in 263.59s (0:04:23) ============================================

@SabineHaas
Copy link
Copy Markdown
Contributor Author

I did go commit by commit now to ease the process, but I am not sure how comments are presented when you afterwards changed the specific parts of code I commented on. There may be outdated comments.

Commit ebece71 was a bit big to be reviewed.

What do you mean with "cry for benchmark tests" in b292bd4?

I think it doesn't make sense to check the creation of transformers with efficiency as time series for all cases all over again - I thought if we want to test this we would have to do it in a benchmark test.

Can you add more info on how transformers are modeled and what the parameters mean in the RTD? Both in Modell_Assumptions.rst

added

and in the parameter description for efficiency as a specific case.

It already says "Ratio of energy output/energy input." there, this accounts for a transformer, as well.

Do you have knowledge to share how to use multilple in/outputs?

Only how to define them, as explained here. I haven't used a transformer with multiple in- or outflows, yet.

@SabineHaas
Copy link
Copy Markdown
Contributor Author

Executing all pytests locally results in an error:

I don't get any error. But also didn't before I changed parts of the code - so maybe you should run the tests again to be sure.

@Bachibouzouk
Copy link
Copy Markdown
Collaborator

'd:\pycharmprojects\mvs_eland\in'

@smartie2076 , the error is only local because it looks into one of the input files it found in your path (cf above).

when tests/test_input_folder_parameters.py fails you have to look at which folder is in there, it might be (like here) a local folder

@smartie2076
Copy link
Copy Markdown
Collaborator

I think it doesn't make sense to check the creation of transformers with efficiency as time series for all cases all over again - I thought if we want to test this we would have to do it in a benchmark test.

It also is in a benchmark test, I believe.

Do you have knowledge to share how to use multilple in/outputs?

Only how to define them, as explained here. I haven't used a transformer with multiple in- or outflows, yet.

Acknowledged, we can see when implementing more benchmark tests.

Copy link
Copy Markdown
Collaborator

@smartie2076 smartie2076 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! If I am right, you only had to add assertion messages and notes where you test which functions. Thats all good!

I would add the sentence about the changed D1 functions in the changelog.md, but yeah...

@smartie2076 smartie2076 merged commit 6a7286b into dev Nov 5, 2020
@smartie2076 smartie2076 deleted the fix/transformer_component_definition branch November 5, 2020 09:51
@smartie2076 smartie2076 mentioned this pull request Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants