1///|
2pub struct Axes {
3 priv @python.PyObject
obj : struct @python.PyObject {
// private fields
}
PyObject
4}
5
6///| Plot y versus x as lines and/or markers. Same as `matplotlib.pyplot.plot` in Python.
7///
8/// ## Arguments
9///
10/// - `xs`: x-coordinates of the points to plot.
11/// - `ys`: y-coordinates of the points to plot.
12///
13/// ## Optional Arguments
14///
15/// - `format`: A format string that specifies the color and line style of the plot. Default is "r" (red line).
16/// - `label`: A label for the plot, used in the legend. Default is None.
17/// - `linewidth`: The width of the line. Default is 1.0.
18/// - `linestyle`: The style of the line. Default is solid line.
19/// - `alpha`: The transparency of the plot. Default is 1.0 (opaque).
20///
21/// (To be added later)
22pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, xs : Array[Double], ys : Array[Double], color~ : Color = .., label~ : String? = .., linewidth~ : Double = .., alpha~ : Double = .., linestyle~ : LineStyle = ..) -> Unit
Plot y versus x as lines and/or markers. Same as matplotlib.pyplot.plot in Python.
Arguments
xs: x-coordinates of the points to plot.
ys: y-coordinates of the points to plot.
Optional Arguments
format: A format string that specifies the color and line style of the plot. Default is "r" (red line).
label: A label for the plot, used in the legend. Default is None.
linewidth: The width of the line. Default is 1.0.
linestyle: The style of the line. Default is solid line.
alpha: The transparency of the plot. Default is 1.0 (opaque).
(To be added later)
plot(
23 Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes,
24 Array[Double]
xs : type Array[T]
An Array is a collection of values that supports random access and can
grow in size.
Array[Double
Double],
25 Array[Double]
ys : type Array[T]
An Array is a collection of values that supports random access and can
grow in size.
Array[Double
Double],
26 Color
color~ : enum Color {
Aliceblue
Antiquewhite
Aqua
Aquamarine
Azure
Beige
Bisque
Black
Blanchedalmond
Blue
Blueviolet
Brown
Burlywood
Cadetblue
Chartreuse
Chocolate
Coral
Cornflowerblue
Cornsilk
Crimson
Cyan
Darkblue
Darkcyan
Darkgoldenrod
Darkgray
Darkgreen
Darkgrey
Darkkhaki
Darkmagenta
Darkolivegreen
Darkorange
Darkorchid
Darkred
Darksalmon
Darkseagreen
Darkslateblue
Darkslategray
Darkslategrey
Darkturquoise
Darkviolet
Deeppink
Deepskyblue
Dimgray
Dimgrey
Dodgerblue
Firebrick
Floralwhite
Forestgreen
Fuchsia
Gainsboro
Ghostwhite
Gold
Goldenrod
Gray
Green
Greenyellow
Grey
Honeydew
Hotpink
Indianred
Indigo
Ivory
Khaki
Lavender
Lavenderblush
Lawngreen
Lemonchiffon
Lightblue
Lightcoral
Lightcyan
Lightgoldenrodyellow
Lightgray
Lightgreen
Lightgrey
Lightpink
Lightsalmon
Lightseagreen
Lightskyblue
Lightslategray
Lightslategrey
Lightsteelblue
Lightyellow
Lime
Limegreen
Linen
Magenta
Maroon
Mediumaquamarine
Mediumblue
Mediumorchid
Mediumpurple
Mediumseagreen
Mediumslateblue
Mediumspringgreen
Mediumturquoise
Mediumvioletred
Midnightblue
Mintcream
Mistyrose
Moccasin
Navajowhite
Navy
Oldlace
Olive
Olivedrab
Orange
Orangered
Orchid
Palegoldenrod
Palegreen
Paleturquoise
Palevioletred
Papayawhip
Peachpuff
Peru
Pink
Plum
Powderblue
Purple
Rebeccapurple
Red
Rosybrown
Royalblue
Saddlebrown
Salmon
Sandybrown
Seagreen
Seashell
Sienna
Silver
Skyblue
Slateblue
Slategray
Slategrey
Snow
Springgreen
Steelblue
Tan
Teal
Thistle
Tomato
Turquoise
Violet
Wheat
White
Whitesmoke
Yellow
Yellowgreen
Rgb(Int, Int, Int)
}
Color = Color
Blue,
27 String?
label~ : String
String? = String?
None,
28 Double
linewidth~ : Double
Double = 1.0,
29 Double
alpha~ : Double
Double = 1.0,
30 LineStyle
linestyle~ : enum LineStyle {
Solid
Dashed
Dotted
DashDot
}
LineStyle = LineStyle
Solid
31) -> Unit
Unit {
32 guard Array[Double]
xs.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (x : Int, y : Int) -> Bool
!= 0 else {
33 (input : String) -> Unit
Prints any value that implements the Show trait to the standard output,
followed by a newline.
Parameters:
value : The value to be printed. Must implement the Show trait.
Example:
test "println" {
println(42)
println("Hello, World!")
println([1, 2, 3])
}
println("Error: xs must have at least one element.")
34 return
35 }
36 guard Array[Double]
xs.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (self : Int, other : Int) -> Bool
Compares two integers for equality.
Parameters:
self : The first integer to compare.
other : The second integer to compare.
Returns true if both integers have the same value, false otherwise.
Example:
test "Int::op_equal" {
inspect(42 == 42, content="true")
inspect(42 == -42, content="false")
}
== Array[Double]
ys.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() else {
37 (input : String) -> Unit
Prints any value that implements the Show trait to the standard output,
followed by a newline.
Parameters:
value : The value to be printed. Must implement the Show trait.
Example:
test "println" {
println(42)
println("Hello, World!")
println([1, 2, 3])
}
println("Error: xs and ys must have the same length.")
38 return
39 }
40 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("plot") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
41 let @python.PyList
xs = Array[Double]
xs.(self : Array[Double], f : (Double) -> @python.PyFloat) -> Array[@python.PyFloat]
Maps a function over the elements of the array.
Example
let v = [3, 4, 5]
let v2 = v.map(fn (x) {x + 1})
assert_eq(v2, [4, 5, 6])
map(struct @python.PyFloat {
// private fields
}
PyFloat(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
::from) |> struct @python.PyList {
// private fields
}
PyList(Array[@python.PyFloat]) -> @python.PyList
Create a new python list from a python object array
Example
test "PyList::from" {
let arr: Array[&IsPyObject] = Array::new()
let one = PyInteger::from(1);
let two = PyFloat::from(2.0);
let three = PyString::from("three");
arr.push(one)
arr.push(two)
arr.push(three)
let list = PyList::from(arr);
inspect!(list, content="[1, 2.0, \'three\']")
}
::from
42 let @python.PyList
ys = Array[Double]
ys.(self : Array[Double], f : (Double) -> @python.PyFloat) -> Array[@python.PyFloat]
Maps a function over the elements of the array.
Example
let v = [3, 4, 5]
let v2 = v.map(fn (x) {x + 1})
assert_eq(v2, [4, 5, 6])
map(struct @python.PyFloat {
// private fields
}
PyFloat(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
::from) |> struct @python.PyList {
// private fields
}
PyList(Array[@python.PyFloat]) -> @python.PyList
Create a new python list from a python object array
Example
test "PyList::from" {
let arr: Array[&IsPyObject] = Array::new()
let one = PyInteger::from(1);
let two = PyFloat::from(2.0);
let three = PyString::from("three");
arr.push(one)
arr.push(two)
arr.push(three)
let list = PyList::from(arr);
inspect!(list, content="[1, 2.0, \'three\']")
}
::from
43 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(2)
44 @python.PyTuple
args..(self : @python.PyTuple, idx : Int, item : @python.PyList) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, @python.PyList
xs)..(self : @python.PyTuple, idx : Int, item : @python.PyList) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(1, @python.PyList
ys)
45 let @python.PyDict
kwargs : struct @python.PyDict {
// private fields
}
PyDict = struct @python.PyDict {
// private fields
}
PyDict::() -> @python.PyDict
Creates a new python dict object.
Example
test "PyDict::new" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = { 'one': 1, 'two': 2.0, 'three': True }
print(d) # Output: {'one': 1, 'two': 2.0, 'three': True}
new()
46 @python.PyDict
kwargs
47 ..(self : @python.PyDict, key : String, val : @python.PyString) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("color", Color
color.(self : Color) -> @python.PyString
to_pystr())
48 ..(self : @python.PyDict, key : String, val : @python.PyFloat) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("linewidth", struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
linewidth))
49 ..(self : @python.PyDict, key : String, val : @python.PyFloat) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("alpha", struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
alpha))
50 ..(self : @python.PyDict, key : String, val : @python.PyString) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("linestyle", LineStyle
linestyle.(self : LineStyle) -> @python.PyString
to_pystr())
51 if String?
label is (String) -> String?
Some(String
l) {
52 @python.PyDict
kwargs.(self : @python.PyDict, key : String, val : @python.PyString) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("label", struct @python.PyString {
// private fields
}
PyString::(String) -> @python.PyString
Create a PyString from a string
Example
test "PyString::from" {
let s = @python.PyString::from("hello");
inspect(s, content="\'hello\'");
}
from(String
l))
53 }
54 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~, @python.PyDict
kwargs~)
55
56}
57
58///|
59/// Creates a scatter plot on the axes. Each data point is represented by a
60/// marker at the coordinates specified by `x` and `y` arrays.
61/// Same as `matplotlib.pyplot.scatter` in Python.
62///
63/// Parameters:
64///
65/// * `self`: The axes on which to create the scatter plot.
66/// * `xs`: An array of x-coordinates for the data points.
67/// * `ys`: An array of y-coordinates for the data points.
68/// * `color`: The color of the markers. Defaults to blue.
69/// * `marker`: The style of the markers. Defaults to circle ('o').
70/// * `alpha`: The transparency level of the markers, ranging from 0.0
71/// (transparent) to 1.0 (opaque). Defaults to 1.0.
72///
73/// Example:
74///
75/// ```moonbit
76/// test "Axes::scatter" {
77/// let (fig, axes) = @matplotlib.subplots(1, 1)
78/// let x = [1.0, 2.0, 3.0]
79/// let y = [4.0, 5.0, 6.0]
80/// axes[0][0].scatter(x, y, color=Red, marker=Star, alpha=0.5)
81/// }
82/// ```
83pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, xs : Array[Double], ys : Array[Double], color~ : Color = .., marker~ : Marker = .., alpha~ : Double = ..) -> Unit
Creates a scatter plot on the axes. Each data point is represented by a
marker at the coordinates specified by x and y arrays.
Same as matplotlib.pyplot.scatter in Python.
Parameters:
self: The axes on which to create the scatter plot.
xs: An array of x-coordinates for the data points.
ys: An array of y-coordinates for the data points.
color: The color of the markers. Defaults to blue.
marker: The style of the markers. Defaults to circle ('o').
alpha: The transparency level of the markers, ranging from 0.0
(transparent) to 1.0 (opaque). Defaults to 1.0.
Example:
test "Axes::scatter" {
let (fig, axes) = @matplotlib.subplots(1, 1)
let x = [1.0, 2.0, 3.0]
let y = [4.0, 5.0, 6.0]
axes[0][0].scatter(x, y, color=Red, marker=Star, alpha=0.5)
}
scatter(
84 Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes,
85 Array[Double]
xs : type Array[T]
An Array is a collection of values that supports random access and can
grow in size.
Array[Double
Double],
86 Array[Double]
ys : type Array[T]
An Array is a collection of values that supports random access and can
grow in size.
Array[Double
Double],
87 Color
color~ : enum Color {
Aliceblue
Antiquewhite
Aqua
Aquamarine
Azure
Beige
Bisque
Black
Blanchedalmond
Blue
Blueviolet
Brown
Burlywood
Cadetblue
Chartreuse
Chocolate
Coral
Cornflowerblue
Cornsilk
Crimson
Cyan
Darkblue
Darkcyan
Darkgoldenrod
Darkgray
Darkgreen
Darkgrey
Darkkhaki
Darkmagenta
Darkolivegreen
Darkorange
Darkorchid
Darkred
Darksalmon
Darkseagreen
Darkslateblue
Darkslategray
Darkslategrey
Darkturquoise
Darkviolet
Deeppink
Deepskyblue
Dimgray
Dimgrey
Dodgerblue
Firebrick
Floralwhite
Forestgreen
Fuchsia
Gainsboro
Ghostwhite
Gold
Goldenrod
Gray
Green
Greenyellow
Grey
Honeydew
Hotpink
Indianred
Indigo
Ivory
Khaki
Lavender
Lavenderblush
Lawngreen
Lemonchiffon
Lightblue
Lightcoral
Lightcyan
Lightgoldenrodyellow
Lightgray
Lightgreen
Lightgrey
Lightpink
Lightsalmon
Lightseagreen
Lightskyblue
Lightslategray
Lightslategrey
Lightsteelblue
Lightyellow
Lime
Limegreen
Linen
Magenta
Maroon
Mediumaquamarine
Mediumblue
Mediumorchid
Mediumpurple
Mediumseagreen
Mediumslateblue
Mediumspringgreen
Mediumturquoise
Mediumvioletred
Midnightblue
Mintcream
Mistyrose
Moccasin
Navajowhite
Navy
Oldlace
Olive
Olivedrab
Orange
Orangered
Orchid
Palegoldenrod
Palegreen
Paleturquoise
Palevioletred
Papayawhip
Peachpuff
Peru
Pink
Plum
Powderblue
Purple
Rebeccapurple
Red
Rosybrown
Royalblue
Saddlebrown
Salmon
Sandybrown
Seagreen
Seashell
Sienna
Silver
Skyblue
Slateblue
Slategray
Slategrey
Snow
Springgreen
Steelblue
Tan
Teal
Thistle
Tomato
Turquoise
Violet
Wheat
White
Whitesmoke
Yellow
Yellowgreen
Rgb(Int, Int, Int)
}
Color = Color
Blue,
88 Marker
marker~ : enum Marker {
Point
Pixel
Circle
Octagon
Square
Pentagon
Plus
PlusFilled
Star
Hexagon1
Hexagon2
X
XFilled
Diamond
ThinDiamond
Vline
Hline
TriangleUp
TriangleDown
TriangleLeft
TriangleRight
TriDown
TriUp
TriLeft
TriRight
}
Marker = Marker::Marker
Circle,
89 Double
alpha~ : Double
Double = 1.0
90) -> Unit
Unit {
91 guard Array[Double]
xs.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (x : Int, y : Int) -> Bool
!= 0 else {
92 (input : String) -> Unit
Prints any value that implements the Show trait to the standard output,
followed by a newline.
Parameters:
value : The value to be printed. Must implement the Show trait.
Example:
test "println" {
println(42)
println("Hello, World!")
println([1, 2, 3])
}
println("Error: xs must have at least one element.")
93 return
94 }
95 guard Array[Double]
xs.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (self : Int, other : Int) -> Bool
Compares two integers for equality.
Parameters:
self : The first integer to compare.
other : The second integer to compare.
Returns true if both integers have the same value, false otherwise.
Example:
test "Int::op_equal" {
inspect(42 == 42, content="true")
inspect(42 == -42, content="false")
}
== Array[Double]
ys.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() else {
96 (input : String) -> Unit
Prints any value that implements the Show trait to the standard output,
followed by a newline.
Parameters:
value : The value to be printed. Must implement the Show trait.
Example:
test "println" {
println(42)
println("Hello, World!")
println([1, 2, 3])
}
println("Error: xs and ys must have the same length.")
97 return
98 }
99 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("scatter") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
100 let @python.PyList
xs = Array[Double]
xs.(self : Array[Double], f : (Double) -> @python.PyFloat) -> Array[@python.PyFloat]
Maps a function over the elements of the array.
Example
let v = [3, 4, 5]
let v2 = v.map(fn (x) {x + 1})
assert_eq(v2, [4, 5, 6])
map(struct @python.PyFloat {
// private fields
}
PyFloat(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
::from) |> struct @python.PyList {
// private fields
}
PyList(Array[@python.PyFloat]) -> @python.PyList
Create a new python list from a python object array
Example
test "PyList::from" {
let arr: Array[&IsPyObject] = Array::new()
let one = PyInteger::from(1);
let two = PyFloat::from(2.0);
let three = PyString::from("three");
arr.push(one)
arr.push(two)
arr.push(three)
let list = PyList::from(arr);
inspect!(list, content="[1, 2.0, \'three\']")
}
::from
101 let @python.PyList
ys = Array[Double]
ys.(self : Array[Double], f : (Double) -> @python.PyFloat) -> Array[@python.PyFloat]
Maps a function over the elements of the array.
Example
let v = [3, 4, 5]
let v2 = v.map(fn (x) {x + 1})
assert_eq(v2, [4, 5, 6])
map(struct @python.PyFloat {
// private fields
}
PyFloat(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
::from) |> struct @python.PyList {
// private fields
}
PyList(Array[@python.PyFloat]) -> @python.PyList
Create a new python list from a python object array
Example
test "PyList::from" {
let arr: Array[&IsPyObject] = Array::new()
let one = PyInteger::from(1);
let two = PyFloat::from(2.0);
let three = PyString::from("three");
arr.push(one)
arr.push(two)
arr.push(three)
let list = PyList::from(arr);
inspect!(list, content="[1, 2.0, \'three\']")
}
::from
102 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(2)
103 @python.PyTuple
args..(self : @python.PyTuple, idx : Int, item : @python.PyList) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, @python.PyList
xs)..(self : @python.PyTuple, idx : Int, item : @python.PyList) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(1, @python.PyList
ys)
104 let @python.PyDict
kwargs : struct @python.PyDict {
// private fields
}
PyDict = struct @python.PyDict {
// private fields
}
PyDict::() -> @python.PyDict
Creates a new python dict object.
Example
test "PyDict::new" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = { 'one': 1, 'two': 2.0, 'three': True }
print(d) # Output: {'one': 1, 'two': 2.0, 'three': True}
new()
105 @python.PyDict
kwargs
106 ..(self : @python.PyDict, key : String, val : @python.PyString) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("color", Color
color.(self : Color) -> @python.PyString
to_pystr())
107 ..(self : @python.PyDict, key : String, val : @python.PyString) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("marker", Marker
marker.(self : Marker) -> @python.PyString
to_pystr())
108 ..(self : @python.PyDict, key : String, val : @python.PyFloat) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("alpha", struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
alpha))
109 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~, @python.PyDict
kwargs~)
110
111}
112
113///|
114pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, xs : Array[Double], ys : Array[Double], bottom~ : Double = ..) -> Unit
stem(
115 Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes,
116 Array[Double]
xs : type Array[T]
An Array is a collection of values that supports random access and can
grow in size.
Array[Double
Double],
117 Array[Double]
ys : type Array[T]
An Array is a collection of values that supports random access and can
grow in size.
Array[Double
Double],
118 Double
bottom~ : Double
Double = 0.0
119) -> Unit
Unit {
120 guard Array[Double]
xs.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (x : Int, y : Int) -> Bool
!= 0 else {
121 (input : String) -> Unit
Prints any value that implements the Show trait to the standard output,
followed by a newline.
Parameters:
value : The value to be printed. Must implement the Show trait.
Example:
test "println" {
println(42)
println("Hello, World!")
println([1, 2, 3])
}
println("Error: xs must have at least one element.")
122 return
123 }
124 guard Array[Double]
xs.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (self : Int, other : Int) -> Bool
Compares two integers for equality.
Parameters:
self : The first integer to compare.
other : The second integer to compare.
Returns true if both integers have the same value, false otherwise.
Example:
test "Int::op_equal" {
inspect(42 == 42, content="true")
inspect(42 == -42, content="false")
}
== Array[Double]
ys.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() else {
125 (input : String) -> Unit
Prints any value that implements the Show trait to the standard output,
followed by a newline.
Parameters:
value : The value to be printed. Must implement the Show trait.
Example:
test "println" {
println(42)
println("Hello, World!")
println([1, 2, 3])
}
println("Error: xs and ys must have the same length.")
126 return
127 }
128 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("stem") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
129 let @python.PyList
xs = Array[Double]
xs.(self : Array[Double], f : (Double) -> @python.PyFloat) -> Array[@python.PyFloat]
Maps a function over the elements of the array.
Example
let v = [3, 4, 5]
let v2 = v.map(fn (x) {x + 1})
assert_eq(v2, [4, 5, 6])
map(struct @python.PyFloat {
// private fields
}
PyFloat(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
::from) |> struct @python.PyList {
// private fields
}
PyList(Array[@python.PyFloat]) -> @python.PyList
Create a new python list from a python object array
Example
test "PyList::from" {
let arr: Array[&IsPyObject] = Array::new()
let one = PyInteger::from(1);
let two = PyFloat::from(2.0);
let three = PyString::from("three");
arr.push(one)
arr.push(two)
arr.push(three)
let list = PyList::from(arr);
inspect!(list, content="[1, 2.0, \'three\']")
}
::from
130 let @python.PyList
ys = Array[Double]
ys.(self : Array[Double], f : (Double) -> @python.PyFloat) -> Array[@python.PyFloat]
Maps a function over the elements of the array.
Example
let v = [3, 4, 5]
let v2 = v.map(fn (x) {x + 1})
assert_eq(v2, [4, 5, 6])
map(struct @python.PyFloat {
// private fields
}
PyFloat(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
::from) |> struct @python.PyList {
// private fields
}
PyList(Array[@python.PyFloat]) -> @python.PyList
Create a new python list from a python object array
Example
test "PyList::from" {
let arr: Array[&IsPyObject] = Array::new()
let one = PyInteger::from(1);
let two = PyFloat::from(2.0);
let three = PyString::from("three");
arr.push(one)
arr.push(two)
arr.push(three)
let list = PyList::from(arr);
inspect!(list, content="[1, 2.0, \'three\']")
}
::from
131 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(2)
132 @python.PyTuple
args..(self : @python.PyTuple, idx : Int, item : @python.PyList) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, @python.PyList
xs)..(self : @python.PyTuple, idx : Int, item : @python.PyList) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(1, @python.PyList
ys)
133 let @python.PyDict
kwargs : struct @python.PyDict {
// private fields
}
PyDict = struct @python.PyDict {
// private fields
}
PyDict::() -> @python.PyDict
Creates a new python dict object.
Example
test "PyDict::new" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = { 'one': 1, 'two': 2.0, 'three': True }
print(d) # Output: {'one': 1, 'two': 2.0, 'three': True}
new()
134 @python.PyDict
kwargs..(self : @python.PyDict, key : String, val : @python.PyFloat) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("bottom", struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
bottom))
135 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~, @python.PyDict
kwargs~)
136
137}
138
139///|
140/// Creates a bar plot on the axes. Each bar is centered at the x-coordinates
141/// with the specified heights. Same as `matplotlib.pyplot.bar` in Python.
142///
143/// Parameters:
144///
145/// * `self`: The axes on which to create the bar plot.
146/// * `xs`: An array of x-coordinates for the center of each bar.
147/// * `heights`: An array of heights for each bar.
148/// * `width`: The width of each bar. Defaults to 0.8.
149/// * `bottom`: The y-coordinate of the bottom of each bar. Defaults to 0.0.
150/// * `color`: The color of the bars. Defaults to blue.
151///
152/// Example:
153///
154/// ```moonbit
155/// test "Axes::bar" {
156/// let (fig, axes) = @matplotlib.subplots(1, 1)
157/// let x = [1.0, 2.0, 3.0]
158/// let heights = [4.0, 5.0, 6.0]
159/// axes[0][0].bar(x, heights, width=0.5, color=Red)
160/// }
161/// ```
162pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, xs : Array[Double], heights : Array[Double], width~ : Double = .., bottom~ : Double = .., color~ : Color = ..) -> Unit
Creates a bar plot on the axes. Each bar is centered at the x-coordinates
with the specified heights. Same as matplotlib.pyplot.bar in Python.
Parameters:
self: The axes on which to create the bar plot.
xs: An array of x-coordinates for the center of each bar.
heights: An array of heights for each bar.
width: The width of each bar. Defaults to 0.8.
bottom: The y-coordinate of the bottom of each bar. Defaults to 0.0.
color: The color of the bars. Defaults to blue.
Example:
test "Axes::bar" {
let (fig, axes) = @matplotlib.subplots(1, 1)
let x = [1.0, 2.0, 3.0]
let heights = [4.0, 5.0, 6.0]
axes[0][0].bar(x, heights, width=0.5, color=Red)
}
bar(
163 Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes,
164 Array[Double]
xs : type Array[T]
An Array is a collection of values that supports random access and can
grow in size.
Array[Double
Double],
165 Array[Double]
heights : type Array[T]
An Array is a collection of values that supports random access and can
grow in size.
Array[Double
Double],
166 Double
width~ : Double
Double = 0.8,
167 Double
bottom~ : Double
Double = 0.0,
168 Color
color~ : enum Color {
Aliceblue
Antiquewhite
Aqua
Aquamarine
Azure
Beige
Bisque
Black
Blanchedalmond
Blue
Blueviolet
Brown
Burlywood
Cadetblue
Chartreuse
Chocolate
Coral
Cornflowerblue
Cornsilk
Crimson
Cyan
Darkblue
Darkcyan
Darkgoldenrod
Darkgray
Darkgreen
Darkgrey
Darkkhaki
Darkmagenta
Darkolivegreen
Darkorange
Darkorchid
Darkred
Darksalmon
Darkseagreen
Darkslateblue
Darkslategray
Darkslategrey
Darkturquoise
Darkviolet
Deeppink
Deepskyblue
Dimgray
Dimgrey
Dodgerblue
Firebrick
Floralwhite
Forestgreen
Fuchsia
Gainsboro
Ghostwhite
Gold
Goldenrod
Gray
Green
Greenyellow
Grey
Honeydew
Hotpink
Indianred
Indigo
Ivory
Khaki
Lavender
Lavenderblush
Lawngreen
Lemonchiffon
Lightblue
Lightcoral
Lightcyan
Lightgoldenrodyellow
Lightgray
Lightgreen
Lightgrey
Lightpink
Lightsalmon
Lightseagreen
Lightskyblue
Lightslategray
Lightslategrey
Lightsteelblue
Lightyellow
Lime
Limegreen
Linen
Magenta
Maroon
Mediumaquamarine
Mediumblue
Mediumorchid
Mediumpurple
Mediumseagreen
Mediumslateblue
Mediumspringgreen
Mediumturquoise
Mediumvioletred
Midnightblue
Mintcream
Mistyrose
Moccasin
Navajowhite
Navy
Oldlace
Olive
Olivedrab
Orange
Orangered
Orchid
Palegoldenrod
Palegreen
Paleturquoise
Palevioletred
Papayawhip
Peachpuff
Peru
Pink
Plum
Powderblue
Purple
Rebeccapurple
Red
Rosybrown
Royalblue
Saddlebrown
Salmon
Sandybrown
Seagreen
Seashell
Sienna
Silver
Skyblue
Slateblue
Slategray
Slategrey
Snow
Springgreen
Steelblue
Tan
Teal
Thistle
Tomato
Turquoise
Violet
Wheat
White
Whitesmoke
Yellow
Yellowgreen
Rgb(Int, Int, Int)
}
Color = Color
Blue
169) -> Unit
Unit {
170 guard Array[Double]
xs.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (x : Int, y : Int) -> Bool
!= 0 else {
171 (input : String) -> Unit
Prints any value that implements the Show trait to the standard output,
followed by a newline.
Parameters:
value : The value to be printed. Must implement the Show trait.
Example:
test "println" {
println(42)
println("Hello, World!")
println([1, 2, 3])
}
println("Error: xs must have at least one element.")
172 return
173 }
174 guard Array[Double]
xs.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (self : Int, other : Int) -> Bool
Compares two integers for equality.
Parameters:
self : The first integer to compare.
other : The second integer to compare.
Returns true if both integers have the same value, false otherwise.
Example:
test "Int::op_equal" {
inspect(42 == 42, content="true")
inspect(42 == -42, content="false")
}
== Array[Double]
heights.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() else {
175 (input : String) -> Unit
Prints any value that implements the Show trait to the standard output,
followed by a newline.
Parameters:
value : The value to be printed. Must implement the Show trait.
Example:
test "println" {
println(42)
println("Hello, World!")
println([1, 2, 3])
}
println("Error: xs and heights must have the same length.")
176 return
177 }
178 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("bar") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
179 let @python.PyList
xs = Array[Double]
xs.(self : Array[Double], f : (Double) -> @python.PyFloat) -> Array[@python.PyFloat]
Maps a function over the elements of the array.
Example
let v = [3, 4, 5]
let v2 = v.map(fn (x) {x + 1})
assert_eq(v2, [4, 5, 6])
map(struct @python.PyFloat {
// private fields
}
PyFloat(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
::from) |> struct @python.PyList {
// private fields
}
PyList(Array[@python.PyFloat]) -> @python.PyList
Create a new python list from a python object array
Example
test "PyList::from" {
let arr: Array[&IsPyObject] = Array::new()
let one = PyInteger::from(1);
let two = PyFloat::from(2.0);
let three = PyString::from("three");
arr.push(one)
arr.push(two)
arr.push(three)
let list = PyList::from(arr);
inspect!(list, content="[1, 2.0, \'three\']")
}
::from
180 let @python.PyList
heights = Array[Double]
heights.(self : Array[Double], f : (Double) -> @python.PyFloat) -> Array[@python.PyFloat]
Maps a function over the elements of the array.
Example
let v = [3, 4, 5]
let v2 = v.map(fn (x) {x + 1})
assert_eq(v2, [4, 5, 6])
map(struct @python.PyFloat {
// private fields
}
PyFloat(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
::from) |> struct @python.PyList {
// private fields
}
PyList(Array[@python.PyFloat]) -> @python.PyList
Create a new python list from a python object array
Example
test "PyList::from" {
let arr: Array[&IsPyObject] = Array::new()
let one = PyInteger::from(1);
let two = PyFloat::from(2.0);
let three = PyString::from("three");
arr.push(one)
arr.push(two)
arr.push(three)
let list = PyList::from(arr);
inspect!(list, content="[1, 2.0, \'three\']")
}
::from
181 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(2)
182 @python.PyTuple
args..(self : @python.PyTuple, idx : Int, item : @python.PyList) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, @python.PyList
xs)..(self : @python.PyTuple, idx : Int, item : @python.PyList) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(1, @python.PyList
heights)
183 let @python.PyDict
kwargs : struct @python.PyDict {
// private fields
}
PyDict = struct @python.PyDict {
// private fields
}
PyDict::() -> @python.PyDict
Creates a new python dict object.
Example
test "PyDict::new" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = { 'one': 1, 'two': 2.0, 'three': True }
print(d) # Output: {'one': 1, 'two': 2.0, 'three': True}
new()
184 @python.PyDict
kwargs
185 ..(self : @python.PyDict, key : String, val : @python.PyFloat) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("width", struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
width))
186 ..(self : @python.PyDict, key : String, val : @python.PyString) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("color", Color
color.(self : Color) -> @python.PyString
to_pystr())
187 ..(self : @python.PyDict, key : String, val : @python.PyFloat) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("bottom", struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
bottom))
188 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~, @python.PyDict
kwargs~)
189
190}
191
192///|
193pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, ys : Array[Double], widths : Array[Double], hight~ : Double = .., left~ : Double = .., color~ : Color = ..) -> Unit
barh(
194 Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes,
195 Array[Double]
ys : type Array[T]
An Array is a collection of values that supports random access and can
grow in size.
Array[Double
Double],
196 Array[Double]
widths : type Array[T]
An Array is a collection of values that supports random access and can
grow in size.
Array[Double
Double],
197 Double
hight~ : Double
Double = 0.8,
198 Double
left~ : Double
Double = 0.0,
199 Color
color~ : enum Color {
Aliceblue
Antiquewhite
Aqua
Aquamarine
Azure
Beige
Bisque
Black
Blanchedalmond
Blue
Blueviolet
Brown
Burlywood
Cadetblue
Chartreuse
Chocolate
Coral
Cornflowerblue
Cornsilk
Crimson
Cyan
Darkblue
Darkcyan
Darkgoldenrod
Darkgray
Darkgreen
Darkgrey
Darkkhaki
Darkmagenta
Darkolivegreen
Darkorange
Darkorchid
Darkred
Darksalmon
Darkseagreen
Darkslateblue
Darkslategray
Darkslategrey
Darkturquoise
Darkviolet
Deeppink
Deepskyblue
Dimgray
Dimgrey
Dodgerblue
Firebrick
Floralwhite
Forestgreen
Fuchsia
Gainsboro
Ghostwhite
Gold
Goldenrod
Gray
Green
Greenyellow
Grey
Honeydew
Hotpink
Indianred
Indigo
Ivory
Khaki
Lavender
Lavenderblush
Lawngreen
Lemonchiffon
Lightblue
Lightcoral
Lightcyan
Lightgoldenrodyellow
Lightgray
Lightgreen
Lightgrey
Lightpink
Lightsalmon
Lightseagreen
Lightskyblue
Lightslategray
Lightslategrey
Lightsteelblue
Lightyellow
Lime
Limegreen
Linen
Magenta
Maroon
Mediumaquamarine
Mediumblue
Mediumorchid
Mediumpurple
Mediumseagreen
Mediumslateblue
Mediumspringgreen
Mediumturquoise
Mediumvioletred
Midnightblue
Mintcream
Mistyrose
Moccasin
Navajowhite
Navy
Oldlace
Olive
Olivedrab
Orange
Orangered
Orchid
Palegoldenrod
Palegreen
Paleturquoise
Palevioletred
Papayawhip
Peachpuff
Peru
Pink
Plum
Powderblue
Purple
Rebeccapurple
Red
Rosybrown
Royalblue
Saddlebrown
Salmon
Sandybrown
Seagreen
Seashell
Sienna
Silver
Skyblue
Slateblue
Slategray
Slategrey
Snow
Springgreen
Steelblue
Tan
Teal
Thistle
Tomato
Turquoise
Violet
Wheat
White
Whitesmoke
Yellow
Yellowgreen
Rgb(Int, Int, Int)
}
Color = Color
Blue
200) -> Unit
Unit {
201 guard Array[Double]
ys.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (x : Int, y : Int) -> Bool
!= 0 else {
202 (input : String) -> Unit
Prints any value that implements the Show trait to the standard output,
followed by a newline.
Parameters:
value : The value to be printed. Must implement the Show trait.
Example:
test "println" {
println(42)
println("Hello, World!")
println([1, 2, 3])
}
println("Error: ys must have at least one element.")
203 return
204 }
205 guard Array[Double]
ys.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (self : Int, other : Int) -> Bool
Compares two integers for equality.
Parameters:
self : The first integer to compare.
other : The second integer to compare.
Returns true if both integers have the same value, false otherwise.
Example:
test "Int::op_equal" {
inspect(42 == 42, content="true")
inspect(42 == -42, content="false")
}
== Array[Double]
widths.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() else {
206 (input : String) -> Unit
Prints any value that implements the Show trait to the standard output,
followed by a newline.
Parameters:
value : The value to be printed. Must implement the Show trait.
Example:
test "println" {
println(42)
println("Hello, World!")
println([1, 2, 3])
}
println("Error: ys and widths must have the same length.")
207 return
208 }
209 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("barh") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
210 let @python.PyList
ys = Array[Double]
ys.(self : Array[Double], f : (Double) -> @python.PyFloat) -> Array[@python.PyFloat]
Maps a function over the elements of the array.
Example
let v = [3, 4, 5]
let v2 = v.map(fn (x) {x + 1})
assert_eq(v2, [4, 5, 6])
map(struct @python.PyFloat {
// private fields
}
PyFloat(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
::from) |> struct @python.PyList {
// private fields
}
PyList(Array[@python.PyFloat]) -> @python.PyList
Create a new python list from a python object array
Example
test "PyList::from" {
let arr: Array[&IsPyObject] = Array::new()
let one = PyInteger::from(1);
let two = PyFloat::from(2.0);
let three = PyString::from("three");
arr.push(one)
arr.push(two)
arr.push(three)
let list = PyList::from(arr);
inspect!(list, content="[1, 2.0, \'three\']")
}
::from
211 let @python.PyList
widths = Array[Double]
widths.(self : Array[Double], f : (Double) -> @python.PyFloat) -> Array[@python.PyFloat]
Maps a function over the elements of the array.
Example
let v = [3, 4, 5]
let v2 = v.map(fn (x) {x + 1})
assert_eq(v2, [4, 5, 6])
map(struct @python.PyFloat {
// private fields
}
PyFloat(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
::from) |> struct @python.PyList {
// private fields
}
PyList(Array[@python.PyFloat]) -> @python.PyList
Create a new python list from a python object array
Example
test "PyList::from" {
let arr: Array[&IsPyObject] = Array::new()
let one = PyInteger::from(1);
let two = PyFloat::from(2.0);
let three = PyString::from("three");
arr.push(one)
arr.push(two)
arr.push(three)
let list = PyList::from(arr);
inspect!(list, content="[1, 2.0, \'three\']")
}
::from
212 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(2)
213 @python.PyTuple
args..(self : @python.PyTuple, idx : Int, item : @python.PyList) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, @python.PyList
ys)..(self : @python.PyTuple, idx : Int, item : @python.PyList) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(1, @python.PyList
widths)
214 let @python.PyDict
kwargs : struct @python.PyDict {
// private fields
}
PyDict = struct @python.PyDict {
// private fields
}
PyDict::() -> @python.PyDict
Creates a new python dict object.
Example
test "PyDict::new" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = { 'one': 1, 'two': 2.0, 'three': True }
print(d) # Output: {'one': 1, 'two': 2.0, 'three': True}
new()
215 @python.PyDict
kwargs
216 ..(self : @python.PyDict, key : String, val : @python.PyFloat) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("height", struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
hight))
217 ..(self : @python.PyDict, key : String, val : @python.PyString) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("color", Color
color.(self : Color) -> @python.PyString
to_pystr())
218 ..(self : @python.PyDict, key : String, val : @python.PyFloat) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("left", struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
left))
219 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~, @python.PyDict
kwargs~)
220
221}
222
223///|
224/// Creates a pie chart on the axes. Each data point in `values` represents a
225/// wedge of the pie, and the size of each wedge is determined by the relative
226/// value with respect to the sum of all values.
227/// Same as `matplotlib.pyplot.pie` in Python.
228///
229/// Parameters:
230///
231/// * `self` : The axes on which to create the pie chart.
232/// * `values` : An array of numerical values that determine the size of each
233/// wedge.
234/// * `labels` : Optional array of strings to label each wedge. Must have the
235/// same length as `values` if provided.
236/// * `colors` : Optional array of colors for each wedge. Must have the same
237/// length as `values` if provided.
238///
239/// Example:
240///
241/// ```moonbit
242/// test "Axes::pie" {
243/// let (fig, axes) = @matplotlib.subplots(1, 1)
244/// let values = [35.0, 25.0, 40.0]
245/// let labels = ["A", "B", "C"]
246/// let colors = [
247/// @matplotlib.Color::Red,
248/// @matplotlib.Color::Green,
249/// @matplotlib.Color::Blue,
250/// ]
251/// axes[0][0].pie(values, labels~, colors~)
252/// }
253/// ```
254pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, xs : Array[Double], labels~ : Array[String] = .., colors~ : Array[Color] = ..) -> Unit
Creates a pie chart on the axes. Each data point in values represents a
wedge of the pie, and the size of each wedge is determined by the relative
value with respect to the sum of all values.
Same as matplotlib.pyplot.pie in Python.
Parameters:
self : The axes on which to create the pie chart.
values : An array of numerical values that determine the size of each
wedge.
labels : Optional array of strings to label each wedge. Must have the
same length as values if provided.
colors : Optional array of colors for each wedge. Must have the same
length as values if provided.
Example:
test "Axes::pie" {
let (fig, axes) = @matplotlib.subplots(1, 1)
let values = [35.0, 25.0, 40.0]
let labels = ["A", "B", "C"]
let colors = [
@matplotlib.Color::Red,
@matplotlib.Color::Green,
@matplotlib.Color::Blue,
]
axes[0][0].pie(values, labels~, colors~)
}
pie(
255 Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes,
256 Array[Double]
xs : type Array[T]
An Array is a collection of values that supports random access and can
grow in size.
Array[Double
Double],
257 Array[String]
labels~ : type Array[T]
An Array is a collection of values that supports random access and can
grow in size.
Array[String
String] = [],
258 Array[Color]
colors~ : type Array[T]
An Array is a collection of values that supports random access and can
grow in size.
Array[enum Color {
Aliceblue
Antiquewhite
Aqua
Aquamarine
Azure
Beige
Bisque
Black
Blanchedalmond
Blue
Blueviolet
Brown
Burlywood
Cadetblue
Chartreuse
Chocolate
Coral
Cornflowerblue
Cornsilk
Crimson
Cyan
Darkblue
Darkcyan
Darkgoldenrod
Darkgray
Darkgreen
Darkgrey
Darkkhaki
Darkmagenta
Darkolivegreen
Darkorange
Darkorchid
Darkred
Darksalmon
Darkseagreen
Darkslateblue
Darkslategray
Darkslategrey
Darkturquoise
Darkviolet
Deeppink
Deepskyblue
Dimgray
Dimgrey
Dodgerblue
Firebrick
Floralwhite
Forestgreen
Fuchsia
Gainsboro
Ghostwhite
Gold
Goldenrod
Gray
Green
Greenyellow
Grey
Honeydew
Hotpink
Indianred
Indigo
Ivory
Khaki
Lavender
Lavenderblush
Lawngreen
Lemonchiffon
Lightblue
Lightcoral
Lightcyan
Lightgoldenrodyellow
Lightgray
Lightgreen
Lightgrey
Lightpink
Lightsalmon
Lightseagreen
Lightskyblue
Lightslategray
Lightslategrey
Lightsteelblue
Lightyellow
Lime
Limegreen
Linen
Magenta
Maroon
Mediumaquamarine
Mediumblue
Mediumorchid
Mediumpurple
Mediumseagreen
Mediumslateblue
Mediumspringgreen
Mediumturquoise
Mediumvioletred
Midnightblue
Mintcream
Mistyrose
Moccasin
Navajowhite
Navy
Oldlace
Olive
Olivedrab
Orange
Orangered
Orchid
Palegoldenrod
Palegreen
Paleturquoise
Palevioletred
Papayawhip
Peachpuff
Peru
Pink
Plum
Powderblue
Purple
Rebeccapurple
Red
Rosybrown
Royalblue
Saddlebrown
Salmon
Sandybrown
Seagreen
Seashell
Sienna
Silver
Skyblue
Slateblue
Slategray
Slategrey
Snow
Springgreen
Steelblue
Tan
Teal
Thistle
Tomato
Turquoise
Violet
Wheat
White
Whitesmoke
Yellow
Yellowgreen
Rgb(Int, Int, Int)
}
Color] = []
259) -> Unit
Unit {
260 guard Array[Double]
xs.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (self_ : Int, other : Int) -> Bool
> 0 else {
261 (input : String) -> Unit
Prints any value that implements the Show trait to the standard output,
followed by a newline.
Parameters:
value : The value to be printed. Must implement the Show trait.
Example:
test "println" {
println(42)
println("Hello, World!")
println([1, 2, 3])
}
println("Error: xs must have at least one element.")
262 return
263 }
264 guard Array[String]
labels.(self : Array[String]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (self : Int, other : Int) -> Bool
Compares two integers for equality.
Parameters:
self : The first integer to compare.
other : The second integer to compare.
Returns true if both integers have the same value, false otherwise.
Example:
test "Int::op_equal" {
inspect(42 == 42, content="true")
inspect(42 == -42, content="false")
}
== 0 (Bool, Bool) -> Bool
|| Array[String]
labels.(self : Array[String]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (self : Int, other : Int) -> Bool
Compares two integers for equality.
Parameters:
self : The first integer to compare.
other : The second integer to compare.
Returns true if both integers have the same value, false otherwise.
Example:
test "Int::op_equal" {
inspect(42 == 42, content="true")
inspect(42 == -42, content="false")
}
== Array[Double]
xs.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() else {
265 (input : String) -> Unit
Prints any value that implements the Show trait to the standard output,
followed by a newline.
Parameters:
value : The value to be printed. Must implement the Show trait.
Example:
test "println" {
println(42)
println("Hello, World!")
println([1, 2, 3])
}
println("Error: labels must have the same length as xs or be empty.")
266 return
267 }
268 guard Array[Color]
colors.(self : Array[Color]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (self : Int, other : Int) -> Bool
Compares two integers for equality.
Parameters:
self : The first integer to compare.
other : The second integer to compare.
Returns true if both integers have the same value, false otherwise.
Example:
test "Int::op_equal" {
inspect(42 == 42, content="true")
inspect(42 == -42, content="false")
}
== 0 (Bool, Bool) -> Bool
|| Array[Color]
colors.(self : Array[Color]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (self : Int, other : Int) -> Bool
Compares two integers for equality.
Parameters:
self : The first integer to compare.
other : The second integer to compare.
Returns true if both integers have the same value, false otherwise.
Example:
test "Int::op_equal" {
inspect(42 == 42, content="true")
inspect(42 == -42, content="false")
}
== Array[Double]
xs.(self : Array[Double]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() else {
269 (input : String) -> Unit
Prints any value that implements the Show trait to the standard output,
followed by a newline.
Parameters:
value : The value to be printed. Must implement the Show trait.
Example:
test "println" {
println(42)
println("Hello, World!")
println([1, 2, 3])
}
println("Error: colors must have the same length as xs or be empty.")
270 return
271 }
272 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("pie") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
273 let @python.PyList
xs = Array[Double]
xs.(self : Array[Double], f : (Double) -> @python.PyFloat) -> Array[@python.PyFloat]
Maps a function over the elements of the array.
Example
let v = [3, 4, 5]
let v2 = v.map(fn (x) {x + 1})
assert_eq(v2, [4, 5, 6])
map(struct @python.PyFloat {
// private fields
}
PyFloat(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
::from) |> struct @python.PyList {
// private fields
}
PyList(Array[@python.PyFloat]) -> @python.PyList
Create a new python list from a python object array
Example
test "PyList::from" {
let arr: Array[&IsPyObject] = Array::new()
let one = PyInteger::from(1);
let two = PyFloat::from(2.0);
let three = PyString::from("three");
arr.push(one)
arr.push(two)
arr.push(three)
let list = PyList::from(arr);
inspect!(list, content="[1, 2.0, \'three\']")
}
::from
274 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(1)
275 @python.PyTuple
args..(self : @python.PyTuple, idx : Int, item : @python.PyList) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, @python.PyList
xs)
276 let @python.PyDict
kwargs : struct @python.PyDict {
// private fields
}
PyDict = struct @python.PyDict {
// private fields
}
PyDict::() -> @python.PyDict
Creates a new python dict object.
Example
test "PyDict::new" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = { 'one': 1, 'two': 2.0, 'three': True }
print(d) # Output: {'one': 1, 'two': 2.0, 'three': True}
new()
277 if Array[String]
labels.(self : Array[String]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (self_ : Int, other : Int) -> Bool
> 0 {
278 let @python.PyList
labels = Array[String]
labels.(self : Array[String], f : (String) -> @python.PyString) -> Array[@python.PyString]
Maps a function over the elements of the array.
Example
let v = [3, 4, 5]
let v2 = v.map(fn (x) {x + 1})
assert_eq(v2, [4, 5, 6])
map(struct @python.PyString {
// private fields
}
PyString(String) -> @python.PyString
Create a PyString from a string
Example
test "PyString::from" {
let s = @python.PyString::from("hello");
inspect(s, content="\'hello\'");
}
::from) |> struct @python.PyList {
// private fields
}
PyList(Array[@python.PyString]) -> @python.PyList
Create a new python list from a python object array
Example
test "PyList::from" {
let arr: Array[&IsPyObject] = Array::new()
let one = PyInteger::from(1);
let two = PyFloat::from(2.0);
let three = PyString::from("three");
arr.push(one)
arr.push(two)
arr.push(three)
let list = PyList::from(arr);
inspect!(list, content="[1, 2.0, \'three\']")
}
::from
279 @python.PyDict
kwargs.(self : @python.PyDict, key : String, val : @python.PyList) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("labels", @python.PyList
labels)
280 }
281 if Array[Color]
colors.(self : Array[Color]) -> Int
Returns the number of elements in the array.
Parameters:
array : The array whose length is to be determined.
Returns the number of elements in the array as an integer.
Example:
test "Array::length" {
let arr = [1, 2, 3]
inspect(arr.length(), content="3")
let empty : Array[Int] = []
inspect(empty.length(), content="0")
}
length() (self_ : Int, other : Int) -> Bool
> 0 {
282 let @python.PyList
colors = Array[Color]
colors.(self : Array[Color], f : (Color) -> @python.PyString) -> Array[@python.PyString]
Maps a function over the elements of the array.
Example
let v = [3, 4, 5]
let v2 = v.map(fn (x) {x + 1})
assert_eq(v2, [4, 5, 6])
map(fn(Color
c) { Color
c.(self : Color) -> @python.PyString
to_pystr() }) |> struct @python.PyList {
// private fields
}
PyList(Array[@python.PyString]) -> @python.PyList
Create a new python list from a python object array
Example
test "PyList::from" {
let arr: Array[&IsPyObject] = Array::new()
let one = PyInteger::from(1);
let two = PyFloat::from(2.0);
let three = PyString::from("three");
arr.push(one)
arr.push(two)
arr.push(three)
let list = PyList::from(arr);
inspect!(list, content="[1, 2.0, \'three\']")
}
::from
283 @python.PyDict
kwargs.(self : @python.PyDict, key : String, val : @python.PyList) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("colors", @python.PyList
colors)
284 }
285 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~, @python.PyDict
kwargs~)
286
287}
288
289///|
290pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, x : Double, y : Double, s : String, alpha~ : Double = .., color~ : Color = .., background~ : Color = .., fontsize~ : Double = .., rotation~ : Double = ..) -> Unit
text(
291 Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes,
292 Double
x : Double
Double,
293 Double
y : Double
Double,
294 String
s : String
String,
295 Double
alpha~ : Double
Double = 1.0,
296 Color
color~ : enum Color {
Aliceblue
Antiquewhite
Aqua
Aquamarine
Azure
Beige
Bisque
Black
Blanchedalmond
Blue
Blueviolet
Brown
Burlywood
Cadetblue
Chartreuse
Chocolate
Coral
Cornflowerblue
Cornsilk
Crimson
Cyan
Darkblue
Darkcyan
Darkgoldenrod
Darkgray
Darkgreen
Darkgrey
Darkkhaki
Darkmagenta
Darkolivegreen
Darkorange
Darkorchid
Darkred
Darksalmon
Darkseagreen
Darkslateblue
Darkslategray
Darkslategrey
Darkturquoise
Darkviolet
Deeppink
Deepskyblue
Dimgray
Dimgrey
Dodgerblue
Firebrick
Floralwhite
Forestgreen
Fuchsia
Gainsboro
Ghostwhite
Gold
Goldenrod
Gray
Green
Greenyellow
Grey
Honeydew
Hotpink
Indianred
Indigo
Ivory
Khaki
Lavender
Lavenderblush
Lawngreen
Lemonchiffon
Lightblue
Lightcoral
Lightcyan
Lightgoldenrodyellow
Lightgray
Lightgreen
Lightgrey
Lightpink
Lightsalmon
Lightseagreen
Lightskyblue
Lightslategray
Lightslategrey
Lightsteelblue
Lightyellow
Lime
Limegreen
Linen
Magenta
Maroon
Mediumaquamarine
Mediumblue
Mediumorchid
Mediumpurple
Mediumseagreen
Mediumslateblue
Mediumspringgreen
Mediumturquoise
Mediumvioletred
Midnightblue
Mintcream
Mistyrose
Moccasin
Navajowhite
Navy
Oldlace
Olive
Olivedrab
Orange
Orangered
Orchid
Palegoldenrod
Palegreen
Paleturquoise
Palevioletred
Papayawhip
Peachpuff
Peru
Pink
Plum
Powderblue
Purple
Rebeccapurple
Red
Rosybrown
Royalblue
Saddlebrown
Salmon
Sandybrown
Seagreen
Seashell
Sienna
Silver
Skyblue
Slateblue
Slategray
Slategrey
Snow
Springgreen
Steelblue
Tan
Teal
Thistle
Tomato
Turquoise
Violet
Wheat
White
Whitesmoke
Yellow
Yellowgreen
Rgb(Int, Int, Int)
}
Color = Color::Color
Black,
297 Color
background~ : enum Color {
Aliceblue
Antiquewhite
Aqua
Aquamarine
Azure
Beige
Bisque
Black
Blanchedalmond
Blue
Blueviolet
Brown
Burlywood
Cadetblue
Chartreuse
Chocolate
Coral
Cornflowerblue
Cornsilk
Crimson
Cyan
Darkblue
Darkcyan
Darkgoldenrod
Darkgray
Darkgreen
Darkgrey
Darkkhaki
Darkmagenta
Darkolivegreen
Darkorange
Darkorchid
Darkred
Darksalmon
Darkseagreen
Darkslateblue
Darkslategray
Darkslategrey
Darkturquoise
Darkviolet
Deeppink
Deepskyblue
Dimgray
Dimgrey
Dodgerblue
Firebrick
Floralwhite
Forestgreen
Fuchsia
Gainsboro
Ghostwhite
Gold
Goldenrod
Gray
Green
Greenyellow
Grey
Honeydew
Hotpink
Indianred
Indigo
Ivory
Khaki
Lavender
Lavenderblush
Lawngreen
Lemonchiffon
Lightblue
Lightcoral
Lightcyan
Lightgoldenrodyellow
Lightgray
Lightgreen
Lightgrey
Lightpink
Lightsalmon
Lightseagreen
Lightskyblue
Lightslategray
Lightslategrey
Lightsteelblue
Lightyellow
Lime
Limegreen
Linen
Magenta
Maroon
Mediumaquamarine
Mediumblue
Mediumorchid
Mediumpurple
Mediumseagreen
Mediumslateblue
Mediumspringgreen
Mediumturquoise
Mediumvioletred
Midnightblue
Mintcream
Mistyrose
Moccasin
Navajowhite
Navy
Oldlace
Olive
Olivedrab
Orange
Orangered
Orchid
Palegoldenrod
Palegreen
Paleturquoise
Palevioletred
Papayawhip
Peachpuff
Peru
Pink
Plum
Powderblue
Purple
Rebeccapurple
Red
Rosybrown
Royalblue
Saddlebrown
Salmon
Sandybrown
Seagreen
Seashell
Sienna
Silver
Skyblue
Slateblue
Slategray
Slategrey
Snow
Springgreen
Steelblue
Tan
Teal
Thistle
Tomato
Turquoise
Violet
Wheat
White
Whitesmoke
Yellow
Yellowgreen
Rgb(Int, Int, Int)
}
Color = Color::Color
White,
298 Double
fontsize~ : Double
Double = 12.0,
299 Double
rotation~ : Double
Double = 0.0
300) -> Unit
Unit {
301 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("text") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
302 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(3)
303 @python.PyTuple
args
304 ..(self : @python.PyTuple, idx : Int, item : @python.PyFloat) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
x))
305 ..(self : @python.PyTuple, idx : Int, item : @python.PyFloat) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(1, struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
y))
306 ..(self : @python.PyTuple, idx : Int, item : @python.PyString) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(2, struct @python.PyString {
// private fields
}
PyString::(String) -> @python.PyString
Create a PyString from a string
Example
test "PyString::from" {
let s = @python.PyString::from("hello");
inspect(s, content="\'hello\'");
}
from(String
s))
307 let @python.PyDict
kwargs : struct @python.PyDict {
// private fields
}
PyDict = struct @python.PyDict {
// private fields
}
PyDict::() -> @python.PyDict
Creates a new python dict object.
Example
test "PyDict::new" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = { 'one': 1, 'two': 2.0, 'three': True }
print(d) # Output: {'one': 1, 'two': 2.0, 'three': True}
new()
308 @python.PyDict
kwargs
309 ..(self : @python.PyDict, key : String, val : @python.PyFloat) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("alpha", struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
alpha))
310 ..(self : @python.PyDict, key : String, val : @python.PyString) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("color", Color
color.(self : Color) -> @python.PyString
to_pystr())
311 ..(self : @python.PyDict, key : String, val : @python.PyString) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("backgroundcolor", Color
background.(self : Color) -> @python.PyString
to_pystr())
312 ..(self : @python.PyDict, key : String, val : @python.PyFloat) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("fontsize", struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
fontsize))
313 ..(self : @python.PyDict, key : String, val : @python.PyFloat) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("rotation", struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
rotation))
314 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~, @python.PyDict
kwargs~)
315
316}
317
318///| Set the x-axis view limits. Same as `matplotlib.axes.Axes.set_xlim` in Python.
319///
320/// ## Arguments
321///
322/// - `left`: The left limit of the x-axis.
323/// - `right`: The right limit of the x-axis.
324pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, left : Double, right : Double) -> Unit
Set the x-axis view limits. Same as matplotlib.axes.Axes.set_xlim in Python.
Arguments
left: The left limit of the x-axis.
right: The right limit of the x-axis.
set_xlim(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes, Double
left : Double
Double, Double
right : Double
Double) -> Unit
Unit {
325 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("set_xlim") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
326 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(2)
327 @python.PyTuple
args..(self : @python.PyTuple, idx : Int, item : @python.PyFloat) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
left))..(self : @python.PyTuple, idx : Int, item : @python.PyFloat) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(1, struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
right))
328 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict = ..) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~)
329
330}
331
332///|
333/// Gets the x-axis limits of the current axes. Same as `matplotlib.axes.Axes.get_xlim` in Python.
334///
335/// Parameters:
336///
337/// * `self` : The Axes instance to get the limits from.
338///
339/// Returns a tuple of two `Double` values representing the left and right limits
340/// of the x-axis.
341///
342/// Example:
343///
344/// ```moonbit
345/// test "Axes::get_xlim" {
346/// let (fig, axes) = @matplotlib.subplots(1, 1)
347/// axes[0][0].set_xlim(-1.0, 1.0)
348/// let (left, right) = axes[0][0].get_xlim()
349/// inspect!((left, right), content="(-1.0, 1.0)")
350/// }
351/// ```
352pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes) -> (Double, Double)
Gets the x-axis limits of the current axes. Same as matplotlib.axes.Axes.get_xlim in Python.
Parameters:
self : The Axes instance to get the limits from.
Returns a tuple of two Double values representing the left and right limits
of the x-axis.
Example:
test "Axes::get_xlim" {
let (fig, axes) = @matplotlib.subplots(1, 1)
axes[0][0].set_xlim(-1.0, 1.0)
let (left, right) = axes[0][0].get_xlim()
inspect!((left, right), content="(-1.0, 1.0)")
}
get_xlim(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes) -> (Double
Double, Double
Double) {
353 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("get_xlim") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
354 guard @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple = .., kwargs~ : @python.PyDict = ..) -> @python.PyObjectEnum?
invoke() is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyTuple) -> @python.PyObjectEnum
PyTuple(@python.PyTuple
t))
355 guard @python.PyTuple
t.(self : @python.PyTuple, idx : Int) -> @python.PyObjectEnum?
Get the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.get(-1) will return None.
Example:
test "PyTuple::get" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
inspect!(tuple.get(0).unwrap(), content="PyInteger(1)")
inspect!(tuple.get(1).unwrap(), content="PyFloat(2.0)")
inspect!(tuple.get(2).unwrap(), content="PyString(three)")
inspect!(tuple.get(3), content="None")
}
The above code is equivalent the following python code:
tuple = (1, 2.0, "three")
print(tuple) # Output: (1, 2.0, 'three')
print(tuple[0]) # Output: 1
print(tuple[1]) # Output: 2.0
print(tuple[2]) # Output: three
get(0) is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyFloat) -> @python.PyObjectEnum
PyFloat(@python.PyFloat
left))
356 guard @python.PyTuple
t.(self : @python.PyTuple, idx : Int) -> @python.PyObjectEnum?
Get the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.get(-1) will return None.
Example:
test "PyTuple::get" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
inspect!(tuple.get(0).unwrap(), content="PyInteger(1)")
inspect!(tuple.get(1).unwrap(), content="PyFloat(2.0)")
inspect!(tuple.get(2).unwrap(), content="PyString(three)")
inspect!(tuple.get(3), content="None")
}
The above code is equivalent the following python code:
tuple = (1, 2.0, "three")
print(tuple) # Output: (1, 2.0, 'three')
print(tuple[0]) # Output: 1
print(tuple[1]) # Output: 2.0
print(tuple[2]) # Output: three
get(1) is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyFloat) -> @python.PyObjectEnum
PyFloat(@python.PyFloat
right))
357 let Double
left = @python.PyFloat
left.(self : @python.PyFloat) -> Double
Convert a PyFloat to a Double.
Example
test "PyFloat::to_double" {
let f = @python.PyFloat::from(3.5);
assert_eq!(f.to_double(), 3.5);
}
to_double()
358 let Double
right = @python.PyFloat
right.(self : @python.PyFloat) -> Double
Convert a PyFloat to a Double.
Example
test "PyFloat::to_double" {
let f = @python.PyFloat::from(3.5);
assert_eq!(f.to_double(), 3.5);
}
to_double()
359 return (Double
left, Double
right)
360}
361
362///| Set the y-axis view limits. Same as `matplotlib.axes.Axes.set_ylim` in Python.
363///
364/// ## Arguments
365///
366/// - `bottom`: The bottom limit of the y-axis.
367/// - `top`: The top limit of the y-axis.
368pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, bottom : Double, top : Double) -> Unit
Set the y-axis view limits. Same as matplotlib.axes.Axes.set_ylim in Python.
Arguments
bottom: The bottom limit of the y-axis.
top: The top limit of the y-axis.
set_ylim(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes, Double
bottom : Double
Double, Double
top : Double
Double) -> Unit
Unit {
369 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("set_ylim") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
370 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(2)
371 @python.PyTuple
args..(self : @python.PyTuple, idx : Int, item : @python.PyFloat) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
bottom))..(self : @python.PyTuple, idx : Int, item : @python.PyFloat) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(1, struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
top))
372 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict = ..) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~)
373
374}
375
376///|
377/// Gets the y-axis limits of the current axes.
378/// Same as `matplotlib.axes.Axes.get_ylim` in Python.
379///
380/// Parameters:
381///
382/// * `self` : The Axes instance to get the limits from.
383///
384/// Returns a tuple of two `Double` values representing the bottom and top limits
385/// of the y-axis.
386///
387/// Example:
388///
389/// ```moonbit
390/// test "Axes::get_ylim" {
391/// let (fig, axes) = @matplotlib.subplots(1, 1)
392/// axes[0][0].set_ylim(-1.0, 1.0)
393/// let (bottom, top) = axes[0][0].get_ylim()
394/// inspect!((bottom, top), content="(-1.0, 1.0)")
395/// }
396/// ```
397pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes) -> (Double, Double)
Gets the y-axis limits of the current axes.
Same as matplotlib.axes.Axes.get_ylim in Python.
Parameters:
self : The Axes instance to get the limits from.
Returns a tuple of two Double values representing the bottom and top limits
of the y-axis.
Example:
test "Axes::get_ylim" {
let (fig, axes) = @matplotlib.subplots(1, 1)
axes[0][0].set_ylim(-1.0, 1.0)
let (bottom, top) = axes[0][0].get_ylim()
inspect!((bottom, top), content="(-1.0, 1.0)")
}
get_ylim(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes) -> (Double
Double, Double
Double) {
398 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("get_ylim") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
399 guard @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple = .., kwargs~ : @python.PyDict = ..) -> @python.PyObjectEnum?
invoke() is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyTuple) -> @python.PyObjectEnum
PyTuple(@python.PyTuple
t))
400 guard @python.PyTuple
t.(self : @python.PyTuple, idx : Int) -> @python.PyObjectEnum?
Get the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.get(-1) will return None.
Example:
test "PyTuple::get" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
inspect!(tuple.get(0).unwrap(), content="PyInteger(1)")
inspect!(tuple.get(1).unwrap(), content="PyFloat(2.0)")
inspect!(tuple.get(2).unwrap(), content="PyString(three)")
inspect!(tuple.get(3), content="None")
}
The above code is equivalent the following python code:
tuple = (1, 2.0, "three")
print(tuple) # Output: (1, 2.0, 'three')
print(tuple[0]) # Output: 1
print(tuple[1]) # Output: 2.0
print(tuple[2]) # Output: three
get(0) is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyFloat) -> @python.PyObjectEnum
PyFloat(@python.PyFloat
bottom))
401 guard @python.PyTuple
t.(self : @python.PyTuple, idx : Int) -> @python.PyObjectEnum?
Get the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.get(-1) will return None.
Example:
test "PyTuple::get" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
inspect!(tuple.get(0).unwrap(), content="PyInteger(1)")
inspect!(tuple.get(1).unwrap(), content="PyFloat(2.0)")
inspect!(tuple.get(2).unwrap(), content="PyString(three)")
inspect!(tuple.get(3), content="None")
}
The above code is equivalent the following python code:
tuple = (1, 2.0, "three")
print(tuple) # Output: (1, 2.0, 'three')
print(tuple[0]) # Output: 1
print(tuple[1]) # Output: 2.0
print(tuple[2]) # Output: three
get(1) is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyFloat) -> @python.PyObjectEnum
PyFloat(@python.PyFloat
top))
402 let Double
bottom = @python.PyFloat
bottom.(self : @python.PyFloat) -> Double
Convert a PyFloat to a Double.
Example
test "PyFloat::to_double" {
let f = @python.PyFloat::from(3.5);
assert_eq!(f.to_double(), 3.5);
}
to_double()
403 let Double
top = @python.PyFloat
top.(self : @python.PyFloat) -> Double
Convert a PyFloat to a Double.
Example
test "PyFloat::to_double" {
let f = @python.PyFloat::from(3.5);
assert_eq!(f.to_double(), 3.5);
}
to_double()
404 return (Double
bottom, Double
top)
405}
406
407///|
408/// Sets the x-axis bounds of the current axes.
409/// Same as `matplotlib.axes.Axes.set_xbound` in Python.
410///
411/// Parameters:
412///
413/// * `self` : The axes instance to set the bounds for.
414/// * `lower` : The lower bound of the x-axis.
415/// * `upper` : The upper bound of the x-axis.
416///
417/// Example:
418///
419/// ```moonbit
420/// test "Axes::set_xbound" {
421/// let (fig, axes) = @matplotlib.subplots(1, 1)
422/// axes[0][0].set_xbound(-1.0, 1.0)
423/// let (lower, upper) = axes[0][0].get_xbound()
424/// inspect!((lower, upper), content="(-1.0, 1.0)")
425/// }
426/// ```
427pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, lower : Double, upper : Double) -> Unit
Sets the x-axis bounds of the current axes.
Same as matplotlib.axes.Axes.set_xbound in Python.
Parameters:
self : The axes instance to set the bounds for.
lower : The lower bound of the x-axis.
upper : The upper bound of the x-axis.
Example:
test "Axes::set_xbound" {
let (fig, axes) = @matplotlib.subplots(1, 1)
axes[0][0].set_xbound(-1.0, 1.0)
let (lower, upper) = axes[0][0].get_xbound()
inspect!((lower, upper), content="(-1.0, 1.0)")
}
set_xbound(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes, Double
lower : Double
Double, Double
upper : Double
Double) -> Unit
Unit {
428 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("set_xbound") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
429 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(2)
430 @python.PyTuple
args..(self : @python.PyTuple, idx : Int, item : @python.PyFloat) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
lower))..(self : @python.PyTuple, idx : Int, item : @python.PyFloat) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(1, struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
upper))
431 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict = ..) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~)
432
433}
434
435///|
436/// Gets the x-axis bounds of the current axes.
437/// Same as `matplotlib.axes.Axes.get_xbound` in Python.
438///
439/// Parameters:
440///
441/// * `axes` : The Axes instance to get the bounds from.
442///
443/// Returns a tuple of two `Double` values representing the lower and upper
444/// bounds of the x-axis.
445///
446/// Example:
447///
448/// ```moonbit
449/// test "Axes::get_xbound" {
450/// let (fig, axes) = @matplotlib.subplots(1, 1)
451/// axes[0][0].set_xbound(-1.0, 1.0)
452/// let (lower, upper) = axes[0][0].get_xbound()
453/// inspect!((lower, upper), content="(-1.0, 1.0)")
454/// }
455/// ```
456pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes) -> (Double, Double)
Gets the x-axis bounds of the current axes.
Same as matplotlib.axes.Axes.get_xbound in Python.
Parameters:
axes : The Axes instance to get the bounds from.
Returns a tuple of two Double values representing the lower and upper
bounds of the x-axis.
Example:
test "Axes::get_xbound" {
let (fig, axes) = @matplotlib.subplots(1, 1)
axes[0][0].set_xbound(-1.0, 1.0)
let (lower, upper) = axes[0][0].get_xbound()
inspect!((lower, upper), content="(-1.0, 1.0)")
}
get_xbound(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes) -> (Double
Double, Double
Double) {
457 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("get_xbound") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
458 guard @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple = .., kwargs~ : @python.PyDict = ..) -> @python.PyObjectEnum?
invoke() is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyTuple) -> @python.PyObjectEnum
PyTuple(@python.PyTuple
t))
459 guard @python.PyTuple
t.(self : @python.PyTuple, idx : Int) -> @python.PyObjectEnum?
Get the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.get(-1) will return None.
Example:
test "PyTuple::get" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
inspect!(tuple.get(0).unwrap(), content="PyInteger(1)")
inspect!(tuple.get(1).unwrap(), content="PyFloat(2.0)")
inspect!(tuple.get(2).unwrap(), content="PyString(three)")
inspect!(tuple.get(3), content="None")
}
The above code is equivalent the following python code:
tuple = (1, 2.0, "three")
print(tuple) # Output: (1, 2.0, 'three')
print(tuple[0]) # Output: 1
print(tuple[1]) # Output: 2.0
print(tuple[2]) # Output: three
get(0) is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyFloat) -> @python.PyObjectEnum
PyFloat(@python.PyFloat
lower))
460 guard @python.PyTuple
t.(self : @python.PyTuple, idx : Int) -> @python.PyObjectEnum?
Get the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.get(-1) will return None.
Example:
test "PyTuple::get" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
inspect!(tuple.get(0).unwrap(), content="PyInteger(1)")
inspect!(tuple.get(1).unwrap(), content="PyFloat(2.0)")
inspect!(tuple.get(2).unwrap(), content="PyString(three)")
inspect!(tuple.get(3), content="None")
}
The above code is equivalent the following python code:
tuple = (1, 2.0, "three")
print(tuple) # Output: (1, 2.0, 'three')
print(tuple[0]) # Output: 1
print(tuple[1]) # Output: 2.0
print(tuple[2]) # Output: three
get(1) is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyFloat) -> @python.PyObjectEnum
PyFloat(@python.PyFloat
upper))
461 let Double
lower = @python.PyFloat
lower.(self : @python.PyFloat) -> Double
Convert a PyFloat to a Double.
Example
test "PyFloat::to_double" {
let f = @python.PyFloat::from(3.5);
assert_eq!(f.to_double(), 3.5);
}
to_double()
462 let Double
upper = @python.PyFloat
upper.(self : @python.PyFloat) -> Double
Convert a PyFloat to a Double.
Example
test "PyFloat::to_double" {
let f = @python.PyFloat::from(3.5);
assert_eq!(f.to_double(), 3.5);
}
to_double()
463 return (Double
lower, Double
upper)
464}
465
466///|
467/// Sets the y-axis bounds of the current axes.
468/// Same as `matplotlib.axes.Axes.set_ybound` in Python.
469///
470/// Parameters:
471///
472/// * `axes` : The Axes instance to set the bounds for.
473/// * `lower` : The lower bound of the y-axis.
474/// * `upper` : The upper bound of the y-axis.
475///
476/// Example:
477///
478/// ```moonbit
479/// ///|
480/// test "Axes::set_ybound" {
481/// let (fig, axes) = @matplotlib.subplots(1, 1)
482/// axes[0][0].set_ybound(-1.0, 1.0)
483/// let (lower, upper) = axes[0][0].get_ybound()
484/// inspect!((lower, upper), content="(-1.0, 1.0)")
485/// }
486/// ```
487pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, lower : Double, upper : Double) -> Unit
Sets the y-axis bounds of the current axes.
Same as matplotlib.axes.Axes.set_ybound in Python.
Parameters:
axes : The Axes instance to set the bounds for.
lower : The lower bound of the y-axis.
upper : The upper bound of the y-axis.
Example:
///|
test "Axes::set_ybound" {
let (fig, axes) = @matplotlib.subplots(1, 1)
axes[0][0].set_ybound(-1.0, 1.0)
let (lower, upper) = axes[0][0].get_ybound()
inspect!((lower, upper), content="(-1.0, 1.0)")
}
set_ybound(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes, Double
lower : Double
Double, Double
upper : Double
Double) -> Unit
Unit {
488 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("set_ybound") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
489 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(2)
490 @python.PyTuple
args..(self : @python.PyTuple, idx : Int, item : @python.PyFloat) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
lower))..(self : @python.PyTuple, idx : Int, item : @python.PyFloat) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(1, struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
upper))
491 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict = ..) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~)
492
493}
494
495///|
496/// Gets the y-axis bounds of the current axes. Same as
497/// `matplotlib.axes.Axes.get_ybound` in Python.
498///
499/// Parameters:
500///
501/// * `axes` : The Axes instance to get the bounds from.
502///
503/// Returns a tuple of two `Double` values representing the lower and upper
504/// bounds of the y-axis.
505///
506/// Example:
507///
508/// ```moonbit
509/// ///|
510/// test "Axes::get_ybound" {
511/// let (fig, axes) = @matplotlib.subplots(1, 1)
512/// axes[0][0].set_ybound(-1.0, 1.0)
513/// let (lower, upper) = axes[0][0].get_ybound()
514/// inspect!((lower, upper), content="(-1.0, 1.0)")
515/// }
516/// ```
517pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes) -> (Double, Double)
Gets the y-axis bounds of the current axes. Same as
matplotlib.axes.Axes.get_ybound in Python.
Parameters:
axes : The Axes instance to get the bounds from.
Returns a tuple of two Double values representing the lower and upper
bounds of the y-axis.
Example:
///|
test "Axes::get_ybound" {
let (fig, axes) = @matplotlib.subplots(1, 1)
axes[0][0].set_ybound(-1.0, 1.0)
let (lower, upper) = axes[0][0].get_ybound()
inspect!((lower, upper), content="(-1.0, 1.0)")
}
get_ybound(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes) -> (Double
Double, Double
Double) {
518 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("get_ybound") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
519 guard @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple = .., kwargs~ : @python.PyDict = ..) -> @python.PyObjectEnum?
invoke() is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyTuple) -> @python.PyObjectEnum
PyTuple(@python.PyTuple
t))
520 guard @python.PyTuple
t.(self : @python.PyTuple, idx : Int) -> @python.PyObjectEnum?
Get the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.get(-1) will return None.
Example:
test "PyTuple::get" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
inspect!(tuple.get(0).unwrap(), content="PyInteger(1)")
inspect!(tuple.get(1).unwrap(), content="PyFloat(2.0)")
inspect!(tuple.get(2).unwrap(), content="PyString(three)")
inspect!(tuple.get(3), content="None")
}
The above code is equivalent the following python code:
tuple = (1, 2.0, "three")
print(tuple) # Output: (1, 2.0, 'three')
print(tuple[0]) # Output: 1
print(tuple[1]) # Output: 2.0
print(tuple[2]) # Output: three
get(0) is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyFloat) -> @python.PyObjectEnum
PyFloat(@python.PyFloat
lower))
521 guard @python.PyTuple
t.(self : @python.PyTuple, idx : Int) -> @python.PyObjectEnum?
Get the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.get(-1) will return None.
Example:
test "PyTuple::get" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
inspect!(tuple.get(0).unwrap(), content="PyInteger(1)")
inspect!(tuple.get(1).unwrap(), content="PyFloat(2.0)")
inspect!(tuple.get(2).unwrap(), content="PyString(three)")
inspect!(tuple.get(3), content="None")
}
The above code is equivalent the following python code:
tuple = (1, 2.0, "three")
print(tuple) # Output: (1, 2.0, 'three')
print(tuple[0]) # Output: 1
print(tuple[1]) # Output: 2.0
print(tuple[2]) # Output: three
get(1) is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyFloat) -> @python.PyObjectEnum
PyFloat(@python.PyFloat
upper))
522 let Double
lower = @python.PyFloat
lower.(self : @python.PyFloat) -> Double
Convert a PyFloat to a Double.
Example
test "PyFloat::to_double" {
let f = @python.PyFloat::from(3.5);
assert_eq!(f.to_double(), 3.5);
}
to_double()
523 let Double
upper = @python.PyFloat
upper.(self : @python.PyFloat) -> Double
Convert a PyFloat to a Double.
Example
test "PyFloat::to_double" {
let f = @python.PyFloat::from(3.5);
assert_eq!(f.to_double(), 3.5);
}
to_double()
524 return (Double
lower, Double
upper)
525}
526
527///|
528/// Sets the title of the axes. Provides the same functionality as
529/// `matplotlib.axes.Axes.set_title` in Python.
530///
531/// Parameters:
532///
533/// * `self` : The axes instance to set the title for.
534/// * `title` : The text to be displayed as the title of the axes.
535///
536/// Example:
537///
538/// ```moonbit
539/// ///|
540/// test "Axes::set_title" {
541/// let (fig, axes) = @matplotlib.subplots(1, 1)
542/// axes[0][0].set_title("My Plot")
543/// inspect!(axes[0][0].get_title(), content="\"My Plot\"")
544/// }
545/// ```
546pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, title : String) -> Unit
Sets the title of the axes. Provides the same functionality as
matplotlib.axes.Axes.set_title in Python.
Parameters:
self : The axes instance to set the title for.
title : The text to be displayed as the title of the axes.
Example:
///|
test "Axes::set_title" {
let (fig, axes) = @matplotlib.subplots(1, 1)
axes[0][0].set_title("My Plot")
inspect!(axes[0][0].get_title(), content="\"My Plot\"")
}
set_title(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes, String
title : String
String) -> Unit
Unit {
547 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("set_title") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
548 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(1)
549 @python.PyTuple
args..(self : @python.PyTuple, idx : Int, item : @python.PyString) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, struct @python.PyString {
// private fields
}
PyString::(String) -> @python.PyString
Create a PyString from a string
Example
test "PyString::from" {
let s = @python.PyString::from("hello");
inspect(s, content="\'hello\'");
}
from(String
title))
550 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict = ..) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~)
551
552}
553
554///|
555/// Gets the title text of the current axes. Provides the same functionality as
556/// `matplotlib.axes.Axes.get_title` in Python.
557///
558/// Parameters:
559///
560/// * `axes` : The axes instance from which to retrieve the title.
561///
562/// Returns the current title text of the axes as a string.
563///
564/// Example:
565///
566/// ```moonbit
567/// ///|
568/// test "Axes::get_title" {
569/// let (fig, axes) = @matplotlib.subplots(1, 1)
570/// axes[0][0].set_title("My Plot")
571/// inspect!(axes[0][0].get_title(), content="\"My Plot\"")
572/// }
573/// ```
574pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes) -> String
Gets the title text of the current axes. Provides the same functionality as
matplotlib.axes.Axes.get_title in Python.
Parameters:
axes : The axes instance from which to retrieve the title.
Returns the current title text of the axes as a string.
Example:
///|
test "Axes::get_title" {
let (fig, axes) = @matplotlib.subplots(1, 1)
axes[0][0].set_title("My Plot")
inspect!(axes[0][0].get_title(), content="\"My Plot\"")
}
get_title(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes) -> String
String {
575 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("get_title") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
576 guard @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple = .., kwargs~ : @python.PyDict = ..) -> @python.PyObjectEnum?
invoke() is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyString) -> @python.PyObjectEnum
PyString(@python.PyString
title))
577 @python.PyString
title.(self : @python.PyString) -> String
to_string()
578}
579
580///| Set the label for the x-axis. Same as `matplotlib.axes.Axes.set_xlabel` in Python.
581///
582/// ## Arguments
583///
584/// - `xlabel`: The label string for the x-axis.
585pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, xlabel : String) -> Unit
Set the label for the x-axis. Same as matplotlib.axes.Axes.set_xlabel in Python.
Arguments
xlabel: The label string for the x-axis.
set_xlabel(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes, String
xlabel : String
String) -> Unit
Unit {
586 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("set_xlabel") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
587 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(1)
588 @python.PyTuple
args..(self : @python.PyTuple, idx : Int, item : @python.PyString) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, struct @python.PyString {
// private fields
}
PyString::(String) -> @python.PyString
Create a PyString from a string
Example
test "PyString::from" {
let s = @python.PyString::from("hello");
inspect(s, content="\'hello\'");
}
from(String
xlabel))
589 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict = ..) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~)
590
591}
592
593///|
594/// Gets the label text of the x-axis of the current axes. Provides the same
595/// functionality as `matplotlib.axes.Axes.get_xlabel` in Python.
596///
597/// Parameters:
598///
599/// * `axes`: The axes instance from which to retrieve the x-axis label.
600///
601/// Returns the current x-axis label text as a string.
602///
603/// Example:
604///
605/// ```moonbit
606/// ///|
607/// test "Axes::get_xlabel" {
608/// let (fig, axes) = @matplotlib.subplots(1, 1)
609/// axes[0][0].set_xlabel("X Label")
610/// inspect!(axes[0][0].get_xlabel(), content="\"X Label\"")
611/// }
612/// ```
613pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes) -> String
Gets the label text of the x-axis of the current axes. Provides the same
functionality as matplotlib.axes.Axes.get_xlabel in Python.
Parameters:
axes: The axes instance from which to retrieve the x-axis label.
Returns the current x-axis label text as a string.
Example:
///|
test "Axes::get_xlabel" {
let (fig, axes) = @matplotlib.subplots(1, 1)
axes[0][0].set_xlabel("X Label")
inspect!(axes[0][0].get_xlabel(), content="\"X Label\"")
}
get_xlabel(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes) -> String
String {
614 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("get_xlabel") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
615 guard @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple = .., kwargs~ : @python.PyDict = ..) -> @python.PyObjectEnum?
invoke() is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyString) -> @python.PyObjectEnum
PyString(@python.PyString
xlabel))
616 @python.PyString
xlabel.(self : @python.PyString) -> String
to_string()
617}
618
619///| Set the label for the y-axis. Same as `matplotlib.axes.Axes.set_ylabel` in Python.
620///
621/// ## Arguments
622///
623/// - `ylabel`: The label string for the y-axis.
624pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, ylabel : String) -> Unit
Set the label for the y-axis. Same as matplotlib.axes.Axes.set_ylabel in Python.
Arguments
ylabel: The label string for the y-axis.
set_ylabel(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes, String
ylabel : String
String) -> Unit
Unit {
625 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("set_ylabel") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
626 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(1)
627 @python.PyTuple
args..(self : @python.PyTuple, idx : Int, item : @python.PyString) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, struct @python.PyString {
// private fields
}
PyString::(String) -> @python.PyString
Create a PyString from a string
Example
test "PyString::from" {
let s = @python.PyString::from("hello");
inspect(s, content="\'hello\'");
}
from(String
ylabel))
628 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict = ..) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~)
629
630}
631
632///|
633/// Gets the label text of the y-axis of the current axes. Provides the same
634/// functionality as `matplotlib.axes.Axes.get_ylabel` in Python.
635///
636/// Parameters:
637///
638/// * `axes`: The axes instance from which to retrieve the y-axis label.
639///
640/// Returns the current y-axis label text as a string.
641///
642/// Example:
643///
644/// ```moonbit
645/// ///|
646/// test "Axes::get_ylabel" {
647/// let (fig, axes) = @matplotlib.subplots(1, 1)
648/// axes[0][0].set_ylabel("Y Label")
649/// inspect!(axes[0][0].get_ylabel(), content="\"Y Label\"")
650/// }
651/// ```
652pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes) -> String
Gets the label text of the y-axis of the current axes. Provides the same
functionality as matplotlib.axes.Axes.get_ylabel in Python.
Parameters:
axes: The axes instance from which to retrieve the y-axis label.
Returns the current y-axis label text as a string.
Example:
///|
test "Axes::get_ylabel" {
let (fig, axes) = @matplotlib.subplots(1, 1)
axes[0][0].set_ylabel("Y Label")
inspect!(axes[0][0].get_ylabel(), content="\"Y Label\"")
}
get_ylabel(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes) -> String
String {
653 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("get_ylabel") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
654 guard @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple = .., kwargs~ : @python.PyDict = ..) -> @python.PyObjectEnum?
invoke() is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyString) -> @python.PyObjectEnum
PyString(@python.PyString
ylabel))
655 @python.PyString
ylabel.(self : @python.PyString) -> String
to_string()
656}
657
658///|
659pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, base~ : Double = ..) -> Unit
loglog(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes, Double
base~ : Double
Double = 10.0) -> Unit
Unit {
660 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("loglog") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
661 let @python.PyDict
kwargs : struct @python.PyDict {
// private fields
}
PyDict = struct @python.PyDict {
// private fields
}
PyDict::() -> @python.PyDict
Creates a new python dict object.
Example
test "PyDict::new" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = { 'one': 1, 'two': 2.0, 'three': True }
print(d) # Output: {'one': 1, 'two': 2.0, 'three': True}
new()
662 @python.PyDict
kwargs..(self : @python.PyDict, key : String, val : @python.PyFloat) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("base", struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
base))
663 let _ = @python.PyCallable
f.(self : @python.PyCallable, kwargs~ : @python.PyDict, args~ : @python.PyTuple = ..) -> @python.PyObjectEnum?
invoke(@python.PyDict
kwargs~)
664
665}
666
667///|
668pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, base~ : Double = ..) -> Unit
semilogx(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes, Double
base~ : Double
Double = 10.0) -> Unit
Unit {
669 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("semilogx") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
670 let @python.PyDict
kwargs : struct @python.PyDict {
// private fields
}
PyDict = struct @python.PyDict {
// private fields
}
PyDict::() -> @python.PyDict
Creates a new python dict object.
Example
test "PyDict::new" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = { 'one': 1, 'two': 2.0, 'three': True }
print(d) # Output: {'one': 1, 'two': 2.0, 'three': True}
new()
671 @python.PyDict
kwargs..(self : @python.PyDict, key : String, val : @python.PyFloat) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("base", struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
base))
672 let _ = @python.PyCallable
f.(self : @python.PyCallable, kwargs~ : @python.PyDict, args~ : @python.PyTuple = ..) -> @python.PyObjectEnum?
invoke(@python.PyDict
kwargs~)
673
674}
675
676///|
677pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, base~ : Double = ..) -> Unit
semilogy(Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes, Double
base~ : Double
Double = 10.0) -> Unit
Unit {
678 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("semilogy") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
679 let @python.PyDict
kwargs : struct @python.PyDict {
// private fields
}
PyDict = struct @python.PyDict {
// private fields
}
PyDict::() -> @python.PyDict
Creates a new python dict object.
Example
test "PyDict::new" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = { 'one': 1, 'two': 2.0, 'three': True }
print(d) # Output: {'one': 1, 'two': 2.0, 'three': True}
new()
680 @python.PyDict
kwargs..(self : @python.PyDict, key : String, val : @python.PyFloat) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("base", struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
base))
681 let _ = @python.PyCallable
f.(self : @python.PyCallable, kwargs~ : @python.PyDict, args~ : @python.PyTuple = ..) -> @python.PyObjectEnum?
invoke(@python.PyDict
kwargs~)
682
683}
684
685///|
686pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, visiable : Bool, color~ : Color = .., linestyle~ : LineStyle = .., linewidth~ : Double = .., alpha~ : Double = ..) -> Unit
grid(
687 Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes,
688 Bool
visiable : Bool
Bool,
689 Color
color~ : enum Color {
Aliceblue
Antiquewhite
Aqua
Aquamarine
Azure
Beige
Bisque
Black
Blanchedalmond
Blue
Blueviolet
Brown
Burlywood
Cadetblue
Chartreuse
Chocolate
Coral
Cornflowerblue
Cornsilk
Crimson
Cyan
Darkblue
Darkcyan
Darkgoldenrod
Darkgray
Darkgreen
Darkgrey
Darkkhaki
Darkmagenta
Darkolivegreen
Darkorange
Darkorchid
Darkred
Darksalmon
Darkseagreen
Darkslateblue
Darkslategray
Darkslategrey
Darkturquoise
Darkviolet
Deeppink
Deepskyblue
Dimgray
Dimgrey
Dodgerblue
Firebrick
Floralwhite
Forestgreen
Fuchsia
Gainsboro
Ghostwhite
Gold
Goldenrod
Gray
Green
Greenyellow
Grey
Honeydew
Hotpink
Indianred
Indigo
Ivory
Khaki
Lavender
Lavenderblush
Lawngreen
Lemonchiffon
Lightblue
Lightcoral
Lightcyan
Lightgoldenrodyellow
Lightgray
Lightgreen
Lightgrey
Lightpink
Lightsalmon
Lightseagreen
Lightskyblue
Lightslategray
Lightslategrey
Lightsteelblue
Lightyellow
Lime
Limegreen
Linen
Magenta
Maroon
Mediumaquamarine
Mediumblue
Mediumorchid
Mediumpurple
Mediumseagreen
Mediumslateblue
Mediumspringgreen
Mediumturquoise
Mediumvioletred
Midnightblue
Mintcream
Mistyrose
Moccasin
Navajowhite
Navy
Oldlace
Olive
Olivedrab
Orange
Orangered
Orchid
Palegoldenrod
Palegreen
Paleturquoise
Palevioletred
Papayawhip
Peachpuff
Peru
Pink
Plum
Powderblue
Purple
Rebeccapurple
Red
Rosybrown
Royalblue
Saddlebrown
Salmon
Sandybrown
Seagreen
Seashell
Sienna
Silver
Skyblue
Slateblue
Slategray
Slategrey
Snow
Springgreen
Steelblue
Tan
Teal
Thistle
Tomato
Turquoise
Violet
Wheat
White
Whitesmoke
Yellow
Yellowgreen
Rgb(Int, Int, Int)
}
Color = Color::Color
Blue,
690 LineStyle
linestyle~ : enum LineStyle {
Solid
Dashed
Dotted
DashDot
}
LineStyle = LineStyle::LineStyle
Solid,
691 Double
linewidth~ : Double
Double = 1.0,
692 Double
alpha~ : Double
Double = 0.8
693) -> Unit
Unit {
694 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("grid") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
695 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(1)
696 @python.PyTuple
args..(self : @python.PyTuple, idx : Int, item : @python.PyBool) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, struct @python.PyBool {
// private fields
}
PyBool::(Bool) -> @python.PyBool
Create a python boolean object from moonbit bool.
Example
test "PyBool::from" {
let t = PyBool::from(true);
inspect!(t, content="True")
}
The above code is equivalent to:
t = True
print(t) # Output: True
from(Bool
visiable))
697 let @python.PyDict
kwargs : struct @python.PyDict {
// private fields
}
PyDict = struct @python.PyDict {
// private fields
}
PyDict::() -> @python.PyDict
Creates a new python dict object.
Example
test "PyDict::new" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = { 'one': 1, 'two': 2.0, 'three': True }
print(d) # Output: {'one': 1, 'two': 2.0, 'three': True}
new()
698 @python.PyDict
kwargs
699 ..(self : @python.PyDict, key : String, val : @python.PyString) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("color", Color
color.(self : Color) -> @python.PyString
to_pystr())
700 ..(self : @python.PyDict, key : String, val : @python.PyString) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("linestyle", LineStyle
linestyle.(self : LineStyle) -> @python.PyString
to_pystr())
701 ..(self : @python.PyDict, key : String, val : @python.PyFloat) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("linewidth", struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
linewidth))
702 ..(self : @python.PyDict, key : String, val : @python.PyFloat) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("alpha", struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
alpha))
703 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~, @python.PyDict
kwargs~)
704
705}
706
707///|
708pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, x : Double, ymin : Double, ymax : Double, color~ : Color = .., linestyle~ : LineStyle = ..) -> Unit
vline(
709 Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes,
710 Double
x : Double
Double,
711 Double
ymin : Double
Double,
712 Double
ymax : Double
Double,
713 Color
color~ : enum Color {
Aliceblue
Antiquewhite
Aqua
Aquamarine
Azure
Beige
Bisque
Black
Blanchedalmond
Blue
Blueviolet
Brown
Burlywood
Cadetblue
Chartreuse
Chocolate
Coral
Cornflowerblue
Cornsilk
Crimson
Cyan
Darkblue
Darkcyan
Darkgoldenrod
Darkgray
Darkgreen
Darkgrey
Darkkhaki
Darkmagenta
Darkolivegreen
Darkorange
Darkorchid
Darkred
Darksalmon
Darkseagreen
Darkslateblue
Darkslategray
Darkslategrey
Darkturquoise
Darkviolet
Deeppink
Deepskyblue
Dimgray
Dimgrey
Dodgerblue
Firebrick
Floralwhite
Forestgreen
Fuchsia
Gainsboro
Ghostwhite
Gold
Goldenrod
Gray
Green
Greenyellow
Grey
Honeydew
Hotpink
Indianred
Indigo
Ivory
Khaki
Lavender
Lavenderblush
Lawngreen
Lemonchiffon
Lightblue
Lightcoral
Lightcyan
Lightgoldenrodyellow
Lightgray
Lightgreen
Lightgrey
Lightpink
Lightsalmon
Lightseagreen
Lightskyblue
Lightslategray
Lightslategrey
Lightsteelblue
Lightyellow
Lime
Limegreen
Linen
Magenta
Maroon
Mediumaquamarine
Mediumblue
Mediumorchid
Mediumpurple
Mediumseagreen
Mediumslateblue
Mediumspringgreen
Mediumturquoise
Mediumvioletred
Midnightblue
Mintcream
Mistyrose
Moccasin
Navajowhite
Navy
Oldlace
Olive
Olivedrab
Orange
Orangered
Orchid
Palegoldenrod
Palegreen
Paleturquoise
Palevioletred
Papayawhip
Peachpuff
Peru
Pink
Plum
Powderblue
Purple
Rebeccapurple
Red
Rosybrown
Royalblue
Saddlebrown
Salmon
Sandybrown
Seagreen
Seashell
Sienna
Silver
Skyblue
Slateblue
Slategray
Slategrey
Snow
Springgreen
Steelblue
Tan
Teal
Thistle
Tomato
Turquoise
Violet
Wheat
White
Whitesmoke
Yellow
Yellowgreen
Rgb(Int, Int, Int)
}
Color = Color::Color
Blue,
714 LineStyle
linestyle~ : enum LineStyle {
Solid
Dashed
Dotted
DashDot
}
LineStyle = LineStyle::LineStyle
Solid
715) -> Unit
Unit {
716 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("vlines") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
717 let @python.PyFloat
x = struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
x)
718 let @python.PyFloat
ymin = struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
ymin)
719 let @python.PyFloat
ymax = struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
ymax)
720 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(3)
721 @python.PyTuple
args..(self : @python.PyTuple, idx : Int, item : @python.PyFloat) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, @python.PyFloat
x)..(self : @python.PyTuple, idx : Int, item : @python.PyFloat) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(1, @python.PyFloat
ymin)..(self : @python.PyTuple, idx : Int, item : @python.PyFloat) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(2, @python.PyFloat
ymax)
722 let @python.PyDict
kwargs : struct @python.PyDict {
// private fields
}
PyDict = struct @python.PyDict {
// private fields
}
PyDict::() -> @python.PyDict
Creates a new python dict object.
Example
test "PyDict::new" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = { 'one': 1, 'two': 2.0, 'three': True }
print(d) # Output: {'one': 1, 'two': 2.0, 'three': True}
new()
723 @python.PyDict
kwargs
724 ..(self : @python.PyDict, key : String, val : @python.PyString) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("colors", Color
color.(self : Color) -> @python.PyString
to_pystr())
725 ..(self : @python.PyDict, key : String, val : @python.PyString) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("linestyles", LineStyle
linestyle.(self : LineStyle) -> @python.PyString
to_pystr())
726 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~, @python.PyDict
kwargs~)
727
728}
729
730///|
731pub fn struct Axes {
obj: @python.PyObject
// private fields
}
Axes::(self : Axes, y : Double, xmin : Double, xmax : Double, color~ : Color = .., linestyle~ : LineStyle = ..) -> Unit
hline(
732 Axes
self : struct Axes {
obj: @python.PyObject
// private fields
}
Axes,
733 Double
y : Double
Double,
734 Double
xmin : Double
Double,
735 Double
xmax : Double
Double,
736 Color
color~ : enum Color {
Aliceblue
Antiquewhite
Aqua
Aquamarine
Azure
Beige
Bisque
Black
Blanchedalmond
Blue
Blueviolet
Brown
Burlywood
Cadetblue
Chartreuse
Chocolate
Coral
Cornflowerblue
Cornsilk
Crimson
Cyan
Darkblue
Darkcyan
Darkgoldenrod
Darkgray
Darkgreen
Darkgrey
Darkkhaki
Darkmagenta
Darkolivegreen
Darkorange
Darkorchid
Darkred
Darksalmon
Darkseagreen
Darkslateblue
Darkslategray
Darkslategrey
Darkturquoise
Darkviolet
Deeppink
Deepskyblue
Dimgray
Dimgrey
Dodgerblue
Firebrick
Floralwhite
Forestgreen
Fuchsia
Gainsboro
Ghostwhite
Gold
Goldenrod
Gray
Green
Greenyellow
Grey
Honeydew
Hotpink
Indianred
Indigo
Ivory
Khaki
Lavender
Lavenderblush
Lawngreen
Lemonchiffon
Lightblue
Lightcoral
Lightcyan
Lightgoldenrodyellow
Lightgray
Lightgreen
Lightgrey
Lightpink
Lightsalmon
Lightseagreen
Lightskyblue
Lightslategray
Lightslategrey
Lightsteelblue
Lightyellow
Lime
Limegreen
Linen
Magenta
Maroon
Mediumaquamarine
Mediumblue
Mediumorchid
Mediumpurple
Mediumseagreen
Mediumslateblue
Mediumspringgreen
Mediumturquoise
Mediumvioletred
Midnightblue
Mintcream
Mistyrose
Moccasin
Navajowhite
Navy
Oldlace
Olive
Olivedrab
Orange
Orangered
Orchid
Palegoldenrod
Palegreen
Paleturquoise
Palevioletred
Papayawhip
Peachpuff
Peru
Pink
Plum
Powderblue
Purple
Rebeccapurple
Red
Rosybrown
Royalblue
Saddlebrown
Salmon
Sandybrown
Seagreen
Seashell
Sienna
Silver
Skyblue
Slateblue
Slategray
Slategrey
Snow
Springgreen
Steelblue
Tan
Teal
Thistle
Tomato
Turquoise
Violet
Wheat
White
Whitesmoke
Yellow
Yellowgreen
Rgb(Int, Int, Int)
}
Color = Color::Color
Blue,
737 LineStyle
linestyle~ : enum LineStyle {
Solid
Dashed
Dotted
DashDot
}
LineStyle = LineStyle::LineStyle
Solid
738) -> Unit
Unit {
739 guard Axes
self.@python.PyObject
obj.(self : @python.PyObject, attr : String, print_err~ : Bool = ..) -> @python.PyObjectEnum?
get_attr("hlines") is (@python.PyObjectEnum) -> @python.PyObjectEnum?
Some(PyObjectEnum::(@python.PyCallable) -> @python.PyObjectEnum
PyCallable(@python.PyCallable
f))
740 let @python.PyFloat
y = struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
y)
741 let @python.PyFloat
xmin = struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
xmin)
742 let @python.PyFloat
xmax = struct @python.PyFloat {
// private fields
}
PyFloat::(Double) -> @python.PyFloat
Create a PyFloat from a Double value.
Example
test "PyFloat::from" {
let f = @python.PyFloat::from(3.5);
inspect!(f, content="3.5")
}
from(Double
xmax)
743 let @python.PyTuple
args = struct @python.PyTuple {
// private fields
}
PyTuple::(UInt64) -> @python.PyTuple
Create a PyTuple object.
Notes: Tuple type must know the size of the tuple.
Example:
test "PyTuple::new" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(1, 2.0, \'three\')")
}
new(3)
744 @python.PyTuple
args..(self : @python.PyTuple, idx : Int, item : @python.PyFloat) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(0, @python.PyFloat
y)..(self : @python.PyTuple, idx : Int, item : @python.PyFloat) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(1, @python.PyFloat
xmin)..(self : @python.PyTuple, idx : Int, item : @python.PyFloat) -> Unit
Set the item at the given index.
Notes: Although python supports negative index, in moonbit, we don't have plan to
support it. Code like tuple.set(-1, item) will raise IndexOutOfBoundError.
Example:
test "PyTuple::set" {
let tuple = PyTuple::new(3)
tuple
..set(0, PyInteger::from(1))
..set(1, PyFloat::from(2.0))
..set(2, PyString::from("three"));
inspect!(tuple, content="(10, 2.0, \'three\')")
}
set(2, @python.PyFloat
xmax)
745 let @python.PyDict
kwargs : struct @python.PyDict {
// private fields
}
PyDict = struct @python.PyDict {
// private fields
}
PyDict::() -> @python.PyDict
Creates a new python dict object.
Example
test "PyDict::new" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = { 'one': 1, 'two': 2.0, 'three': True }
print(d) # Output: {'one': 1, 'two': 2.0, 'three': True}
new()
746 @python.PyDict
kwargs
747 ..(self : @python.PyDict, key : String, val : @python.PyString) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("colors", Color
color.(self : Color) -> @python.PyString
to_pystr())
748 ..(self : @python.PyDict, key : String, val : @python.PyString) -> Unit
Set the elements of the dict by its key (String).
Example
test "PyDict::set" {
let dict = PyDict::new()
dict
..set("one", PyInteger::from(1))
..set("two", PyFloat::from(2.0))
..set("three", PyBool::from(true));
inspect!(dict, content="{\'one\': 1, \'two\': 2.0, \'three\': True}")
}
The above code is equivalent to:
d = dict()
d['one'] = 1
d['two'] = 2.0
d['three'] = True
set("linestyles", LineStyle
linestyle.(self : LineStyle) -> @python.PyString
to_pystr())
749 let _ = @python.PyCallable
f.(self : @python.PyCallable, args~ : @python.PyTuple, kwargs~ : @python.PyDict) -> @python.PyObjectEnum?
invoke(@python.PyTuple
args~, @python.PyDict
kwargs~)
750
751}
752