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

Setup QuantEcon-wasm library #1

Merged
merged 3 commits into from
Jan 23, 2025
Merged

Setup QuantEcon-wasm library #1

merged 3 commits into from
Jan 23, 2025

Conversation

kp992
Copy link
Collaborator

@kp992 kp992 commented Jan 4, 2025

Setup QuantEcon-wasm library. This PR mirrors the original QuantEcon.py library and removes numba dependency for WASM environments.

@kp992
Copy link
Collaborator Author

kp992 commented Jan 5, 2025

Locally all the tests are passing:

% pytest -n auto
============================================================================ test session starts =============================================================================
platform darwin -- Python 3.10.15, pytest-8.1.0, pluggy-1.4.0
rootdir: /Users/kpl/repos/QuantEcon.py-wasm
configfile: pytest.ini
plugins: anyio-4.0.0, xdist-3.6.1
8 workers [532 items]   
....................................................................................................................................................................... [ 31%]
............................x......................................................................................................................................... [ 62%]
...................................................................................................................................................................... [ 93%]
.................................                                                                                                                                      [100%]
============================================================================== warnings summary ==============================================================================
quantecon_wasm/markov/tests/test_ddp.py::TestFiniteHorizon::test_backward_induction
quantecon_wasm/markov/tests/test_ddp.py::test_ddp_beta_1_not_implemented_error
  /Users/kpl/repos/QuantEcon.py-wasm/quantecon_wasm/markov/ddp.py:430: UserWarning: infinite horizon solution methods are disabled with beta=1
    warnings.warn(msg)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================ 531 passed, 1 xfailed, 2 warnings in 57.99s =================================================================

One of the tests is failing and is known to me. It's marked with xfail.

@mmcky
Copy link
Contributor

mmcky commented Jan 7, 2025

@kp992 I will dive into this error on Thur/Fri this week.

@mmcky
Copy link
Contributor

mmcky commented Jan 10, 2025

@kp992 an fail is an expected fail so that isn't causing the failure

Looks like tolerances are different

=========================== short test summary info ============================
FAILED quantecon_wasm/tests/test_quad.py::TestQnwbeta::test_qnwbeta_nodes_3d - AssertionError: 
Not equal to tolerance rtol=1e-07, atol=0

Mismatched elements: 459 / 945 (48.6%)
Max absolute difference among violations: 0.92125805
Max relative difference among violations: 2.55069065
 ACTUAL: array([[0.022479, 0.236368, 0.022315],
       [0.26579 , 0.236368, 0.022315],
       [0.943737, 0.236368, 0.022315],...
 DESIRED: array([[0.022479, 0.236368, 0.022315],
       [0.114679, 0.236368, 0.022315],
       [0.26579 , 0.236368, 0.022315],...
FAILED quantecon_wasm/tests/test_quad.py::TestQnwbeta::test_qnwbeta_weights_3d - AssertionError: 
Not equal to tolerance rtol=1e-07, atol=0

Mismatched elements: 297 / 315 (94.3%)
Max absolute difference among violations: 0.02843322
Max relative difference among violations: 9.73330951
 ACTUAL: array([7.406938e-05, 1.685941e-04, 6.900889e-06, 6.900889e-06,
       1.685941e-04, 7.406938e-05, 7.406938e-05, 6.015995e-05,
       1.369339e-04, 5.604977e-06, 5.604977e-06, 1.369339e-04,...
 DESIRED: array([7.406938e-05, 1.462522e-04, 1.685941e-04, 1.417735e-04,
       8.785608e-05, 3.627328e-05, 6.900889e-06, 8.981213e-04,
       1.773368e-03, 2.044271e-03, 1.719061e-03, 1.065291e-03,...
====== 2 failed, 529 passed, 1 xfailed, 14 warnings in 106.61s (0:01:46) =======

@kp992
Copy link
Collaborator Author

kp992 commented Jan 10, 2025

Thanks @mmcky for checking that. Are they failing on your local machine too?

@kp992
Copy link
Collaborator Author

kp992 commented Jan 11, 2025

Ah, I get it. My local machine was using numpy 1.26 but with the numpy 2.2.1, I start getting these errors.

Copy link
Contributor

@mmcky mmcky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @kp992 - it will be interesting to start benchmarking the wasm and non-wasm versions via the test cases :-)

dynamic = ["description", "version"]
requires-python = ">=3.7"
dependencies = [
'numpy>=1.17.0',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kp992 does this need to be numpy >= 2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, thanks. Nice catch!

@mmcky
Copy link
Contributor

mmcky commented Jan 23, 2025

@kp992 happy for me to merge this? or want to make that change first?

@kp992
Copy link
Collaborator Author

kp992 commented Jan 23, 2025

sure, lets merge this.

@mmcky mmcky merged commit e6cf0e0 into main Jan 23, 2025
2 checks passed
@mmcky mmcky deleted the setup1 branch January 23, 2025 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants