Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

hydra_resolvers_test.py 868 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  1. import unittest
  2. from omegaconf import OmegaConf
  3. from super_gradients.common.environment.env_helpers import register_hydra_resolvers
  4. class HydraResolversTest(unittest.TestCase):
  5. def setUp(self) -> None:
  6. register_hydra_resolvers()
  7. def test_add(self):
  8. conf = OmegaConf.create({"a": 1, "b": 2, "c": 3, "a_plus_b": "${add: ${a},${b}}", "a_plus_b_plus_c": "${add: ${a}, ${b}, ${c}}"})
  9. assert conf["a_plus_b"] == 3
  10. assert conf["a_plus_b_plus_c"] == 6
  11. def test_cond(self):
  12. conf = OmegaConf.create(
  13. {
  14. "boolean": True,
  15. "a": "red_pill",
  16. "b": "blue_pill",
  17. "result": "${cond:${boolean}, ${a}, ${b}}",
  18. }
  19. )
  20. assert conf["result"] == "red_pill"
  21. conf["boolean"] = False
  22. assert conf["result"] == "blue_pill"
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...