Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ repos:
exclude: '(\.Rd|python/doc/source/reference/.*|test-doctest-.*)'

- repo: https://github.com/tox-dev/tox-ini-fmt
rev: 1.7.2
rev: 1.10.0
hooks:
- id: tox-ini-fmt

- repo: https://github.com/tox-dev/pyproject-fmt
rev: v2.25.2
rev: v2.30.3
hooks:
- id: pyproject-fmt
additional_dependencies: ["tox>=4.12.1"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.21
rev: v0.17.2
hooks:
# Run the formatter.
- id: ruff-format
Expand All @@ -54,7 +54,7 @@ repos:
require_serial: true

- repo: https://github.com/astral-sh/ty-pre-commit
rev: v0.0.89
rev: v0.0.92
hooks:
- id: ty
args: [--project=python, --isolated]
Expand All @@ -65,7 +65,7 @@ repos:
- id: sphinx-lint

- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.3.9030
rev: v0.4.3.9032
hooks:
- id: parsable-R
- id: no-browser-statement
Expand Down
2 changes: 1 addition & 1 deletion c/update_readme.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
import subprocess
from pathlib import Path


def replace_between_markers(
Expand Down
16 changes: 9 additions & 7 deletions python/benchmarks/bench.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import importlib
import pathlib
import numpy as np
import pandas as pd
import shutil
import subprocess
import timeit

import cpuinfo
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import numpy as np
import pandas as pd

import moocore
import timeit
import cpuinfo
import shutil
import subprocess
import importlib

timeit_template_return_1_value = """
def inner(_it, _timer{init}):
Expand Down
10 changes: 5 additions & 5 deletions python/benchmarks/bench_epsilon.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

"""

from bench import Bench, read_data, check_float_values

import numpy as np
import moocore
import pathlib
import matplotlib.pyplot as plt

import matplotlib.pyplot as plt
import numpy as np
from bench import Bench, check_float_values, read_data
from jmetal.core.quality_indicator import EpsilonIndicator as jmetal_EPS

import moocore

path_to_data = "../../testsuite/data/"
if not pathlib.Path(path_to_data).expanduser().exists():
path_to_data = (
Expand Down
23 changes: 11 additions & 12 deletions python/benchmarks/bench_hv.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@

"""

import pathlib

import matplotlib.pyplot as plt
import numpy as np
import torch
from bench import (
Bench,
read_datasets_and_filter_dominated,
get_geomrange,
check_float_values,
get_geomrange,
read_datasets_and_filter_dominated,
)

import numpy as np
import moocore
import pathlib
import matplotlib.pyplot as plt

from botorch.utils.multi_objective.hypervolume import Hypervolume as botorch_HV
import torch
from nevergrad.optimization.multiobjective import HypervolumeIndicator as ng_HV
from fast_pareto import hypervolume as fp_hv
from optuna._hypervolume import compute_hypervolume as optuna_hv

## paretobench is 2x slower than botorch, so too slow for benchmarking.
## https://github.com/electronsandstuff/ParetoBench/issues/57
Expand All @@ -31,8 +27,11 @@
## https://github.com/secondmind-labs/trieste/issues/917
# from trieste.acquisition.multi_objective import Pareto as trieste_Pareto
# import tensorflow as tf

from moarchiving import get_mo_archive as moarch_get_mo_archive
from nevergrad.optimization.multiobjective import HypervolumeIndicator as ng_HV
from optuna._hypervolume import compute_hypervolume as optuna_hv

import moocore

# FIXME: How to test both float and Fractions?
moarch_get_mo_archive.hypervolume_computation_float_type = float
Expand Down
9 changes: 5 additions & 4 deletions python/benchmarks/bench_hvapprox.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@

"""

import numpy as np
import moocore
import pathlib
import matplotlib.pyplot as plt
import timeit # time_hv_exact

import matplotlib.pyplot as plt
import numpy as np
from bench import (
Bench,
read_datasets_and_filter_dominated,
get_range,
read_datasets_and_filter_dominated,
timeit_template_return_1_value, # time_hv_exact
)

import moocore

# See https://github.com/multi-objective/testsuite/tree/main/data
path_to_data = "../../testsuite/data/"
assert pathlib.Path(path_to_data).expanduser().exists()
Expand Down
9 changes: 4 additions & 5 deletions python/benchmarks/bench_igdplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@

"""

import matplotlib.pyplot as plt
import numpy as np
from bench import (
Bench,
check_float_values,
get_geomrange,
read_datasets_and_filter_dominated,
)

import numpy as np
import moocore
import matplotlib.pyplot as plt

from desdeo.tools.indicators_unary import igd_plus_indicator as desdeo_igd_plus
from jmetal.core.quality_indicator import (
InvertedGenerationalDistancePlus as jmetal_IGDplus,
)

import moocore

files = {
"ran.1000pts.3d": "ran.1000pts.3d.10",
}
Expand Down
15 changes: 7 additions & 8 deletions python/benchmarks/bench_ndom.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,27 @@
"""

import gc
import numpy as np
import moocore
import matplotlib.pyplot as plt

from bench import Bench, get_geomrange, check_float_vector

import matplotlib.pyplot as plt
import numpy as np
import torch
from bench import Bench, check_float_vector, get_geomrange
from botorch.utils.multi_objective.pareto import (
is_non_dominated as botorch_is_nondominated,
)

from desdeo.tools.non_dominated_sorting import (
non_dominated as desdeo_is_nondominated,
)
from fast_pareto import is_pareto_front as fast_pareto_is_pf
from optuna.study._multi_objective import _is_pareto_front as optuna_is_pf

## paretobench is always slower than botorch, too slower for benchmarking.
# import paretobench
from paretoset import paretoset
from fast_pareto import is_pareto_front as fast_pareto_is_pf
from optuna.study._multi_objective import _is_pareto_front as optuna_is_pf
from patatune.util import get_dominated as patatune_get_dominated

import moocore

# See https://github.com/multi-objective/testsuite/tree/main/data
files = {
# range are the (start, stop, num) parameters for np.geomspace()
Expand Down
16 changes: 8 additions & 8 deletions python/benchmarks/bench_ndsort.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@

"""

from bench import Bench, get_geomrange, check_array_equal

import numpy as np
import matplotlib.pyplot as plt
import moocore

from pymoo.util.nds.non_dominated_sorting import (
NonDominatedSorting as pymoo_NDS,
)
import numpy as np
from bench import Bench, check_array_equal, get_geomrange
from desdeo.tools.non_dominated_sorting import (
fast_non_dominated_sort as desdeo_nds,
)
from paretoset import paretorank as paretoset_paretorank
from pymoo.util.nds.non_dominated_sorting import (
NonDominatedSorting as pymoo_NDS,
)

import moocore

## It cannot be installed: https://github.com/esa/pygmo2/issues/152
# from pygmo import pareto_dominance as pg_pareto_dominance

Expand Down
1 change: 1 addition & 0 deletions python/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ruff: noqa: D100, D103
import pytest

import moocore


Expand Down
1 change: 1 addition & 0 deletions python/doc/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ruff: noqa: D100, D103
import pytest

import moocore


Expand Down
6 changes: 3 additions & 3 deletions python/doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
from datetime import date
import sphinx

import os
import sys
from datetime import date

import sphinx

# Building the docs requires installing the package.
import moocore
Expand Down
4 changes: 2 additions & 2 deletions python/doc/source/my_unsrt_style.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ruff: noqa: D100, D101, D102
from pybtex.style.formatting.unsrt import Style as UnsrtStyle
from pybtex.style.template import sentence, href, join, optional, field
from pybtex.plugin import register_plugin
from pybtex.style.formatting.unsrt import Style as UnsrtStyle
from pybtex.style.template import field, href, join, optional, sentence


class MyUnsrtStyle(UnsrtStyle):
Expand Down
1 change: 1 addition & 0 deletions python/doc/source/my_unused_images.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ruff: noqa: D100
from pathlib import Path

from docutils import nodes
from sphinx.util import logging

Expand Down
5 changes: 3 additions & 2 deletions python/doc/source/super_with_brackets.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# ruff: noqa: D100, D101
from dataclasses import dataclass, field
from sphinxcontrib.bibtex.style.referencing import BracketStyle, PersonStyle
from sphinxcontrib.bibtex.style.referencing.super_ import SuperReferenceStyle

from sphinxcontrib.bibtex.plugin import (
register_plugin as sphinxcontrib_register_plugin,
)
from sphinxcontrib.bibtex.style.referencing import BracketStyle, PersonStyle
from sphinxcontrib.bibtex.style.referencing.super_ import SuperReferenceStyle


@dataclass
Expand Down
9 changes: 5 additions & 4 deletions python/examples/_utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import numpy as np
import moocore
import matplotlib.pyplot as plt
from matplotlib.patches import Arc
from matplotlib.colors import to_hex
import numpy as np
import plotly.graph_objects as go
from matplotlib.colors import to_hex
from matplotlib.patches import Arc
from plotly.subplots import make_subplots

import moocore


def plot_3d(what, x, title, plotly=False, rank=False, show_index=False):
"""Scatter plot of 3D points."""
Expand Down
1 change: 1 addition & 0 deletions python/examples/plot_eaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import numpy as np
import pandas as pd

import moocore

A = moocore.get_dataset("ALG_1_dat.xz")
Expand Down
6 changes: 3 additions & 3 deletions python/examples/plot_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"""

# sphinx_gallery_multi_image = "single"
import moocore
import numpy as np
import matplotlib.pyplot as plt

import numpy as np
from _utils import plotly_3d, plotly_3d_side_by_side

import moocore


def generate_ndset_plotly_3d(n, method, seed):
"""Generate points with moocore.generate_ndset() and plot them with plotly_3d()."""
Expand Down
6 changes: 3 additions & 3 deletions python/examples/plot_generate_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
"""

# sphinx_gallery_multi_image = "single"
import moocore
import numpy as np
import matplotlib.pyplot as plt
import numpy as np
from _utils import plot_sequence_2d, plotly_3d, plotly_3d_side_by_side

from _utils import plotly_3d, plotly_3d_side_by_side, plot_sequence_2d
import moocore


def plotly_generate_sequence_3d(what, n, method, seed, show_index=False):
Expand Down
3 changes: 2 additions & 1 deletion python/examples/plot_hv_approx.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
"""

# sphinx_gallery_multi_image = "single"
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

import moocore

# %%
Expand Down
3 changes: 2 additions & 1 deletion python/examples/plot_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import numpy as np

import moocore

# %%
Expand Down Expand Up @@ -80,8 +81,8 @@
# Assuming minimization of both objectives, A is better than B in terms of Pareto optimality.
#

import pandas as pd
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns

sns.set_theme()
Expand Down
Loading
Loading