ADGEfficiency / energy-py-linear

Optimize energy assets using mixed-integer linear programming
GNU General Public License v3.0
89 stars 27 forks source link

Remove Pandas and NumPy #1

Closed tomharvey closed 5 years ago

tomharvey commented 5 years ago

Removing Pandas and Numpy as dependancies.

These are both pretty large and aren't adding anything substantial to the library. Users of the library and dependant code bases will be happier for it.

I've added a test to the output of the view. I've written the test such as it will check for equality when changing the output from a DataFrame to a Dict. There is def room for better refactoring of that test (and other parts)

Type Changes

The result is no longer a DataFrame, but a Dict. When using the library, we can do what we want with this Dict, including pd.DataFrame(dict), or write to a csv, or just pull certain parts out of it.

Instead of applying formula to Series, I'm looping through each result and cleaning the data to insert into the result set. It gets rid of a lot of the use of iloc which will be unfamiliar to non-pandas users and instead of info.loc[:, 'Import [MW]'] - info.loc[:, 'Export [MW]'] we can have import - export. Hopefully it makes for more readable code.

Lots of NumPy in the test suite was being used to do things like compare lists, or fuzzy compare. Here, I've used list comprehensions and routing to achieve the same thing.

NumPy was also being used for it's NaN. I've used None instead.

Setup Changes

I've added pulp as an install_requires. listing requirements in setup.py instead of requirements will make it easier to use as a pip installable library.

And, I've added an alias for pytest so the test suite can be run with python setup.py test

ADGEfficiency commented 5 years ago

Thanks pal!