-
Notifications
You must be signed in to change notification settings - Fork 40
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: set up flexibility for multiple versions of MATReader #148
Conversation
|
You use f-strings in grid.py and profiles.py. While I like it, it can be problematic when the package is installed on the server where Python 3.5.2 is installed. I had to generate a wind profile on the server this morning and I had to edit prereise/gather/winddata/rap/power_curves to refactor a couple of f-strings. |
@rouille the point of the Without that line, all tests pass, but the
We could make this logic more clear by defining this method for |
The docstring for Grid has been updated, and all f-strings removed. |
Types have been updated for the columns being read from the matfiles (see: #144). There were many places where we had columns full of zeros, but they should have been |
Good point. I would recommend to define the |
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.
Nice work.
fcc4174
to
626dc30
Compare
Purpose
Set up flexibility to use one of many different MATReader sub-classes, depending on the engine that was used to run the scenario and produce the
input.mat
file.What is the code doing
In
mat_reader.py
, moving the existing_build_network()
code to a new subclass:REISEMATReader
.In
profiles.py
, changing the return type ofget_data()
and_read_data()
when given a.mat
extension. Instead of loading theinput.mat
file to instantiate and return aGrid
, we just return the path to the.mat
file (still trying to open it, and downloading it from the server if needed), because we don't know in here how we should interpret theinput.mat
file to produce a grid.In
analyze.py
, adaptingget_grid()
now that using theInputData
method returns a path to aninput.mat
file. We use our knowledge about the scenario to then instantiate a Grid, passing theengine
used as an additional parameter.In
grid.py
, adding a new parameter to Grid instantiation:engine
, to specify which engine was used to create aninput.mat
file if we are not creating a Grid fromusa_tamu
. Thisengine
parameter will determine which type of MATReader subclass to use to read the matfile. Currently only'REISE'
is a valid choice, which points to our new REISEMATReader class, and any other choice will throw an error.Testing
All unit tests pass:
An integration test passes, whether the file has already been downloaded or not:
Time to review
One hour. There aren't many lines of code that have changed, but the changes are in several different files/objects that have to do a graceful dance for
get_grid()
to always work.