def _get_instrument_from_file(filename): with open(os.path.join(filename, 'instrument.txt')) as f: lines = f.readlines()[1:] sep = ifirst(lines, '\n') keywords_instrument = yaml.load(''.join(lines[:sep])) name = keywords_instrument.pop('name') keywords_calibration = yaml.load(''.join(lines[sep+2:])) calibration = QubicCalibration(**keywords_calibration) return QubicInstrument(name, calibration, **keywords_instrument)
def test_ifirst3(): assert ifirst([1, 2, 2, 3], 2.0) == 1 assert ilast([1, 2, 2, 3], 2.0) == 2
def test_ifirst1(): assert ifirst([1, 2, 3], lambda x: x > 1.5) == 1 assert ilast([1, 2, 3], lambda x: x > 1.5) == 2
def test_ifirst3(): assert ifirst([1, 2, 2, 3], 2.) == 1 assert ilast([1, 2, 2, 3], 2.) == 2