Have Browserify transform Hintify continue on error - gulp

I'm using Gulp with Browserify and Hintify. The standard way to catch errors seems to be something like:
browserify({
entries: 'app.js',
transform: [
// Some other transforms
plugins.hintify
]
// A bunch of other settings
}).bundle()
// Error handling
.on('error', function(error) {
util.beep(); // Util is gulp-util
util.log(error);
this.emit('end');
})
.pipe(...)
This works great, and everytime I violate my jshint I get something like this:
Users/me/Sites/project/client/scripts/app.js: line 11, col 23, Missing semicolon.
And the build stops.
However, I'd kinda like the build to continue even if I forget a semicolon. Right now, any jshint error stops the build from processing. I like to check if my code is up to par, but it shouldn't prevent everything from building if I have an unused argument in a function.
Help?

The current setup works for me (configuration sam as here):
var jshint = require('gulp-jshint');
var notify = require('gulp-notify');
var stylish = require('jshint-stylish')
...
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
//.pipe(jshint.reporter('fail')) // <- omit a fail reporter
...
OR
...
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'))
.on('error', notify.onError({ message: 'JS hint fail'})) // <- pipe fail to notification
...
This gives me the output:
...
src\m\typings.js
line 0 col 0 ES5 option is now set per default
line 3 col 18 ['SUCCESS'] is better written in dot notation.
line 4 col 18 ['FAILURE'] is better written in dot notation.
line 5 col 18 ['UNSTABLE'] is better written in dot notation.
line 6 col 18 ['NOT_BUILT'] is better written in dot notation.
line 10 col 26 ['info'] is better written in dot notation.
line 11 col 26 ['success'] is better written in dot notation.
line 12 col 26 ['mark'] is better written in dot notation.
line 13 col 26 ['warn'] is better written in dot notation.
line 14 col 26 ['error'] is better written in dot notation.
line 15 col 26 ['debug'] is better written in dot notation.
line 16 col 26 ['none'] is better written in dot notation.
line 18 col 1 Unnecessary semicolon.
‼ 13 warnings
[10:08:32] src\m\typings.js
src\helper\scaffolding.helper.js
line 0 col 0 ES5 option is now set per default
line 65 col 61 Regular parameters cannot come after default parameters.
line 82 col 79 Expected an assignment or function call and instead saw an expression.
line 84 col 77 Regular parameters cannot come after default parameters.
line 90 col 39 Expected an assignment or function call and instead saw an expression.
line 91 col 21 Missing 'new' prefix when invoking a constructor.
line 91 col 60 Expected an assignment or function call and instead saw an expression.
line 105 col 46 Expected an assignment or function call and instead saw an expression.
line 106 col 29 Missing 'new' prefix when invoking a constructor.
line 106 col 103 Expected an assignment or function call and instead saw an expression.
line 3 col 12 'require' is not defined.
line 4 col 14 'require' is not defined.
line 5 col 11 'require' is not defined.
line 6 col 19 'require' is not defined.
line 7 col 10 'require' is not defined.
line 8 col 13 'require' is not defined.
line 9 col 13 'require' is not defined.
line 33 col 17 'none' is not defined.
line 42 col 13 'color' is not defined.
line 45 col 13 'color' is not defined.
line 48 col 13 'color' is not defined.
line 51 col 13 'color' is not defined.
line 54 col 13 'color' is not defined.
line 57 col 13 'color' is not defined.
line 60 col 13 'color' is not defined.
line 63 col 12 'color' is not defined.
line 85 col 25 'process' is not defined.
× 2 errors
‼ 25 warnings
[10:08:32] src\helper\scaffolding.helper.js
src\helper\scaffolding.server.js
line 0 col 0 ES5 option is now set per default
line 22 col 44 Expected an assignment or function call and instead saw an expression.
line 23 col 25 Missing 'new' prefix when invoking a constructor.
line 23 col 75 Expected an assignment or function call and instead saw an expression.
line 25 col 43 Expected an assignment or function call and instead saw an expression.
line 26 col 25 Missing 'new' prefix when invoking a constructor.
line 26 col 117 Expected an assignment or function call and instead saw an expression.
line 38 col 40 Expected an assignment or function call and instead saw an expression.
line 39 col 21 Missing 'new' prefix when invoking a constructor.
line 39 col 50 Expected an assignment or function call and instead saw an expression.
line 74 col 43 Expected an assignment or function call and instead saw an expression.
line 75 col 25 Missing 'new' prefix when invoking a constructor.
line 75 col 96 Expected an assignment or function call and instead saw an expression.
line 4 col 12 'require' is not defined.
line 5 col 13 'require' is not defined.
line 7 col 13 'require' is not defined.
‼ 16 warnings
[10:08:32] src\helper\scaffolding.server.js
src\server\publish.js
line 0 col 0 ES5 option is now set per default
line 17 col 17 Missing 'new' prefix when invoking a constructor.
line 17 col 54 Expected an assignment or function call and instead saw an expression.
line 29 col 21 Missing 'new' prefix when invoking a constructor.
line 29 col 44 Expected an assignment or function call and instead saw an expression.
line 3 col 12 'require' is not defined.
line 4 col 13 'require' is not defined.
line 7 col 14 'require' is not defined.
line 9 col 12 'require' is not defined.
line 10 col 10 'require' is not defined.
line 11 col 14 'require' is not defined.
line 12 col 13 'require' is not defined.
‼ 12 warnings
[10:08:32] gulp-notify: [Error running Gulp] JS hint fail
[10:08:32] src\server\publish.js
[10:08:32] Finished 'build' after 1.61 s
with jshint ^1.12.0

Related

ValueError; Quantreg with Intercept

I am working with the following dataframe, called test:
y intercept x
0 -1.6168468132687293 1 NA
1 1.5500031232431757 1 NA
2 1.5952617833602785 1 1.5500031232431757
3 1.1390724309357498 1 1.5952617833602785
4 0.9950311340335872 1 1.1390724309357498
5 0.7095780139613861 1 0.9950311340335872
6 0.5962529862944801 1 0.7095780139613861
7 0.6555353674581792 1 0.5962529862944801
8 1.0008751093886736 1 0.6555353674581792
9 1.2648319050758074 1 1.0008751093886736
I am trying to apply the smf.quantreg() function to the dataframe as follows:
import statsmodels.formula.api as smf
Output_pre = smf.quantreg('y ~ intercept + x', test , missing = 'drop')
Output = Output_pre.fit(q=0.25)
The equivalent standard statsmodels.ols() function works just fine. However, applying the smf.quantreg() function yields the following error:
ValueError: operands could not be broadcast together with shapes (3,) (2,)
Why is that so and how do I solve this issue?
I found out myself. By default, the function gives an intercept. Hence the input matrix is not full rank when including a second intercept (two columns are perfectly colinear).

Coordinate "conversion of nan to int64" error

I am trying to correct the topography of some GPR data using GPR-O. The topographic data I have is in the form of coordinates and elevations for the four corners of each survey square. I have manually entered the coordinate, instead of calling on an xlsx file, to simply try it out using the following:
initialize
surveyparams.minline=01; % Lowest line number
surveyparams.nmorelines=4; % Would be 3 if you had 4 parallel lines with the numbers 0 1 2 3
surveyparams.lineincr=1.0; % Distance between the lines in meters
surveyparams.pnameraw='data/raw/Square_N_1/'; % Directory for the raw data
surveyparams.pnametrf='data/processed/Square_N_1/'; % Directroy for the processed data
preprawdata(surveyparams,3);
data=readdata(surveyparams);
vel=0.13;
elevdat=[226746,134520,867;226749,134524,867;226740,134529,866;226738,134525,866]
xpos=[]
elev=makeElev(elevdat,xpos,data,surveyparams);
data=elevCorrect(data,elev,vel);
maxelev=max(elev);
plotGPRline(data,0,2,vel,maxelev)
However, I receive the following error after the matrix has been created:
error: conversion of nan to int64_t value failed
error: called from
elevCorrect at line 44 column 8
Square_N_1 at line 22 column 12

Julia CSV.read not recognizing "select" keyword

I am reading in a space-delimited file using the CSV library in Julia.
edgeList = CSV.read(
joinpath(dataDirectory, "out.file"),
types=[Int, Int],
header=["node1", "node2"],
skipto=3,
select=[1,2]
)
This yields the following error:
MethodError: no method matching CSV.File(::String; types=DataType[Int64, Int64], header=["node1", "node2"], skipto=3, select=[1, 2])
Closest candidates are:
CSV.File(::Any; header, normalizenames, datarow, skipto, footerskip, limit, transpose, comment, use_mmap, ignoreemptylines, missingstrings, missingstring, delim, ignorerepeated, quotechar, openquotechar, closequotechar, escapechar, dateformat, decimal, truestrings, falsestrings, type, types, typemap, categorical, pool, strict, silencewarnings, threaded, debug, parsingdebug, allowmissing) at /Users/n.jordanjameson/.julia/packages/CSV/4GOjG/src/CSV.jl:221 got unsupported keyword argument "select"
I am using Julia v. 1.6.2. Here is the output versioninfo():
Julia Version 1.6.2
Commit 1b93d53fc4 (2021-07-14 15:36 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin18.7.0)
CPU: Intel(R) Core(TM) i7-5650U CPU # 2.20GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, broadwell)
The version of CSV is 0.10.4. The wiki for this version of CSV is here: https://csv.juliadata.org/stable/reading.html#CSV.read, and it has a select / drop entry.
The file I am trying to read is from here: http://konect.cc/networks/moreno_crime/ (the file I'm using is called "out.moreno_crime_crime"). The first few lines are:
% bip unweighted
% 1476 829 551
1 1
1 2
1 3
1 4
2 5
2 6
2 7
2 8
2 9
2 10
I get a different error than you, can you restart Julia and make sure?
julia> CSV.read("/home/akako/Downloads/moreno_crime/out.moreno_crime_crime"; types=[Int, Int],
header=["node1", "node2"],
skipto=3,
select=[1,2]
)
ERROR: ArgumentError: provide a valid sink argument, like `using DataFrames; CSV.read(source, DataFrame)`
Stacktrace:
[1] read(source::String, sink::Nothing; copycols::Bool, kwargs::Base.Pairs{Symbol, Any, NTuple{4, Symbol}, NamedTuple{(:types, :header, :skipto, :select), Tuple{Vector{DataType}, Vector{String}, Int64, Vector{Int64}}}})
# CSV ~/.julia/packages/CSV/jFiCn/src/CSV.jl:89
[2] top-level scope
# REPL[8]:1
Stacktrace:
this error is telling you you can't CSV.read without a target sink, you might want to use CSV.File
julia> CSV.File("/home/akako/Downloads/moreno_crime/out.moreno_crime_crime"; types=[Int, Int],
header=["node1", "node2"],
skipto=3,
select=[1,2]
)
┌ Warning: thread = 1 warning: parsed expected 2 columns, but didn't reach end of line around data row: 1. Parsing extra columns and widening final columnset
└ # CSV ~/.julia/packages/CSV/jFiCn/src/file.jl:579
1476-element CSV.File:
CSV.Row: (node1 = 1, node2 = 1, Column3 = missing)
CSV.Row: (node1 = 1, node2 = 2, Column3 = missing)
CSV.Row: (node1 = 1, node2 = 3, Column3 = missing)
CSV.Row: (node1 = 1, node2 = 4, Column3 = missing)

incremental search method script errors

I wrote my very first octave script which is a code for the incremental search method for root finding but I encountered numerous errors that I found hard to understand.
The following is the script:
clear
syms x;
fct=input('enter your function in standard form: ');
f=str2func(fct); % This built in octave function creates functions from strings
Xmax=input('X maximum= ');
Xinit=input('X initial= ');
dx=input('dx= ');
epsi=input('epsi= ');
N=10; % the amount by which dx is decreased in case a root was found.
while (x<=Xmax)
f1=f(Xinit);
x=x+dx
f2=f(x);
if (abs(f2)>(1/epsi))
disp('The function approches infinity at ', num2str(x));
x=x+epsi;
else
if ((f2*f1)>0)
x=x+dx;
elseif ((f2*f1)==0)
disp('a root at ', num2str );
x=x+epsi;
else
if (dx < epsi)
disp('a root at ', num2str);
x=x+epsi;
else
x=x-dx;
dx=dx/N;
x=x+dx;
end
end
end
end
when running it the following errors showed up:
>> Incremental
enter your function in standard form: 1+(5.25*x)-(sec(sqrt(0.68*x)))
warning: passing floating-point values to sym is dangerous, see "help sym"
warning: called from
double_to_sym_heuristic at line 50 column 7
sym at line 379 column 13
mtimes at line 63 column 5
Incremental at line 3 column 4
warning: passing floating-point values to sym is dangerous, see "help sym"
warning: called from
double_to_sym_heuristic at line 50 column 7
sym at line 379 column 13
mtimes at line 63 column 5
Incremental at line 3 column 4
error: wrong type argument 'class'
error: str2func: FCN_NAME must be a string
error: called from
Incremental at line 4 column 2
Below is the flowchart of the incremental search method:
The problem happens in this line:
fct=input('enter your function in standard form: ');
Here input takes the user input and evaluates it. It tries to convert it into a number. In the next line,
f=str2func(fct)
you assume fct is a string.
To fix the problems, tell input to just return the user's input unchanged as a string (see the docs):
fct=input('enter your function in standard form: ', 's');

substitution within a vim function using regex

I'm trying to turn a macro into a Function. Whilst I can save the macro I'd like to make it a function I can call.
I'm de-duping a specific element in a large concatenation of xml files using the following
G$b"myw0"n4ywdd:264501?^Rn/\dcw^Rm^[
Which gets parts of the last line into registers m and n then goes to a known line above the dedupe data and searches backwards for the contents of register n and replaces the number in the line with register m. The known line is to make sure I find the first occurrence that's not part of the de-dedupe set. Works fine if a bit slow when running 600 times.
On the function I've managed to duplicate everything except the cw with the contents of register m part.
function! MakeUnique()
let i = 0
while i <= 1
:200
:let #n=""
:let #m=""
:normal! G
:normal! $
:normal! b
:normal! "myw
:normal! 0
:normal! "n4yw
:200
execute "call search('".#n."','b')"
let i += 1
endwhile
endfunction
I've tried a few combinations of substitutions along the lines of the following but with no success.
Try 1
Register n = <dataid>389 and register m = <dataid>333
I changed the Line at the end of the file for this try to and changed "nyw to ny$
<dataId>333<dataid> <dataId>389
I would expect that subcommand when executed would read . s/<dataId>333/<dataId>389/
let subCommand=". s/".#m"/'".#n."'/"
exec subCommand
But given the result it doesn't seem as if #n is expanding
Result:
</dataid>
Try 2
In this case #n = 389
let subCommand=". s/[0-9][0-9][0-9]/".#n."/"
exec subCommand
This one works but the \d+ part may b 3 - 5 digits and I can't get a regex to work in this case, ie
s/\(\d\+\)/".#m."/
doesn't work and I get a E486: Pattern not found d+
Questions:
Is there any way to use regex match in the let subcommand = bit eg let subCommand = ". s/\d+/".#n"/"
Alternatively how do I replace using something like
let subCommand=". s/".#m"/'".#n."'/"
Or is there a vimscript equivalent of cw^Rm ?
Data example, cut down to fit.
The first iteration of the macro will change 6415 to 8790 in the identified line below.
I'm trying to replicate that in a Function.
1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2 <createsaleRequest>
3 <sale>
4 <saleNumber>9987166</saleNumber>
5 <dataId>6315</dataId>
6 </sale>
7 ...
8 </createsaleRequest>
9
10
11 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
12 <createsaleRequest>
13 <sale>
14 <saleNumber>9988166</saleNumber>
15 <dataId>6415</dataId>
16 </sale>
17 ...
18 </createsaleRequest>
19
20 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
21 <createsaleRequest>
22 <sale>
23 <saleNumber>9987921</saleNumber>
24 <dataId>6315</dataId>
25 </sale>
26 ...
27 </createsaleRequest>
28
29
30 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
31 <createsaleRequest>
32 <sale>
33 <saleNumber>9987411</saleNumber>
34 <dataId>6415</dataId> <!-- Change this on first run through -->
35 </sale>
36 ...
37 </createsaleRequest>
38
39 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
40 <createsaleRequest>
41 <sale>
42 <saleNumber>9987411</saleNumber>
43 <dataId>6193</dataId>
44 </sale>
45 ...
46 </createsaleRequest>
47
48
49
50
51 <dataId>6315</dataId> 6789
52 <dataId>6415</dataId> 8790
EDIT
Added a cut down data example to try and make the question make sense.
Edit
Found the problem. I'd left the second . out of the match portion. This let subCommand=". s/".#m."/".#n."/"works and is significantly faster than the macro. Don't know how to close the question.
I would like to know what ". ." means. I'm guessing it's an escape pattern that works in vimscript.