Skip to content

Commit

Permalink
[FTheoryTools] Serialize resolutions
Browse files Browse the repository at this point in the history
  • Loading branch information
HereAround committed Oct 18, 2024
1 parent 3fdbdf0 commit 30582f4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ function save_object(s::SerializerState, h::HypersurfaceModel)
attrs_dict[key] = value
end
end
if has_resolutions(h)
res = resolutions(h)
resolution_loci = [k[1] for k in res]
exceptional_divisors = [k[2] for k in res]
attrs_dict[:resolution_loci] = resolution_loci
attrs_dict[:exceptional_divisors] = exceptional_divisors

Check warning on line 64 in experimental/FTheoryTools/src/Serialization/hypersurface_models.jl

View check run for this annotation

Codecov / codecov/patch

experimental/FTheoryTools/src/Serialization/hypersurface_models.jl#L60-L64

Added lines #L60 - L64 were not covered by tests
end
!isempty(attrs_dict) && save_typed_object(s, attrs_dict, :__attrs)
end
end
Expand All @@ -75,7 +82,15 @@ function load_object(s::DeserializerState, ::Type{<:HypersurfaceModel}, params::
model.defining_classes = defining_classes
attrs_data = haskey(s, :__attrs) ? load_typed_object(s, :__attrs) : Dict{Symbol, Any}()
for (key, value) in attrs_data
set_attribute!(model, Symbol(key), value)
if (key != :resolution_loci) && (key != :exceptional_divisors)
set_attribute!(model, Symbol(key), value)
end
end
if haskey(attrs_data, :resolution_loci)
resolution_loci = attrs_data[:resolution_loci]
exceptional_divisors = attrs_data[:exceptional_divisors]
@req length(exceptional_divisors) == length(exceptional_divisors) "Inconsistency upon loading resolutions"
set_attribute!(model, :resolutions, [[resolution_loci[i], exceptional_divisors[i]] for i in 1:length(resolution_loci)])

Check warning on line 93 in experimental/FTheoryTools/src/Serialization/hypersurface_models.jl

View check run for this annotation

Codecov / codecov/patch

experimental/FTheoryTools/src/Serialization/hypersurface_models.jl#L90-L93

Added lines #L90 - L93 were not covered by tests
end
@req cox_ring(ambient_space(model)) == parent(hypersurface_equation(model)) "Hypersurface polynomial not in Cox ring of toric ambient space"
return model
Expand Down
17 changes: 16 additions & 1 deletion experimental/FTheoryTools/src/Serialization/tate_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ function save_object(s::SerializerState, gtm::GlobalTateModel)
attrs_dict[key] = value
end
end
if has_resolutions(gtm)
res = resolutions(gtm)
resolution_loci = [k[1] for k in res]
exceptional_divisors = [k[2] for k in res]
attrs_dict[:resolution_loci] = resolution_loci
attrs_dict[:exceptional_divisors] = exceptional_divisors
end
!isempty(attrs_dict) && save_typed_object(s, attrs_dict, :__attrs)
end
end
Expand All @@ -76,7 +83,15 @@ function load_object(s::DeserializerState, ::Type{<: GlobalTateModel}, params::T
model.defining_classes = defining_classes
attrs_data = haskey(s, :__attrs) ? load_typed_object(s, :__attrs) : Dict{Symbol, Any}()
for (key, value) in attrs_data
set_attribute!(model, Symbol(key), value)
if (key != :resolution_loci) && (key != :exceptional_divisors)
set_attribute!(model, Symbol(key), value)
end
end
if haskey(attrs_data, :resolution_loci)
resolution_loci = attrs_data[:resolution_loci]
exceptional_divisors = attrs_data[:exceptional_divisors]
@req length(exceptional_divisors) == length(exceptional_divisors) "Inconsistency upon loading resolutions"
set_attribute!(model, :resolutions, [[resolution_loci[i], exceptional_divisors[i]] for i in 1:length(resolution_loci)])
end
@req cox_ring(ambient_space(model)) == parent(tate_polynomial(model)) "Tate polynomial not in Cox ring of toric ambient space"
return model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ function save_object(s::SerializerState, w::WeierstrassModel)
attrs_dict[key] = value
end
end
if has_resolutions(w)
res = resolutions(w)
resolution_loci = [k[1] for k in res]
exceptional_divisors = [k[2] for k in res]
attrs_dict[:resolution_loci] = resolution_loci
attrs_dict[:exceptional_divisors] = exceptional_divisors

Check warning on line 65 in experimental/FTheoryTools/src/Serialization/weierstrass_models.jl

View check run for this annotation

Codecov / codecov/patch

experimental/FTheoryTools/src/Serialization/weierstrass_models.jl#L61-L65

Added lines #L61 - L65 were not covered by tests
end
!isempty(attrs_dict) && save_typed_object(s, attrs_dict, :__attrs)
end
end
Expand All @@ -76,7 +83,15 @@ function load_object(s::DeserializerState, ::Type{<: WeierstrassModel}, params::
model.defining_classes = defining_classes
attrs_data = haskey(s, :__attrs) ? load_typed_object(s, :__attrs) : Dict{Symbol, Any}()
for (key, value) in attrs_data
set_attribute!(model, Symbol(key), value)
if (key != :resolution_loci) && (key != :exceptional_divisors)
set_attribute!(model, Symbol(key), value)
end
end
if haskey(attrs_data, :resolution_loci)
resolution_loci = attrs_data[:resolution_loci]
exceptional_divisors = attrs_data[:exceptional_divisors]
@req length(exceptional_divisors) == length(exceptional_divisors) "Inconsistency upon loading resolutions"
set_attribute!(model, :resolutions, [[resolution_loci[i], exceptional_divisors[i]] for i in 1:length(resolution_loci)])

Check warning on line 94 in experimental/FTheoryTools/src/Serialization/weierstrass_models.jl

View check run for this annotation

Codecov / codecov/patch

experimental/FTheoryTools/src/Serialization/weierstrass_models.jl#L91-L94

Added lines #L91 - L94 were not covered by tests
end
@req cox_ring(ambient_space(model)) == parent(weierstrass_polynomial(model)) "Weierstrass polynomial not in Cox ring of toric ambient space"
return model
Expand Down

0 comments on commit 30582f4

Please sign in to comment.