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

Add toExternalString(MutableMatrix) #3362

Merged

Conversation

d-torrance
Copy link
Member

Before

i1 : toExternalString mutableMatrix {{1, 2}, {3, 4}}
stdio:1:1:(3): error: can't convert local symbol or invisible global symbol 'RawMutableMatrix' to external string
null: here is the first use of 'RawMutableMatrix'

After

i1 : toExternalString mutableMatrix {{1, 2}, {3, 4}}

o1 = mutableMatrix(map(ZZ^2,ZZ^2,{{1, 2}, {3, 4}}))

The error message was essentially the same for mutable lists and
mutable hash tables, so we combine them.  We also drop
toExternalString(Type), since Type is a subclass of MutableHashTable,
and we can just use inheritance.
We just use the same method as we use for mutable lists and hash
tables.
@d-torrance d-torrance force-pushed the to-external-string-mutable-matrix branch from e5595a1 to e82f71d Compare August 6, 2024 19:03
@d-torrance d-torrance changed the title Add describe(MutableMatrix) and toExternalString(MutableMatrix) Add toExternalString(MutableMatrix) Aug 6, 2024
@d-torrance
Copy link
Member Author

I've re-written this so that toExternalString for mutable hash tables, lists, and matrices all call the same function that uses synonym in the error message.

Before

i1 : toExternalString new SelfInitializingType of HashTable
stdio:1:1:(3): error: anonymous type cannot be converted to external string

i2 : toExternalString mutableMatrix {{0}}
stdio:2:1:(3): error: can't convert local symbol or invisible global symbol 'RawMutableMatrix' to external string
null: here is the first use of 'RawMutableMatrix'

After

i1 : toExternalString new SelfInitializingType of HashTable
stdio:1:1:(3): error: anonymous self initializing type cannot be converted to external string

i2 : toExternalString mutableMatrix {{0}}
stdio:2:1:(3): error: anonymous mutable matrix cannot be converted to external string

@mahrud
Copy link
Member

mahrud commented Aug 6, 2024

Looks good. Mind if I send in a couple of commits, clearing up unnecessary toExternalString methods for different types of rings?

@d-torrance
Copy link
Member Author

Go for it!

@mahrud
Copy link
Member

mahrud commented Aug 7, 2024

Now we have:

i1 : select(methods toExternalString, m -> ancestor(MutableHashTable, m#1))

o1 = {0 => (toExternalString, Monoid)          }
     {1 => (toExternalString, MutableHashTable)}
     {2 => (toExternalString, Ring)            }
     {3 => (toExternalString, Variety)         }

But among these, the mutable hash table one is just an error:

i3 : code o1#1

o3 = -- code for method: toExternalString(MutableHashTable)
     ../../Macaulay2/m2/nets.m2:73:39-76:43: --source code:
     toExternalString MutableList      := s -> (
         if hasAttribute(s,ReverseDictionary)
         then toString getAttribute(s,ReverseDictionary)
         else error("anonymous ", synonym class s,

And the other three are convenient exceptions because you can make a matrix, list, or hash table immutable, but you can't turn a monoid, ring, or variety immutable.

Tangentially:

  1. typing code 1 above gives the code for (toExternalString, BasicList), because select didn't update the cached methods list. Maybe we should have the after print of NumberedVerticalList automatically update a unified variable "lastlist", which can be used by all help, code, etc?
  2. the last line of (toExternalString, MutableList) is dropped for some reason.

Copy link
Member

@mahrud mahrud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with this. If the changes I added are okay, feel free to merge!

@d-torrance d-torrance merged commit 6fa451f into Macaulay2:development Aug 7, 2024
5 checks passed
@mahrud
Copy link
Member

mahrud commented Aug 8, 2024

Related: have you seen #1026?

@d-torrance d-torrance deleted the to-external-string-mutable-matrix branch September 3, 2024 13:03
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

Successfully merging this pull request may close these issues.

2 participants