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

load-matrix throws error (NumberFormatException) #69

Closed
maruscia opened this issue Jan 27, 2013 · 4 comments
Closed

load-matrix throws error (NumberFormatException) #69

maruscia opened this issue Jan 27, 2013 · 4 comments
Labels
Milestone

Comments

@maruscia
Copy link

While loading any adjacency matrix file (generated with nw's save-matrix)

Trace:
error (NumberFormatException)
while observer running NW:LOAD-MATRIX
called by procedure SAVE-TOPOLOGY
called by Button 'save-topology'

java.lang.NumberFormatException: For input string: "0,00"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1222)
at java.lang.Double.parseDouble(Double.java:510)
at edu.uci.ics.jung.io.MatrixFile.createMatrixFromFile(MatrixFile.java:117)
at edu.uci.ics.jung.io.MatrixFile.load(MatrixFile.java:98)
at edu.uci.ics.jung.io.MatrixFile.load(MatrixFile.java:148)
at org.nlogo.extensions.nw.jung.Matrix$.load(IO.scala:30)
at org.nlogo.extensions.nw.jung.Primitives$LoadMatrix$.createTurtles(Primitives.scala:278)
at org.nlogo.extensions.nw.jung.Primitives$LoadMatrix$.createTurtles(Primitives.scala:275)
at org.nlogo.extensions.nw.NetworkExtensionUtil$turtleCreatingCommand$class.perform(NetworkExtensionUtil.scala:99)
at org.nlogo.extensions.nw.jung.Primitives$LoadMatrix$.perform(Primitives.scala:275)
at org.nlogo.prim._extern.perform(_extern.java:54)
at org.nlogo.nvm.Context.stepConcurrent(Context.java:91)
at org.nlogo.nvm.ConcurrentJob.step(ConcurrentJob.java:82)
at org.nlogo.job.JobThread.org$nlogo$job$JobThread$$runPrimaryJobs(JobThread.scala:143)
at org.nlogo.job.JobThread$$anonfun$run$1.apply$mcV$sp(JobThread.scala:78)
at org.nlogo.job.JobThread$$anonfun$run$1.apply(JobThread.scala:76)
at org.nlogo.job.JobThread$$anonfun$run$1.apply(JobThread.scala:76)
at scala.util.control.Exception$Catch.apply(Exception.scala:88)
at org.nlogo.util.Exceptions$.handling(Exceptions.scala:41)
at org.nlogo.job.JobThread.run(JobThread.scala:75)

@maruscia
Copy link
Author

FIXED by s/,/./ all commas in generated file 👎

@nicolaspayette
Copy link
Member

Thank you for reporting this issue.

I suspect this is related to the OS's regional settings: I assume you are using a regional number format that has a comma instead of a dot as the decimal separator?

My hypothesis is that Jung (the graph library that much of the nw extension is based on) applies the regional setting when producing the file... but not when loading it. If that is the case, it is indeed a bug: it should either respect it both ways, or force the use of a dot when saving.

I'll see if I can coax Jung into the right behavior. If not, we might have to roll our own matrix load/save operations, which may not be that big of a deal.

In the meanwhile, maybe you can try changing your regional settings to see if it fixes the problem? (I'd actually like to have the confirmation that those are, indeed, the culprits.)

@maruscia
Copy link
Author

I tried changing my regional settings, it didn't fix the problem.

@nicolaspayette
Copy link
Member

@maruscia, it seems like, somehow, your JVM did not pick up the change. I don't know what OS you're on, but sometimes, you need to reboot for that kind of changes to take effect.

In any case, the bug will be fixed in the next release of the extension.

In the meanwhile, you can continue swapping commas for dots like you did before, or force NetLogo to use the US locale by starting it (from the folder where it is installed) with:

java -Duser.language=us -Djava.library.path=./lib -Djava.ext.dirs= -XX:MaxPermSize=128m -Xmx1024m -Dfile.encoding=UTF-8 -jar NetLogo.jar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants