def test_write(self): """ Tests :attr:`colour.io.iestm2714.SpectralDistribution_IESTM2714.write` method. """ sd_r = SpectralDistribution_IESTM2714( os.path.join(RESOURCES_DIRECTORY, 'Fluorescent.spdx')).read() sd_r.path = os.path.join(self._temporary_directory, 'Fluorescent.spdx') self.assertTrue(sd_r.write()) sd_t = SpectralDistribution_IESTM2714(sd_r.path).read() self.test_read(sd_t) self.assertEquals(sd_r, sd_t)
def test_read(self, sd=None): """ Tests :attr:`colour.io.iestm2714.SpectralDistribution_IESTM2714.read` method. Parameters ---------- sd : SpectralDistribution_IESTM2714, optional Optional *IES TM-27-14* spectral distribution for read tests. """ if sd is None: sd = SpectralDistribution_IESTM2714( os.path.join(RESOURCES_DIRECTORY, 'Fluorescent.spdx')) self.assertTrue(sd.read()) sd_r = SpectralDistribution(FLUORESCENT_FILE_SPECTRAL_DATA) np.testing.assert_array_equal(sd_r.domain, sd.domain) np.testing.assert_almost_equal(sd_r.values, sd.values, decimal=7) for test, read in ((FLUORESCENT_FILE_HEADER, sd.header), (FLUORESCENT_FILE_SPECTRAL_DESCRIPTION, sd)): for key, value in test.items(): for specification in read.mapping.elements: if key == specification.element: self.assertEquals( getattr(read, specification.attribute), value)