florianschanda / miss_hit

MATLAB Independent, Small & Safe, High Integrity Tools - code formatter and more
GNU General Public License v3.0
158 stars 21 forks source link

run miss_hit on octave jupyter notebook #264

Open Remi-Gau opened 1 year ago

Remi-Gau commented 1 year ago

What kind of feature is this?

Your MATLAB/Octave environment

MISS_HIT component affected

Describe the solution you'd like

I have some demos that I keep primarily in Octave jupyter notebooks so they can be run in the browser on binder.

My current workflow involves converting the jupyter notebook to a .m file with this script:

https://github.com/cpp-lln-lab/bidspm/blob/main/demos/convert.py

Apply miss_hit to the .m file and then fix the notebook.

Being able to apply miss_hit directly to the notebook would be definitely a nice to have.

florianschanda commented 1 year ago

https://nbformat.readthedocs.io/en/latest/format_description.html#notebook-file-format

florianschanda commented 1 year ago

Could you email me 1-2 of these notebooks so I have something to work from? Ideally with a few mistakes in them that you'd like MISS_HIT to fix? My email is in the commit logs. I have never used jupyter, i barely know what it is, so to avoid making a non-representative testcase it would be best if you could provide something.

Even better if you will allow me to put it in the test-suite.

Remi-Gau commented 1 year ago

I actually have a few that I use as demo to run in binder on some projects.

For example: https://github.com/cpp-lln-lab/bidspm/blob/main/demos/MoAE/moae_01_bids_app.ipynb

Or see several here: https://github.com/bids-standard/bids-matlab/tree/dev/demos/notebooks

Notebooks are actually json files with all cell contents stored in an array of cells that can either be markdown or code.

{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "13de9b92",
   "metadata": {},
   "source": [
    "# MoAE demo\n",
    " (C) Copyright 2022 Remi Gau\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e0e9b1e0",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "addpath('/home/remi/matlab/SPM/spm12');"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Octave",
   "language": "python",
   "name": "octave"
  },
  "language_info": {
   "file_extension": ".m",
   "help_links": [
    {
     "text": "GNU Octave",
     "url": "https://www.gnu.org/software/octave/support.html"
    },
    {
     "text": "Octave Kernel",
     "url": "https://github.com/Calysto/octave_kernel"
    },
    {
     "text": "MetaKernel Magics",
     "url": "https://metakernel.readthedocs.io/en/latest/source/README.html"
    }
   ],
   "mimetype": "text/x-octave",
   "name": "python",
   "version": "3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:58:50) \n[GCC 10.3.0]"
  },
  "vscode": {
   "interpreter": {
    "hash": "57bcab47fba392aaf2481e270a6c32db0c9d247c375febbd49c7b44fb61a4644"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
florianschanda commented 1 year ago

I assume you use this kernel? https://github.com/Calysto/octave_kernel

Remi-Gau commented 1 year ago

yes indeed!

florianschanda commented 1 year ago

I am thinking on how to produce feedback. For example in https://github.com/Calysto/octave_kernel/blob/main/octave_kernel.ipynb

The first bit of code is:

t = linspace(0,6*pi,100);
plot(sin(t))
grid on
hold on
plot(cos(t), 'r')

There are some missing ; so how do I complain?

In the notebook shown on github it says In [1]: I could use that maybe, so say:

foo.ipynb:In [1]:2:13: missing semicolon

Would that be user-friendly enough?

I do something similar for matlab-in-simulink blocks so at least it would be consistent?

Remi-Gau commented 1 year ago

yes that would look good to me. And if you can things consistent for you to make your life easier: go for it.