Skip to content

Commit

Permalink
feat: adjust Column, Schema and Table to changes in Row (#216)
Browse files Browse the repository at this point in the history
### Summary of Changes

* In `Column`:
  * Rename `count` to `n_rows` and make it a property

* In `Schema`:
  * Rename `get_column_names` to `column_names` and make it a property
  * Rename `get_type_of_column` to `get_column_type`

* In `Table`:
  * Rename `count_columns` to `n_columns` and make it a property
  * Rename `count_rows` to `n_rows` and make it a property
  * Rename `get_type_of_column` to `get_column_type`
* Remove `row count` from `summary` since it's the same for all columns
anyway
  • Loading branch information
lars-reimann committed Apr 20, 2023
1 parent b12fc68 commit ca3eebb
Show file tree
Hide file tree
Showing 43 changed files with 187 additions and 186 deletions.
23 changes: 12 additions & 11 deletions src/safeds/data/tabular/containers/_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ def name(self) -> str:
"""
return self._name

@property
def n_rows(self) -> int:
"""
Return the number of elements in the column.
Returns
-------
n_rows : int
The number of elements.
"""
return len(self._data)

@property
def type(self) -> ColumnType:
"""
Expand Down Expand Up @@ -148,17 +160,6 @@ def get_value(self, index: int) -> Any:
# Information
# ------------------------------------------------------------------------------------------------------------------

def count(self) -> int:
"""
Return the number of elements in the column.
Returns
-------
count : int
The number of elements.
"""
return len(self._data)

def all(self, predicate: Callable[[Any], bool]) -> bool:
"""
Check if all values have a given property.
Expand Down
4 changes: 2 additions & 2 deletions src/safeds/data/tabular/containers/_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def column_names(self) -> list[str]:
>>> row.column_names
['a', 'b']
"""
return self._schema.get_column_names()
return self._schema.column_names

@property
def n_columns(self) -> int:
Expand Down Expand Up @@ -426,7 +426,7 @@ def get_column_type(self, column_name: str) -> ColumnType:
>>> row.get_column_type("a")
Integer
"""
return self._schema.get_type_of_column(column_name)
return self._schema.get_column_type(column_name)

# ------------------------------------------------------------------------------------------------------------------
# Conversion
Expand Down

0 comments on commit ca3eebb

Please sign in to comment.