-
Notifications
You must be signed in to change notification settings - Fork 4
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 #212 from fitbenchmarking/167_rename_minimizers_li…
…st_defaults_file Issue #167: Rename minimizers_list_defaults.json to fitbenchmarking_default_options.json
- Loading branch information
Showing
11 changed files
with
131 additions
and
46 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"minimizers": { | ||
"mantid" : ["BFGS", "Conjugate gradient (Fletcher-Reeves imp.)", | ||
"Conjugate gradient (Polak-Ribiere imp.)", | ||
"Damped GaussNewton", | ||
"Levenberg-Marquardt", "Levenberg-MarquardtMD", | ||
"Simplex","SteepestDescent", | ||
"Trust Region"], | ||
"scipy" : ["lm", "trf", "dogbox"], | ||
"sasview" : ["amoeba", "lm", "newton", "de", "pt", "mp"] | ||
} | ||
} |
This file was deleted.
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,26 @@ | ||
''' | ||
This file will handle all interaction with the options configuration file. | ||
''' | ||
|
||
import json | ||
|
||
|
||
def get_option(options_file='fitbenchmarking/fitbenchmarking_default_options.json', option=None): | ||
''' | ||
Get a value for the given option from a config file. | ||
The options file should contain json formatted data | ||
The default path is fitbenchmarking/fitbenchmarking_default_options.json | ||
@param options_file :: The file name for the options configuration. | ||
@param option :: String for specifying the option to return. | ||
@returns :: json parsed item from the options file | ||
''' | ||
options = json.load(open(options_file, 'r')) | ||
if option is None: | ||
return options | ||
else: | ||
try: | ||
return options[option] | ||
except KeyError: | ||
raise ValueError('Option not found in file: {}'.format(options_file)) |
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,59 @@ | ||
''' | ||
Test the options.py file | ||
''' | ||
|
||
import datetime | ||
import json | ||
import os | ||
import unittest | ||
|
||
import fitbenchmarking.utils.options as options | ||
|
||
try: | ||
FileNotFoundError | ||
except NameError: | ||
FileNotFoundError = IOError | ||
|
||
|
||
class OptionsTests(unittest.TestCase): | ||
def setUp(self): | ||
''' | ||
Create an options file and store input | ||
''' | ||
|
||
opts = {'option1': True, | ||
'option2': [0, 1, 2, 3, 4, 5], | ||
'option3': {'foo': 1, 'bar': 2}} | ||
|
||
opts_file = 'test_options_tests_{}.txt'.format(datetime.datetime.now()) | ||
with open(opts_file, 'w') as f: | ||
f.write(json.dumps(opts)) | ||
|
||
self.options = opts | ||
self.options_file = opts_file | ||
|
||
def tearDown(self): | ||
os.remove(self.options_file) | ||
|
||
def testGetOption(self): | ||
# Test whole options dict | ||
opts = options.get_option(options_file=self.options_file) | ||
self.assertEqual(opts, self.options) | ||
|
||
# Test individual options | ||
for k in self.options: | ||
val = options.get_option(options_file=self.options_file, option=k) | ||
self.assertEqual(val, self.options[k]) | ||
|
||
# Test missing options | ||
with self.assertRaises(ValueError): | ||
options.get_option(options_file=self.options_file, option='not_real') | ||
|
||
# Test missing file | ||
with self.assertRaises(FileNotFoundError): | ||
fake_file = 'fake_{}'.format(self.options_file) | ||
options.get_option(options_file=fake_file) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |