Skip to content

Commit

Permalink
Merge branch 'main' into 161-set-number-of-trees-for-random-forests
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann authored Apr 22, 2023
2 parents 07aa5c2 + 4f08a2c commit a0a61ff
Show file tree
Hide file tree
Showing 44 changed files with 897 additions and 435 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ report/
megalinter-reports/

# Other
.DS_Store/
.DS_Store
*.log
120 changes: 110 additions & 10 deletions docs/development/guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,113 @@ It's more important to provide a user-friendly API to many people than to save s

## Document API elements

The docstrings **should** use the [numpydoc](https://numpydoc.readthedocs.io/en/latest/format.html) format. The descriptions **should not** start with "this" and **should** use imperative mood. Refer to the subsections below for more details on how to document specific API elements.

!!! success "**DO** (library code):"

```py
def add_ints(a: int, b: int) -> int:
"""Add two integers."""
return a + b
```

!!! failure "**DON'T** (library code):"

```py
def add_ints(a: int, b: int) -> int:
"""This function adds two integers."""
return a + b
```

!!! failure "**DON'T** (library code):"

```py
def add_ints(a: int, b: int) -> int:
"""Adds two integers."""
return a + b
```

### Modules

All modules should have

* a one-line description ([short summary][short-summary-section]),
* a longer description if needed ([extended summary][extended-summary-section]).

Example:

```py
"""Containers for tabular data."""
```

### Classes

All classes should have

* a short description,
* examples that show how to use them correctly,
* a description of their attributes.
* a one-line description ([short summary][short-summary-section]),
* a longer description if needed ([extended summary][extended-summary-section])
* a description of the parameters of their `__init__` method ([`Parameters` section][parameters-section]),
* examples that show how to use them correctly ([`Examples` section][examples-section]).

All functions should have
Example:

```py
"""
A row is a collection of named values.
Parameters
----------
data : Mapping[str, Any] | None
The data. If None, an empty row is created.
* a short description,
* examples that show how to use them correctly,
* a description of their parameters,
* a description of their results,
* a description of any exceptions that are raised.
Examples
--------
>>> from safeds.data.tabular.containers import Row
>>> row = Row({"a": 1, "b": 2})
"""
```

The documentation should follow the [numpydoc](https://numpydoc.readthedocs.io/en/latest/format.html) format.
### Functions

All functions should have

* a one-line description ([short summary][short-summary-section]),
* a longer description if needed ([extended summary][extended-summary-section])
* a description of their parameters ([`Parameters` section][parameters-section]),
* a description of their results ([`Returns` section][returns-section]),
* a description of any exceptions that may be raised and under which conditions that may happen ([`Raises` section][raises-section]),
* a description of any warnings that may be issued and under which conditions that may happen ([`Warns` section][warns-section]),
* examples that show how to use them correctly ([`Examples` section][examples-section]).

Example:

```py
"""
Return the value of a specified column.
Parameters
----------
column_name : str
The column name.
Returns
-------
value : Any
The column value.
Raises
------
UnknownColumnNameError
If the row does not contain the specified column.
Examples
--------
>>> from safeds.data.tabular.containers import Row
>>> row = Row({"a": 1, "b": 2})
>>> row.get_value("a")
1
"""
```

## Test non-trivial functions

Expand Down Expand Up @@ -202,3 +294,11 @@ Passing values that are commonly used together around separately is tedious, ver

[src-folder]: https://github.com/Safe-DS/Stdlib/tree/main/src
[tests-folder]: https://github.com/Safe-DS/Stdlib/tree/main/tests

[short-summary-section]: https://numpydoc.readthedocs.io/en/latest/format.html#short-summary
[extended-summary-section]: https://numpydoc.readthedocs.io/en/latest/format.html#extended-summary
[parameters-section]: https://numpydoc.readthedocs.io/en/latest/format.html#parameters
[returns-section]: https://numpydoc.readthedocs.io/en/latest/format.html#returns
[raises-section]: https://numpydoc.readthedocs.io/en/latest/format.html#raises
[warns-section]: https://numpydoc.readthedocs.io/en/latest/format.html#warns
[examples-section]: https://numpydoc.readthedocs.io/en/latest/format.html#examples
102 changes: 2 additions & 100 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ pandas = "^2.0.0"
pillow = "^9.5.0"
scikit-learn = "^1.2.0"
seaborn = "^0.12.2"
polars = {extras = ["pandas", "pyarrow", "xlsx2csv"], version = "^0.17.5"}

[tool.poetry.group.dev.dependencies]
pytest = "^7.2.1"
Expand Down
16 changes: 8 additions & 8 deletions src/safeds/data/image/containers/_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class Image:
"""

@staticmethod
def from_jpeg_file(path: str) -> Image:
def from_jpeg_file(path: str | Path) -> Image:
"""
Create an image from a JPEG file.
Parameters
----------
path : str
path : str | Path
The path to the JPEG file.
Returns
Expand All @@ -41,13 +41,13 @@ def from_jpeg_file(path: str) -> Image:
)

@staticmethod
def from_png_file(path: str) -> Image:
def from_png_file(path: str | Path) -> Image:
"""
Create an image from a PNG file.
Parameters
----------
path : str
path : str | Path
The path to the PNG file.
Returns
Expand Down Expand Up @@ -86,25 +86,25 @@ def format(self) -> ImageFormat:
# Conversion
# ------------------------------------------------------------------------------------------------------------------

def to_jpeg_file(self, path: str) -> None:
def to_jpeg_file(self, path: str | Path) -> None:
"""
Save the image as a JPEG file.
Parameters
----------
path : str
path : str | Path
The path to the JPEG file.
"""
Path(path).parent.mkdir(parents=True, exist_ok=True)
self._image.save(path, format="jpeg")

def to_png_file(self, path: str) -> None:
def to_png_file(self, path: str | Path) -> None:
"""
Save the image as a PNG file.
Parameters
----------
path : str
path : str | Path
The path to the PNG file.
"""
Path(path).parent.mkdir(parents=True, exist_ok=True)
Expand Down
3 changes: 0 additions & 3 deletions src/safeds/data/tabular/containers/_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ def __eq__(self, other: object) -> bool:
def __getitem__(self, index: int) -> Any:
return self.get_value(index)

def __hash__(self) -> int:
return hash(self._data)

def __iter__(self) -> Iterator[Any]:
return iter(self._data)

Expand Down
Loading

0 comments on commit a0a61ff

Please sign in to comment.