Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix floating point comparison #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pyninjotiff/tests/test_ninjotiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
colormap = page.tags['color_map'].value
for i in range(3):
assert(np.all(np.array(colormap[i * 256:(i + 1) * 256]) == np.arange(256) * 256))
assert(np.all(res[0, ::256] == np.array([1, 86, 170, 255])))

Check notice on line 129 in pyninjotiff/tests/test_ninjotiff.py

View check run for this annotation

codefactor.io / CodeFactor

pyninjotiff/tests/test_ninjotiff.py#L129

multiple spaces after ',' (E241)


def test_write_bw_inverted_ir():
Expand Down Expand Up @@ -172,7 +172,7 @@
colormap = page.tags['color_map'].value
for i in range(3):
assert(np.all(np.array(colormap[i * 256:(i + 1) * 256]) == np.arange(255, -1, -1) * 256))
assert(np.all(res[0, ::256] == np.array([1, 86, 170, 255])))

Check notice on line 175 in pyninjotiff/tests/test_ninjotiff.py

View check run for this annotation

codefactor.io / CodeFactor

pyninjotiff/tests/test_ninjotiff.py#L175

multiple spaces after ',' (E241)


def test_write_bw_fill():
Expand Down Expand Up @@ -222,7 +222,7 @@
colormap = page.tags['color_map'].value
for i in range(3):
assert(np.all(np.array(colormap[i * 256:(i + 1) * 256]) == np.arange(256) * 256))
assert(np.all(res[0, ::256] == np.array([1, 86, 170, 255])))

Check notice on line 225 in pyninjotiff/tests/test_ninjotiff.py

View check run for this annotation

codefactor.io / CodeFactor

pyninjotiff/tests/test_ninjotiff.py#L225

multiple spaces after ',' (E241)
assert(np.all(res[256, :] == 0))


Expand Down Expand Up @@ -273,7 +273,7 @@
colormap = page.tags['color_map'].value
for i in range(3):
assert(np.all(np.array(colormap[i * 256:(i + 1) * 256]) == np.arange(255, -1, -1) * 256))
assert(np.all(res[0, ::256] == np.array([1, 86, 170, 255])))

Check notice on line 276 in pyninjotiff/tests/test_ninjotiff.py

View check run for this annotation

codefactor.io / CodeFactor

pyninjotiff/tests/test_ninjotiff.py#L276

multiple spaces after ',' (E241)
assert(np.all(res[256, :] == 0))


Expand Down Expand Up @@ -302,9 +302,9 @@
('calibration', None),
('modifiers', None),
('mode', 'RGB'),
('enhancement_history', [{'scale': np.array([1, 1, -1]), 'offset': np.array([0, 0, 1])},

Check notice on line 305 in pyninjotiff/tests/test_ninjotiff.py

View check run for this annotation

codefactor.io / CodeFactor

pyninjotiff/tests/test_ninjotiff.py#L305

multiple spaces after ',' (E241)
{'scale': np.array([0.0266347, 0.03559078, 0.01329783]),
'offset': np.array([-0.02524969, -0.01996642, 3.8918446])},

Check notice on line 307 in pyninjotiff/tests/test_ninjotiff.py

View check run for this annotation

codefactor.io / CodeFactor

pyninjotiff/tests/test_ninjotiff.py#L307

multiple spaces after ',' (E241)
{'gamma': 1.6}])])

kwargs = {'compute': True, 'fill_value': None, 'sat_id': 6300014,
Expand Down Expand Up @@ -370,9 +370,9 @@
('calibration', None),
('modifiers', None),
('mode', 'RGB'),
('enhancement_history', [{'scale': np.array([1, 1, -1]), 'offset': np.array([0, 0, 1])},

Check notice on line 373 in pyninjotiff/tests/test_ninjotiff.py

View check run for this annotation

codefactor.io / CodeFactor

pyninjotiff/tests/test_ninjotiff.py#L373

multiple spaces after ',' (E241)
{'scale': np.array([0.0266347, 0.03559078, 0.01329783]),
'offset': np.array([-0.02524969, -0.01996642, 3.8918446])},

Check notice on line 375 in pyninjotiff/tests/test_ninjotiff.py

View check run for this annotation

codefactor.io / CodeFactor

pyninjotiff/tests/test_ninjotiff.py#L375

multiple spaces after ',' (E241)
{'gamma': 1.6}])])

kwargs = {'compute': True, 'fill_value': None, 'sat_id': 6300014,
Expand Down Expand Up @@ -421,9 +421,9 @@
('calibration', None),
('modifiers', None),
('mode', 'RGB'),
('enhancement_history', [{'scale': np.array([1, 1, -1]), 'offset': np.array([0, 0, 1])},

Check notice on line 424 in pyninjotiff/tests/test_ninjotiff.py

View check run for this annotation

codefactor.io / CodeFactor

pyninjotiff/tests/test_ninjotiff.py#L424

multiple spaces after ',' (E241)
{'scale': np.array([0.0266347, 0.03559078, 0.01329783]),
'offset': np.array([-0.02524969, -0.01996642, 3.8918446])},

Check notice on line 426 in pyninjotiff/tests/test_ninjotiff.py

View check run for this annotation

codefactor.io / CodeFactor

pyninjotiff/tests/test_ninjotiff.py#L426

multiple spaces after ',' (E241)
{'gamma': 1.6}])])

kwargs = {'compute': True, 'fill_value': None, 'sat_id': 6300014,
Expand Down Expand Up @@ -519,7 +519,10 @@
for key, val in tags.items():
if key in ['datetime', '40002', '40003', '40006']:
continue
assert(val == read_tags[key].value)
if np.asarray(val).dtype.kind == "f":
np.testing.assert_allclose(val, read_tags[key].value)
else:
assert(val == read_tags[key].value)


@pytest.mark.skip(reason="this is no implemented yet.")
Expand Down Expand Up @@ -597,9 +600,9 @@
('calibration', None),
('modifiers', None),
('mode', 'RGBA'),
('enhancement_history', [{'scale': np.array([1, 1, -1]), 'offset': np.array([0, 0, 1])},

Check notice on line 603 in pyninjotiff/tests/test_ninjotiff.py

View check run for this annotation

codefactor.io / CodeFactor

pyninjotiff/tests/test_ninjotiff.py#L603

multiple spaces after ',' (E241)
{'scale': np.array([0.0266347, 0.03559078, 0.01329783]),
'offset': np.array([-0.02524969, -0.01996642, 3.8918446])},

Check notice on line 605 in pyninjotiff/tests/test_ninjotiff.py

View check run for this annotation

codefactor.io / CodeFactor

pyninjotiff/tests/test_ninjotiff.py#L605

multiple spaces after ',' (E241)
{'gamma': 1.6}])])

kwargs = {'compute': True, 'fill_value': None, 'sat_id': 6300014,
Expand Down Expand Up @@ -701,7 +704,7 @@
assert(np.allclose(colormap[:256], cm_vis))
assert(np.allclose(colormap[256:512], cm_vis))
assert(np.allclose(colormap[512:], cm_vis))
assert(np.allclose(res[0, ::205], np.array([1, 64, 128, 192, 255])))

Check notice on line 707 in pyninjotiff/tests/test_ninjotiff.py

View check run for this annotation

codefactor.io / CodeFactor

pyninjotiff/tests/test_ninjotiff.py#L707

multiple spaces after ',' (E241)


def _load_file_values_with_colormap(filename):
Expand Down Expand Up @@ -793,7 +796,7 @@
assert(np.allclose(colormap[:256], ir_map))
assert(np.allclose(colormap[256:512], ir_map))
assert(np.allclose(colormap[512:], ir_map))
assert(np.allclose(res[0, ::205], np.array([1, 64, 128, 192, 255])))

Check notice on line 799 in pyninjotiff/tests/test_ninjotiff.py

View check run for this annotation

codefactor.io / CodeFactor

pyninjotiff/tests/test_ninjotiff.py#L799

multiple spaces after ',' (E241)


def test_write_p():
Expand Down
Loading