You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Errors when working over non-prime finite fields #88
The following gives an error in both 10.7 and 10,8 (only on this Sage distribution):
C = codes.random_linear_code(GF(9), 10, 5)
C.minimum_distance()
NotImplementedError: conversion of (Givaro) finite field element to GAP not implemented except for fields defined by Conway polynomials.
Moreover, I had some complicated code that was giving me a different output on MacOS and Linux (Windows with WSL). I'm quite confident the correct result is the one I obtain on Linux. The computations basically involved computing linear codes and their duals, over non-prime finite fields. I wasn't able to pin-point the exact thing that fails, but the previous issue makes me wonder if there is some issue between Sage and GAP.
Thank you for the report, Rodrigo. There have certainly been some issues with Sage's
GAP interface. What we are doing here is to package each version of Sage, as it is
released, for macOS. So if you are seeing differences between different versions of Sage then you should probably report a bug at sage-support.
Can you please provide some more information about which versions of Sage you
are using on these different platforms, and some specifics about the platforms?
On Windows 11 I'm using Arch-Linux (up to date) with WSL, and SageMath 10.7 from their repositories (via pacman). On MacOS (15.6.1, with M4 processor), I tried the image from this project for both 10.7 and 10.8. The error above shows up in both.
The code that gives me a different output is the following:
CT is the dual code of C, so it should be the orthogonal space (a linear code is basically a vector space). With MacOS, this gives that v is not in CT, however it says the second print is True, meaning v is orthogonal to every row of G, so it should be in the dual code. Moreover, if we try to check whether the rows of the generator matrix of the dual (matrix whose rows are a basis for the dual), we get False for some of them.
In contrast, in other distributions (even in Sagecell, for example), you should get the same for the first two statements, and you should get certainly True for the last print. (The first two depend on the choice of polynomial for the extension from F3 to F9. In fact, this MacOS distribution is using a different polynomial than the rest. Maybe this is causing this problem, if some other parts of Sage expect the finite field to be constructed in a certain way).
Since I'm not sure whether this is related to this package, or in general to Sage, I didn't post it in their GitHub. If you think this would belong there, please let me know.
The NonImplementedError would seem to be the place to start. I should be able to find where in the Sage code that is being generated. Of course, it is not exactly an error. But it probably means that some third party code is missing from our package. Both givaro and GAP are included, but maybe something else is missing, or is older than the version used in the arch package.
If something is missing from our package it is not a Sage bug. However it is possible that someone who reads sage-support will know where that error comes from. So posting it there might produce some useful information.
@RodrigoSanJose : My apologies for letting this issue languish for so long. While I am no closer to resolving it, I can answer your question of whether this is a Sage issue which should be reported on sage-support.
The answer is Yes.
I realized that I had a way of getting some information about the origin of the problem because, as part of building the app, I also build sage itself from source. So I checked what happens when I execute your example commands in the sage build directory. (I copy parts of that directory into the app, but do not change anything in it.) I did this check for Sage 10.8. I found that the local build and the app produce the same results (as one would expect). The NotImplemented exception is raised in both cases. I also ran your other code. This produced the same answer for the app as for the local build of Sage. But the answer was different from the one produced by Sage 10.7. All three of the Boolean results were False with 10.8 whereas the results were False, True, False with 10.7. Since the first two are logically equivalent, this means that 10.8 is no longer producing the logically impossible result that 10.7 produced. But the answer is still wrong, since the third Boolean value should be True.
Of course there is no such thing as a standard build of Sage, since the Sage build system attempts to use libraries which are installed on the system, and hence will not be guaranteed to be the same on two different systems, even if they have the same hardware and OS version. Nonetheless, I think this can be classified as a Sage problem, not a defect of the Sage_macOS app, and so it should be reported on sage-support. The chances of finding someone there who is familiar with (or maybe the author of) the linear code module is pretty good, I think.
@culler No worries. I actually posted a question on sage-support, but I did not receive any answer.
As you mention, versions 10.5 and 10.6 of the app seem to work fine. While the examples I gave use linear codes, that is just because it is the area I work on. But I think the problem is related to how finite fields are handled. For example, if I remember correctly, the polynomial used to construct F9 with version 10.8 of the app was different from the one used in versions 10.5 and 10.6 (I cannot check at the moment because I downgraded to 10.6). This may cause the problem with the minimum distance, since GAP may expect a Conway polynomial (looking at the error message).
Following your hint, I think I can now explain what you are seeing.
Sage includes a database of Conway polynomials for finite fields. When I attempted to look up a Conway polynomial in the data base using the Sage_macOS 10.8 app I got an error saying that the module _lzma could not be found. Indeed, I discovered that _lzma is missing from both 10.7 and 10.8. But it is a dependency of the conway_polynomials package. The finite fields code apparently needs the conway_polynomials package to create GAP finite fields, but when a call to lookup a conway polynomial fails it does not produce a helpful exception saying that the lookup failed. Instead it produces a long and incomprehensible traceback suggesting some other issue but, luckily as you discovered, the incomprehensible traceback does provide a small hint that Conway polynomials are involved.
The _lzma package is not a Sage package, it is part of the python standard library. The major change I made from 10.6 to 10.7 was to adapt my build system so that it would not depend on Sage's python3 spkg, because certain Sage developers were insistent that the python3 spkg had to be removed even though it worked fine. So I now build my own python3 as part of the app build. I don't know why my python3 build is not creating _lzma, nor why I did not notice that. But I should be able to build it easily enough and add it to the 10.8 app. It might take me a few days, though, given the time of year.
@RodrigoSanJose I think I have now resolved this issue. I have posted a pre-release of a new version (2.8.2)of SageMath 10.8 which (for me) can execute all of your example code without errors and with the expected results.
Can you please test the pre-release and confirm whether v2.8.2 fixes this issue for you? Thank you.
There were multiple technical causes, none of which were directly implicated by any of the error messages. The main ones were the missing python lzma module, which caused the conway polynomial package to fail, and an invalid setting for sage.env.MTXLIB which caused meataxe not to be able to find its tables. The latter turned out to be dependent on config data generated when building python.
Reacted by Rodrigo San-José and Guillermo Moreno-Socías
Activity
culler commentedon Oct 28, 2025
Thank you for the report, Rodrigo. There have certainly been some issues with Sage's
GAP interface. What we are doing here is to package each version of Sage, as it is
released, for macOS. So if you are seeing differences between different versions of Sage then you should probably report a bug at sage-support.
Can you please provide some more information about which versions of Sage you
are using on these different platforms, and some specifics about the platforms?
RodrigoSanJose commentedon Oct 28, 2025
On Windows 11 I'm using Arch-Linux (up to date) with WSL, and SageMath 10.7 from their repositories (via pacman). On MacOS (15.6.1, with M4 processor), I tried the image from this project for both 10.7 and 10.8. The error above shows up in both.
The code that gives me a different output is the following:
CT is the dual code of C, so it should be the orthogonal space (a linear code is basically a vector space). With MacOS, this gives that v is not in CT, however it says the second print is True, meaning v is orthogonal to every row of G, so it should be in the dual code. Moreover, if we try to check whether the rows of the generator matrix of the dual (matrix whose rows are a basis for the dual), we get False for some of them.
In contrast, in other distributions (even in Sagecell, for example), you should get the same for the first two statements, and you should get certainly True for the last print. (The first two depend on the choice of polynomial for the extension from F3 to F9. In fact, this MacOS distribution is using a different polynomial than the rest. Maybe this is causing this problem, if some other parts of Sage expect the finite field to be constructed in a certain way).
Since I'm not sure whether this is related to this package, or in general to Sage, I didn't post it in their GitHub. If you think this would belong there, please let me know.
culler commentedon Oct 28, 2025
Thanks!
The NonImplementedError would seem to be the place to start. I should be able to find where in the Sage code that is being generated. Of course, it is not exactly an error. But it probably means that some third party code is missing from our package. Both givaro and GAP are included, but maybe something else is missing, or is older than the version used in the arch package.
If something is missing from our package it is not a Sage bug. However it is possible that someone who reads sage-support will know where that error comes from. So posting it there might produce some useful information.
NathanDunfield commentedon Oct 29, 2025
This error is new for the Sage 10.7 version of our macOS app. For 10.5 and 10.6:
does not raise an exception.
culler commentedon Dec 23, 2025
@RodrigoSanJose : My apologies for letting this issue languish for so long. While I am no closer to resolving it, I can answer your question of whether this is a Sage issue which should be reported on sage-support.
The answer is Yes.
I realized that I had a way of getting some information about the origin of the problem because, as part of building the app, I also build sage itself from source. So I checked what happens when I execute your example commands in the sage build directory. (I copy parts of that directory into the app, but do not change anything in it.) I did this check for Sage 10.8. I found that the local build and the app produce the same results (as one would expect). The NotImplemented exception is raised in both cases. I also ran your other code. This produced the same answer for the app as for the local build of Sage. But the answer was different from the one produced by Sage 10.7. All three of the Boolean results were False with 10.8 whereas the results were False, True, False with 10.7. Since the first two are logically equivalent, this means that 10.8 is no longer producing the logically impossible result that 10.7 produced. But the answer is still wrong, since the third Boolean value should be True.
Of course there is no such thing as a standard build of Sage, since the Sage build system attempts to use libraries which are installed on the system, and hence will not be guaranteed to be the same on two different systems, even if they have the same hardware and OS version. Nonetheless, I think this can be classified as a Sage problem, not a defect of the Sage_macOS app, and so it should be reported on sage-support. The chances of finding someone there who is familiar with (or maybe the author of) the linear code module is pretty good, I think.
culler commentedon Dec 23, 2025
I also checked the output of your test commands with the Sage 10.5 and 10.6 versions of the app. The results for both versions were:
RodrigoSanJose commentedon Dec 24, 2025
@culler No worries. I actually posted a question on sage-support, but I did not receive any answer.
As you mention, versions 10.5 and 10.6 of the app seem to work fine. While the examples I gave use linear codes, that is just because it is the area I work on. But I think the problem is related to how finite fields are handled. For example, if I remember correctly, the polynomial used to construct F9 with version 10.8 of the app was different from the one used in versions 10.5 and 10.6 (I cannot check at the moment because I downgraded to 10.6). This may cause the problem with the minimum distance, since GAP may expect a Conway polynomial (looking at the error message).
culler commentedon Dec 24, 2025
Following your hint, I think I can now explain what you are seeing.
Sage includes a database of Conway polynomials for finite fields. When I attempted to look up a Conway polynomial in the data base using the Sage_macOS 10.8 app I got an error saying that the module _lzma could not be found. Indeed, I discovered that _lzma is missing from both 10.7 and 10.8. But it is a dependency of the conway_polynomials package. The finite fields code apparently needs the conway_polynomials package to create GAP finite fields, but when a call to lookup a conway polynomial fails it does not produce a helpful exception saying that the lookup failed. Instead it produces a long and incomprehensible traceback suggesting some other issue but, luckily as you discovered, the incomprehensible traceback does provide a small hint that Conway polynomials are involved.
The _lzma package is not a Sage package, it is part of the python standard library. The major change I made from 10.6 to 10.7 was to adapt my build system so that it would not depend on Sage's python3 spkg, because certain Sage developers were insistent that the python3 spkg had to be removed even though it worked fine. So I now build my own python3 as part of the app build. I don't know why my python3 build is not creating _lzma, nor why I did not notice that. But I should be able to build it easily enough and add it to the 10.8 app. It might take me a few days, though, given the time of year.
culler commentedon Dec 27, 2025
@RodrigoSanJose I think I have now resolved this issue. I have posted a pre-release of a new version (2.8.2)of SageMath 10.8 which (for me) can execute all of your example code without errors and with the expected results.
Can you please test the pre-release and confirm whether v2.8.2 fixes this issue for you? Thank you.
RodrigoSanJose commentedon Dec 27, 2025
@culler Everything seems to be working as it should now. Thanks so much for the fix!
culler commentedon Dec 27, 2025
Thanks for testing!
There were multiple technical causes, none of which were directly implicated by any of the error messages. The main ones were the missing python lzma module, which caused the conway polynomial package to fail, and an invalid setting for sage.env.MTXLIB which caused meataxe not to be able to find its tables. The latter turned out to be dependent on config data generated when building python.