Skip to content

Commit

Permalink
feat: categorize API elements (#1263)
Browse files Browse the repository at this point in the history
### Summary of Changes

Modifies the language stubs in preparation for the Custom
Editor/Visualization PR #1243.
Defines/Adjusts the DataScienceCategories and assigns them to a sample
amount of functions and classes from the Safe-Ds language.

---------

Co-authored-by: Lars Reimann <[email protected]>
  • Loading branch information
GideonKoenig and lars-reimann authored Nov 14, 2024
1 parent 011ba31 commit d0d971e
Show file tree
Hide file tree
Showing 40 changed files with 196 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Image {
*/
@Impure([ImpurityReason.FileReadFromParameterizedPath("path")])
@PythonName("from_file")
@Category(DataScienceCategory.DataImport)
static fun fromFile(
path: String
) -> image: Image
Expand All @@ -60,6 +61,7 @@ class Image {
*/
@Impure([ImpurityReason.FileWriteToParameterizedPath("path")])
@PythonName("to_jpeg_file")
@Category(DataScienceCategory.DataExport)
fun toJpegFile(
path: String
)
Expand All @@ -77,6 +79,7 @@ class Image {
*/
@Impure([ImpurityReason.FileWriteToParameterizedPath("path")])
@PythonName("to_png_file")
@Category(DataScienceCategory.DataExport)
fun toPngFile(
path: String
)
Expand All @@ -98,6 +101,7 @@ class Image {
*/
@Pure
@PythonName("change_channel")
@Category(DataScienceCategory.DataProcessingQImage)
fun changeChannel(
channel: Int
) -> newImage: Image
Expand All @@ -119,6 +123,7 @@ class Image {
* }
*/
@Pure
@Category(DataScienceCategory.DataProcessingQImage)
fun resize(
@PythonName("new_width") const newWidth: Int,
@PythonName("new_height") const newHeight: Int
Expand All @@ -145,6 +150,7 @@ class Image {
*/
@Pure
@PythonName("convert_to_grayscale")
@Category(DataScienceCategory.DataProcessingQImage)
fun convertToGrayscale() -> newImage: Image

/**
Expand All @@ -166,6 +172,7 @@ class Image {
* }
*/
@Pure
@Category(DataScienceCategory.DataProcessingQImage)
fun crop(
const x: Int,
const y: Int,
Expand Down Expand Up @@ -193,6 +200,7 @@ class Image {
*/
@Pure
@PythonName("flip_vertically")
@Category(DataScienceCategory.DataProcessingQImage)
fun flipVertically() -> newImage: Image

/**
Expand All @@ -210,6 +218,7 @@ class Image {
*/
@Pure
@PythonName("flip_horizontally")
@Category(DataScienceCategory.DataProcessingQImage)
fun flipHorizontally() -> newImage: Image

/**
Expand All @@ -233,6 +242,7 @@ class Image {
*/
@Pure
@PythonName("adjust_brightness")
@Category(DataScienceCategory.DataProcessingQImage)
fun adjustBrightness(
const factor: Float
) -> newImage: Image where {
Expand All @@ -256,6 +266,7 @@ class Image {
*/
@Pure
@PythonName("add_noise")
@Category(DataScienceCategory.DataProcessingQImage)
fun addNoise(
@PythonName("standard_deviation") const standardDeviation: Float
) -> newImage: Image where {
Expand All @@ -282,6 +293,7 @@ class Image {
*/
@Pure
@PythonName("adjust_contrast")
@Category(DataScienceCategory.DataProcessingQImage)
fun adjustContrast(
const factor: Float
) -> newImage: Image where {
Expand All @@ -308,6 +320,7 @@ class Image {
*/
@Pure
@PythonName("adjust_color_balance")
@Category(DataScienceCategory.DataProcessingQImage)
fun adjustColorBalance(
const factor: Float
) -> newImage: Image where {
Expand All @@ -331,6 +344,7 @@ class Image {
* }
*/
@Pure
@Category(DataScienceCategory.DataProcessingQImage)
fun blur(
const radius: Int
) -> newImage: Image where {
Expand All @@ -356,6 +370,7 @@ class Image {
* }
*/
@Pure
@Category(DataScienceCategory.DataProcessingQImage)
fun sharpen(
const factor: Float
) -> newImage: Image where {
Expand All @@ -377,6 +392,7 @@ class Image {
*/
@Pure
@PythonName("invert_colors")
@Category(DataScienceCategory.DataProcessingQImage)
fun invertColors() -> newImage: Image

/**
Expand All @@ -394,6 +410,7 @@ class Image {
*/
@Pure
@PythonName("rotate_right")
@Category(DataScienceCategory.DataProcessingQImage)
fun rotateRight() -> newImage: Image

/**
Expand All @@ -411,6 +428,7 @@ class Image {
*/
@Pure
@PythonName("rotate_left")
@Category(DataScienceCategory.DataProcessingQImage)
fun rotateLeft() -> newImage: Image

/**
Expand All @@ -428,5 +446,6 @@ class Image {
*/
@Pure
@PythonName("find_edges")
@Category(DataScienceCategory.DataProcessingQImage)
fun findEdges() -> newImage: Image
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class ImageList {
*/
@Pure
@PythonName("from_images")
@Category(DataScienceCategory.DataImport)
static fun fromImages(
images: List<Image>
) -> imageList: ImageList
Expand All @@ -64,6 +65,7 @@ class ImageList {
*/
@Impure([ImpurityReason.FileReadFromParameterizedPath("path")])
@PythonName("from_files")
@Category(DataScienceCategory.DataImport)
static fun fromFiles(
path: union<List<String>, String>
) -> imageList: ImageList
Expand All @@ -77,6 +79,7 @@ class ImageList {
*/
@Pure
@PythonName("get_image")
@Category(DataScienceCategory.UtilitiesQImage)
fun getImage(
index: Int
) -> image: Image
Expand All @@ -91,6 +94,7 @@ class ImageList {
* @result indices all occurrences of the image
*/
@Pure
@Category(DataScienceCategory.UtilitiesQImage)
fun index(
image: Image
) -> indices: List<Int>
Expand All @@ -104,6 +108,7 @@ class ImageList {
*/
@Pure
@PythonName("has_image")
@Category(DataScienceCategory.UtilitiesQImage)
fun hasImage(
image: Image
) -> hasImage: Boolean
Expand All @@ -115,6 +120,7 @@ class ImageList {
*/
@Impure([ImpurityReason.FileWriteToParameterizedPath("path")])
@PythonName("to_jpeg_files")
@Category(DataScienceCategory.DataExport)
fun toJpegFiles(
path: union<List<String>, String>
)
Expand All @@ -126,6 +132,7 @@ class ImageList {
*/
@Impure([ImpurityReason.FileWriteToParameterizedPath("path")])
@PythonName("to_png_files")
@Category(DataScienceCategory.DataExport)
fun toPngFiles(
path: union<List<String>, String>
)
Expand All @@ -139,6 +146,7 @@ class ImageList {
*/
@Pure
@PythonName("to_images")
@Category(DataScienceCategory.UtilitiesQConversion)
fun toImages(
indices: List<Int>? = null
) -> images: List<Image>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ from safeds.data.tabular.typing import DataType
* val column = Column("test", [1, 2, 3]);
* }
*/
@Category(DataScienceCategory.BasicElement)
class Column<out T = Any?>(
name: String,
data: List<T> = []
Expand Down Expand Up @@ -130,6 +131,7 @@ class Column<out T = Any?>(
* }
*/
@Pure
@Category(DataScienceCategory.DataExplorationQGeneral)
fun all(
predicate: (cell: Cell<T>) -> satisfiesPredicate: Cell<Boolean?>,
@PythonName("ignore_unknown") ignoreUnknown: Boolean = true,
Expand Down Expand Up @@ -173,6 +175,7 @@ class Column<out T = Any?>(
* }
*/
@Pure
@Category(DataScienceCategory.DataExplorationQGeneral)
fun any(
predicate: (cell: Cell<T>) -> satisfiesPredicate: Cell<Boolean?>,
@PythonName("ignore_unknown") ignoreUnknown: Boolean = true,
Expand Down Expand Up @@ -211,6 +214,7 @@ class Column<out T = Any?>(
* }
*/
@Pure
@Category(DataScienceCategory.DataExplorationQGeneral)
fun countIf(
predicate: (cell: Cell<T>) -> satisfiesPredicate: Cell<Boolean?>,
@PythonName("ignore_unknown") ignoreUnknown: Boolean = true,
Expand Down Expand Up @@ -254,6 +258,7 @@ class Column<out T = Any?>(
* }
*/
@Pure
@Category(DataScienceCategory.DataExplorationQGeneral)
fun none(
predicate: (cell: Cell<T>) -> satisfiesPredicate: Cell<Boolean?>,
@PythonName("ignore_unknown") ignoreUnknown: Boolean = true,
Expand All @@ -276,6 +281,7 @@ class Column<out T = Any?>(
* }
*/
@Pure
@Category(DataScienceCategory.DataProcessingQColumn)
fun rename(
@PythonName("new_name") newName: String
) -> renamedColumn: Column<T>
Expand All @@ -297,6 +303,7 @@ class Column<out T = Any?>(
* }
*/
@Pure
@Category(DataScienceCategory.DataProcessingQColumn)
fun transform<R>(
transformer: (cell: Cell<T>) -> transformedCell: Cell<R>
) -> transformedColumn: Column<R>
Expand Down Expand Up @@ -346,6 +353,7 @@ class Column<out T = Any?>(
*/
@Pure
@PythonName("correlation_with")
@Category(DataScienceCategory.DataExplorationQMetric)
fun correlationWith(
other: Column<Any>
) -> correlation: Float
Expand All @@ -365,6 +373,7 @@ class Column<out T = Any?>(
*/
@Pure
@PythonName("distinct_value_count")
@Category(DataScienceCategory.DataExplorationQMetric)
fun distinctValueCount(
@PythonName("ignore_missing_values") ignoreMissingValues: Boolean = true
) -> distinctValueCount: Int
Expand Down Expand Up @@ -393,6 +402,7 @@ class Column<out T = Any?>(
* }
*/
@Pure
@Category(DataScienceCategory.DataExplorationQMetric)
fun idness() -> idness: Float

/**
Expand All @@ -407,6 +417,7 @@ class Column<out T = Any?>(
* }
*/
@Pure
@Category(DataScienceCategory.DataExplorationQMetric)
fun max() -> max: T?

/**
Expand All @@ -423,6 +434,7 @@ class Column<out T = Any?>(
* }
*/
@Pure
@Category(DataScienceCategory.DataExplorationQMetric)
fun mean() -> mean: T

/**
Expand All @@ -440,6 +452,7 @@ class Column<out T = Any?>(
* }
*/
@Pure
@Category(DataScienceCategory.DataExplorationQMetric)
fun median() -> median: T

/**
Expand All @@ -454,6 +467,7 @@ class Column<out T = Any?>(
* }
*/
@Pure
@Category(DataScienceCategory.DataExplorationQMetric)
fun min() -> min: T?

/**
Expand All @@ -469,6 +483,7 @@ class Column<out T = Any?>(
*/
@Pure
@PythonName("missing_value_count")
@Category(DataScienceCategory.DataExplorationQMetric)
fun missingValueCount() -> missingValueCount: Int

/**
Expand All @@ -490,6 +505,7 @@ class Column<out T = Any?>(
*/
@Pure
@PythonName("missing_value_ratio")
@Category(DataScienceCategory.DataExplorationQMetric)
fun missingValueRatio() -> missingValueRatio: Float

/**
Expand All @@ -509,6 +525,7 @@ class Column<out T = Any?>(
* }
*/
@Pure
@Category(DataScienceCategory.DataExplorationQMetric)
fun mode(
@PythonName("ignore_missing_values") ignoreMissingValues: Boolean = true,
) -> mode: List<T?>
Expand All @@ -531,6 +548,7 @@ class Column<out T = Any?>(
* }
*/
@Pure
@Category(DataScienceCategory.DataExplorationQMetric)
fun stability() -> stability: Float

/**
Expand All @@ -549,6 +567,7 @@ class Column<out T = Any?>(
*/
@Pure
@PythonName("standard_deviation")
@Category(DataScienceCategory.DataExplorationQMetric)
fun standardDeviation() -> standardDeviation: Float

/**
Expand All @@ -566,6 +585,7 @@ class Column<out T = Any?>(
* }
*/
@Pure
@Category(DataScienceCategory.DataExplorationQMetric)
fun variance() -> variance: Float

/**
Expand All @@ -581,6 +601,7 @@ class Column<out T = Any?>(
*/
@Pure
@PythonName("to_list")
@Category(DataScienceCategory.UtilitiesQConversion)
fun toList() -> values: List<T>

/**
Expand All @@ -597,5 +618,6 @@ class Column<out T = Any?>(
*/
@Pure
@PythonName("to_table")
@Category(DataScienceCategory.UtilitiesQConversion)
fun toTable() -> table: Table
}
Loading

0 comments on commit d0d971e

Please sign in to comment.