-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #299 from dyson-ai/feature/fix_graph_units
Feature/fix graph units
- Loading branch information
Showing
7 changed files
with
127 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import unittest | ||
import bencher as bch | ||
|
||
from bencher.example.example_meta import BenchableObject | ||
|
||
|
||
class TestBenchResultBase(unittest.TestCase): | ||
def test_to_dataset(self): | ||
bench = BenchableObject().to_bench() | ||
|
||
res_repeat1 = bench.plot_sweep( | ||
"sweep1repeat", | ||
input_vars=[BenchableObject.param.float1], | ||
result_vars=[BenchableObject.param.distance, BenchableObject.param.sample_noise], | ||
run_cfg=bch.BenchRunCfg(repeats=1), | ||
plot=False, | ||
) | ||
|
||
res_repeat2 = bench.plot_sweep( | ||
"sweep2repeat", | ||
input_vars=[BenchableObject.param.float1], | ||
result_vars=[BenchableObject.param.distance, BenchableObject.param.sample_noise], | ||
run_cfg=bch.BenchRunCfg(repeats=2), | ||
plot=False, | ||
) | ||
|
||
# print(res_repeat1.to_dataset()) | ||
# print(res_repeat1.to_hv_dataset().data) | ||
# print(res_repeat1.to_hv_dataset_old().data) | ||
|
||
# print(res_repeat1.to_dataset()["distance"].attrs) | ||
|
||
# print(res_repeat2.to_dataset()) | ||
# print(res_repeat2.to_hv_dataset()) | ||
# print(res_repeat2.to_dataset()["distance"].attrs) | ||
|
||
self.assertEqual( | ||
res_repeat1.to_dataset()["distance"].attrs, res_repeat2.to_dataset()["distance"].attrs | ||
) | ||
|
||
# bm.__call__(float_vars=1, sample_with_repeats=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import unittest | ||
import bencher as bch | ||
from bencher.example.example_meta import BenchableObject | ||
|
||
|
||
class TestBenchMeta(unittest.TestCase): | ||
def test_repeats_equal(self): | ||
# bench = bch.Bench("meta", BenchMeta()) | ||
|
||
bench = bch.Bench("bench", BenchableObject()) | ||
|
||
res1 = bench.plot_sweep( | ||
"repeats", input_vars=[BenchableObject.param.float1], run_cfg=bch.BenchRunCfg(repeats=1) | ||
) | ||
|
||
res1_eq = bench.plot_sweep( | ||
"repeats", input_vars=[BenchableObject.param.float1], run_cfg=bch.BenchRunCfg(repeats=1) | ||
) | ||
|
||
res2 = bench.plot_sweep( | ||
"repeats", input_vars=[BenchableObject.param.float1], run_cfg=bch.BenchRunCfg(repeats=2) | ||
) | ||
|
||
self.assertTrue( | ||
res1.to_dataset(bch.ReduceType.NONE).identical(res1_eq.to_dataset(bch.ReduceType.NONE)), | ||
"created with identical settings so should be equal", | ||
) | ||
|
||
self.assertFalse( | ||
res1.to_dataset(bch.ReduceType.NONE).identical(res2.to_dataset(bch.ReduceType.NONE)), | ||
"different number of repeats so should not be equal", | ||
) | ||
|
||
res1_ds = res1.to_dataset(bch.ReduceType.SQUEEZE) | ||
res2_ds = res2.to_dataset(bch.ReduceType.REDUCE) | ||
|
||
self.assertFalse( | ||
res1_ds.identical(res2_ds), "should not be equal because of std_dev column" | ||
) | ||
|
||
res2_ds = res2_ds.drop_vars("distance_std") | ||
res2_ds = res2_ds.drop_vars("sample_noise_std") | ||
|
||
print(res1_ds) | ||
print(res2_ds) | ||
print(res1_ds["distance"].attrs) | ||
print(res2_ds["distance"].attrs) | ||
|
||
self.assertTrue( | ||
res1_ds.equals(res2_ds), "should be equal because of removed std_dev column" | ||
) | ||
|
||
self.assertTrue( | ||
res1_ds.identical(res2_ds), "should be equal because of removed std_dev column" | ||
) |