77from numpy .testing import assert_allclose
88
99
10- class TestExamples :
11-
12- def test_basic_example_flh (self ):
13- # tests full load hours
14- weather = be .get_weather_data ('weather.csv' )
15- my_turbine , e126 = be .initialise_wind_turbines ()
16- be .calculate_power_output (weather , my_turbine , e126 )
17-
18- assert_allclose (1766.6870 , (e126 .power_output .sum () /
19- e126 .nominal_power ), 0.01 )
20- assert_allclose (1882.7567 , (my_turbine .power_output .sum () /
21- my_turbine .nominal_power ), 0.01 )
22-
23- def _notebook_run (self , path ):
24- """
25- Execute a notebook via nbconvert and collect output.
26- Returns (parsed nb object, execution errors)
27- """
28- dirname , __ = os .path .split (path )
29- os .chdir (dirname )
30- with tempfile .NamedTemporaryFile (suffix = ".ipynb" ) as fout :
31- args = ["jupyter" , "nbconvert" , "--to" , "notebook" , "--execute" ,
32- "--ExecutePreprocessor.timeout=60" ,
33- "--output" , fout .name , path ]
34- subprocess .check_call (args )
35-
36- fout .seek (0 )
37- nb = nbformat .read (fout , nbformat .current_nbformat )
38-
39- errors = [output for cell in nb .cells if "outputs" in cell
40- for output in cell ["outputs" ]
41- if output .output_type == "error" ]
42-
43- return nb , errors
44-
45- def test_basic_example_ipynb (self ):
46- dir_path = os .path .dirname (os .path .realpath (__file__ ))
47- nb , errors = self ._notebook_run (os .path .join (dir_path ,
48- 'basic_example.ipynb' ))
49- assert errors == []
10+ # class TestExamples:
11+ #
12+ # def test_basic_example_flh(self):
13+ # # tests full load hours
14+ # weather = be.get_weather_data('weather.csv')
15+ # my_turbine, e126 = be.initialise_wind_turbines()
16+ # be.calculate_power_output(weather, my_turbine, e126)
17+ #
18+ # assert_allclose(1766.6870, (e126.power_output.sum() /
19+ # e126.nominal_power), 0.01)
20+ # assert_allclose(1882.7567, (my_turbine.power_output.sum() /
21+ # my_turbine.nominal_power), 0.01)
22+ #
23+ # def _notebook_run(self, path):
24+ # """
25+ # Execute a notebook via nbconvert and collect output.
26+ # Returns (parsed nb object, execution errors)
27+ # """
28+ # dirname, __ = os.path.split(path)
29+ # os.chdir(dirname)
30+ # with tempfile.NamedTemporaryFile(suffix=".ipynb") as fout:
31+ # args = ["jupyter", "nbconvert", "--to", "notebook", "--execute",
32+ # "--ExecutePreprocessor.timeout=60",
33+ # "--output", fout.name, path]
34+ # subprocess.check_call(args)
35+ #
36+ # fout.seek(0)
37+ # nb = nbformat.read(fout, nbformat.current_nbformat)
38+ #
39+ # errors = [output for cell in nb.cells if "outputs" in cell
40+ # for output in cell["outputs"]
41+ # if output.output_type == "error"]
42+ #
43+ # return nb, errors
44+ #
45+ # def test_basic_example_ipynb(self):
46+ # dir_path = os.path.dirname(os.path.realpath(__file__))
47+ # nb, errors = self._notebook_run(os.path.join(dir_path,
48+ # 'basic_example.ipynb'))
49+ # assert errors == []
0 commit comments