Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admirable project but llthreads is incorrectly required #1

Closed
fusion809 opened this issue Oct 16, 2017 · 35 comments
Closed

Admirable project but llthreads is incorrectly required #1

fusion809 opened this issue Oct 16, 2017 · 35 comments

Comments

@fusion809
Copy link

fusion809 commented Oct 16, 2017

Hi,

The llthreads dependency seems to be required incorrectly as I have installed the llthreads2 (version 0.1.4) from the repository you linked in the documentation. It installs its crucial library to /usr/lib/lua/5.3/llthreads2.so with llthreads2.so being the notable part of that path. When I symlink this path to /usr/lib/lua/5.3/llthreads.so I get yet another error when I try to load lua-plot:

error loading module 'llthreads' from file '/usr/lib/lua/5.3/llthreads.so':
        /usr/lib/lua/5.3/llthreads.so: undefined symbol: luaopen_llthreads
stack traceback:
        [C]: in ?
        [C]: in function 'require'
        /usr/share/lua/5.3/lua-plot.lua:21: in main chunk
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: in ?
> lp = require("lua-plot")
/usr/share/lua/5.3/lua-plot.lua:21: module 'llthreads' not found:
        no field package.preload['llthreads']
        no file '/usr/share/lua/5.3/llthreads.lua'
        no file '/usr/share/lua/5.3/llthreads/init.lua'
        no file '/usr/lib/lua/5.3/llthreads.lua'
        no file '/usr/lib/lua/5.3/llthreads/init.lua'
        no file './llthreads.lua'
        no file './llthreads/init.lua'
        no file '/usr/lib/lua/5.3/llthreads.so'
        no file '/usr/lib/lua/5.3/loadall.so'
        no file './llthreads.so'
stack traceback:
        [C]: in function 'require'
        /usr/share/lua/5.3/lua-plot.lua:21: in main chunk
        [C]: in function 'require'
        stdin:1: in main chunk
        [C]: in ?

If I disable the use of llthreads by editing line 17 of lua-plot.lua changing nil to 1 everything works, fine, however. So it is clearly with what's done with llthreads. If relevant my platform is Arch Linux and I installed llthreads2 with this PKGBUILD:

pkgname=lua-llthreads2
pkgver=0.1.4
pkgrel=1
pkgdesc="This is full dropin replacement for llthreads library"
arch=("i686" "x86_64")
url="http://github.com/moteus/lua-llthreads2/"
license=("MIT")
depends=("lua")
makedepends=("luarocks")
source=("$pkgname-$pkgver.tar.gz::https://github.com/moteus/$pkgname/archive/v$pkgver.tar.gz")
md5sums=('b76af7ef6970b0e8089472fe377d3757')

build() {
	cd "$srcdir/$pkgname-$pkgver"
	luarocks make --pack-binary-rock "rockspecs/$pkgname-$pkgver-1.rockspec"
}

package() {
	cd "$srcdir/$pkgname-$pkgver"
	install -Dm755 llthreads2.so "$pkgdir/usr/lib/lua/5.3/llthreads2.so"
	install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

Thanks for your time

@aryajur
Copy link
Owner

aryajur commented Oct 16, 2017

Thanks for pointing this out. I built the llthreads2 module manually to llthreads.dll. I will update the lua-plot code to require llthreads2. Before that can you please check if in your local lua-plot.lua file if you change llthreads to llthreads2 does it work then for you?

@fusion809
Copy link
Author

Ya your plotting example works perfectly now with that fix.

@fusion809
Copy link
Author

By-the-way is it possible to plot arrays against one another? I have solved an ordinary differential equation in Lua and I'd like to plot my y array against my x array. Is this possible?

@aryajur
Copy link
Owner

aryajur commented Oct 17, 2017

I have updated the code to look for llthreads2 as well. Please try it with the new code as well.

The AddSeries function in the plot object as described here: https://www.amved.com/milindsweb/lua_plot.html#L5

can be called in 2 ways:
plot:AddSeries(xvalues,yvalues[,AttributesTable])
or
plot:AddSeries(xyPoints[,AttributesTable])

The 1st way allows separate x value and y value arrays and the second method where you have a table of x,y points (this is how the example on the documentation page uses it).

Example of the 1st method for the same example will be:
p:AddSeries({1,2,3},{1,2,3})

If you are writing some code that may be helpful as a separate math package consider adding it to the LuaMath project here: https://github.com/aryajur/LuaMath

Here I am consolidating all math routines I make and use to make a generalized math package to be used with any Lua version directly. lua-plot is included as a submodule in there also it has complex number support.

@aryajur aryajur closed this as completed Oct 17, 2017
@fusion809
Copy link
Author

fusion809 commented Oct 17, 2017

I actually tried that syntax before I asked. It didn't work so I assumed I was using the wrong syntax. This is what I have to plot in my program:

lp = require("lua-plot")
p = lp.plot{}
p:AddSeries(t, theta)
p:Redraw()

The plot doesn't seem to start, I get GTK warnings at the command-line that suggest the plot is attempting to run but it doesn't launch as I can't see it. Here is exactly what I see at the command-line if you're wondering:

(lua:23005): Gtk-WARNING **: Theme parsing error: gtk.css:1036:92: Missing closing bracket at end of linear gradient

(lua:23005): Gtk-WARNING **: Theme parsing error: gtk.css:1036:94: Expected semicolon

(lua:23005): Gtk-WARNING **: Theme parsing error: gtk.css:1036:124: Expected semicolon

(lua:23005): Gtk-WARNING **: Theme parsing error: gtk.css:1147:50: Expected semicolon

(lua:23005): Gtk-WARNING **: Theme parsing error: gtk.css:3129:50: Expected semicolon

where t and theta are my coordinate arrays.

@aryajur
Copy link
Owner

aryajur commented Oct 17, 2017 via email

@fusion809
Copy link
Author

@aryajur
Copy link
Owner

aryajur commented Oct 17, 2017

So I looked at it. It seems that since the number of points were a million the plotting was having a problem. I added some code to basically sample 1 in every 10 points from the t and theta arrays and then it works. Also I committed an improvement to make the graph plotting of large data sets faster. Here is the updated code for your sample:

--Plot theta against t
local nt,ntheta = {},{}
for i = 1,1000000,10 do
	nt[#nt + 1] = t[i] 
	ntheta[#ntheta + 1] = theta[i]
end

lp = require("lua-plot")
p = lp.plot{}
p:AddSeries(nt, ntheta)
p:Show()

@aryajur
Copy link
Owner

aryajur commented Oct 18, 2017

I have redone the AddSeries function to allow very large data sets and now the million points also works. I will be committing it shortly.

@aryajur aryajur reopened this Oct 18, 2017
@fusion809
Copy link
Author

Ah for my program it still fails with the error:

6.6136225385094e-09

(lua:21267): Gtk-WARNING **: Theme parsing error: gtk.css:1036:92: Missing closing bracket at end of linear gradient

(lua:21267): Gtk-WARNING **: Theme parsing error: gtk.css:1036:94: Expected semicolon

(lua:21267): Gtk-WARNING **: Theme parsing error: gtk.css:1036:124: Expected semicolon

(lua:21267): Gtk-WARNING **: Theme parsing error: gtk.css:1147:50: Expected semicolon

(lua:21267): Gtk-WARNING **: Theme parsing error: gtk.css:3129:50: Expected semicolon
lua: simple-pendulum-array.lua:125: attempt to index a boolean value (global 'lp')
stack traceback:
        simple-pendulum-array.lua:125: in main chunk
        [C]: in ?

@aryajur
Copy link
Owner

aryajur commented Oct 18, 2017 via email

@fusion809
Copy link
Author

Sounds like a good idea, but unfortunately with 1e3 points it just gives:

3.0182151926628e-05

(lua:4719): Gtk-WARNING **: Theme parsing error: gtk.css:1036:92: Missing closing bracket at end of linear gradient

(lua:4719): Gtk-WARNING **: Theme parsing error: gtk.css:1036:94: Expected semicolon

(lua:4719): Gtk-WARNING **: Theme parsing error: gtk.css:1036:124: Expected semicolon

(lua:4719): Gtk-WARNING **: Theme parsing error: gtk.css:1147:50: Expected semicolon

(lua:4719): Gtk-WARNING **: Theme parsing error: gtk.css:3129:50: Expected semicolon

and exits. No graph, no nothing.

@aryajur
Copy link
Owner

aryajur commented Oct 18, 2017

I just committed the new version which is working for the million data points. You can try this. If this does not work can you try the plot using the following and see if this works:

require("iuplua")
require("iuplua_plot")

plot = iup.plot{
--    TITLE = "Plot Test",
    MARGINBOTTOM = 20,
}


plot:Begin(0)

for i = 1,1000000,1 do
    plot:Add(t[i], theta[i])
end

plot:End()

dlg = iup.dialog{
    TITLE = "Plot Test",
    SIZE = "400x200",
    plot,
}

dlg:showxy(iup.CENTER, iup.CENTER)

iup.MainLoop()

@fusion809
Copy link
Author

This issue is really persistent your fix I just pulled and it doesn't work (same output as before). I tried this snippet of code and it too didn't work, gave this output:

3.0182151926628e-05

(lua:6375): Gtk-WARNING **: Theme parsing error: gtk.css:1036:92: Missing closing bracket at end of linear gradient

(lua:6375): Gtk-WARNING **: Theme parsing error: gtk.css:1036:94: Expected semicolon

(lua:6375): Gtk-WARNING **: Theme parsing error: gtk.css:1036:124: Expected semicolon

(lua:6375): Gtk-WARNING **: Theme parsing error: gtk.css:1147:50: Expected semicolon

(lua:6375): Gtk-WARNING **: Theme parsing error: gtk.css:3129:50: Expected semicolon
lua: simple-pendulum-array.lua:140: bad argument #2 to 'Add' (number expected, got nil)
stack traceback:
        [C]: in function 'iuplua.PlotAdd'
        simple-pendulum-array.lua:140: in main chunk
        [C]: in ?

@aryajur
Copy link
Owner

aryajur commented Oct 18, 2017

Ok since the issue is still present when you run the plotting script I gave without using lua-plot it is not related to lua-plot but something to do with GTK.
You said you were able to plot the example which as points. How many points can you plot in your system. 1000 does not work and 3 works, does 100 work?
I will post tjis issue to the IUP library list since it seems to be an issue from there.

If you can run this script and increase COUNT by 10 every time and see when it fails would be helpful. Also the error messages if they are different from above:

require("iuplua")
require("iuplua_plot")

plot = iup.plot{
--    TITLE = "Plot Test",
    MARGINBOTTOM = 20,
}

COUNT = 10
plot:Begin(0)

for i = 1,COUNT do
    plot:Add(i, 2*i)
end

plot:End()

dlg = iup.dialog{
    TITLE = "Plot Test",
    SIZE = "400x200",
    plot,
}

dlg:showxy(iup.CENTER, iup.CENTER)

iup.MainLoop()

@fusion809
Copy link
Author

fusion809 commented Oct 18, 2017

I've managed to plot using Lua plot with your example at https://www.amved.com/milindsweb/lua_plot.html#L9. With N=100 it also does not work. Plotting in other programs (e.g. GNU Octave) with large number of steps works fine and my PC has pretty good specs 8 x 2394 MHz CPU cores and 16 GB RAM. Dual NVIDIA and Intel graphics cards. So I doubt it's my hardware.

@fusion809
Copy link
Author

fusion809 commented Oct 18, 2017

The GNU Octave program I ran to see whether plotting works in it is:

clear all
t=linspace(0,350,100001); 
lsode_options("relative tolerance", 1e-15);
y = lsode("lorenz",[ 1.0; 1.0; 1.0]',t);

figure(1)

subplot(221)
plot(y(:,1),y(:,2),'-');
xlabel('x(t)','FontSize',16);
ylabel('y(t)','FontSize',16);

subplot(222)
plot(y(:,1),y(:,3),'-');
xlabel('x(t)','FontSize',16);
ylabel('z(t)','FontSize',16);

subplot(223)
plot(y(:,2),y(:,3),'-');
xlabel('y(t)','FontSize',16);
ylabel('z(t)','FontSize',16);

where lorenz is defined as:

function dy = lorenz(y,t)
dy = zeros(3,1);
P = 10;
r = 28;
b = 8/3;
dy(1) = P*(y(2) - y(1));
dy(2) = -y(1)*y(3) + r*y(1) - y(2);
dy(3) = y(1)*y(2) - b*y(3);

if you're wondering if I tested it thoroughly.

@aryajur
Copy link
Owner

aryajur commented Oct 18, 2017

I don't think it is a hardware issue at your end but something with the IUP library. So I wanted to see the result of the script (lets say for COUNT 10, 50 and 100) and see when it fails:

require("iuplua")
require("iuplua_plot")

plot = iup.plot{
--    TITLE = "Plot Test",
    MARGINBOTTOM = 20,
}

COUNT = 10
plot:Begin(0)

for i = 1,COUNT do
    plot:Add(i, 2*i)
end

plot:End()

dlg = iup.dialog{
    TITLE = "Plot Test",
    SIZE = "400x200",
    plot,
}

dlg:showxy(iup.CENTER, iup.CENTER)

iup.MainLoop()

@fusion809
Copy link
Author

Past tense makes me wonder if you're saying you've done this or you want me to do this?

@aryajur
Copy link
Owner

aryajur commented Oct 18, 2017

Sorry I want you to run this on your system and let me know for which COUNT magnitude it fails so I have better information to add to the issue on the IUP mailing list. I have already posted this error on the mailing list.
Another question is did you compile the IUP library from source or did you get the binaries?

@fusion809
Copy link
Author

Compiled it from source using the Arch User Repository (AUR) — https://aur.archlinux.org/packages/iup and https://aur.archlinux.org/packages/lua-iup. Your test works fine. No output at the command-line besides GTK warnings.

@aryajur
Copy link
Owner

aryajur commented Oct 18, 2017

Thanks for this info. Also when you say the test works fine does that mean the graph shows up even for COUNT = 100? If yes does it show up for COUNT=1000

@fusion809
Copy link
Author

COUNT=10 is what I used for COUNT=100 and 1000 it works fine though.

@fusion809
Copy link
Author

Oh and COUNT=1e6 works fine too.

@aryajur
Copy link
Owner

aryajur commented Oct 18, 2017

Ok that is strange it works for all those points in the sample script. So now if you use this in pendulum does it work:

require("iuplua")
require("iuplua_plot")

plot = iup.plot{
--    TITLE = "Plot Test",
    MARGINBOTTOM = 20,
}


plot:Begin(0)

for i = 1,1000 do
    plot:Add(t[i], theta[i])
end

plot:End()

dlg = iup.dialog{
    TITLE = "Plot Test",
    SIZE = "400x200",
    plot,
}

dlg:showxy(iup.CENTER, iup.CENTER)

iup.MainLoop()

@fusion809
Copy link
Author

Works fine. Thanks.

@aryajur
Copy link
Owner

aryajur commented Oct 18, 2017

Ok, so what if you plot the entire thing using this sample script, does this work:

require("iuplua")
require("iuplua_plot")

plot = iup.plot{
--    TITLE = "Plot Test",
    MARGINBOTTOM = 20,
}


plot:Begin(0)

for i = 1,#t do
    plot:Add(t[i], theta[i])
end

plot:End()

dlg = iup.dialog{
    TITLE = "Plot Test",
    SIZE = "400x200",
    plot,
}

dlg:showxy(iup.CENTER, iup.CENTER)

iup.MainLoop()

@fusion809
Copy link
Author

Works fine, although the graph is very large given the fact SIZE is set at 400x200.

@aryajur
Copy link
Owner

aryajur commented Oct 18, 2017

oh ok, you can adjust the size. So now can you try the lua-plot way of plotting the same. Does this work:

--Plot theta against t
local nt,ntheta = {},{}
for i = 1,1000 do
	nt[#nt + 1] = t[i] 
	ntheta[#ntheta + 1] = theta[i]
end

lp = require("lua-plot")
p = lp.plot{}
p:AddSeries(nt, ntheta)
p:Show()

@fusion809
Copy link
Author

fusion809 commented Oct 18, 2017

That was interesting... A window popped up for a few milliseconds (so few that it disappeared before I could make anything out) then closed and the program exited.

@aryajur
Copy link
Owner

aryajur commented Oct 18, 2017

oh ok, can you try this then, I added io.read() in the end so that it waits for you to press enter before exiting the program:

--Plot theta against t
local nt,ntheta = {},{}
for i = 1,1000 do
	nt[#nt + 1] = t[i] 
	ntheta[#ntheta + 1] = theta[i]
end

lp = require("lua-plot")
p = lp.plot{}
p:AddSeries(nt, ntheta)
p:Show()
io.read()

@fusion809
Copy link
Author

fusion809 commented Oct 18, 2017

Worked although the data on the y axis was cut off

screenshot_20171018_175107

It doesn't look like it should though. As it's meant to be a wave like shape.

@aryajur
Copy link
Owner

aryajur commented Oct 18, 2017

We just plotted 1000 points so I believe that was all there was. So now since this works can we try the full data now:

--Plot theta against t
lp = require("lua-plot")
p = lp.plot{}
p:AddSeries(t, theta)
p:Show()
io.read()

@fusion809
Copy link
Author

There it goes, it's now working fine and dandy.

@aryajur
Copy link
Owner

aryajur commented Oct 18, 2017

Great! I will close the issue now. Thank you for working with me on this!

@aryajur aryajur closed this as completed Oct 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants