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

Implemented network generation. #27

Merged
merged 12 commits into from
Nov 18, 2024
Merged

Implemented network generation. #27

merged 12 commits into from
Nov 18, 2024

Conversation

vanlankveldthijs
Copy link
Contributor

Resolves issue #16

Can switch between Delaunay and 'redundant' networks.

Also comes with a demo notebook, but this does not have extensive documentation or explanation (yet).

Copy link

@FreekvanLeijen FreekvanLeijen left a comment

Choose a reason for hiding this comment

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

Hi Thijs, looks nice! I added some remarks.

pydepsi/network.py Outdated Show resolved Hide resolved
pydepsi/network.py Outdated Show resolved Hide resolved
min_length: float, minimum length of any generated arc.
max_length: float, maximum length of any generated arc or None.
max_links: int, maximum number of arcs per node for the redundant method.
num_groups: int, number of parts to split the orientations around each node into for the redundant method.

Choose a reason for hiding this comment

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

Please rename to num_parts (like in original implementation, indicates 'partitions', i.e., sub-division.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed the 'groups' arguments and variables to 'partitions'.
I generally don't like shortening terms unless they are extremely common. In code, clarity usually trumps brevity.

However, I could still change this to 'parts' if you still prefer this.

pydepsi/network.py Outdated Show resolved Hide resolved
Copy link
Member

@rogerkuou rogerkuou left a comment

Choose a reason for hiding this comment

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

Thanks @vanlankveldthijs for the nice implementation! I have some comments but they are all very minor.

Apart from the in line comments, can you also add some unit tests to the functions? Thanks!

arcs: list of pairs, point indices describing the adjacent nodes. The pairs are sorted, as is the list.
"""
if min_length <= 0:
print(f"min_length must be positive (currently: {min_length})")
Copy link
Member

Choose a reason for hiding this comment

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

I like the screen feedbacks! For consitency and good practice, consider using Python logger? This allow the user to access these information later.

You can find an example of using logger for warning in stmtools io module. Here we can simply using info.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I replaced the print messages by logger messages.

However, testing shows that info messages do not show in the example notebook when an invalid argument is provided. Instead the code will fail because of incorrect return values without any message with the reason.

When using logger.warning, the example notebook displays these messages as desired.
I set them to 'warning' instead of 'info'. Let me know if I should make them 'info' regardless.

Copy link
Member

@rogerkuou rogerkuou Nov 11, 2024

Choose a reason for hiding this comment

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

Hi Thijs @vanlankveldthijs , I think we shoud still use info, since the information here are not warning messages.

By default, Jupyter kernel uses warning as default level. I guess that's why the info does not should up. Maybe try the following setting in your Notebook? I think they will enable displaying the INFO messages.

import logging
logging.basicConfig(level=logging.INFO)

Copy link
Member

Choose a reason for hiding this comment

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

@vanlankveldthijs sorry given another look in the context, I realized maybe the information here should be error?maybe let update that?

pydepsi/network.py Outdated Show resolved Hide resolved
pydepsi/network.py Show resolved Hide resolved
pydepsi/network.py Outdated Show resolved Hide resolved
@vanlankveldthijs
Copy link
Contributor Author

vanlankveldthijs commented Oct 24, 2024

Added unit tests for network.py

To enable these, I had to add some test data to the repository.
Normally, it isn't recommended to add binary data to a git repository.
However, I don't expect this data to ever be changed, so its impact should be limited. I also chose to add the 'sparsified' dataset (see example notebook) instead of the full input dataset. This reduces the storage space from +/-26M to 391K.

@rogerkuou
Copy link
Member

rogerkuou commented Nov 11, 2024

Added unit tests for network.py

To enable these, I had to add some test data to the repository. Normally, it isn't recommended to add binary data to a git repository. However, I don't expect this data to ever be changed, so its impact should be limited. I also chose to add the 'sparsified' dataset (see example notebook) instead of the full input dataset. This reduces the storage space from +/-26M to 391K.

Thanks Thijs! I replied in the logging comment. However I did not see the unit tests. Maybe you forgot to push them? (or maybe I missed them?)

@vanlankveldthijs
Copy link
Contributor Author

Added unit tests for network.py
To enable these, I had to add some test data to the repository. Normally, it isn't recommended to add binary data to a git repository. However, I don't expect this data to ever be changed, so its impact should be limited. I also chose to add the 'sparsified' dataset (see example notebook) instead of the full input dataset. This reduces the storage space from +/-26M to 391K.

Thanks Thijs! I replied in the logging comment. However I did not see the unit tests. Maybe you forgot to push them? (or maybe I missed them?)

I may have forgot to push the tests. They should be there now :)

@rogerkuou
Copy link
Member

Hi @vanlankveldthijs, thanks! The unit test are all good! I did one change myselft to merge your test data file into one chunk to reduce the number of files. In order to eliminate the files from history, I overrite your last commit.

I have one more minor comment on the logging. I suggest to use error, seem the above comments. Please feel free to adapt it or not. The others are all good to merge!

@vanlankveldthijs vanlankveldthijs merged commit d44b352 into main Nov 18, 2024
9 checks passed
@vanlankveldthijs vanlankveldthijs deleted the 16_generate_arcs branch November 18, 2024 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants