Comments (3)
Sorry for not following up on that earlier! It flew under my radar! So... I like the idea of a class if there are some additional things we want this class to manage (i.e., some methods that operates on these attributes, some argument validation to be coded, e.g., through the @property
decorator for setters and getters). I would not do it as a class if it is nothing more than the equivalent of a "C structure" (i.e., just a list of attributes) as shown in example 1. For such a case, the Python dictionary works already quite well, plus they allow the use of the ** operator that can be nifty in some case. How familiar are you with the use of the * and ** operators to unpack list and dictionaries (when used in the call of a function) or to allow unspecified positional and keyword arguments (when used in the signatures of a function)? Maybe these can be useful? They often are when working with a larger number of arguments.
That is:
args = ['[binary data here]', 'test.nii.gz']
nv.addVolume(*args)
kwargs = {"data_buffer": '[binary data here]', "name": 'test.nii.gz'}
nv.addVolume(**kwargs)
and
def addVolume(
self,
data_buffer,
name,
*args,
**kwarg
):
# some code
self.some_other_method_that _requires_the_additional_arguments(*args, **kwargs)
# some other code
This is quite neat in combination with config files (e.g., json or yaml) which are read as dictionaries that can be passed directly into functions. For a concreate example, you can have a look at these line of codes:
These lines use the following portion of a YAML config:
Note that since these arguments are passed to the constructor of the ICA
(https://mne.tools/stable/generated/mne.preprocessing.ICA.html), any argument that this constructor accept will work, without me having to define them in my code. Further, the signature of the ICA
constructor can change and the users of my code would still be able to use the new arguments available to ICA
without me having to change a line of code in my own library.
I am not sure if any of this can be useful for your specific use case; I'll have a better idea when I see what the actual code looks like and how efficient/cumbersome it is.
from ipyniivue.
Thank you. I saw your response earlier but I get to implementing these ideas. I'll write a response once I write some implementations.
from ipyniivue.
Sure thing, @AnthonyAndroulakis
from ipyniivue.
Related Issues (20)
- Build does not work on windows
- Testing for examples HOT 3
- MNE source files are not displayed HOT 3
- run_custom_code is painfully slow HOT 5
- add_volume should accept a pathlib Path object as input
- ipyniivue installting correctly but viewer window not showing up
- a
- Graph features
- Add custom colormaps
- devDependency requirement on @jupyterlab/builder@^4.0.0
- load_meshes HOT 1
- Building documentation HOT 8
- Review code of NiiVue Jupyter notebook integration in IPyNiiVue HOT 4
- load_meshes does not add the mesh to self.meshes in MacOS and Linux HOT 5
- Restarting the kernel fails to destroy the NiiVue object
- jupyterlab 4 support HOT 4
- ENH: Integration with MNE-Python
- Possible to add overlays and/or possibly saving the whole scene as .html file to harddrive?
- Prototype of ipyniivue using anywidget HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipyniivue.