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

Enable CI on windows-latest #48

Merged
merged 8 commits into from
Mar 21, 2023
Merged

Enable CI on windows-latest #48

merged 8 commits into from
Mar 21, 2023

Conversation

marcofavoritobi
Copy link
Contributor

Proposed changes

This PR makes the test CI workflow to run over windows-latest.

Fixes

n/a

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

n/a

@codecov-commenter
Copy link

codecov-commenter commented Mar 17, 2023

Codecov Report

Merging #48 (6a3b098) into main (4624af4) will increase coverage by 0.06%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #48      +/-   ##
==========================================
+ Coverage   96.79%   96.86%   +0.06%     
==========================================
  Files          31       31              
  Lines        1499     1499              
==========================================
+ Hits         1451     1452       +1     
+ Misses         48       47       -1     
Impacted Files Coverage Δ
black_it/loss_functions/gsl_div.py 100.00% <ø> (ø)
black_it/samplers/xgboost.py 100.00% <100.00%> (+1.78%) ⬆️

@marcofavoritobi marcofavoritobi force-pushed the ci/enable-windows branch 9 times, most recently from 27064b9 to b222365 Compare March 17, 2023 22:00
@marcofavoritobi
Copy link
Contributor Author

Tests failing on Windows: https://github.com/bancaditalia/black-it/actions/runs/4451921576/jobs/7819104632?pr=48#step:6:3367

FAILED tests/test_calibrator.py::TestCalibrate::test_calibrator_calibrate[2]
FAILED tests/test_calibrator.py::TestCalibrate::test_calibrator_calibrate[1]
FAILED tests/test_examples/test_docker_sir.py::TestDockerSirMainExample::test_run
FAILED black_it/loss_functions/gsl_div.py::black_it.loss_functions.gsl_div.GslDivLoss.discretize
FAILED tests/test_samplers/test_xgboost.py::test_xgboost_2d - assert False

@marcofavoritobi marcofavoritobi force-pushed the ci/enable-windows branch 5 times, most recently from 83c7a50 to 41754d9 Compare March 18, 2023 12:01
@marcofavoritobi marcofavoritobi marked this pull request as ready for review March 18, 2023 12:16
@marcofavoritobi marcofavoritobi force-pushed the ci/enable-windows branch 4 times, most recently from cc206fd to 19af72c Compare March 18, 2023 20:06
Copy link
Contributor

@AldoGl AldoGl left a comment

Choose a reason for hiding this comment

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

LGTM, thanks. After this and #47 we should probably advertise that we now support Windows and MacOS on the GitHub page and on the website, but we can do this in another PR

@@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
os: [ubuntu-latest]
os: [ubuntu-latest, windows-latest]
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏼

@@ -135,6 +135,7 @@ def fit(self, X: NDArray[np.float64], y: NDArray[np.float64]) -> None:
max_depth=self.max_depth, # original: 5
alpha=self.alpha,
n_estimators=self.n_estimators,
random_state=self._get_random_seed(),
Copy link
Contributor

Choose a reason for hiding this comment

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

sorry, probably my fault, thanks for spotting it!

@marcofavoritobi marcofavoritobi force-pushed the ci/enable-windows branch 2 times, most recently from c1add84 to b5e8818 Compare March 20, 2023 14:51
In XGBoostSampler.fit, XGBRegressor constructor did not have the
random_state argument set; this ended up in non-reproducible results
even if random_state of the BaseSampler was set correctly.
This commit fixes a subtle bug in XGBoostSampler._clip_losses. The check
on large/small floats makes use of np.where, which returns a tuple where
the conditions provided in input hold. In case of one condition, it returns
a tuple of one element. However, right below, the result was used as if it
were the actual list of items that satisfied the condition, rather than
as it is wrapped with a tuple. This makes the check always to fail, and to
clip even when not needed.

The proposed change correctly unpacks the tuple returned by np.where.
This change is motivated by the fact that, for some reason, the representation
of Numpy arrays in Windows also include their dtype.

For example, running the following code snippet on Linux:

    GslDivLoss.discretize(
        [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
        nb_values = 3,
        start_index = 1,
        stop_index = 10
    )

Gives:

    array([1, 1, 1, 2, 2, 2, 2, 3, 3, 3])

While on Windows, the same code produces the following representation:

    array([1, 1, 1, 2, 2, 2, 2, 3, 3, 3], dtype=int64)

This of course led to the failure of the doctest, since it is based on the representation of the object being tested for equality.
Using .tolist() was a relatively straighforward (although less elegant) solution.
We had to workaround issue #49 by providing different expected results
for Windows.
@AldoGl AldoGl force-pushed the ci/enable-windows branch from 6a3b098 to f4655d5 Compare March 20, 2023 18:59
@marcofavoritobi
Copy link
Contributor Author

marcofavoritobi commented Mar 21, 2023

Thanks @AldoGl for ce29fdf and f4655d5!

@marcofavoritobi marcofavoritobi merged commit c0e2e68 into main Mar 21, 2023
@AldoGl AldoGl deleted the ci/enable-windows branch March 21, 2023 09: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.

4 participants