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

Improve test coverage #231

Open
7 of 18 tasks
fneum opened this issue Apr 30, 2021 · 12 comments
Open
7 of 18 tasks

Improve test coverage #231

fneum opened this issue Apr 30, 2021 · 12 comments

Comments

@fneum
Copy link
Member

fneum commented Apr 30, 2021

There are some modules where test coverage can improve. Let's target step by step:

io:

components:

  • madd()
  • mremove()
  • copy()
  • __getitem__() aka network[:,:]
  • consistency_check()

linopt:

  • get_sol()
  • get_dual()

linopf:

  • ramp limits
  • store constraints
  • global constraints
  • ilopf()

opf:

  • ramp limits, shut down, start up

pf:

  • sub_network_pf_singlebus()
  • aggregate_multi_graph()

as well as

  • networkclustering
  • plots
  • stats
@fneum
Copy link
Member Author

fneum commented Jul 8, 2021

@rockstaedt
Copy link
Contributor

Hey! I would like to contribute to this issue :) Can you recommend any unit/function I could start with?

@FabianHofmann
Copy link
Collaborator

Great @rockstaedt! It depends a bit on how deep you are in the pypsa code. I'd say for a first step try to tackle the functions madd and mremove.
For madd:

  1. Test that components are actually added to the static as well as the time dependent dataframe (e.g. n.generators_t.p_max_pu). This can be done via checking the index.
  2. Check that defaults are set correctly. These come from n.component_attrs and should fill values which are not specified in madd (only test one or two single values)
  3. madd should fail with a misspelled component (something like 'Gnerators')
  4. Re-adding the same generator name should fail
    ...

For mremove:

  1. Check that components are actually removed from static and time-dependent
  2. Removal of non-existent components should fail
  3. Removal with misspelled component names should fail

The test functions could go into a new test script like test_components.py.

@rockstaedt
Copy link
Contributor

Great! Thanks 👍🏼 I'm on it!

rockstaedt added a commit to rockstaedt/PyPSA that referenced this issue Jul 19, 2021
@rockstaedt
Copy link
Contributor

rockstaedt commented Jul 19, 2021

In the above commit, I created the unit tests for mremove().

How do you want to proceed? Should I already open a pull request?

I would be happy about every feedback :)

@FabianHofmann
Copy link
Collaborator

Wonderful @rockstaedt, looks clean are usable! If you want, you can start a PR in draft mode and continue adding things (at least the madd would be good). As soon as you think you are ready we review and pull it in.

@rockstaedt
Copy link
Contributor

Sounds good! I'll draft the pull request and continue with madd() 👍🏼

@rockstaedt
Copy link
Contributor

Tests for madd() are also done 👍🏻

FabianHofmann added a commit that referenced this issue Jul 26, 2021
* Add tests for mremove #231

* Add tests for madd

* Use a subset for generator components

* Remove test_mremove_non_component

Test function was removed because it has the same test behaviour as test_mremove_misspelled_component.

* Use pandas series instead of list

* Strengthen assertion

* Rename function for better understanding

Co-authored-by: Fabian Hofmann <hofmann@fias.uni-frankfurt.de>
@fneum fneum pinned this issue Jan 2, 2022
@pz-max
Copy link
Contributor

pz-max commented Jun 7, 2022

@LukasFrankenQ and @pz-max will take care of at least one test as well

@rockstaedt
Copy link
Contributor

Just finished my master thesis and have some time now. I could also do some unit tests. Any recommendations?

@FabianHofmann
Copy link
Collaborator

hey @rockstaedt, that would be wonderful! How about copy and __get_item__() for a start?

@FabianHofmann
Copy link
Collaborator

@rockstaedt, if you scroll down here https://app.codecov.io/gh/PyPSA/PyPSA and open up the pypsa folder, you see the coverage of the individual modules, e.g. descriptors and networkclustering have quite low coverage. That should be tackled as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants