Skip to content

Commit f68f293

Browse files
authored
Merge pull request #5399 from ajdapretnar/python-script-default
Python Script: Change default script
2 parents 7ff45aa + 18652c4 commit f68f293

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Orange/widgets/data/owpythonscript.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@
3636
__all__ = ["OWPythonScript"]
3737

3838

39+
DEFAULT_SCRIPT = """import numpy as np
40+
from Orange.data import Table, Domain, ContinuousVariable, DiscreteVariable
41+
42+
domain = Domain([ContinuousVariable("age"),
43+
ContinuousVariable("height"),
44+
DiscreteVariable("gender", values=("M", "F"))])
45+
arr = np.array([
46+
[25, 186, 0],
47+
[30, 164, 1]])
48+
out_data = Table.from_numpy(domain, arr)
49+
"""
50+
3951
def text_format(foreground=Qt.black, weight=QFont.Normal):
4052
fmt = QTextCharFormat()
4153
fmt.setForeground(QBrush(foreground))
@@ -423,8 +435,8 @@ class Outputs:
423435

424436
settings_version = 2
425437
scriptLibrary: 'List[_ScriptData]' = Setting([{
426-
"name": "Hello world",
427-
"script": "print('Hello world')\n",
438+
"name": "Table from numpy",
439+
"script": DEFAULT_SCRIPT,
428440
"filename": None
429441
}])
430442
currentScriptIndex = Setting(0)

0 commit comments

Comments
 (0)