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

FileNames is not deterministic #1250

Closed
vsht opened this issue Apr 10, 2021 · 1 comment · Fixed by #1254
Closed

FileNames is not deterministic #1250

vsht opened this issue Apr 10, 2021 · 1 comment · Fixed by #1254

Comments

@vsht
Copy link

vsht commented Apr 10, 2021

Another problem I noticed is that FileNames is not deterministic. This sort of complicates the debugging
since every time FeynCalc files from the given directory are loaded in a different ordering. For example
TestDir.zip

In[1]:= FileNames[{"*.m"}, "TestDir"]
Out[1]= {TestDir/FCMatchSolve.m, TestDir/SharedObjects.m, TestDir/FCCompareResults.m, TestDir/FCReorderList.m, TestDir/Sum.m, TestDir/LegacyObjects.m, TestDir/Series3.m, TestDir/Factor.m, TestDir/FCBlockMatrix.m, TestDir/SharedObjectsTypesetting.m, TestDir/FeynCalcExternal.m, TestDir/Collect.m, TestDir/Explicit.m, TestDir/TimedIntegrate.m, TestDir/CacheManagement.m, TestDir/SharedOptions.m, TestDir/Isolate.m, TestDir/SharedTools.m, TestDir/FCCheckSyntax.m, TestDir/Series2.m, TestDir/FeynCalcForm.m, TestDir/Solve.m, TestDir/DataType.m, TestDir/FeynCalcInternal.m}

In[2]:= 

Goodbye!

╭─ ~/Downloads                                                                                             ✔  6s  19.83G RAM  15:07:48 
╰─ mathicsscript
'/home/vs/.local/lib/python3.8/site-packages/mathicsscript/settings.m' was not found.

Mathicscript: 2.0.1, Mathics 2.1.1.dev0
on CPython 3.8.8 (default, Feb 20 2021, 00:00:00) 
using SymPy 1.7.1, mpmath 1.2.1, numpy 1.18.4, cython 0.29.14

Copyright (C) 2011-2021 The Mathics Team.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions.
See the documentation for the full license.

Quit by pressing CONTROL-D

In[1]:= FileNames[{"*.m"}, "TestDir"]
Out[1]= {TestDir/Solve.m, TestDir/Collect.m, TestDir/SharedTools.m, TestDir/FCBlockMatrix.m, TestDir/FCMatchSolve.m, TestDir/SharedObjectsTypesetting.m, TestDir/FeynCalcExternal.m, TestDir/SharedObjects.m, TestDir/Series3.m, TestDir/Sum.m, TestDir/LegacyObjects.m, TestDir/CacheManagement.m, TestDir/FCCompareResults.m, TestDir/Series2.m, TestDir/DataType.m, TestDir/FCCheckSyntax.m, TestDir/Explicit.m, TestDir/FeynCalcInternal.m, TestDir/SharedOptions.m, TestDir/FeynCalcForm.m, TestDir/TimedIntegrate.m, TestDir/Factor.m, TestDir/Isolate.m, TestDir/FCReorderList.m}

In[2]:= 

Goodbye!

You see that in the first session FCMatchSolve.m was the first file, while in the second session it was Solve.m
On the contrary, Mma always returns the same ordering

╰─ math         
Mathematica 12.1.1 Kernel for Linux x86 (64-bit)
Copyright 1988-2020 Wolfram Research, Inc.

FrontEndObject::notavail: 
   A front end is not available; certain operations require a front end.

In[1]:= FileNames[{"*.m"}, "TestDir"]                                                                                                        

Out[1]= {TestDir/CacheManagement.m, TestDir/Collect.m, TestDir/DataType.m, TestDir/Explicit.m, TestDir/Factor.m, TestDir/FCBlockMatrix.m, 
 
>    TestDir/FCCheckSyntax.m, TestDir/FCCompareResults.m, TestDir/FCMatchSolve.m, TestDir/FCReorderList.m, TestDir/FeynCalcExternal.m, 
 
>    TestDir/FeynCalcForm.m, TestDir/FeynCalcInternal.m, TestDir/Isolate.m, TestDir/LegacyObjects.m, TestDir/Series2.m, TestDir/Series3.m, 
 
>    TestDir/SharedObjects.m, TestDir/SharedObjectsTypesetting.m, TestDir/SharedOptions.m, TestDir/SharedTools.m, TestDir/Solve.m, 
 
>    TestDir/Sum.m, TestDir/TimedIntegrate.m}

In[2]:=                                                                                                                                      
╭─ ~/Downloads                                                                                                ✔  9s  20G RAM  15:09:37 
╰─ math
Mathematica 12.1.1 Kernel for Linux x86 (64-bit)
Copyright 1988-2020 Wolfram Research, Inc.

FrontEndObject::notavail: 
   A front end is not available; certain operations require a front end.

In[1]:= FileNames[{"*.m"}, "TestDir"]                                                                                                        

Out[1]= {TestDir/CacheManagement.m, TestDir/Collect.m, TestDir/DataType.m, TestDir/Explicit.m, TestDir/Factor.m, TestDir/FCBlockMatrix.m, 
 
>    TestDir/FCCheckSyntax.m, TestDir/FCCompareResults.m, TestDir/FCMatchSolve.m, TestDir/FCReorderList.m, TestDir/FeynCalcExternal.m, 
 
>    TestDir/FeynCalcForm.m, TestDir/FeynCalcInternal.m, TestDir/Isolate.m, TestDir/LegacyObjects.m, TestDir/Series2.m, TestDir/Series3.m, 
 
>    TestDir/SharedObjects.m, TestDir/SharedObjectsTypesetting.m, TestDir/SharedOptions.m, TestDir/SharedTools.m, TestDir/Solve.m, 
 
>    TestDir/Sum.m, TestDir/TimedIntegrate.m}

In[2]:=        

Should I also create a separate issue for that, or is this something easy to fix? I guess that already applying a Sort to the output
would make the output deterministic.

This issue is relevant for #1174

@rocky
Copy link
Member

rocky commented Apr 10, 2021

@vsht Thanks for the report. This is probably easy to fix, but at least for me there is this huge backlog of stuff to get to already.

Perhaps this is something you could put a PR in for? If so, somewhere in https://github.com/mathics/Mathics/blob/master/mathics/builtin/files.py#L5129-L5181 would be where I imagine the change would be.

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

Successfully merging a pull request may close this issue.

2 participants