-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Issue-132: Revert API changes introduces with #86 #163
Conversation
Coverage Report
|
Unfortunately |
But this is fixed by moving Btw: The reason seems to be the following, I didn't know that either.
|
Yes, that has already been adjusted. |
Done |
The class LuxtronikData:
[...]
@classmethod
def deepcopy(cls, data):
return LuxtronikData(deepcopy(data.parameters), deepcopy(data.calculations), deepcopy(data.visibilities)) With this addition, consider this snippet: from luxtronik import LuxtronikData
import copy
import timeit
l = LuxtronikData()
l.parameters.get(0).raw = 1
print("l.parameters.get(0).raw =", l.parameters.get(0).raw)
l2 = LuxtronikData.copy(l)
l3 = copy.copy(l)
l4 = copy.deepcopy(l)
l5 = LuxtronikData.deepcopy(l)
print("===")
l.parameters.get(0).raw = 2
print("l.parameters.get(0).raw =", l.parameters.get(0).raw)
print("l2.parameters.get(0).raw =", l2.parameters.get(0).raw)
print("l3.parameters.get(0).raw =", l3.parameters.get(0).raw)
print("l4.parameters.get(0).raw =", l4.parameters.get(0).raw)
print("l5.parameters.get(0).raw =", l5.parameters.get(0).raw)
print("===")
num = 100
s = """
from luxtronik import LuxtronikData
import copy
l = LuxtronikData()
"""
print(timeit.timeit('l2 = LuxtronikData.copy(l)', setup=s, number=num)/num)
print(timeit.timeit('l3 = copy.copy(l)', setup=s, number=num)/num)
print(timeit.timeit('l4 = copy.deepcopy(l)', setup=s, number=num)/num)
print(timeit.timeit('l5 = LuxtronikData.deepcopy(l)', setup=s, number=num)/num) Output for me:
Thus:
I think that we can also drop class LuxtronikData:
"""
Collection of parameters, calculations and visiblities.
Also provide some high level access functions to their data values.
"""
def __init__(self, parameters=None, calculations=None, visibilities=None, safe=True):
self.parameters = Parameters(safe) if parameters is None else parameters
self.calculations = Calculations() if calculations is None else calculations
self.visibilities = Visibilities() if visibilities is None else visibilities |
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that I am (almost) satisfied with the changes in __init__.py
. (I didn't check the other files yet.)
Thanks for the great work!
0de5bd8
to
8a0bcde
Compare
Done |
LGTM I highly like the fact that we unbreak the API 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, only two minor things are left. And the commit message "Add a decorator to provide the previous api" might be a copy-and-paste leftover from the last PR?
I am looking forward to merging this.
ce7ed46
to
3d824e0
Compare
Now use the title of this pull-request. |
I think everything is resolved and ready. I'll merg it. |
With #86 we split the data from the read/write interface.
However, these changes mean that the existing program needs to be adjusted.
With this pull-request we restore the previous api by:
This allows both the old and the new API to be used.
Fix #132
NOTE: The linter added some format changes.