Skip to content

Commit

Permalink
refactor!: replace safe_ds with safeds (#388)
Browse files Browse the repository at this point in the history
Closes partially #372.

### Summary of Changes

* Rename `safe_ds` to `safeds`.
* Rename `safe_ds_runner` to `safeds_runner`.

---------

Co-authored-by: lars-reimann <[email protected]>
  • Loading branch information
lars-reimann and lars-reimann authored Jan 28, 2023
1 parent f53ab8c commit aeabd97
Show file tree
Hide file tree
Showing 177 changed files with 373 additions and 367 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:

# Requires installation of pytest and pytest-cov
- name: Test with pytest
run: poetry run pytest --doctest-modules --cov=safe_ds_runner --cov-report=xml
run: poetry run pytest --doctest-modules --cov=safeds_runner --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:

# Requires installation of pytest and pytest-cov
- name: Test with pytest
run: poetry run pytest --doctest-modules --cov=safe_ds --cov-report=xml
run: poetry run pytest --doctest-modules --cov=safeds --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ jobs:

# Requires installation of pytest and pytest-cov
- name: Test with pytest
run: poetry run pytest --doctest-modules --cov=safe_ds_runner --cov-report=xml
run: poetry run pytest --doctest-modules --cov=safeds_runner --cov-report=xml

- name: Upload coverage to Codecov
if: ${{ github.actor != 'dependabot[bot]' }}
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:

# Requires installation of pytest and pytest-cov
- name: Test with pytest
run: poetry run pytest --doctest-modules --cov=safe_ds --cov-report=xml
run: poetry run pytest --doctest-modules --cov=safeds --cov-report=xml

- name: Upload coverage to Codecov
if: ${{ github.actor != 'dependabot[bot]' }}
Expand Down
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ disable=
duplicate-code,
metrics,
logging-fstring-interpolation,
too-many-nested-blocks
too-many-nested-blocks,
useless-return
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ import org.eclipse.xtext.generator.IGeneratorContext
*/
class SafeDSGenerator : AbstractGenerator() {

private val codegenPackage = "safeds.codegen"
private val codegenPackage = "safeds_runner.codegen"
private val runtimeBridgePackage = "runtimeBridge"
private val indent = " "

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Imports ----------------------------------------------------------------------

import safeds.codegen
import safeds_runner.codegen

# Pipelines --------------------------------------------------------------------

def test():
f(safeds.codegen.eager_or(g(), g()))
f(safeds.codegen.eager_and(g(), g()))
f(safeds_runner.codegen.eager_or(g(), g()))
f(safeds_runner.codegen.eager_and(g(), g()))
f((h()) == (h()))
f((h()) != (h()))
f((h()) is (h()))
Expand All @@ -19,4 +19,4 @@ def test():
f((h()) - (h()))
f((h()) * (h()))
f((h()) / (h()))
f(safeds.codegen.eager_elvis(i(), i()))
f(safeds_runner.codegen.eager_elvis(i(), i()))
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Imports ----------------------------------------------------------------------

import safeds.codegen
import safeds_runner.codegen

# Pipelines --------------------------------------------------------------------

Expand All @@ -10,5 +10,5 @@ def test():
f(h()[1])
f(C().a)
f(C().c)
f(safeds.codegen.safe_access(factory(), 'a'))
f(safeds.codegen.safe_access(factory(), 'c'))
f(safeds_runner.codegen.safe_access(factory(), 'a'))
f(safeds_runner.codegen.safe_access(factory(), 'c'))
5 changes: 3 additions & 2 deletions Runtime/safe-ds-runner/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ version = "1.0.0"
description = "Run Safe-DS code."
authors = ["Lars Reimann <[email protected]>"]
license = "MIT"

[tool.poetry.scripts]
packages = [
{ include = "safeds_runner" },
]

[tool.poetry.dependencies]
python = "^3.10"
Expand Down
1 change: 0 additions & 1 deletion Runtime/safe-ds-runner/safe_ds_runner/codegen/__init__.py

This file was deleted.

1 change: 1 addition & 0 deletions Runtime/safe-ds-runner/safeds_runner/codegen/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._operators import eager_and, eager_elvis, eager_or, safe_access
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Any, TypeVar, Optional
from typing import Any, Optional, TypeVar


def eager_or(left_operand: bool, right_operand: bool) -> bool:
Expand Down
13 changes: 7 additions & 6 deletions Runtime/safe-ds-runner/tests/codegen/test_eager_and.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest

from safe_ds_runner.codegen import eager_and
from safeds_runner.codegen import eager_and


@pytest.mark.parametrize(
Expand All @@ -10,13 +9,15 @@
(False, True, False),
(True, False, False),
(True, True, True),
]
],
)
def test_should_compute_conjunction(left_operand: bool, right_operand: bool, expected_result: bool):
def test_should_compute_conjunction(
left_operand: bool, right_operand: bool, expected_result: bool
) -> None:
assert eager_and(left_operand, right_operand) == expected_result


def test_should_evaluate_left_operand_before_right_operand():
def test_should_evaluate_left_operand_before_right_operand() -> None:
call_order: list[str] = []

def left() -> bool:
Expand All @@ -32,7 +33,7 @@ def right() -> bool:
assert call_order == ["left", "right"]


def test_should_always_evaluate_both_operands():
def test_should_always_evaluate_both_operands() -> None:
call_order: list[str] = []

def left() -> bool:
Expand Down
13 changes: 7 additions & 6 deletions Runtime/safe-ds-runner/tests/codegen/test_eager_elvis.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from typing import Any

import pytest

from safe_ds_runner.codegen import eager_elvis
from safeds_runner.codegen import eager_elvis


@pytest.mark.parametrize(
Expand All @@ -17,13 +16,15 @@
(True, None, True),
(True, False, True),
(True, True, True),
]
],
)
def test_should_compute_elvis_operation(left_operand: Any, right_operand: Any, expected_result: Any):
def test_should_compute_elvis_operation(
left_operand: Any, right_operand: Any, expected_result: Any
) -> None:
assert eager_elvis(left_operand, right_operand) == expected_result


def test_should_evaluate_left_operand_before_right_operand():
def test_should_evaluate_left_operand_before_right_operand() -> None:
call_order: list[str] = []

def left() -> Any:
Expand All @@ -39,7 +40,7 @@ def right() -> Any:
assert call_order == ["left", "right"]


def test_should_always_evaluate_both_operands():
def test_should_always_evaluate_both_operands() -> None:
call_order: list[str] = []

def left() -> Any:
Expand Down
13 changes: 7 additions & 6 deletions Runtime/safe-ds-runner/tests/codegen/test_eager_or.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest

from safe_ds_runner.codegen import eager_or
from safeds_runner.codegen import eager_or


@pytest.mark.parametrize(
Expand All @@ -10,13 +9,15 @@
(False, True, True),
(True, False, True),
(True, True, True),
]
],
)
def test_should_compute_disjunction(left_operand: bool, right_operand: bool, expected_result: bool):
def test_should_compute_disjunction(
left_operand: bool, right_operand: bool, expected_result: bool
) -> None:
assert eager_or(left_operand, right_operand) == expected_result


def test_should_evaluate_left_operand_before_right_operand():
def test_should_evaluate_left_operand_before_right_operand() -> None:
call_order: list[str] = []

def left() -> bool:
Expand All @@ -32,7 +33,7 @@ def right() -> bool:
assert call_order == ["left", "right"]


def test_should_always_evaluate_both_operands():
def test_should_always_evaluate_both_operands() -> None:
call_order: list[str] = []

def left() -> bool:
Expand Down
20 changes: 9 additions & 11 deletions Runtime/safe-ds-runner/tests/codegen/test_safe_access.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
from typing import Any

import pytest

from safe_ds_runner.codegen import safe_access

from safeds_runner.codegen import safe_access

# Test data --------------------------------------------------------------------


class __C:
def __init__(self):
def __init__(self) -> None:
self.a: int = 1


# Actual tests -----------------------------------------------------------------


@pytest.mark.parametrize(
"receiver,member_name,expected_result",
[
(None, "a", None),
(__C(), "a", 1),
]
],
)
def test_should_guard_against_member_access_on_none(
receiver: Any,
member_name: str,
expected_result: Any
):
receiver: Any, member_name: str, expected_result: Any
) -> None:
assert safe_access(receiver, member_name) == expected_result


def test_should_evaluate_receiver_exactly_once():
def test_should_evaluate_receiver_exactly_once() -> None:
call_order: list[str] = []

def receiver() -> Any:
Expand All @@ -41,6 +39,6 @@ def receiver() -> Any:
assert len(call_order) == 1


def test_should_raise_exception_if_member_does_not_exist():
def test_should_raise_exception_if_member_does_not_exist() -> None:
with pytest.raises(AttributeError, match=r"'__C' object has no attribute 'b'"):
safe_access(__C(), "b")
6 changes: 3 additions & 3 deletions Runtime/safe-ds/demo/demo_Sprint_2.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from safe_ds import plotting
from safe_ds.data import SupervisedDataset, Table
from safe_ds.regression import LinearRegression
from safeds import plotting
from safeds.data import SupervisedDataset, Table
from safeds.regression import LinearRegression
from sklearn.linear_model import LinearRegression as PythonLRS


Expand Down
3 changes: 3 additions & 0 deletions Runtime/safe-ds/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ version = "0.1.0"
description = "The Safe-DS standard library."
authors = ["Lars Reimann <[email protected]>"]
license = "MIT"
packages = [
{ include = "safeds" },
]

[tool.poetry.dependencies]
python = "^3.10"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any

from safe_ds.data import SupervisedDataset, Table
from safe_ds.exceptions import LearningError, PredictionError
from safeds.data import SupervisedDataset, Table
from safeds.exceptions import LearningError, PredictionError
from sklearn.exceptions import NotFittedError


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Optional

# noinspection PyProtectedMember
import safe_ds._util._util_sklearn
from safe_ds.data import SupervisedDataset, Table
import safeds._util._util_sklearn
from safeds.data import SupervisedDataset, Table
from sklearn.ensemble import AdaBoostClassifier as sk_AdaBoostClassifier


Expand Down Expand Up @@ -31,7 +31,7 @@ def fit(self, supervised_dataset: SupervisedDataset) -> None:
LearningError
If the supervised dataset contains invalid values or if the training failed.
"""
self.target_name = safe_ds._util._util_sklearn.fit(
self.target_name = safeds._util._util_sklearn.fit(
self._classification, supervised_dataset
)

Expand All @@ -56,7 +56,7 @@ def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
PredictionError
If prediction with the given dataset failed.
"""
return safe_ds._util._util_sklearn.predict(
return safeds._util._util_sklearn.predict(
self._classification,
dataset,
target_name if target_name is not None else self.target_name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Optional

# noinspection PyProtectedMember
import safe_ds._util._util_sklearn
from safe_ds.data import SupervisedDataset, Table
import safeds._util._util_sklearn
from safeds.data import SupervisedDataset, Table
from sklearn.tree import DecisionTreeClassifier as sk_DecisionTreeClassifier


Expand Down Expand Up @@ -31,7 +31,7 @@ def fit(self, supervised_dataset: SupervisedDataset) -> None:
LearningError
If the supervised dataset contains invalid values or if the training failed.
"""
self.target_name = safe_ds._util._util_sklearn.fit(
self.target_name = safeds._util._util_sklearn.fit(
self._classification, supervised_dataset
)

Expand All @@ -56,7 +56,7 @@ def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
PredictionError
If prediction with the given dataset failed.
"""
return safe_ds._util._util_sklearn.predict(
return safeds._util._util_sklearn.predict(
self._classification,
dataset,
target_name if target_name is not None else self.target_name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Optional

# noinspection PyProtectedMember
import safe_ds._util._util_sklearn
from safe_ds.data import SupervisedDataset, Table
import safeds._util._util_sklearn
from safeds.data import SupervisedDataset, Table
from sklearn.ensemble import GradientBoostingClassifier


Expand Down Expand Up @@ -31,7 +31,7 @@ def fit(self, supervised_dataset: SupervisedDataset) -> None:
LearningError
If the supervised dataset contains invalid values or if the training failed.
"""
self.target_name = safe_ds._util._util_sklearn.fit(
self.target_name = safeds._util._util_sklearn.fit(
self._classification, supervised_dataset
)

Expand All @@ -57,7 +57,7 @@ def predict(self, dataset: Table, target_name: Optional[str] = None) -> Table:
PredictionError
If prediction with the given dataset failed.
"""
return safe_ds._util._util_sklearn.predict(
return safeds._util._util_sklearn.predict(
self._classification,
dataset,
target_name if target_name is not None else self.target_name,
Expand Down
Loading

0 comments on commit aeabd97

Please sign in to comment.