Skip to content

Commit

Permalink
Fix reversed row index in datagrids (#56)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: LucVV <[email protected]>
Co-authored-by: jwmbeenakker <[email protected]>
  • Loading branch information
3 people authored Dec 12, 2023
1 parent e647c2b commit 3afdba8
Show file tree
Hide file tree
Showing 83 changed files with 63,154 additions and 516 deletions.
22 changes: 18 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
with one exception: small features that only simplify access to certain parts of the
ZOS-API can also be added in patch releases.

## [Unreleased]

### Added

### Fixed

### Changed

### Deprecated

### Removed

## [[1.1.2]](https://github.com/MREYE-LUMC/ZOSPy/releases/tag/v1.1.2) - 2023-12-11

### Fixed

- Reversed row index of datagrids in `zospy.utils.zputils.unpack_datagrid` (!42)

## [[1.1.1]](https://github.com/MREYE-LUMC/ZOSPy/releases/tag/v1.1.1) - 2023-09-25

### Added
Expand All @@ -18,8 +36,6 @@ ZOS-API can also be added in patch releases.
### Fixed

- Erroneous parsing of analyses results when textfile encoding was not set to `Unicode` by implementing `zospy.zpcore.ZOS.get_txt_file_encoding` (!36)


- Bug that did not allow users to change the LensUpdateMode directly through `OpticStudioSystem.LensUpdateMode` (#40)

### Changed
Expand All @@ -32,8 +48,6 @@ ZOS-API can also be added in patch releases.

- Separate calls to `ZOS.wakeup` are now redundant. This method will be removed in a later release (#26)

### Removed

## [[1.1.0]](https://github.com/MREYE-LUMC/ZOSPy/releases/tag/v1.1.0) - 2023-07-03

### Added
Expand Down
10 changes: 10 additions & 0 deletions scripts/generate_test_reference_data/systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,13 @@ def polarized_system(oss: zp.zpcore.OpticStudioSystem) -> zp.zpcore.OpticStudioS
lens_front.GetCellAt(18).DoubleValue = 0 # D real

return oss


def decentered_system(oss: zp.zpcore.OpticStudioSystem) -> zp.zpcore.OpticStudioSystem:
oss = simple_system(oss)

field = oss.SystemData.Fields.GetField(1)
field.X = 10
field.Y = 20

return oss
4 changes: 4 additions & 0 deletions scripts/generate_test_reference_data/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ tests:
analysis: psf.huygens_psf
file: test_psf.py
test: test_huygens_psf_returns_correct_result
- model: decentered_system
analysis: psf.huygens_psf
file: test_psf.py
test: test_huygens_psf_asymmetric_returns_correct_result
- model: simple_system
analysis: raysandspots.single_ray_trace
file: test_raysandspots.py
Expand Down
17 changes: 14 additions & 3 deletions tests/analyses/test_psf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import pytest
from pandas.testing import assert_frame_equal

from zospy.analyses.psf import huygens_psf

Expand All @@ -17,9 +18,19 @@ def test_to_json(self, simple_system):
def test_huygens_psf_returns_correct_result(self, simple_system, expected_data):
result = huygens_psf(simple_system)

assert np.allclose(result.Data.astype(float), expected_data.Data.astype(float))
assert_frame_equal(result.Data.astype(float), expected_data.Data.astype(float))

def test_huygens_psf_matches_reference_data(self, simple_system, reference_data):
result = huygens_psf(simple_system)

assert np.allclose(result.Data.astype(float), reference_data.Data.astype(float))
assert_frame_equal(result.Data.astype(float), reference_data.Data.astype(float))

def test_huygens_psf_asymmetric_returns_correct_result(self, decentered_system, expected_data):
result = huygens_psf(decentered_system)

assert_frame_equal(result.Data.astype(float), expected_data.Data.astype(float))

def test_huygens_psf_asymmetric_matches_reference_data(self, decentered_system, reference_data):
result = huygens_psf(decentered_system)

assert_frame_equal(result.Data.astype(float), reference_data.Data.astype(float))
5 changes: 3 additions & 2 deletions tests/analyses/test_surface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import pytest
from pandas.testing import assert_frame_equal

from zospy.analyses.surface import curvature

Expand Down Expand Up @@ -51,7 +52,7 @@ def test_curvature_returns_correct_result(
bfs_reversedirection=bfs_reversedirection,
)

assert np.allclose(result.Data, expected_data.Data, equal_nan=True)
assert_frame_equal(result.Data, expected_data.Data)

@pytest.mark.parametrize(
"sampling,data,remove,surface,showas,contourformat,bfs_criterion,bfs_reversedirection",
Expand Down Expand Up @@ -89,4 +90,4 @@ def test_curvature_matches_reference_data(
bfs_reversedirection=bfs_reversedirection,
)

assert np.allclose(result.Data, reference_data.Data, equal_nan=True)
assert_frame_equal(result.Data, reference_data.Data)
12 changes: 12 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,18 @@ def polarized_system(simple_system) -> zp.zpcore.OpticStudioSystem:
return oss


@pytest.fixture
def decentered_system(simple_system) -> zp.zpcore.OpticStudioSystem:
"""Simple system with incoming rays at a non-zero angle"""
oss = simple_system

field = oss.SystemData.Fields.GetField(1)
field.X = 10
field.Y = 20

return oss


@pytest.fixture
def nsc_empty_system(oss, system_save_file) -> zp.zpcore.OpticStudioSystem:
oss.new()
Expand Down
Loading

0 comments on commit 3afdba8

Please sign in to comment.