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 |
gerw
left a comment
There was a problem hiding this comment.
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 😄 |
gerw
left a comment
There was a problem hiding this comment.
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.