Skip to content

Commit

Permalink
Merge branch 'main' into implement_grid_search
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescMartiEscofetQC committed Jun 26, 2024
2 parents c2bda63 + 2f530b2 commit d4cfb2a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
env: ["py310", "py311", "py312"]
steps:
- name: Checkout branch
Expand Down
38 changes: 38 additions & 0 deletions docs/development.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Development
===========

The ``metalearners`` repository can be cloned as follows

.. code-block:: console
git clone https://github.com/Quantco/metalearners.git
The dependencies are managed via
`pixi <https://pixi.sh/latest/>`_. Please make sure to install ``pixi`` on
your system. Once pixi is installed, you can install and run the
pre-commit hooks as follows:


.. code-block:: console
pixi run pre-commit-install
pixi run pre-commit-run
You can run the tests as follows:

.. code-block:: console
pixi run postinstall
pixi run pytest tests
You can build the documentation locally by running

.. code-block:: console
pixi run -e docs postinstall
pixi run -e docs docs
You can then inspect the locally built docs by opening ``docs/_build/index.html``.

You can find all pixi tasks in ``pixi.toml``.
2 changes: 2 additions & 0 deletions docs/examples/example_reuse.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@
"drlearner = DRLearner(\n",
" nuisance_model_factory=LGBMRegressor,\n",
" treatment_model_factory=LGBMRegressor,\n",
" nuisance_model_params={\"verbose\": -1},\n",
" treatment_model_params={\"verbose\": -1},\n",
" fitted_propensity_model=trained_propensity_model,\n",
" is_classification=False,\n",
" n_variants=2,\n",
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Welcome to metalearners's documentation!
Glossary <glossary.rst>
What about parallelism? <parallelism.rst>
Examples <examples/index.rst>
Development <development.rst>
FAQ <faq.rst>
API Reference <api/modules>
Change Log <changelog.rst>
Expand Down
5 changes: 3 additions & 2 deletions metalearners/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,10 @@ def convert_treatment(treatment: Vector) -> np.ndarray:
new_treatment = treatment.to_numpy()
if new_treatment.dtype == bool:
return new_treatment.astype(int)
elif new_treatment.dtype == float and all(x.is_integer() for x in new_treatment):
if new_treatment.dtype == float and all(x.is_integer() for x in new_treatment):
return new_treatment.astype(int)
elif new_treatment.dtype != int:

if not pd.api.types.is_integer_dtype(new_treatment):
raise TypeError(
"Treatment must be boolean, integer or float with integer values."
)
Expand Down

0 comments on commit d4cfb2a

Please sign in to comment.