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

♻️ Refactor DatasetModel to use properties #828

Closed
s-weigand opened this issue Sep 18, 2021 · 6 comments
Closed

♻️ Refactor DatasetModel to use properties #828

s-weigand opened this issue Sep 18, 2021 · 6 comments
Labels
Status: Lack of interest Issue went stale | cold | lack of (user) interest Type: Refactor Refactoring code
Milestone

Comments

@s-weigand
Copy link
Member

s-weigand commented Sep 18, 2021

Version information

  • pyglotaran version: main (2f1afe7)
  • Python version: all
  • Operating System: all

Describe the refactoring

Currently DatasetModel uses a lot of get_ and set_ methods

def set_coordinates(self, coords: dict[str, np.ndarray]):
"""Sets the dataset model's coordinates."""
self._coords = coords
def get_coordinates(self) -> dict[Hashable, np.ndarray]:
"""Gets the dataset model's coordinates."""
return self._coords

The same functionality could be achieved using properties and setter.

Using get_ and set_ is c++ like from the 90's, we have nice syntax sugar let's use it.

In [4]: import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
...

Additional context

Besides refactoring of glotaran/model/dataset_model.py this will need additional changes to the tests and where it is used.

@s-weigand s-weigand added Type: Refactor Refactoring code Status: Available Can be picked up to work on good first issue Good for newcomers labels Sep 18, 2021
@fidelak
Copy link

fidelak commented Sep 18, 2021

Would you mind if I worked on this one?

@s-weigand s-weigand added this to the v0.5.0 milestone Sep 18, 2021
@s-weigand s-weigand removed the good first issue Good for newcomers label Sep 18, 2021
@s-weigand
Copy link
Member Author

@fidelak Sorry, I just talked to @joernweissenborn and this issue is quite tricky since it requires to interact with our runtime "decorator magic" (code that writes code).
But #807 should be a good first issue.

@fidelak
Copy link

fidelak commented Sep 18, 2021

@s-weigand I assume you're talking about the follow up in #815? I will give it a shot

@s-weigand s-weigand removed the Status: Available Can be picked up to work on label Sep 18, 2021
@s-weigand
Copy link
Member Author

Oops, yes I meant #815 ofc 😅
@fidelak Thanks for contributing 😄

@s-weigand s-weigand modified the milestones: v0.5.0, v1.0.0 Sep 18, 2021
@stale
Copy link

stale bot commented Jun 19, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Lack of interest Issue went stale | cold | lack of (user) interest label Jun 19, 2023
Copy link

stale bot commented Dec 19, 2023

This issue has been closed due to lack of recent activity. Please open a new issue if you're still encountering this problem. Thanks for your contributions!

@stale stale bot closed this as completed Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Lack of interest Issue went stale | cold | lack of (user) interest Type: Refactor Refactoring code
Projects
None yet
Development

No branches or pull requests

2 participants