Open masa16 opened 7 years ago
AFAIK the is not such thing like import numpy as np
- require is file-based, and include is modules based but does not support renaming.
Naming collision can also come from such statements in the same way as with your expression, so I dont really see a difference here. in fact, i like expressions ;-)
Ok, it's one additional line, but thats all. IMO the difference between Numo::DFloat
and DF
is neglectable, because I use autocompletion during editing all the time - so I don't really type it. And it's even easier to read, if the long form is used.
I see these import-renamings all the time in python scripts and it usually confuses me more than it helps. Perhaps it reminds me to much of this bad-but-still-so-popular habit of fortran programmers (around me) to shorted every variable or functions name to the very unreadable minimum.
I think it is important to make the code smaller. To type Numo :: DFloat, you need to press the keyboard 12 times at all times. No 14 times (I forgot to press the shift key). This is a waste of life. And life is short. I think that "NArray" must be a tool that can be enjoyed even by school children. Children know which toys are the most interesting.
I consider NArray is not just like a library accessed through descriptive API.
It will be a tool used also in command line or Jupyter notebook.
I have already seen a code including include Numo
, but I do not know they understand a side effect.
So I think it requires the right manner of writing shortly.
And it influences the design of Numo module.
This style is right as a Ruby code, but I prefer less typing.
First idea:
In this case, you can omit Numo module name. However, Numo module functions like
Numo.max(a,b)
become top-level methods.Another idea:
It is able to write more shortly. But it requires assignment. Collision of constant name may happen.
What is Numo-convension for abbreviaton corresponding to
import numpy as np
?New method for constructor is possible. Old NArray style:
Numpy style: