-
Notifications
You must be signed in to change notification settings - Fork 132
Reorganize World #207
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
Reorganize World #207
Conversation
|
Oh. My. God. :D I would vote for merging everything else first so I don't have to fix all of my PRs.^^ To make sure that there are no bugs left: How about you add another test that basically does what |
worldengine/draw.py
Outdated
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.
At this point I would suggest introducing a reference to the ocean at the very top of the function; it will make thinks more readable.
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.
done
|
Given this one would have quite an impact it would nice to have the opinion of @psi29a before merging it |
|
I looked over it once, comments above. I guess this should be merged as soon as possible, since it will break every piece of code that isn't already merged. (I would prefer if #188 and #203 could be merged first, so I don't have to invest more work... but overall it might even be easier if they were merged after this PR.) I also want to mention all the used "thresholds" again - it would be really nice if they could just be stored via for-loop. It would make it slightly easier to modify/add thresholds. |
|
About: I think that would not work because platec could give different results on different platforms (for example because of rounding or different optimization with floating numbers) |
|
Maybe if you started from a plate-only world? |
|
Great googly moogly... I'll give this an eye-ball around lunch today. Can you give a brief overview of what you are trying accomplish with this PR? That way I have a clue as to what I'm looking at. :) Not that what you've posted above isn't good enough, this is just a large PR. Message me on gtalk. |
|
GitHub did not told me you edited the comment... I will reach you on GTalk. The main idea is to put some order in the World class:
Each layer is an instance of Layer, LayerWithThresholds or LayerWithQuantiles. All of these classes have a field named data which is a numpy array. Then they could have also thresholds or quantiles :) The idea is to make layers to be more homogeneous: before world.elevation['data'] and world.ocean were numpy arrays. Now you would access both as world.layers['elevation'].data and world.layers['ocean'].data. When we add a new piece of information (e.g., wind) we just add a new layer. Aside from that I tried to use encapsulation when possible, so using method such as world.is_ocean(pos) instead of accessing directly variables (e.g., world.ocean[y, x] or world.elevation['data'][y, x]). This should make the code more explicit and more robust to changes. I left direct access to internal variables where it made sense for performance reasons. |
|
Since you mention performance, I wrote a little script yesterday. It accesses an array 50 million times via different means, that's around the order of accesses WorldEngine performs for a medium-sized world. An additional suggestion, to keep things clear and clean, would be to add new functions to def temperature(self, x1=None,y1=None,x2=None,y2=None):
return self.layers['temperature'].data[y1:y2+1, x1:x2+1]
def temperature(self):
return self.layers['temperature'].data
def layer(self, layer):
return self.layers[layer].dataSo when somebody wants to do fancy stuff with numpy, e.g. EDIT: I see you already had the same idea. I guess, this is the time and place to do this kind of stuff.^^ |
73380b4 to
027e4fa
Compare
|
We need to merge this one :) |
|
No real comments, and looks good to me. |
|
Great, thanks! |
This is an initial step to reorganize the World class. Other refactoring will follow but I thought it would be better to start discussing and merging this one.
Now most of data is grouped either under generation_params or in layers.
A Layer represent a piece of information available for each cell. Each layer has a matrix of data, some of them have also thresholds while others have quantiles.
The idea is to treat layers in the more homogeneous way possible.