Coder Social home page Coder Social logo

Comments (12)

paulmasson avatar paulmasson commented on June 19, 2024

The errors thrown in Math show up in the JavaScript console as uncaught exceptions. Is this sufficient for your purposes or did you have something else in mind?

from mathcell.

axkr avatar axkr commented on June 19, 2024

Sometimes I get an "empty HTML frame" in the web interface http://matheclipse.org/ from a command like below, because the function name ("TestFunction" in this case) is undefined, or the Math.js lib throws an exception like 'Unsupported elliptic nome'.

For all these cases it would be nice to have at least a "status" output line with the error message.

 Plot(TestFunction(x), {x, -2*Pi, 2*Pi},PlotRange->{-1,1})

from mathcell.

paulmasson avatar paulmasson commented on June 19, 2024

I've devised a way to automatically show errors in the MathCell, but it is browser dependent. For errors in the code of the cell, like undefined functions, it should work fine for all browsers because the error is local. For numerical errors coming from Math it displays a useful message in Firefox, but Chrome denies access to the full Error object and only displays a generic 'Script error.' for security reasons.

If you want to try it out, you'll need to use version 1.2.4 of Math and 1.7.5 of MathCell.

from mathcell.

axkr avatar axkr commented on June 19, 2024

Thanks, this is much better than showing an empty frame (in my "dynamic" use case) and let the user search in the browser console.

from mathcell.

axkr avatar axkr commented on June 19, 2024

In mathcell.js:311:23 I get this (translated) message only in the Firefox console:

"Unexpected value NaN parsing attribute y"

for this script:

<html>
<head>
<meta charset="utf-8">
<title>MathCell</title>
</head>

<body>

<script src="https://cdn.jsdelivr.net/gh/paulmasson/[email protected]/build/math.js"></script>
<script src="https://cdn.jsdelivr.net/gh/paulmasson/[email protected]/build/mathcell.js"></script>
<script src="https://cdn.jsdelivr.net/gh/mathjax/[email protected]/MathJax.js?config=TeX-AMS_HTML"></script>
<p style="text-align: center; line-height: 2"><span style="font-size: 20pt">MathCell</span></p>

<div class="mathcell" style="height: 4in">
<script>

var parent = document.scripts[ document.scripts.length - 1 ].parentNode;

var id = generateId();
parent.id = id;

MathCell( id, [ { type: 'buttons', values: ['cot','tan','sin','cos'], labels: ['Cot','Tan','Sin','Cos'], name: 'f', label: 'f' }
 ] );

parent.update = function( id ) {

var f = getVariable(id, 'f');

function z1(x) { return (window[f]((x))); }

var p1 = plot( z1, [0, (6.283185307179586)], { } );
var data = [ p1 ];
var config = { type: 'svg'  };
evaluate( id, data, config );

}

parent.update( id );

</script>
</div>

</body>
</html>

from mathcell.

paulmasson avatar paulmasson commented on June 19, 2024

I've added a check to plotting outputs to catch bad input.

Try version 1.7.6 and see if it takes care of this issue.

from mathcell.

axkr avatar axkr commented on June 19, 2024

Now it displays an error "Error: Infinity or NaN in input data" for example above.

But why isn't the cot(x) function not displayed?

from mathcell.

paulmasson avatar paulmasson commented on June 19, 2024

Because cot(0)=Infinity and subsequent rounding operations lead to an indeterminant NaN that messes up the plotting. Need to avoid the exact origin.

from mathcell.

paulmasson avatar paulmasson commented on June 19, 2024

I've discovered the trick I'm using to get a reference to the bad cell only works on the first load of the page. That may be enough for you, but I'll keep thinking about how to improve on this version.

from mathcell.

paulmasson avatar paulmasson commented on June 19, 2024

Figured out how to track active cells easily. Now if the cell initially has no error but develops one after manipulation of interacts, the error message should be displayed. Version 1.7.7 has the fix.

from mathcell.

axkr avatar axkr commented on June 19, 2024

The cot(x) function plot isn't displayed in the example above, if I replace with version 1.7.7.

Only the error message Error: Infinity or NaN in input data is displayed

from mathcell.

paulmasson avatar paulmasson commented on June 19, 2024

The cot(x) function plot isn't displayed in the example above, if I replace with version 1.7.7.

Only the error message Error: Infinity or NaN in input data is displayed

Because there is a singularity at the origin

from mathcell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.