Commit 269de7aa authored by Edward Fauchon-Jones's avatar Edward Fauchon-Jones
Browse files

Refactor omega seq check as overridden OmegaVsTime

parent 9d307da3
Pipeline #12668 passed with stage
in 1 minute and 14 seconds
......@@ -84,8 +84,7 @@ format2 = OrderedDict((
('Omega-vs-time', OmegaVsTime)))
format2Interfield = OrderedDict((
('mass-vs-time-ordering', MassVsTimeOrdering),
('Omega-vs-time-monotonicity', OmegaVsTimeMonotonicity),))
('mass-vs-time-ordering', MassVsTimeOrdering),))
format3 = OrderedDict((
('remnant-mass-vs-time', RemnantMassVsTime),
......@@ -601,24 +601,19 @@ class LNhatzVsTime(ROMSplineSpec):
class OmegaVsTime(ROMSplineSpec):
"""Specification for the `Omega-vs-time` field"""
name = 'Omega-vs-time'
class OmegaVsTimeMonotonicity(InterfieldSpec):
"""Specification for the `Omega-vs-time` field"""
name = 'Omega-vs-time Monotonicity'
validMsg = "Omega pass monotonicity test"
invalidMsg = "Omega is not monotonic: Suggest downgrading to Format=1"
def valid(self, sim):
OmegaVsTimeValid = OmegaVsTime().valid(sim)
if not isinstance(OmegaVsTimeValid, err.Valid):
return err.InvalidInterfields(self)
def valid(self, sim):
romSplineValid = super(OmegaVsTime, self).valid(sim)
if not isinstance(romSplineValid, err.Valid):
return romSplineValid
Omegas = sim['Omega-vs-time/Y'][:]
if ismonotonic(Omegas):
return err.ValidInterfield(self)
return romSplineValid
return err.InvalidInterfield(self)
return err.InvalidSequence(self)
class MassVsTimeOrdering(InterfieldSpec):
"""Specification for the ordering of fields `mass1/mass2-vs-time``"""
......@@ -1491,16 +1491,12 @@ class TestOmegaVsTime(TestROMSpline):
assert output.strip() == self.output
assert returncode == 1
class TestOmegaVsTimeMonotonicity(TestInterfield):
name = 'omega-vs-time-monotonicity'
def test_invalid_ordering(self):
def test_invalid_monotonicity(self):
('- [INVALID INTERFIELD] omega-vs-time-monotonicity '
('- [INVALID SEQUENCE] Omega-vs-time '
'(<class \'\'>) '
'(Omega is not monotonic: Suggest downgrading to Format=1)'))
self.setNamedDataset('Omega-vs-time/Y', np.array([1,2,4,3]))
self.setNamedDataset('Omega-vs-time/Y', np.array([0,1,2,4,3,5,6,7,8,9]))
(output, returncode) = helper.lvcnrcheck(['-f', '3',], returncode=True)
assert output.strip() == self.output
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment