How to create table in Octave with border? - octave

I want to create a table which looks like this Table01.
Where each column is a vector.
I tried with Octave data frame package but it is not generating table as I expected (With border)
Previously I tried with [t,I_X,I_Y] = table(x,y) which is also not satisfactory.
How can I generate table like the sample I provided and store them in format pdf in a directory?

I imagine you want something similar to uitable in MATLAB. Unfortunately, I don't think that has been implemented yet. However, I think I've found a solution that might help you. Here's the output I get for an example matrix m=magic(4):
If that is what you want, then keep reading! So, first, install the miscellaneous package. If using Ubuntu, you can just do that with
apt-get install octave-miscellaneous
Now, all you have to do is (well,you might run into a small problem, but I'll adress that in a bit):
pkg load miscellaneous
m=magic(4);
textable(m,"file","/tmp/file.tex","clines","rlines");
And voilà, you have the matrix expressed in latex code in "/tmp/file.tex", that you can compile with pdflatex , or alternatively, just copy paste it into something like this to get an image of the table.
Potential problem you might run into. Note that this seems to apply in octave version 4.2.2 which is the one I'm using, so, maybe you wont encounter that problem with your version. When using textable, you might get an error of the style
error: value on right hand side of assignment is undefined
error: called from
textable at line 111 column 5
If that happens, this is because the function textable (whose code you can find in textable.m, you can just use $ locate textable on Ubuntu) seems to use an obsolete (or different) interface to the inputParser object that it uses internally. So, if that happens, just go to line 111 of textable.m and replace
p = inputParser;
p = p.addSwitch ("clines");
p = p.addSwitch ("rlines");
p = p.addParamValue ("math", "X", #ischar);
p = p.addParamValue ("file", "matrix.tex", #ischar);
p = p.addParamValue ("align", "r", #(x) any(strcmpi(x, {"l", "c", "r"})));
p = p.parse (varargin{:});
with
p = inputParser;
p.addSwitch ("clines");
p.addSwitch ("rlines");
p.addParamValue ("math", "X", #ischar);
p.addParamValue ("file", "matrix.tex", #ischar);
p.addParamValue ("align", "r", #(x) any(strcmpi(x, {"l", "c", "r"})));
p.parse (varargin{:});
and you're set to go.

Related

Admin import - Group not found

I am trying to load multiple csv files into a new db using the neo4j-admin import tool on a machine running Debian 11. To try to ensure there's no collisions in the ID fields, I've given every one of my node and relationship files.
However, I'm getting this error:
org.neo4j.internal.batchimport.input.HeaderException: Group 'INVS' not found. Available groups are: [CUST]
This is super frustrating, as I know that the INV group definitely exists. I've checked every file that uses that ID Space and they all include it.Another strange thing is that there are more ID spaces than just the CUST and INV ones. It feels like it's trying to load in relationships before it finishes loading in all of the nodes for some reason.
Here is what I'm seeing when I search through my input files
$ grep -r -h "(INV" ./import | sort | uniq
:ID(INVS),total,:LABEL
:START_ID(INVS),:END_ID(CUST),:TYPE
:START_ID(INVS),:END_ID(ITEM),:TYPE
The top one is from my $NEO4J_HOME/import/nodes folder, the other two are in my $NEO4J_HOME/import/relationships folder.
Is there a nice solution to this? Or have I just stumbled upon a bug here?
Edit: here's the command I've been using from within my $NEO4J_HOME directory:
neo4j-admin import --force=true --high-io=true --skip-duplicate-nodes --nodes=import/nodes/\.* --relationships=import/relationships/\.*
Indeed, such a thing would be great, but i don't think it's possible at the moment.
Anyway it doesn't seems a bug.
I suppose it may be a wanted behavior and / or a feature not yet foreseen.
In fact, on the documentation regarding the regular expression it says:
Assume that you want to include a header and then multiple files that matches a pattern, e.g. containing numbers.
In this case a regular expression can be used
while on the description of --nodes command:
Node CSV header and data. Multiple files will be
logically seen as one big file from the
perspective of the importer. The first line must
contain the header. Multiple data sources like
these can be specified in one import, where each
data source has its own header.
So, it appears that the neo4j-admin import considers the --nodes=import/nodes/\.* as a single .csv with the first header found, hence the error.
Contrariwise with more --nodes there are no problems.

Is it possible to give text format hints in google vision api?

I'm trying to detect handwritten dates isolated in images.
In the cloud vision api, is there a way to give hints about type?
example: the only text present will be dd/mm/yy, d,m and y being digits
The only thing I found is language hints in the documentation.
Sometimes I get results that include letters like O instead of 0.
There is not a way to give hints about type but you can filter the output using client libraries. I downloaded detect.py and requirements.txt from here and modified detect.py (in def detect_text, after line 283):
response = client.text_detection(image=image)
texts = response.text_annotations
#Import regular expressions
import re
print('Date:')
dateStr=texts[0].description
# Test case for letters replacement
#dateStr="Z3 OZ/l7"
#print(dateStr)
dateStr=dateStr.replace("O","0")
dateStr=dateStr.replace("Z","2")
dateStr=dateStr.replace("l","1")
dateList=re.split(' |;|,|/|\n',dateStr)
dd=dateList[0]
mm=dateList[1]
yy=dateList[2]
date=dd+'/'+mm+'/'+yy
print(date)
#for text in texts:
#print('\n"{}"'.format(text.description))
#print('Hello you!')
#vertices = (['({},{})'.format(vertex.x, vertex.y)
# for vertex in text.bounding_poly.vertices])
#print('bounds: {}'.format(','.join(vertices)))
# [END migration_text_detection]
# [END def_detect_text]
Then I launched detect.py inside the virtual environment using this command line:
python detect_dates.py text qAkiq.png
And I got this:
23/02/17
There are few letters that can be mistaken for numbers, so using str.replace(“letter”,”number”) should solve the wrong identifications. I added the most common cases for this example.

Function to open a file and navigate to a specified line number

I have the output of recursive grep (actually ag) in a buffer, which is of the form filename:linenumber: ... [match] ..., and I want to be able to go to the occurrence (file and line number) currently under the cursor. This told me that I could execute normal-mode movements, so after extracting the file:line portion, I wrote this function:
function OpenFileNewTab(name)
let l:pair=split(a:name, ":")
execute "tabnew" get(l:pair, 0)
execute "normal!" get(l:pair, 1) . "G"
endfunction
It is supposed to open the specified file in a tab and then do <lineno>G, like I am able to do manually, to go to the specified line number. However, the cursor just stays on line 1. What am I doing wrong?
This question, by title alone, would be an exact duplicate, but it talks locating symbols in other files, while I already have the locations at hand.
Edit: My mappings for grep / ag are as follows:
nnoremap <Leader>ag :execute "new \| read !ag --literal -w" "<C-r><C-w>" g:repo \| :set filetype=c<CR>
nnoremap <Leader>gf ^v2t:"zy :execute OpenFileNewTab("<C-r>z")<CR>
To get my grep / ag results, I put the cursor on the word I want to search and enter <leader>ag, then, in the new buffer, I put the cursor on a line and enter <leader>gf - it selects from the start up to the second colon and calls OpenFileNewTab.
Edit 2: I'm on Cygwin, if it is of any importance - I doubt it.
Why don't you set &grepprg to call ag ?
" according to man ag
set grepprg=ag\ --vimgrep\ $*
set grepformat=%f:%l:%c:%m
" And then (not tested)
nnoremap <Leader>ag :grep -w <c-r><c-w><cr>
As others have said in the comments, you are just trying to emulate what the quickfix windows already provides. And, we are lucky vim can call grep, and it has a variation point to let us specify which grep program we wish to use: 'grepprg'.
Use file-line plugin. Pressing Enter on a line in the quicklist will normally open that file; file-line will make any filename of the form file:line:column (and several other formats) to open file and position to line and column.
I only found this (old) thread after I posted the exact same question on vi.stackexchange: https://vi.stackexchange.com/q/39557/44764. To help anyone who comes looking, I post the best answer to my question below as an alternative to the answers already given.
The gF command, like gf, opens the file in a new tab but additionally it also positions the cursor on the line after the colon. (I note the OP defines <leader>gf so maybe vim/neovim didn't auto-define gf or gF at the time this thread was originally created.)

Octave 4.0 crashing on audiowrite

I'm trying to split up the long line of audiowrite but when I do Octave 4.0 crashes I'm using Octave 4.0 (which is like matlab) on Ubuntu 16.04 64bit.
audio_prop='BitsPerSample',16,'Artist','artist rt','Title','title section rt','Comment','Comments section rt';
audiowrite('/tmp/test.wav',[sig_full_L(:) -1*sig_full_R(:)],44100,audio_prop)
Can I not split it up this way if not how can I split it up?
Someone asked for the full code so here it is (this causes octave 4.0 to crash)
fs =8000; % Sampling frequency
fs_rate=fs;
dursec=10; %%duration of signal in seconds
t=linspace(0,2*pi,dursec*fs);
freq=primes(fs/2*dursec);
freq=freq';
ya=zeros(1,length(t));
numfreq=numel(freq)
for ii=1:1:numel(freq)
ya = ya+sin(freq(ii,1)*t);
end
audio_prop='BitsPerSample',16,'Artist','artist rt','Title','title section rt','Comment','Comments section rt';
audiowrite('/tmp/test.flac',[ya(:) -1*ya(:)],44100,audio_prop)
I was told by the octave people to fill out a crash / bug report link below
https://savannah.gnu.org/bugs/index.php?47875
Here is one way to wrap a long list of arguments into a single variable,
in order to shorter lines or to allow for reuse in a further function.
First put the arguments in a cell array.
options = {"a", "b", 2};
Then use the cell array expansion, which is a bit hidden there :
Accessing multiple elements of a cell array with the ‘{’ and ‘}’
operators will result in a comma separated list of all the requested
elements
In our case,
options{:}
is interpreted as
"a", "b", 2
so calling
func(arg1, arg2, options{:})
is interpreted as
func(arg1, arg2, "a", "b", 2)
Which answers the question.
#ederag solved this for me. "Even the first line is wrong. Brackets ({})are missing around it. And it should be audio_prop{:} in the second line."
The code with the error should be:
audio_prop={'BitsPerSample',16,'Artist','artist rt','Title','title section rt','Comment','Comments section rt'};
audiowrite('/tmp/test.wav',[sig_full_L(:) -1*sig_full_R(:)],44100,audio_prop{:})

SciTe and Python 3 - problems with configuration [UBUNTU]

I have big problem(s) with configuration of SciTE in context of Python 3. I do not know if details have any meaning, so:
[DETAILS]
I downloaded and executed gen_python_3_api.py.
I created folder "api" in usr/share/scite and copy-pasted there python3.api
I edited SciTEUser.properties as written in documentation of gen_python_3_api.py. It did not help a bit, so:
I used more general way found on website of SciTE. I edited python.properties and added a line:
api.$(file.patterns.py)=$(SciteDefaultHome)\api\python.api.
Still no effect.
I just edited another line of python.properties:
if PLAT_GTK
command.go.*.py=python3 -u "$(FileNameExt)"
It finally worked (or I though so).
[/DETAILS]
Now I want to run simple Fibbonaci program that worked well with IDLE.
def Fib(n):
a = 0
b = 1
FibL = []
for i in range (n):
FibL.append(a)
z = a
a = b
b = b+z
return FibL
n = int(input("Number? "))
print(Fib(n))
And I get:
>python3 -u "test.py"
Number? Traceback (most recent call last):
File "test.py", line 38, in <module>
n = int(input("Number? "))
EOFError: EOF when reading a line
>Exit code: 1
I am completely confused. Do somebody know why this things happen and how to fix it?
First of all, the generation of api is for editing only, not running your code.
Resolve the ambiguity with versions by adding full path to command lines (Hope, you do so in the 5th point of the question details)
The problem is in the line:
n = int(input("Number? "))
Here you want input from user, i.e. interactive running, but editor runs commands inside its process and can output simply.
Change your code by adding variable instead of the input command
n=5
or use parameters http://www.scintilla.org/SciTEDoc.html#property-if
Good luck!