mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-28 20:14:45 +00:00
feat: add contextlib
This commit is contained in:
parent
1eabc1f0c0
commit
d03dcbd392
3 changed files with 31 additions and 6 deletions
|
@ -1 +1,5 @@
|
|||
.Figure: ClassType
|
||||
axes = pyimport "./axes"
|
||||
|
||||
.Figure!: ClassType
|
||||
.Figure!.
|
||||
add_axes!: (self: RefMut(.Figure!), rect: [Nat; 4], projection := Str or NoneType, polar := Bool, label := Str) => axes.Axes!
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
contextlib = pyimport "contextlib"
|
||||
|
||||
# lines = pyimport "../lines"
|
||||
text = pyimport "../text"
|
||||
legend = pyimport "../legend"
|
||||
|
@ -10,9 +12,16 @@ axes = pyimport "../axes"
|
|||
.title!: (title: Str) => text.Text
|
||||
.xlabel!: (label: Str) => text.Text
|
||||
.ylabel!: (label: Str) => text.Text
|
||||
.xlim!: (left := Float, right := Float) => (Float, Float) \
|
||||
and ((left_right: (Float, Float)) => (Float, Float))
|
||||
.ylim!: (bottom := Float, top := Float) => (Float, Float) \
|
||||
and ((bottom_top: (Float, Float)) => (Float, Float))
|
||||
.legend!: (labels := [Str; _]) => legend.Legend
|
||||
.subplots!: (() => (figure.Figure, axes.Axes!)) \
|
||||
and ((nrows: {1}, ncols: {1}) => (figure.Figure, axes.Axes!)) \
|
||||
and ((nrows: {1}, ncols: Nat) => (figure.Figure, [axes.Axes!; _])) \
|
||||
and ((nrows: Nat, ncols: {1}) => (figure.Figure, [axes.Axes!; _])) \
|
||||
and ((nrows: Nat, ncols: Nat) => (figure.Figure, [[axes.Axes!; _]; _]))
|
||||
.savefig!: (fname: Str, dpi := Float or Str, format := Str) => NoneType
|
||||
.subplots!: (() => (figure.Figure!, axes.Axes!)) \
|
||||
and ((nrows: {1}, ncols: {1}) => (figure.Figure!, axes.Axes!)) \
|
||||
and ((nrows: {1}, ncols: Nat) => (figure.Figure!, [axes.Axes!; _])) \
|
||||
and ((nrows: Nat, ncols: {1}) => (figure.Figure!, [axes.Axes!; _])) \
|
||||
and ((nrows: Nat, ncols: Nat) => (figure.Figure!, [[axes.Axes!; _]; _]))
|
||||
.figure!: (num := Int or Str, figsize := [Float; _], dpi := Float) => figure.Figure!
|
||||
.xkcd!: (scale := Float, length := Float, randomness := Float) => contextlib.ExitStack!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue