Skip to content

Commit b1fb2cf

Browse files
authored
Merge pull request #1895 from Shaikh-Ubaid/hide_numpy_by_default
Pickle: Hide "numpy" module unless `--with-intrinsic-mods` is used
2 parents 66c70d7 + 9537df0 commit b1fb2cf

25 files changed

+30
-71967
lines changed

src/lpython/pickle.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,15 @@ class ASRPickleVisitor :
7272
s.append(")");
7373
}
7474
void visit_Module(const ASR::Module_t &x) {
75+
// hide intrinsic modules and numpy module by default
7576
if (!show_intrinsic_modules &&
76-
(x.m_intrinsic || startswith(x.m_name, "lfortran_intrinsic_"))) {
77+
(x.m_intrinsic || startswith(x.m_name, "numpy"))) {
7778
s.append("(");
7879
if (use_colors) {
7980
s.append(color(style::bold));
8081
s.append(color(fg::magenta));
8182
}
82-
s.append("IntrinsicModule");
83+
s.append(x.m_intrinsic ? "IntrinsicModule" : "Module");
8384
if (use_colors) {
8485
s.append(color(fg::reset));
8586
s.append(color(style::reset));
@@ -202,7 +203,9 @@ class ASRJsonVisitor :
202203
}
203204

204205
void visit_Module(const ASR::Module_t &x) {
205-
if (x.m_intrinsic && !show_intrinsic_modules) { // do not show intrinsic modules by default
206+
// hide intrinsic modules and numpy module by default
207+
if (!show_intrinsic_modules &&
208+
(x.m_intrinsic || startswith(x.m_name, "numpy"))) {
206209
s.append("{");
207210
inc_indent(); s.append("\n" + indtd);
208211
s.append("\"node\": \"Module\"");

tests/reference/asr-array_01_decl-39cf894.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "asr-array_01_decl-39cf894.stdout",
9-
"stdout_hash": "7c629e68e8259cdad76c7c5f6fbda500fb11ee53cd85ef36738ad550",
9+
"stdout_hash": "a31f210cef724c6bdf84f10ab9f177708e754b8b32ccbe62f0695d5e",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

tests/reference/asr-array_01_decl-39cf894.stdout

Lines changed: 1 addition & 5996 deletions
Large diffs are not rendered by default.

tests/reference/asr-array_02_decl-e8f6874.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "asr-array_02_decl-e8f6874.stdout",
9-
"stdout_hash": "0248f1a76d6fc9ab351cf53c9dd835d5dbc644423e1d150bc10d6a9a",
9+
"stdout_hash": "fd32bda3bbfa7674acd3e6af34142333625aa7f9d7803cacf448fc24",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

tests/reference/asr-array_02_decl-e8f6874.stdout

Lines changed: 1 addition & 5996 deletions
Large diffs are not rendered by default.

tests/reference/asr-bindc_02-bc1a7ea.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "asr-bindc_02-bc1a7ea.stdout",
9-
"stdout_hash": "a84c81209f918df8b469a9249361ac3b7237cf0967e8dc0800279ff9",
9+
"stdout_hash": "96064ed45528b0957f33def62b58e5af77b4010fef69f95124fcc5df",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

tests/reference/asr-bindc_02-bc1a7ea.stdout

Lines changed: 1 addition & 5996 deletions
Large diffs are not rendered by default.

tests/reference/asr-elemental_01-b58df26.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "asr-elemental_01-b58df26.stdout",
9-
"stdout_hash": "5b6cf6a1bc74628962f642ae611e4cc270e870d66c9d9b496d13067e",
9+
"stdout_hash": "2b7a263e3b7c122e03cf3847e1db4cf3d8f46e7bb32b421bd1814450",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

tests/reference/asr-elemental_01-b58df26.stdout

Lines changed: 1 addition & 5996 deletions
Large diffs are not rendered by default.

tests/reference/asr-generics_array_01-682b1b2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "asr-generics_array_01-682b1b2.stdout",
9-
"stdout_hash": "91946cc87dd5befb12b930f7fd0baca8f6aec64c2dab92317d02345b",
9+
"stdout_hash": "6021ce034db2021fd5698d84ee65b4bf1f7d38d79f71b9734d221893",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0

0 commit comments

Comments
 (0)