Skip to content

Commit

Permalink
making sure that if last_no_of_packets is not specified that it is se…
Browse files Browse the repository at this point in the history
…t to no_of_packets + test
  • Loading branch information
wkerzendorf committed Aug 27, 2014
1 parent eb72f4c commit d9cc9f8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tardis/data/tardis_config_definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,11 @@ montecarlo:

last_no_of_packets:
property_type: int
default: 100
default: -1
mandatory: False
help: This can set the number of packets for the last run. If set to None it will remain the same as all other runs.
help: >
This can set the number of packets for the last run.
If set negative it will remain the same as all other runs.
no_of_virtual_packets:
property_type: int
Expand Down
3 changes: 3 additions & 0 deletions tardis/io/config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,9 @@ def from_config_dict(cls, config_dict, atom_data=None, test_parser=False,
##### Monte Carlo Section

montecarlo_section = validated_config_dict['montecarlo']
if montecarlo_section['last_no_of_packets'] < 0:
montecarlo_section['last_no_of_packets'] = \
montecarlo_section['no_of_packets']

default_convergence_section = {'type': 'damped',
'lock_t_inner_cyles': 1,
Expand Down
9 changes: 9 additions & 0 deletions tardis/io/tests/test_config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ def test_time_explosion(self):
assert_almost_equal(self.config['supernova']['time_explosion'],
13.0 * u.day)


def test_last_no_of_packets():
yaml_data = yaml.load(open(data_path('paper1_tardis_configv1.yml')))
del yaml_data['montecarlo']['last_no_of_packets']
config = config_reader.Configuration.from_config_dict(yaml_data,
test_parser=True)
assert (config.montecarlo.last_no_of_packets ==
config.montecarlo.no_of_packets)

class TestParseConfigV1ASCIIDensity:

def setup(self):
Expand Down

0 comments on commit d9cc9f8

Please sign in to comment.