test_lvcnrcheck.py 62.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# Copyright (C) 2016 Edward Fauchon-Jones
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
import pytest
import test_lvcnrcheck_helper as helper
import h5py as h5
import re
19
import numpy as np
20 21 22 23 24 25 26 27 28 29 30

templateOutput = """# Format 1

## General Fields

- [=] type (NRinjection)
- [=] Format (1)
- [=] name (1.0)
- [=] alternative-names (1.0)
- [=] NR-group (1.0)
- [=] NR-code (1.0)
31
- [=] modification-date (1.0)
32 33
- [=] point-of-contact-email (1.0)
- [=] INSPIRE-bibtex-keys (1.0)
34
- [=] license (LVC-internal)
35
- [=] Lmax (1)
36
- [=] simulation-type (aligned-spins)
37
- [=] auxiliary-info (<class 'h5py._hl.group.Group'>)
38 39 40 41 42 43 44 45 46 47 48 49
- [=] NR-techniques (1.0)

## Error Assessment

- [=] files-in-error-series (1.0)
- [=] comparable-simulation (1.0)
- [=] production-run (0)

## CBC Parameters

- [=] object1 (BH)
- [=] object2 (BH)
50
- [=] mass1 (4.0)
51
- [=] mass2 (1.0)
52
- [=] eta (0.16)
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
- [=] f_lower_at_1MSUN (1.0)
- [=] spin1x (1.0)
- [=] spin1y (1.0)
- [=] spin1z (1.0)
- [=] spin2x (1.0)
- [=] spin2y (1.0)
- [=] spin2z (1.0)
- [=] LNhatx (1.0)
- [=] LNhaty (1.0)
- [=] LNhatz (1.0)
- [=] nhatx (1.0)
- [=] nhaty (1.0)
- [=] nhatz (1.0)
- [=] Omega (1.0)
- [=] eccentricity (1.0)
68 69
- [=] mean_anomaly (1.0)

70 71
# Format 1 (Interfield)

72
- [=] mass-ordering (mass1 >= mass2)
73
- [=] peak-near-zero (waveform peak is at 0.05M which is less than 10.00M from zero)
74
- [=] phase-sense ((2,2) phase is decreasing on average)
75

76 77
# Format 2

78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
- [=] mass1-vs-time (<class 'h5py._hl.group.Group'>)
- [=] mass2-vs-time (<class 'h5py._hl.group.Group'>)
- [=] spin1x-vs-time (<class 'h5py._hl.group.Group'>)
- [=] spin1y-vs-time (<class 'h5py._hl.group.Group'>)
- [=] spin1z-vs-time (<class 'h5py._hl.group.Group'>)
- [=] spin2x-vs-time (<class 'h5py._hl.group.Group'>)
- [=] spin2y-vs-time (<class 'h5py._hl.group.Group'>)
- [=] spin2z-vs-time (<class 'h5py._hl.group.Group'>)
- [=] position1x-vs-time (<class 'h5py._hl.group.Group'>)
- [=] position1y-vs-time (<class 'h5py._hl.group.Group'>)
- [=] position1z-vs-time (<class 'h5py._hl.group.Group'>)
- [=] position2x-vs-time (<class 'h5py._hl.group.Group'>)
- [=] position2y-vs-time (<class 'h5py._hl.group.Group'>)
- [=] position2z-vs-time (<class 'h5py._hl.group.Group'>)
- [=] LNhatx-vs-time (<class 'h5py._hl.group.Group'>)
- [=] LNhaty-vs-time (<class 'h5py._hl.group.Group'>)
- [=] LNhatz-vs-time (<class 'h5py._hl.group.Group'>)
- [=] Omega-vs-time (<class 'h5py._hl.group.Group'>)
96

97 98
# Format 2 (Interfield)

99
- [=] mass-vs-time-ordering (mass1-vs-time >= mass2-vs-time)
100

101 102
# Format 3

103 104 105 106 107 108
- [=] remnant-mass-vs-time (<class 'h5py._hl.group.Group'>)
- [=] remnant-spinx-vs-time (<class 'h5py._hl.group.Group'>)
- [=] remnant-spiny-vs-time (<class 'h5py._hl.group.Group'>)
- [=] remnant-spinz-vs-time (<class 'h5py._hl.group.Group'>)
- [=] remnant-positionx-vs-time (<class 'h5py._hl.group.Group'>)
- [=] remnant-positiony-vs-time (<class 'h5py._hl.group.Group'>)
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
- [=] remnant-positionz-vs-time (<class 'h5py._hl.group.Group'>)

# Phase Modes

- [=] phase_l2_m-1 (<class 'h5py._hl.group.Group'>)
- [=] phase_l2_m-2 (<class 'h5py._hl.group.Group'>)
- [=] phase_l2_m0 (<class 'h5py._hl.group.Group'>)
- [=] phase_l2_m1 (<class 'h5py._hl.group.Group'>)
- [=] phase_l2_m2 (<class 'h5py._hl.group.Group'>)
- [=] phase_l3_m-1 (<class 'h5py._hl.group.Group'>)
- [=] phase_l3_m-2 (<class 'h5py._hl.group.Group'>)
- [=] phase_l3_m-3 (<class 'h5py._hl.group.Group'>)
- [=] phase_l3_m0 (<class 'h5py._hl.group.Group'>)
- [=] phase_l3_m1 (<class 'h5py._hl.group.Group'>)
- [=] phase_l3_m2 (<class 'h5py._hl.group.Group'>)
- [=] phase_l3_m3 (<class 'h5py._hl.group.Group'>)
- [=] phase_l4_m-1 (<class 'h5py._hl.group.Group'>)
- [=] phase_l4_m-2 (<class 'h5py._hl.group.Group'>)
- [=] phase_l4_m-3 (<class 'h5py._hl.group.Group'>)
- [=] phase_l4_m-4 (<class 'h5py._hl.group.Group'>)
- [=] phase_l4_m0 (<class 'h5py._hl.group.Group'>)
- [=] phase_l4_m1 (<class 'h5py._hl.group.Group'>)
- [=] phase_l4_m2 (<class 'h5py._hl.group.Group'>)
- [=] phase_l4_m3 (<class 'h5py._hl.group.Group'>)
- [=] phase_l4_m4 (<class 'h5py._hl.group.Group'>)
- [=] phase_l5_m-1 (<class 'h5py._hl.group.Group'>)
- [=] phase_l5_m-2 (<class 'h5py._hl.group.Group'>)
- [=] phase_l5_m-3 (<class 'h5py._hl.group.Group'>)
- [=] phase_l5_m-4 (<class 'h5py._hl.group.Group'>)
- [=] phase_l5_m-5 (<class 'h5py._hl.group.Group'>)
- [=] phase_l5_m0 (<class 'h5py._hl.group.Group'>)
- [=] phase_l5_m1 (<class 'h5py._hl.group.Group'>)
- [=] phase_l5_m2 (<class 'h5py._hl.group.Group'>)
- [=] phase_l5_m3 (<class 'h5py._hl.group.Group'>)
- [=] phase_l5_m4 (<class 'h5py._hl.group.Group'>)
- [=] phase_l5_m5 (<class 'h5py._hl.group.Group'>)

# Amplitude Modes

- [=] amp_l2_m-1 (<class 'h5py._hl.group.Group'>)
- [=] amp_l2_m-2 (<class 'h5py._hl.group.Group'>)
- [=] amp_l2_m0 (<class 'h5py._hl.group.Group'>)
- [=] amp_l2_m1 (<class 'h5py._hl.group.Group'>)
- [=] amp_l2_m2 (<class 'h5py._hl.group.Group'>)
- [=] amp_l3_m-1 (<class 'h5py._hl.group.Group'>)
- [=] amp_l3_m-2 (<class 'h5py._hl.group.Group'>)
- [=] amp_l3_m-3 (<class 'h5py._hl.group.Group'>)
- [=] amp_l3_m0 (<class 'h5py._hl.group.Group'>)
- [=] amp_l3_m1 (<class 'h5py._hl.group.Group'>)
- [=] amp_l3_m2 (<class 'h5py._hl.group.Group'>)
- [=] amp_l3_m3 (<class 'h5py._hl.group.Group'>)
- [=] amp_l4_m-1 (<class 'h5py._hl.group.Group'>)
- [=] amp_l4_m-2 (<class 'h5py._hl.group.Group'>)
- [=] amp_l4_m-3 (<class 'h5py._hl.group.Group'>)
- [=] amp_l4_m-4 (<class 'h5py._hl.group.Group'>)
- [=] amp_l4_m0 (<class 'h5py._hl.group.Group'>)
- [=] amp_l4_m1 (<class 'h5py._hl.group.Group'>)
- [=] amp_l4_m2 (<class 'h5py._hl.group.Group'>)
- [=] amp_l4_m3 (<class 'h5py._hl.group.Group'>)
- [=] amp_l4_m4 (<class 'h5py._hl.group.Group'>)
- [=] amp_l5_m-1 (<class 'h5py._hl.group.Group'>)
- [=] amp_l5_m-2 (<class 'h5py._hl.group.Group'>)
- [=] amp_l5_m-3 (<class 'h5py._hl.group.Group'>)
- [=] amp_l5_m-4 (<class 'h5py._hl.group.Group'>)
- [=] amp_l5_m-5 (<class 'h5py._hl.group.Group'>)
- [=] amp_l5_m0 (<class 'h5py._hl.group.Group'>)
- [=] amp_l5_m1 (<class 'h5py._hl.group.Group'>)
- [=] amp_l5_m2 (<class 'h5py._hl.group.Group'>)
- [=] amp_l5_m3 (<class 'h5py._hl.group.Group'>)
- [=] amp_l5_m4 (<class 'h5py._hl.group.Group'>)
- [=] amp_l5_m5 (<class 'h5py._hl.group.Group'>)"""
180 181 182 183 184 185


class TestValidFile(object):

    def setup(self):
        self.output = templateOutput
186
        self.f = helper.createValidSim()
187 188

    def test_valid_file(self):
189
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
190
        assert output.strip() == self.output
191
        assert returncode == 0
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209


class TestField(object):
    """Base for testing individual fields

    Attributes
    ----------
    name: str
        Name of field to test.
    f: NamedTemporaryFile
        Temporary LVC NR Waveform input file.
    output: str
        Expected output from `lvcnrcheck` with `f` as input.
    """

    name = 'field'

    def setup(self):
210
        self.f = helper.createValidSim()
211 212 213 214
        self.output = templateOutput

    def setValue(self, value):
        """Set the value of the represented field"""
215
        self.setNamedField(self.name, value)
216 217 218

    def setOutput(self, output):
        """Set the output line of `lvcnrcheck` for the represented field"""
219 220 221 222 223 224 225 226
        self.setNamedOutput(self.name, output)

    def setNamedField(self, name, value):
        """Set the value of the named field"""
        nr = h5.File(self.f.name)
        nr.attrs[name] = value
        nr.close()

227 228 229 230 231 232
    def setNamedDataset(self, name, value):
        """Set the value of the named dataset"""
        nr = h5.File(self.f.name)
        nr[name][:] = value
        nr.close()

233 234
    def setNamedOutput(self, name, output):
        """Set the output line of `lvcnrcheck` for the named field"""
235
        self.output = re.sub(
236
            r'^- \[=\] {0:s} .*?$'.format(name),
237 238 239
            output, self.output, flags=re.MULTILINE)


240 241 242 243 244 245 246 247 248 249 250 251
class TestGroup(TestField):
    """Base for testing individual group fields"""

    def convertToDataset(self):
        """Convert the group to a dataset of the represented field"""
        nr = h5.File(self.f.name)
        del nr[self.name]
        data = np.array([i for i in range(10)])
        nr.create_dataset(self.name, data=data)
        nr.close()


252 253
class TestROMSpline(TestField):
    """Base for testing individual ROMSpline group fields"""
254

255 256
    def convertToDataset(self):
        """Convert the group to a dataset of the represented field"""
257 258
        nr = h5.File(self.f.name)
        del nr[self.name]
259 260
        data = np.array([i for i in range(10)])
        nr.create_dataset(self.name, data=data)
261 262
        nr.close()

263
    def setSubfields(self, subfields):
264
        """Set the subfields of the ROMSpline group field"""
265 266
        nr = h5.File(self.f.name)
        del nr[self.name]
267
        group = nr.create_group(self.name)
268
        for sub in subfields:
269
            data = np.array([float(i) for i in range(10)])
270
            group.create_dataset(sub, data=data)
271 272
        nr.close()

273

274 275 276 277 278
class TestInterfield(TestField):
    """Base for testing field relationships"""
    name = 'interfield'


279
class TestType(TestField):
280 281 282 283 284 285 286 287 288 289 290

    name = 'type'

    def test_invalid_type(self):
        # Invalidate fields type
        self.setValue(1.0)

        # Update template output for fields invalid type
        self.setOutput(
            '- [WRONG TYPE] type (1.0) (Type must be <type \'basestring\'>)')

291
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
292
        assert output.strip() == self.output
293
        assert returncode == 1
294 295 296 297 298 299 300 301 302 303

    def test_invalid_value(self):
        # Invalidate fields value
        self.setValue('invalid')

        # Update template output for fields invalid value
        self.setOutput(
            ('- [INVALID VALUE] type (invalid) '
             '(Value must be one of NRinjection)'))

304
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
305
        assert output.strip() == self.output
306
        assert returncode == 1
307 308


309
class TestFormat(TestField):
310 311 312 313 314 315 316 317

    name = 'Format'

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
            '- [WRONG TYPE] Format (1.0) (Type must be <type \'int\'>)')

318
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
319
        assert output.strip() == self.output
320
        assert returncode == 1
321 322 323 324 325 326 327

    def test_invalid_value(self):
        self.setValue(0)
        self.setOutput(
            ('- [INVALID VALUE] Format (0) '
             '(Value must be one of 1, 2, 3)'))

328
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
329
        assert output.strip() == self.output
330
        assert returncode == 1
331 332


333
class TestSimulationType(TestField):
334 335 336 337 338 339 340 341 342

    name = 'simulation-type'

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
            ('- [WRONG TYPE] simulation-type (1.0) '
             '(Type must be <type \'basestring\'>)'))

343
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
344
        assert output.strip() == self.output
345
        assert returncode == 1
346 347 348 349 350 351 352

    def test_invalid_value(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [INVALID VALUE] simulation-type (invalid) '
             '(Value must be one of aligned-spins, non-spinning, precessing)'))

353
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
354
        assert output.strip() == self.output
355
        assert returncode == 1
356 357


358
class TestName(TestField):
359 360 361 362 363 364 365 366 367

    name = 'name'

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
            ('- [WRONG TYPE] name (1.0) '
             '(Type must be <type \'basestring\'>)'))

368
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
369
        assert output.strip() == self.output
370
        assert returncode == 1
371 372


373
class TestAlternativeNames(TestField):
374 375 376 377 378 379 380 381 382

    name = 'alternative-names'

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
            ('- [WRONG TYPE] alternative-names (1.0) '
             '(Type must be <type \'basestring\'>)'))

383
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
384
        assert output.strip() == self.output
385
        assert returncode == 1
386 387


388
class TestNRGroup(TestField):
389 390 391 392 393 394 395 396 397

    name = 'NR-group'

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
            ('- [WRONG TYPE] NR-group (1.0) '
             '(Type must be <type \'basestring\'>)'))

398
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
399
        assert output.strip() == self.output
400
        assert returncode == 1
401 402


403
class TestNRCode(TestField):
404 405 406 407 408 409 410 411 412

    name = 'NR-code'

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
            ('- [WRONG TYPE] NR-code (1.0) '
             '(Type must be <type \'basestring\'>)'))

413
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
414
        assert output.strip() == self.output
415
        assert returncode == 1
416 417


418
class TestModificationDate(TestField):
419

420
    name = 'modification-date'
421 422 423 424

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
425
            ('- [WRONG TYPE] modification-date (1.0) '
426 427
             '(Type must be <type \'basestring\'>)'))

428
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
429
        assert output.strip() == self.output
430
        assert returncode == 1
431 432


433
class TestPointOfContactEmail(TestField):
434 435 436 437 438 439 440 441 442

    name = 'point-of-contact-email'

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
            ('- [WRONG TYPE] point-of-contact-email (1.0) '
             '(Type must be <type \'basestring\'>)'))

443
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
444
        assert output.strip() == self.output
445
        assert returncode == 1
446 447


448
class TestINSPIREBibtexKeys(TestField):
449 450 451 452 453 454 455 456 457

    name = 'INSPIRE-bibtex-keys'

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
            ('- [WRONG TYPE] INSPIRE-bibtex-keys (1.0) '
             '(Type must be <type \'basestring\'>)'))

458
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
459
        assert output.strip() == self.output
460
        assert returncode == 1
461 462


463
class TestLicense(TestField):
464 465 466 467 468 469 470 471 472

    name = 'license'

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
            ('- [WRONG TYPE] license (1.0) '
             '(Type must be <type \'basestring\'>)'))

473
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
474
        assert output.strip() == self.output
475
        assert returncode == 1
476 477 478 479 480

    def test_invalid_value(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [INVALID VALUE] license (invalid) '
481
             '(Value must be one of LVC-internal, public)'))
482

483
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
484
        assert output.strip() == self.output
485
        assert returncode == 1
486 487


488
class TestLmax(TestField):
489 490 491 492 493 494 495 496

    name = 'Lmax'

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
            '- [WRONG TYPE] Lmax (1.0) (Type must be <type \'int\'>)')

497
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
498
        assert output.strip() == self.output
499
        assert returncode == 1
500 501


502
class TestAuxiliaryInfo(TestGroup):
503 504 505 506 507 508 509 510 511 512

    name = 'auxiliary-info'

    def test_invalid_type(self):
        self.convertToDataset()
        self.setOutput(
            ('- [WRONG TYPE] auxiliary-info '
             '(<class \'h5py._hl.dataset.Dataset\'>) '
             '(Type must be <class \'h5py._hl.group.Group\'>)'))

513
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
514
        assert output.strip() == self.output
515
        assert returncode == 1
516 517


518
class TestNRTechniques(TestField):
519 520 521 522 523 524 525 526 527

    name = 'NR-techniques'

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
            ('- [WRONG TYPE] NR-techniques (1.0) '
             '(Type must be <type \'basestring\'>)'))

528
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
529
        assert output.strip() == self.output
530
        assert returncode == 1
531 532


533
class TestFilesInErrorSeries(TestField):
534 535 536 537 538 539 540 541 542

    name = 'files-in-error-series'

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
            ('- [WRONG TYPE] files-in-error-series (1.0) '
             '(Type must be <type \'basestring\'>)'))

543
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
544
        assert output.strip() == self.output
545
        assert returncode == 1
546 547


548
class TestComparableSimulation(TestField):
549 550 551 552 553 554 555 556 557

    name = 'comparable-simulation'

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
            ('- [WRONG TYPE] comparable-simulation (1.0) '
             '(Type must be <type \'basestring\'>)'))

558
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
559
        assert output.strip() == self.output
560
        assert returncode == 1
561 562


563
class TestProductionRun(TestField):
564 565 566 567 568 569 570 571 572

    name = 'production-run'

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
            ('- [WRONG TYPE] production-run (1.0) '
             '(Type must be <type \'int\'>)'))

573
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
574
        assert output.strip() == self.output
575
        assert returncode == 1
576 577 578 579 580 581 582

    def test_invalid_value(self):
        self.setValue(2)
        self.setOutput(
            ('- [INVALID VALUE] production-run (2) '
             '(Value must be one of 0, 1)'))

583
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
584
        assert output.strip() == self.output
585
        assert returncode == 1
586 587


588
class TestObject1(TestField):
589 590 591 592 593 594 595 596 597

    name = 'object1'

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
            ('- [WRONG TYPE] object1 (1.0) '
             '(Type must be <type \'basestring\'>)'))

598
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
599
        assert output.strip() == self.output
600
        assert returncode == 1
601 602 603 604 605 606 607

    def test_invalid_value(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [INVALID VALUE] object1 (invalid) '
             '(Value must be one of BH, NS)'))

608
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
609
        assert output.strip() == self.output
610
        assert returncode == 1
611 612


613
class TestObject2(TestField):
614 615 616 617 618 619 620 621 622

    name = 'object2'

    def test_invalid_type(self):
        self.setValue(1.0)
        self.setOutput(
            ('- [WRONG TYPE] object2 (1.0) '
             '(Type must be <type \'basestring\'>)'))

623
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
624
        assert output.strip() == self.output
625
        assert returncode == 1
626 627 628 629 630 631 632

    def test_invalid_value(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [INVALID VALUE] object2 (invalid) '
             '(Value must be one of BH, NS)'))

633
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
634
        assert output.strip() == self.output
635
        assert returncode == 1
636 637


638
class TestMass1(TestField):
639 640 641 642 643 644 645 646

    name = 'mass1'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] mass1 (invalid) '
             '(Type must be <type \'float\'>)'))
647 648 649 650
        self.setNamedOutput(
            'mass-ordering',
            ('- [INVALID FIELDS] mass-ordering '
             '(Field dependencies are invalid)'))
651

652
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
653
        assert output.strip() == self.output
654
        assert returncode == 1
655 656


657
class TestMass2(TestField):
658 659 660 661 662 663 664 665

    name = 'mass2'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] mass2 (invalid) '
             '(Type must be <type \'float\'>)'))
666 667 668 669
        self.setNamedOutput(
            'mass-ordering',
            ('- [INVALID FIELDS] mass-ordering '
             '(Field dependencies are invalid)'))
670

671
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
672
        assert output.strip() == self.output
673
        assert returncode == 1
674 675


676
class TestEta(TestField):
677 678 679 680 681 682 683 684 685

    name = 'eta'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] eta (invalid) '
             '(Type must be <type \'float\'>)'))

686
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
687
        assert output.strip() == self.output
688
        assert returncode == 1
689 690


691
class TestFLowerAt1MSUN(TestField):
692 693 694 695 696 697 698 699 700

    name = 'f_lower_at_1MSUN'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] f_lower_at_1MSUN (invalid) '
             '(Type must be <type \'float\'>)'))

701
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
702
        assert output.strip() == self.output
703
        assert returncode == 1
704 705


706
class TestSpin1x(TestField):
707 708 709 710 711 712 713 714 715

    name = 'spin1x'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] spin1x (invalid) '
             '(Type must be <type \'float\'>)'))

716
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
717
        assert output.strip() == self.output
718
        assert returncode == 1
719 720


721
class TestSpin1y(TestField):
722 723 724 725 726 727 728 729 730

    name = 'spin1y'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] spin1y (invalid) '
             '(Type must be <type \'float\'>)'))

731
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
732
        assert output.strip() == self.output
733
        assert returncode == 1
734 735


736
class TestSpin1z(TestField):
737 738 739 740 741 742 743 744 745

    name = 'spin1z'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] spin1z (invalid) '
             '(Type must be <type \'float\'>)'))

746
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
747
        assert output.strip() == self.output
748
        assert returncode == 1
749 750


751
class TestSpin2x(TestField):
752 753 754 755 756 757 758 759 760

    name = 'spin2x'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] spin2x (invalid) '
             '(Type must be <type \'float\'>)'))

761
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
762
        assert output.strip() == self.output
763
        assert returncode == 1
764 765


766
class TestSpin2y(TestField):
767 768 769 770 771 772 773 774 775

    name = 'spin2y'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] spin2y (invalid) '
             '(Type must be <type \'float\'>)'))

776
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
777
        assert output.strip() == self.output
778
        assert returncode == 1
779 780


781
class TestSpin2z(TestField):
782 783 784 785 786 787 788 789 790

    name = 'spin2z'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] spin2z (invalid) '
             '(Type must be <type \'float\'>)'))

791
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
792
        assert output.strip() == self.output
793
        assert returncode == 1
794 795


796
class TestLNhatx(TestField):
797 798 799 800 801 802 803 804 805

    name = 'LNhatx'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] LNhatx (invalid) '
             '(Type must be <type \'float\'>)'))

806
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
807
        assert output.strip() == self.output
808
        assert returncode == 1
809 810


811
class TestLNhaty(TestField):
812 813 814 815 816 817 818 819 820

    name = 'LNhaty'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] LNhaty (invalid) '
             '(Type must be <type \'float\'>)'))

821
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
822
        assert output.strip() == self.output
823
        assert returncode == 1
824 825


826
class TestLNhatz(TestField):
827 828 829 830 831 832 833 834 835

    name = 'LNhatz'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] LNhatz (invalid) '
             '(Type must be <type \'float\'>)'))

836
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
837
        assert output.strip() == self.output
838
        assert returncode == 1
839 840


841
class TestNhatx(TestField):
842 843 844 845 846 847 848 849 850

    name = 'nhatx'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] nhatx (invalid) '
             '(Type must be <type \'float\'>)'))

851
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
852
        assert output.strip() == self.output
853
        assert returncode == 1
854 855


856
class TestNhaty(TestField):
857 858 859 860 861 862 863 864 865

    name = 'nhaty'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] nhaty (invalid) '
             '(Type must be <type \'float\'>)'))

866
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
867
        assert output.strip() == self.output
868
        assert returncode == 1
869 870


871
class TestNhatz(TestField):
872 873 874 875 876 877 878 879 880

    name = 'nhatz'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] nhatz (invalid) '
             '(Type must be <type \'float\'>)'))

881
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
882
        assert output.strip() == self.output
883
        assert returncode == 1
884 885


886
class TestOmega(TestField):
887 888 889 890 891 892 893 894 895

    name = 'Omega'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] Omega (invalid) '
             '(Type must be <type \'float\'>)'))

896
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
897
        assert output.strip() == self.output
898
        assert returncode == 1
899 900


901
class TestEccentricity(TestField):
902 903 904 905 906 907 908 909 910

    name = 'eccentricity'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] eccentricity (invalid) '
             '(Type must be <type \'float\'>)'))

911
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
912
        assert output.strip() == self.output
913
        assert returncode == 1
914 915


916
class TestMeanAnomaly(TestField):
917 918 919 920 921 922 923 924 925

    name = 'mean_anomaly'

    def test_invalid_type(self):
        self.setValue('invalid')
        self.setOutput(
            ('- [WRONG TYPE] mean_anomaly (invalid) '
             '(Type must be <type \'float\'>)'))

926
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
927
        assert output.strip() == self.output
928
        assert returncode == 1
929 930


931 932 933 934 935 936 937 938 939 940 941 942 943 944
class TestMassOrdering(TestInterfield):

    name = 'mass-ordering'

    def test_invalid_mass1(self):
        self.setOutput(
            ('- [INVALID FIELDS] mass-ordering '
             '(Field dependencies are invalid)'))
        self.setNamedField('mass1', 'invalid')
        self.setNamedOutput(
            'mass1',
            ('- [WRONG TYPE] mass1 (invalid) '
             '(Type must be <type \'float\'>)'))

945
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
946
        assert output.strip() == self.output
947
        assert returncode == 1
948 949 950 951 952 953 954 955 956 957 958

    def test_invalid_mass2(self):
        self.setOutput(
            ('- [INVALID FIELDS] mass-ordering '
             '(Field dependencies are invalid)'))
        self.setNamedField('mass2', 'invalid')
        self.setNamedOutput(
            'mass2',
            ('- [WRONG TYPE] mass2 (invalid) '
             '(Type must be <type \'float\'>)'))

959
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
960
        assert output.strip() == self.output
961
        assert returncode == 1
962 963 964 965 966 967 968 969 970 971

    def test_invalid_ordering(self):
        self.setOutput(
            ('- [INVALID INTERFIELD] mass-ordering '
             '(mass1 < mass2)'))
        self.setNamedField('mass1', 1.0)
        self.setNamedOutput('mass1', '- [=] mass1 (1.0)')
        self.setNamedField('mass2', 4.0)
        self.setNamedOutput('mass2', '- [=] mass2 (4.0)')

972
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
973
        assert output.strip() == self.output
974
        assert returncode == 1
975 976


977
class TestMass1VsTime(TestROMSpline):
978 979 980 981

    name = 'mass1-vs-time'

    def test_invalid_type(self):
982
        self.convertToDataset()
983 984
        self.setOutput(
            ('- [WRONG TYPE] mass1-vs-time '
985 986
             '(<class \'h5py._hl.dataset.Dataset\'>) '
             '(Type must be <class \'h5py._hl.group.Group\'>)'))
987 988 989 990
        self.setNamedOutput(
            'mass-vs-time-ordering',
            ('- [INVALID FIELDS] mass-vs-time-ordering '
             '(Field dependencies are invalid)'))
991

992
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
993
        assert output.strip() == self.output
994
        assert returncode == 1
995

996 997
    def test_invalid_subfields(self):
        self.setSubfields(['invalid-1', 'invalid-2'])
998
        self.setOutput(
999
            ('- [INVALID SUBFIELDS] mass1-vs-time '
1000 1001
             '(<class \'h5py._hl.group.Group\'>) '
             '(Field has subfields [invalid-1, invalid-2] '
1002
             'but should have [X, Y, deg, errors, tol])'))
1003 1004 1005 1006
        self.setNamedOutput(
            'mass-vs-time-ordering',
            ('- [INVALID FIELDS] mass-vs-time-ordering '
             '(Field dependencies are invalid)'))
1007

1008
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
1009
        assert output.strip() == self.output
1010
        assert returncode == 1
1011 1012


1013
class TestMass2VsTime(TestROMSpline):
1014 1015 1016 1017

    name = 'mass2-vs-time'

    def test_invalid_type(self):
1018
        self.convertToDataset()
1019 1020
        self.setOutput(
            ('- [WRONG TYPE] mass2-vs-time '
1021 1022
             '(<class \'h5py._hl.dataset.Dataset\'>) '
             '(Type must be <class \'h5py._hl.group.Group\'>)'))
1023 1024 1025 1026
        self.setNamedOutput(
            'mass-vs-time-ordering',
            ('- [INVALID FIELDS] mass-vs-time-ordering '
             '(Field dependencies are invalid)'))
1027

1028
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
1029
        assert output.strip() == self.output
1030
        assert returncode == 1
1031

1032 1033
    def test_invalid_subfields(self):
        self.setSubfields(['invalid-1', 'invalid-2'])
1034
        self.setOutput(
1035
            ('- [INVALID SUBFIELDS] mass2-vs-time '
1036
             '(<class \'h5py._hl.group.Group\'>) '
1037
             '(Field has subfields [invalid-1, invalid-2] '
1038
             'but should have [X, Y, deg, errors, tol])'))
1039 1040 1041 1042
        self.setNamedOutput(
            'mass-vs-time-ordering',
            ('- [INVALID FIELDS] mass-vs-time-ordering '
             '(Field dependencies are invalid)'))
1043

1044
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
1045
        assert output.strip() == self.output
1046
        assert returncode == 1
1047

1048

1049
class TestSpin1xVsTime(TestROMSpline):
1050 1051 1052 1053 1054

    name = 'spin1x-vs-time'

    def test_invalid_type(self):
        self.convertToDataset()
1055
        self.setOutput(
1056 1057 1058
            ('- [WRONG TYPE] spin1x-vs-time '
             '(<class \'h5py._hl.dataset.Dataset\'>) '
             '(Type must be <class \'h5py._hl.group.Group\'>)'))
1059

1060
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
1061
        assert output.strip() == self.output
1062
        assert returncode == 1
1063

1064 1065
    def test_invalid_subfields(self):
        self.setSubfields(['invalid-1', 'invalid-2'])
1066
        self.setOutput(
1067
            ('- [INVALID SUBFIELDS] spin1x-vs-time '
1068 1069
             '(<class \'h5py._hl.group.Group\'>) '
             '(Field has subfields [invalid-1, invalid-2] '
1070
             'but should have [X, Y, deg, errors, tol])'))
1071

1072
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
1073
        assert output.strip() == self.output
1074
        assert returncode == 1
1075

1076

1077
class TestSpin1yVsTime(TestROMSpline):
1078 1079

    name = 'spin1y-vs-time'
1080 1081

    def test_invalid_type(self):
1082 1083 1084 1085 1086 1087
        self.convertToDataset()
        self.setOutput(
            ('- [WRONG TYPE] spin1y-vs-time '
             '(<class \'h5py._hl.dataset.Dataset\'>) '
             '(Type must be <class \'h5py._hl.group.Group\'>)'))

1088
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
1089
        assert output.strip() == self.output
1090
        assert returncode == 1
1091

1092 1093
    def test_invalid_subfields(self):
        self.setSubfields(['invalid-1', 'invalid-2'])
1094
        self.setOutput(
1095
            ('- [INVALID SUBFIELDS] spin1y-vs-time '
1096
             '(<class \'h5py._hl.group.Group\'>) '
1097
             '(Field has subfields [invalid-1, invalid-2] '
1098
             'but should have [X, Y, deg, errors, tol])'))
1099

1100
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
1101
        assert output.strip() == self.output
1102
        assert returncode == 1
1103

1104

1105
class TestSpin1zVsTime(TestROMSpline):
1106 1107 1108 1109 1110 1111 1112 1113 1114 1115

    name = 'spin1z-vs-time'

    def test_invalid_type(self):
        self.convertToDataset()
        self.setOutput(
            ('- [WRONG TYPE] spin1z-vs-time '
             '(<class \'h5py._hl.dataset.Dataset\'>) '
             '(Type must be <class \'h5py._hl.group.Group\'>)'))

1116
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
1117
        assert output.strip() == self.output
1118
        assert returncode == 1
1119

1120 1121
    def test_invalid_subfields(self):
        self.setSubfields(['invalid-1', 'invalid-2'])
1122
        self.setOutput(
1123
            ('- [INVALID SUBFIELDS] spin1z-vs-time '
1124 1125
             '(<class \'h5py._hl.group.Group\'>) '
             '(Field has subfields [invalid-1, invalid-2] '
1126
             'but should have [X, Y, deg, errors, tol])'))
1127

1128
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
1129
        assert output.strip() == self.output
1130
        assert returncode == 1
1131 1132


1133
class TestSpin2xVsTime(TestROMSpline):
1134

1135
    name = 'spin2x-vs-time'
1136 1137

    def test_invalid_type(self):
1138 1139 1140 1141 1142 1143
        self.convertToDataset()
        self.setOutput(
            ('- [WRONG TYPE] spin2x-vs-time '
             '(<class \'h5py._hl.dataset.Dataset\'>) '
             '(Type must be <class \'h5py._hl.group.Group\'>)'))

1144
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
1145
        assert output.strip() == self.output
1146
        assert returncode == 1
1147

1148 1149
    def test_invalid_subfields(self):
        self.setSubfields(['invalid-1', 'invalid-2'])
1150
        self.setOutput(
1151
            ('- [INVALID SUBFIELDS] spin2x-vs-time '
1152
             '(<class \'h5py._hl.group.Group\'>) '
1153
             '(Field has subfields [invalid-1, invalid-2] '
1154
             'but should have [X, Y, deg, errors, tol])'))
1155

1156
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
1157
        assert output.strip() == self.output
1158
        assert returncode == 1
1159

1160

1161
class TestSpin2yVsTime(TestROMSpline):
1162 1163 1164 1165 1166

    name = 'spin2y-vs-time'

    def test_invalid_type(self):
        self.convertToDataset()
1167
        self.setOutput(
1168 1169 1170 1171
            ('- [WRONG TYPE] spin2y-vs-time '
             '(<class \'h5py._hl.dataset.Dataset\'>) '
             '(Type must be <class \'h5py._hl.group.Group\'>)'))

1172
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
1173
        assert output.strip() == self.output
1174
        assert returncode == 1
1175

1176 1177
    def test_invalid_subfields(self):
        self.setSubfields(['invalid-1', 'invalid-2'])
1178
        self.setOutput(
1179
            ('- [INVALID SUBFIELDS] spin2y-vs-time '
1180 1181
             '(<class \'h5py._hl.group.Group\'>) '
             '(Field has subfields [invalid-1, invalid-2] '
1182
             'but should have [X, Y, deg, errors, tol])'))
1183

1184
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
1185
        assert output.strip() == self.output
1186
        assert returncode == 1
1187 1188


1189
class TestSpin2zVsTime(TestROMSpline):
1190

1191
    name = 'spin2z-vs-time'
1192 1193

    def test_invalid_type(self):
1194 1195 1196 1197 1198 1199
        self.convertToDataset()
        self.setOutput(
            ('- [WRONG TYPE] spin2z-vs-time '
             '(<class \'h5py._hl.dataset.Dataset\'>) '
             '(Type must be <class \'h5py._hl.group.Group\'>)'))

1200
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
1201
        assert output.strip() == self.output
1202
        assert returncode == 1
1203

1204 1205
    def test_invalid_subfields(self):
        self.setSubfields(['invalid-1', 'invalid-2'])
1206
        self.setOutput(
1207
            ('- [INVALID SUBFIELDS] spin2z-vs-time '
1208 1209
             '(<class \'h5py._hl.group.Group\'>) '
             '(Field has subfields [invalid-1, invalid-2] '
1210
             'but should have [X, Y, deg, errors, tol])'))
1211

1212
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
1213
        assert output.strip() == self.output
1214
        assert returncode == 1
1215 1216


1217
class TestPosition1xVsTime(TestROMSpline):
1218 1219 1220 1221 1222 1223 1224 1225 1226 1227

    name = 'position1x-vs-time'

    def test_invalid_type(self):
        self.convertToDataset()
        self.setOutput(
            ('- [WRONG TYPE] position1x-vs-time '
             '(<class \'h5py._hl.dataset.Dataset\'>) '
             '(Type must be <class \'h5py._hl.group.Group\'>)'))

1228
        (output, returncode) = helper.lvcnrcheck(['-f', '3', self.f.name], returncode=True)
1229
        assert output.strip() == self.output
1230
        assert returncode == 1
1231

1232 1233
    def test_invalid_subfields(self):
        self.setSubfields(['invalid-1', 'invalid-2'])
1234
        self.setOutput(
1235
            ('- [INVALID SUBFIELDS] position1x-vs-time '
1236
             '(<class \'h5py._hl.group.Group\'>) '