Skip to content

Instantly share code, notes, and snippets.

@parmentelat
Created March 24, 2017 09:25
Show Gist options
  • Save parmentelat/a1e2d10a2461e47853c77a095316222c to your computer and use it in GitHub Desktop.
Save parmentelat/a1e2d10a2461e47853c77a095316222c to your computer and use it in GitHub Desktop.
import pandas as pd
from minisim import Infiltration, Inhabitant, Zone, Weather
import pytest
# using an instance to pass global-like variables among tests
class Vars: pass
@pytest.fixture
def basic_variables():
infiltration = Infiltration("infiltration", 5)
bob = Inhabitant('Bob', 36000)
mary = Inhabitant ('Mary', 36000)
dilbert = Inhabitant('Dilbert', 4000)
weather1 = Weather(400)
weather2 = Weather(800)
hourly_2hours = pd.date_range('1/1/2017', periods = 2, freq = 'H')
hourly_2days = pd.date_range('1/1/2017', periods = 2*24, freq = 'H')
hourly_2weeks = pd.date_range('1/1/2017', periods = 2*7*24, freq = 'H')
vars = Vars()
vars.__dict__ = locals()
return vars
def test_zone_basic(basic_variables):
vars = basic_variables
infiltration = vars.infiltration
bob = vars.bob
mary = vars.mary
weather = vars.weather
date_range = vars.hourly_2hours
zone = Zone(50, infiltration, inhabitants = [bob])
zone.add_inhabitants(mary)
simulation = zone.simulate(date_range, weather, 400)
print(simulation)
import pandas as pd
from minisim import Infiltration, Inhabitant, Zone, Weather
import pytest
@pytest.fixture
def basic_variables():
infiltration = Infiltration("infiltration", 5)
bob = Inhabitant('Bob', 36000)
mary = Inhabitant ('Mary', 36000)
dilbert = Inhabitant('Dilbert', 4000)
weather1 = Weather(400)
weather2 = Weather(800)
hourly_2hours = pd.date_range('1/1/2017', periods = 2, freq = 'H')
hourly_2days = pd.date_range('1/1/2017', periods = 2*24, freq = 'H')
hourly_2weeks = pd.date_range('1/1/2017', periods = 2*7*24, freq = 'H')
return locals()
def test_zone_basic(basic_variables):
vars = basic_variables
infiltration, bob, mary, weather, hourly_2weeks = **vars
zone = Zone(50, infiltration, inhabitants = [bob])
zone.add_inhabitants(mary)
simulation = zone.simulate(date_range, weather, 400)
print(simulation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment