text:
export PDText
export readpdf, tokenize

using CodecZlib
import Base.Unicode

mutable struct PDText
    str::String
    children::Vector{PDText}
    page::Int
    fcoord::Rectangle
    gcoord::Rectangle
end

function PDText(children::Vector{PDText})
    @assert all(c -> c.page == children[1].page, children)
    str = join(map(c -> c.str, children))
    fcoord = merge(map(c -> c.fcoord, children))
    gcoord = merge(map(c -> c.gcoord, children))
    PDText(str, children, children[1].page, fcoord, gcoord)
end

function leaves(text::PDText)
    l = PDText[]
    function f(t::PDText)
        if isempty(t.children)
            push!(l,t)
        else
            foreach(f, t.children)
        end
    end
    f(text)
    l
end

function readpdf(filepath::String)
    if endswith(filepath, ".txt")
        lines = open(readlines, filepath)
    elseif endswith(filepath, ".pdf")
        gzfilepath = "$filepath.0-3-1.txt.gz"
        if !isfile(gzfilepath)
            jar = download_jar("0.3.1")
            run(`java -classpath $jar paperai.pdfextract.PDFExtractor $filepath`)
        end
        lines = open(s -> readlines(GzipDecompressorStream(s)), gzfilepath)
    else
        throw("File error.")
    end

    texts = PDText[]
    for line in lines
        isempty(line) && continue
        items = split(line, '\t')
        page = parse(Int, items[1])
        str = Unicode.normalize(items[2], :NFKC)
        str[1] == '[' && str[end] == ']' && continue

        coord = map(x -> parse(Float64,x), split(items[3]," "))
        fcoord = Rectangle(coord...)
        coord = map(x -> parse(Float64,x), split(items[4]," "))
        gcoord = Rectangle(coord...)
        t = PDText(str, PDText[], page, fcoord, gcoord)
        push!(texts, t)
    end
    texts
end

function tokenize(texts::Vector{PDText})
    tokens = PDText[]
    buffer = [texts[1]]
    average = texts[1].fcoord.w
    for i = 2:length(texts)
        prev, curr = texts[i-1], texts[i]
        expected = prev.fcoord.x + prev.fcoord.w + 0.1*average
        if prev.page != curr.page || prev.fcoord.x > curr.fcoord.x || expected < curr.fcoord.x
            push!(tokens, PDText(buffer))
            buffer = [curr]
            average = curr.fcoord.w
        else
            push!(buffer, curr)
            average = (average + curr.fcoord.w) / 2
        end
    end
    isempty(buffer) || push!(tokens,PDText(buffer))
    tokens
end

function tokenize_line(texts::Vector{PDText})
end

export average_size
function average_size(texts::Vector{PDText})
    w = 0.0
    h = 0.0
    for t in texts
        w += t.fcoord.w
        h += t.fcoord.h
    end
    w /= length(texts)
    h /= length(texts)
end


text:
# This file was generated by the Julia Swagger Code Generator
# Do not modify this file directly. Modify the swagger specification instead.

module Kubernetes

using Random
using Dates
using HTTP
using Swagger
import Swagger: field_name, property_type, hasproperty, validate_property, SwaggerApi, SwaggerModel
import Base: convert, propertynames

include("modelincludes.jl")

include("api_AdmissionregistrationApi.jl")
include("api_AdmissionregistrationV1Api.jl")
include("api_AdmissionregistrationV1beta1Api.jl")
include("api_ApiextensionsApi.jl")
include("api_ApiextensionsV1Api.jl")
include("api_ApiextensionsV1beta1Api.jl")
include("api_ApiregistrationApi.jl")
include("api_ApiregistrationV1Api.jl")
include("api_ApiregistrationV1beta1Api.jl")
include("api_ApisApi.jl")
include("api_AppsApi.jl")
include("api_AppsV1Api.jl")
include("api_AppsV1beta1Api.jl")
include("api_AppsV1beta2Api.jl")
include("api_AuditregistrationApi.jl")
include("api_AuditregistrationV1alpha1Api.jl")
include("api_AuthenticationApi.jl")
include("api_AuthenticationV1Api.jl")
include("api_AuthenticationV1beta1Api.jl")
include("api_AuthorizationApi.jl")
include("api_AuthorizationV1Api.jl")
include("api_AuthorizationV1beta1Api.jl")
include("api_AutoscalingApi.jl")
include("api_AutoscalingV1Api.jl")
include("api_AutoscalingV2beta1Api.jl")
include("api_AutoscalingV2beta2Api.jl")
include("api_BatchApi.jl")
include("api_BatchV1Api.jl")
include("api_BatchV1beta1Api.jl")
include("api_BatchV2alpha1Api.jl")
include("api_CertificatesApi.jl")
include("api_CertificatesV1beta1Api.jl")
include("api_CoordinationApi.jl")
include("api_CoordinationV1Api.jl")
include("api_CoordinationV1beta1Api.jl")
include("api_CoreApi.jl")
include("api_CoreV1Api.jl")
include("api_CustomMetricsV1beta1Api.jl")
include("api_DiscoveryApi.jl")
include("api_DiscoveryV1beta1Api.jl")
include("api_EventsApi.jl")
include("api_EventsV1beta1Api.jl")
include("api_ExtensionsApi.jl")
include("api_ExtensionsV1beta1Api.jl")
include("api_FlowcontrolApiserverApi.jl")
include("api_FlowcontrolApiserverV1alpha1Api.jl")
include("api_LogsApi.jl")
include("api_MetricsV1beta1Api.jl")
include("api_NetworkingApi.jl")
include("api_NetworkingV1Api.jl")
include("api_NetworkingV1beta1Api.jl")
include("api_NodeApi.jl")
include("api_NodeV1alpha1Api.jl")
include("api_NodeV1beta1Api.jl")
include("api_PolicyApi.jl")
include("api_PolicyV1beta1Api.jl")
include("api_RbacAuthorizationApi.jl")
include("api_RbacAuthorizationV1Api.jl")
include("api_RbacAuthorizationV1alpha1Api.jl")
include("api_RbacAuthorizationV1beta1Api.jl")
include("api_SchedulingApi.jl")
include("api_SchedulingV1Api.jl")
include("api_SchedulingV1alpha1Api.jl")
include("api_SchedulingV1beta1Api.jl")
include("api_SettingsApi.jl")
include("api_SettingsV1alpha1Api.jl")
include("api_StorageApi.jl")
include("api_StorageV1Api.jl")
include("api_StorageV1alpha1Api.jl")
include("api_StorageV1beta1Api.jl")
include("api_VersionApi.jl")

# export models
export convert, IoK8sApiAdmissionregistrationV1MutatingWebhook
export convert, IoK8sApiAdmissionregistrationV1MutatingWebhookConfiguration
export convert, IoK8sApiAdmissionregistrationV1MutatingWebhookConfigurationList
export convert, IoK8sApiAdmissionregistrationV1RuleWithOperations
export convert, IoK8sApiAdmissionregistrationV1ServiceReference
export convert, IoK8sApiAdmissionregistrationV1ValidatingWebhook
export convert, IoK8sApiAdmissionregistrationV1ValidatingWebhookConfiguration
export convert, IoK8sApiAdmissionregistrationV1ValidatingWebhookConfigurationList
export convert, IoK8sApiAdmissionregistrationV1WebhookClientConfig
export convert, IoK8sApiAdmissionregistrationV1beta1MutatingWebhook
export convert, IoK8sApiAdmissionregistrationV1beta1MutatingWebhookConfiguration
export convert, IoK8sApiAdmissionregistrationV1beta1MutatingWebhookConfigurationList
export convert, IoK8sApiAdmissionregistrationV1beta1RuleWithOperations
export convert, IoK8sApiAdmissionregistrationV1beta1ServiceReference
export convert, IoK8sApiAdmissionregistrationV1beta1ValidatingWebhook
export convert, IoK8sApiAdmissionregistrationV1beta1ValidatingWebhookConfiguration
export convert, IoK8sApiAdmissionregistrationV1beta1ValidatingWebhookConfigurationList
export convert, IoK8sApiAdmissionregistrationV1beta1WebhookClientConfig
export convert, IoK8sApiAppsV1ControllerRevision
export convert, IoK8sApiAppsV1ControllerRevisionList
export convert, IoK8sApiAppsV1DaemonSet
export convert, IoK8sApiAppsV1DaemonSetCondition
export convert, IoK8sApiAppsV1DaemonSetList
export convert, IoK8sApiAppsV1DaemonSetSpec
export convert, IoK8sApiAppsV1DaemonSetStatus
export convert, IoK8sApiAppsV1DaemonSetUpdateStrategy
export convert, IoK8sApiAppsV1Deployment
export convert, IoK8sApiAppsV1DeploymentCondition
export convert, IoK8sApiAppsV1DeploymentList
export convert, IoK8sApiAppsV1DeploymentSpec
export convert, IoK8sApiAppsV1DeploymentStatus
export convert, IoK8sApiAppsV1DeploymentStrategy
export convert, IoK8sApiAppsV1ReplicaSet
export convert, IoK8sApiAppsV1ReplicaSetCondition
export convert, IoK8sApiAppsV1ReplicaSetList
export convert, IoK8sApiAppsV1ReplicaSetSpec
export convert, IoK8sApiAppsV1ReplicaSetStatus
export convert, IoK8sApiAppsV1RollingUpdateDaemonSet
export convert, IoK8sApiAppsV1RollingUpdateDeployment
export convert, IoK8sApiAppsV1RollingUpdateStatefulSetStrategy
export convert, IoK8sApiAppsV1StatefulSet
export convert, IoK8sApiAppsV1StatefulSetCondition
export convert, IoK8sApiAppsV1StatefulSetList
export convert, IoK8sApiAppsV1StatefulSetSpec
export convert, IoK8sApiAppsV1StatefulSetStatus
export convert, IoK8sApiAppsV1StatefulSetUpdateStrategy
export convert, IoK8sApiAppsV1beta1ControllerRevision
export convert, IoK8sApiAppsV1beta1ControllerRevisionList
export convert, IoK8sApiAppsV1beta1Deployment
export convert, IoK8sApiAppsV1beta1DeploymentCondition
export convert, IoK8sApiAppsV1beta1DeploymentList
export convert, IoK8sApiAppsV1beta1DeploymentRollback
export convert, IoK8sApiAppsV1beta1DeploymentSpec
export convert, IoK8sApiAppsV1beta1DeploymentStatus
export convert, IoK8sApiAppsV1beta1DeploymentStrategy
export convert, IoK8sApiAppsV1beta1RollbackConfig
export convert, IoK8sApiAppsV1beta1RollingUpdateDeployment
export convert, IoK8sApiAppsV1beta1RollingUpdateStatefulSetStrategy
export convert, IoK8sApiAppsV1beta1Scale
export convert, IoK8sApiAppsV1beta1ScaleSpec
export convert, IoK8sApiAppsV1beta1ScaleStatus
export convert, IoK8sApiAppsV1beta1StatefulSet
export convert, IoK8sApiAppsV1beta1StatefulSetCondition
export convert, IoK8sApiAppsV1beta1StatefulSetList
export convert, IoK8sApiAppsV1beta1StatefulSetSpec
export convert, IoK8sApiAppsV1beta1StatefulSetStatus
export convert, IoK8sApiAppsV1beta1StatefulSetUpdateStrategy
export convert, IoK8sApiAppsV1beta2ControllerRevision
export convert, IoK8sApiAppsV1beta2ControllerRevisionList
export convert, IoK8sApiAppsV1beta2DaemonSet
export convert, IoK8sApiAppsV1beta2DaemonSetCondition
export convert, IoK8sApiAppsV1beta2DaemonSetList
export convert, IoK8sApiAppsV1beta2DaemonSetSpec
export convert, IoK8sApiAppsV1beta2DaemonSetStatus
export convert, IoK8sApiAppsV1beta2DaemonSetUpdateStrategy
export convert, IoK8sApiAppsV1beta2Deployment
export convert, IoK8sApiAppsV1beta2DeploymentCondition
export convert, IoK8sApiAppsV1beta2DeploymentList
export convert, IoK8sApiAppsV1beta2DeploymentSpec
export convert, IoK8sApiAppsV1beta2DeploymentStatus
export convert, IoK8sApiAppsV1beta2DeploymentStrategy
export convert, IoK8sApiAppsV1beta2ReplicaSet
export convert, IoK8sApiAppsV1beta2ReplicaSetCondition
export convert, IoK8sApiAppsV1beta2ReplicaSetList
export convert, IoK8sApiAppsV1beta2ReplicaSetSpec
export convert, IoK8sApiAppsV1beta2ReplicaSetStatus
export convert, IoK8sApiAppsV1beta2RollingUpdateDaemonSet
export convert, IoK8sApiAppsV1beta2RollingUpdateDeployment
export convert, IoK8sApiAppsV1beta2RollingUpdateStatefulSetStrategy
export convert, IoK8sApiAppsV1beta2Scale
export convert, IoK8sApiAppsV1beta2ScaleSpec
export convert, IoK8sApiAppsV1beta2ScaleStatus
export convert, IoK8sApiAppsV1beta2StatefulSet
export convert, IoK8sApiAppsV1beta2StatefulSetCondition
export convert, IoK8sApiAppsV1beta2StatefulSetList
export convert, IoK8sApiAppsV1beta2StatefulSetSpec
export convert, IoK8sApiAppsV1beta2StatefulSetStatus
export convert, IoK8sApiAppsV1beta2StatefulSetUpdateStrategy
export convert, IoK8sApiAuditregistrationV1alpha1AuditSink
export convert, IoK8sApiAuditregistrationV1alpha1AuditSinkList
export convert, IoK8sApiAuditregistrationV1alpha1AuditSinkSpec
export convert, IoK8sApiAuditregistrationV1alpha1Policy
export convert, IoK8sApiAuditregistrationV1alpha1ServiceReference
export convert, IoK8sApiAuditregistrationV1alpha1Webhook
export convert, IoK8sApiAuditregistrationV1alpha1WebhookClientConfig
export convert, IoK8sApiAuditregistrationV1alpha1WebhookThrottleConfig
export convert, IoK8sApiAuthenticationV1BoundObjectReference
export convert, IoK8sApiAuthenticationV1TokenRequest
export convert, IoK8sApiAuthenticationV1TokenRequestSpec
export convert, IoK8sApiAuthenticationV1TokenRequestStatus
export convert, IoK8sApiAuthenticationV1TokenReview
export convert, IoK8sApiAuthenticationV1TokenReviewSpec
export convert, IoK8sApiAuthenticationV1TokenReviewStatus
export convert, IoK8sApiAuthenticationV1UserInfo
export convert, IoK8sApiAuthenticationV1beta1TokenReview
export convert, IoK8sApiAuthenticationV1beta1TokenReviewSpec
export convert, IoK8sApiAuthenticationV1beta1TokenReviewStatus
export convert, IoK8sApiAuthenticationV1beta1UserInfo
export convert, IoK8sApiAuthorizationV1LocalSubjectAccessReview
export convert, IoK8sApiAuthorizationV1NonResourceAttributes
export convert, IoK8sApiAuthorizationV1NonResourceRule
export convert, IoK8sApiAuthorizationV1ResourceAttributes
export convert, IoK8sApiAuthorizationV1ResourceRule
export convert, IoK8sApiAuthorizationV1SelfSubjectAccessReview
export convert, IoK8sApiAuthorizationV1SelfSubjectAccessReviewSpec
export convert, IoK8sApiAuthorizationV1SelfSubjectRulesReview
export convert, IoK8sApiAuthorizationV1SelfSubjectRulesReviewSpec
export convert, IoK8sApiAuthorizationV1SubjectAccessReview
export convert, IoK8sApiAuthorizationV1SubjectAccessReviewSpec
export convert, IoK8sApiAuthorizationV1SubjectAccessReviewStatus
export convert, IoK8sApiAuthorizationV1SubjectRulesReviewStatus
export convert, IoK8sApiAuthorizationV1beta1LocalSubjectAccessReview
export convert, IoK8sApiAuthorizationV1beta1NonResourceAttributes
export convert, IoK8sApiAuthorizationV1beta1NonResourceRule
export convert, IoK8sApiAuthorizationV1beta1ResourceAttributes
export convert, IoK8sApiAuthorizationV1beta1ResourceRule
export convert, IoK8sApiAuthorizationV1beta1SelfSubjectAccessReview
export convert, IoK8sApiAuthorizationV1beta1SelfSubjectAccessReviewSpec
export convert, IoK8sApiAuthorizationV1beta1SelfSubjectRulesReview
export convert, IoK8sApiAuthorizationV1beta1SelfSubjectRulesReviewSpec
export convert, IoK8sApiAuthorizationV1beta1SubjectAccessReview
export convert, IoK8sApiAuthorizationV1beta1SubjectAccessReviewSpec
export convert, IoK8sApiAuthorizationV1beta1SubjectAccessReviewStatus
export convert, IoK8sApiAuthorizationV1beta1SubjectRulesReviewStatus
export convert, IoK8sApiAutoscalingV1CrossVersionObjectReference
export convert, IoK8sApiAutoscalingV1HorizontalPodAutoscaler
export convert, IoK8sApiAutoscalingV1HorizontalPodAutoscalerList
export convert, IoK8sApiAutoscalingV1HorizontalPodAutoscalerSpec
export convert, IoK8sApiAutoscalingV1HorizontalPodAutoscalerStatus
export convert, IoK8sApiAutoscalingV1Scale
export convert, IoK8sApiAutoscalingV1ScaleSpec
export convert, IoK8sApiAutoscalingV1ScaleStatus
export convert, IoK8sApiAutoscalingV2beta1CrossVersionObjectReference
export convert, IoK8sApiAutoscalingV2beta1ExternalMetricSource
export convert, IoK8sApiAutoscalingV2beta1ExternalMetricStatus
export convert, IoK8sApiAutoscalingV2beta1HorizontalPodAutoscaler
export convert, IoK8sApiAutoscalingV2beta1HorizontalPodAutoscalerCondition
export convert, IoK8sApiAutoscalingV2beta1HorizontalPodAutoscalerList
export convert, IoK8sApiAutoscalingV2beta1HorizontalPodAutoscalerSpec
export convert, IoK8sApiAutoscalingV2beta1HorizontalPodAutoscalerStatus
export convert, IoK8sApiAutoscalingV2beta1MetricSpec
export convert, IoK8sApiAutoscalingV2beta1MetricStatus
export convert, IoK8sApiAutoscalingV2beta1ObjectMetricSource
export convert, IoK8sApiAutoscalingV2beta1ObjectMetricStatus
export convert, IoK8sApiAutoscalingV2beta1PodsMetricSource
export convert, IoK8sApiAutoscalingV2beta1PodsMetricStatus
export convert, IoK8sApiAutoscalingV2beta1ResourceMetricSource
export convert, IoK8sApiAutoscalingV2beta1ResourceMetricStatus
export convert, IoK8sApiAutoscalingV2beta2CrossVersionObjectReference
export convert, IoK8sApiAutoscalingV2beta2ExternalMetricSource
export convert, IoK8sApiAutoscalingV2beta2ExternalMetricStatus
export convert, IoK8sApiAutoscalingV2beta2HorizontalPodAutoscaler
export convert, IoK8sApiAutoscalingV2beta2HorizontalPodAutoscalerCondition
export convert, IoK8sApiAutoscalingV2beta2HorizontalPodAutoscalerList
export convert, IoK8sApiAutoscalingV2beta2HorizontalPodAutoscalerSpec
export convert, IoK8sApiAutoscalingV2beta2HorizontalPodAutoscalerStatus
export convert, IoK8sApiAutoscalingV2beta2MetricIdentifier
export convert, IoK8sApiAutoscalingV2beta2MetricSpec
export convert, IoK8sApiAutoscalingV2beta2MetricStatus
export convert, IoK8sApiAutoscalingV2beta2MetricTarget
export convert, IoK8sApiAutoscalingV2beta2MetricValueStatus
export convert, IoK8sApiAutoscalingV2beta2ObjectMetricSource
export convert, IoK8sApiAutoscalingV2beta2ObjectMetricStatus
export convert, IoK8sApiAutoscalingV2beta2PodsMetricSource
export convert, IoK8sApiAutoscalingV2beta2PodsMetricStatus
export convert, IoK8sApiAutoscalingV2beta2ResourceMetricSource
export convert, IoK8sApiAutoscalingV2beta2ResourceMetricStatus
export convert, IoK8sApiBatchV1Job
export convert, IoK8sApiBatchV1JobCondition
export convert, IoK8sApiBatchV1JobList
export convert, IoK8sApiBatchV1JobSpec
export convert, IoK8sApiBatchV1JobStatus
export convert, IoK8sApiBatchV1beta1CronJob
export convert, IoK8sApiBatchV1beta1CronJobList
export convert, IoK8sApiBatchV1beta1CronJobSpec
export convert, IoK8sApiBatchV1beta1CronJobStatus
export convert, IoK8sApiBatchV1beta1JobTemplateSpec
export convert, IoK8sApiBatchV2alpha1CronJob
export convert, IoK8sApiBatchV2alpha1CronJobList
export convert, IoK8sApiBatchV2alpha1CronJobSpec
export convert, IoK8sApiBatchV2alpha1CronJobStatus
export convert, IoK8sApiBatchV2alpha1JobTemplateSpec
export convert, IoK8sApiCertificatesV1beta1CertificateSigningRequest
export convert, IoK8sApiCertificatesV1beta1CertificateSigningRequestCondition
export convert, IoK8sApiCertificatesV1beta1CertificateSigningRequestList
export convert, IoK8sApiCertificatesV1beta1CertificateSigningRequestSpec
export convert, IoK8sApiCertificatesV1beta1CertificateSigningRequestStatus
export convert, IoK8sApiCoordinationV1Lease
export convert, IoK8sApiCoordinationV1LeaseList
export convert, IoK8sApiCoordinationV1LeaseSpec
export convert, IoK8sApiCoordinationV1beta1Lease
export convert, IoK8sApiCoordinationV1beta1LeaseList
export convert, IoK8sApiCoordinationV1beta1LeaseSpec
export convert, IoK8sApiCoreV1AWSElasticBlockStoreVolumeSource
export convert, IoK8sApiCoreV1Affinity
export convert, IoK8sApiCoreV1AttachedVolume
export convert, IoK8sApiCoreV1AzureDiskVolumeSource
export convert, IoK8sApiCoreV1AzureFilePersistentVolumeSource
export convert, IoK8sApiCoreV1AzureFileVolumeSource
export convert, IoK8sApiCoreV1Binding
export convert, IoK8sApiCoreV1CSIPersistentVolumeSource
export convert, IoK8sApiCoreV1CSIVolumeSource
export convert, IoK8sApiCoreV1Capabilities
export convert, IoK8sApiCoreV1CephFSPersistentVolumeSource
export convert, IoK8sApiCoreV1CephFSVolumeSource
export convert, IoK8sApiCoreV1CinderPersistentVolumeSource
export convert, IoK8sApiCoreV1CinderVolumeSource
export convert, IoK8sApiCoreV1ClientIPConfig
export convert, IoK8sApiCoreV1ComponentCondition
export convert, IoK8sApiCoreV1ComponentStatus
export convert, IoK8sApiCoreV1ComponentStatusList
export convert, IoK8sApiCoreV1ConfigMap
export convert, IoK8sApiCoreV1ConfigMapEnvSource
export convert, IoK8sApiCoreV1ConfigMapKeySelector
export convert, IoK8sApiCoreV1ConfigMapList
export convert, IoK8sApiCoreV1ConfigMapNodeConfigSource
export convert, IoK8sApiCoreV1ConfigMapProjection
export convert, IoK8sApiCoreV1ConfigMapVolumeSource
export convert, IoK8sApiCoreV1Container
export convert, IoK8sApiCoreV1ContainerImage
export convert, IoK8sApiCoreV1ContainerPort
export convert, IoK8sApiCoreV1ContainerState
export convert, IoK8sApiCoreV1ContainerStateRunning
export convert, IoK8sApiCoreV1ContainerStateTerminated
export convert, IoK8sApiCoreV1ContainerStateWaiting
export convert, IoK8sApiCoreV1ContainerStatus
export convert, IoK8sApiCoreV1DaemonEndpoint
export convert, IoK8sApiCoreV1DownwardAPIProjection
export convert, IoK8sApiCoreV1DownwardAPIVolumeFile
export convert, IoK8sApiCoreV1DownwardAPIVolumeSource
export convert, IoK8sApiCoreV1EmptyDirVolumeSource
export convert, IoK8sApiCoreV1EndpointAddress
export convert, IoK8sApiCoreV1EndpointPort
export convert, IoK8sApiCoreV1EndpointSubset
export convert, IoK8sApiCoreV1Endpoints
export convert, IoK8sApiCoreV1EndpointsList
export convert, IoK8sApiCoreV1EnvFromSource
export convert, IoK8sApiCoreV1EnvVar
export convert, IoK8sApiCoreV1EnvVarSource
export convert, IoK8sApiCoreV1EphemeralContainer
export convert, IoK8sApiCoreV1Event
export convert, IoK8sApiCoreV1EventList
export convert, IoK8sApiCoreV1EventSeries
export convert, IoK8sApiCoreV1EventSource
export convert, IoK8sApiCoreV1ExecAction
export convert, IoK8sApiCoreV1FCVolumeSource
export convert, IoK8sApiCoreV1FlexPersistentVolumeSource
export convert, IoK8sApiCoreV1FlexVolumeSource
export convert, IoK8sApiCoreV1FlockerVolumeSource
export convert, IoK8sApiCoreV1GCEPersistentDiskVolumeSource
export convert, IoK8sApiCoreV1GitRepoVolumeSource
export convert, IoK8sApiCoreV1GlusterfsPersistentVolumeSource
export convert, IoK8sApiCoreV1GlusterfsVolumeSource
export convert, IoK8sApiCoreV1HTTPGetAction
export convert, IoK8sApiCoreV1HTTPHeader
export convert, IoK8sApiCoreV1Handler
export convert, IoK8sApiCoreV1HostAlias
export convert, IoK8sApiCoreV1HostPathVolumeSource
export convert, IoK8sApiCoreV1ISCSIPersistentVolumeSource
export convert, IoK8sApiCoreV1ISCSIVolumeSource
export convert, IoK8sApiCoreV1KeyToPath
export convert, IoK8sApiCoreV1Lifecycle
export convert, IoK8sApiCoreV1LimitRange
export convert, IoK8sApiCoreV1LimitRangeItem
export convert, IoK8sApiCoreV1LimitRangeList
export convert, IoK8sApiCoreV1LimitRangeSpec
export convert, IoK8sApiCoreV1LoadBalancerIngress
export convert, IoK8sApiCoreV1LoadBalancerStatus
export convert, IoK8sApiCoreV1LocalObjectReference
export convert, IoK8sApiCoreV1LocalVolumeSource
export convert, IoK8sApiCoreV1NFSVolumeSource
export convert, IoK8sApiCoreV1Namespace
export convert, IoK8sApiCoreV1NamespaceCondition
export convert, IoK8sApiCoreV1NamespaceList
export convert, IoK8sApiCoreV1NamespaceSpec
export convert, IoK8sApiCoreV1NamespaceStatus
export convert, IoK8sApiCoreV1Node
export convert, IoK8sApiCoreV1NodeAddress
export convert, IoK8sApiCoreV1NodeAffinity
export convert, IoK8sApiCoreV1NodeCondition
export convert, IoK8sApiCoreV1NodeConfigSource
export convert, IoK8sApiCoreV1NodeConfigStatus
export convert, IoK8sApiCoreV1NodeDaemonEndpoints
export convert, IoK8sApiCoreV1NodeList
export convert, IoK8sApiCoreV1NodeSelector
export convert, IoK8sApiCoreV1NodeSelectorRequirement
export convert, IoK8sApiCoreV1NodeSelectorTerm
export convert, IoK8sApiCoreV1NodeSpec
export convert, IoK8sApiCoreV1NodeStatus
export convert, IoK8sApiCoreV1NodeSystemInfo
export convert, IoK8sApiCoreV1ObjectFieldSelector
export convert, IoK8sApiCoreV1ObjectReference
export convert, IoK8sApiCoreV1PersistentVolume
export convert, IoK8sApiCoreV1PersistentVolumeClaim
export convert, IoK8sApiCoreV1PersistentVolumeClaimCondition
export convert, IoK8sApiCoreV1PersistentVolumeClaimList
export convert, IoK8sApiCoreV1PersistentVolumeClaimSpec
export convert, IoK8sApiCoreV1PersistentVolumeClaimStatus
export convert, IoK8sApiCoreV1PersistentVolumeClaimVolumeSource
export convert, IoK8sApiCoreV1PersistentVolumeList
export convert, IoK8sApiCoreV1PersistentVolumeSpec
export convert, IoK8sApiCoreV1PersistentVolumeStatus
export convert, IoK8sApiCoreV1PhotonPersistentDiskVolumeSource
export convert, IoK8sApiCoreV1Pod
export convert, IoK8sApiCoreV1PodAffinity
export convert, IoK8sApiCoreV1PodAffinityTerm
export convert, IoK8sApiCoreV1PodAntiAffinity
export convert, IoK8sApiCoreV1PodCondition
export convert, IoK8sApiCoreV1PodDNSConfig
export convert, IoK8sApiCoreV1PodDNSConfigOption
export convert, IoK8sApiCoreV1PodIP
export convert, IoK8sApiCoreV1PodList
export convert, IoK8sApiCoreV1PodReadinessGate
export convert, IoK8sApiCoreV1PodSecurityContext
export convert, IoK8sApiCoreV1PodSpec
export convert, IoK8sApiCoreV1PodStatus
export convert, IoK8sApiCoreV1PodTemplate
export convert, IoK8sApiCoreV1PodTemplateList
export convert, IoK8sApiCoreV1PodTemplateSpec
export convert, IoK8sApiCoreV1PortworxVolumeSource
export convert, IoK8sApiCoreV1PreferredSchedulingTerm
export convert, IoK8sApiCoreV1Probe
export convert, IoK8sApiCoreV1ProjectedVolumeSource
export convert, IoK8sApiCoreV1QuobyteVolumeSource
export convert, IoK8sApiCoreV1RBDPersistentVolumeSource
export convert, IoK8sApiCoreV1RBDVolumeSource
export convert, IoK8sApiCoreV1ReplicationController
export convert, IoK8sApiCoreV1ReplicationControllerCondition
export convert, IoK8sApiCoreV1ReplicationControllerList
export convert, IoK8sApiCoreV1ReplicationControllerSpec
export convert, IoK8sApiCoreV1ReplicationControllerStatus
export convert, IoK8sApiCoreV1ResourceFieldSelector
export convert, IoK8sApiCoreV1ResourceQuota
export convert, IoK8sApiCoreV1ResourceQuotaList
export convert, IoK8sApiCoreV1ResourceQuotaSpec
export convert, IoK8sApiCoreV1ResourceQuotaStatus
export convert, IoK8sApiCoreV1ResourceRequirements
export convert, IoK8sApiCoreV1SELinuxOptions
export convert, IoK8sApiCoreV1ScaleIOPersistentVolumeSource
export convert, IoK8sApiCoreV1ScaleIOVolumeSource
export convert, IoK8sApiCoreV1ScopeSelector
export convert, IoK8sApiCoreV1ScopedResourceSelectorRequirement
export convert, IoK8sApiCoreV1Secret
export convert, IoK8sApiCoreV1SecretEnvSource
export convert, IoK8sApiCoreV1SecretKeySelector
export convert, IoK8sApiCoreV1SecretList
export convert, IoK8sApiCoreV1SecretProjection
export convert, IoK8sApiCoreV1SecretReference
export convert, IoK8sApiCoreV1SecretVolumeSource
export convert, IoK8sApiCoreV1SecurityContext
export convert, IoK8sApiCoreV1Service
export convert, IoK8sApiCoreV1ServiceAccount
export convert, IoK8sApiCoreV1ServiceAccountList
export convert, IoK8sApiCoreV1ServiceAccountTokenProjection
export convert, IoK8sApiCoreV1ServiceList
export convert, IoK8sApiCoreV1ServicePort
export convert, IoK8sApiCoreV1ServiceSpec
export convert, IoK8sApiCoreV1ServiceStatus
export convert, IoK8sApiCoreV1SessionAffinityConfig
export convert, IoK8sApiCoreV1StorageOSPersistentVolumeSource
export convert, IoK8sApiCoreV1StorageOSVolumeSource
export convert, IoK8sApiCoreV1Sysctl
export convert, IoK8sApiCoreV1TCPSocketAction
export convert, IoK8sApiCoreV1Taint
export convert, IoK8sApiCoreV1Toleration
export convert, IoK8sApiCoreV1TopologySelectorLabelRequirement
export convert, IoK8sApiCoreV1TopologySelectorTerm
export convert, IoK8sApiCoreV1TopologySpreadConstraint
export convert, IoK8sApiCoreV1TypedLocalObjectReference
export convert, IoK8sApiCoreV1Volume
export convert, IoK8sApiCoreV1VolumeDevice
export convert, IoK8sApiCoreV1VolumeMount
export convert, IoK8sApiCoreV1VolumeNodeAffinity
export convert, IoK8sApiCoreV1VolumeProjection
export convert, IoK8sApiCoreV1VsphereVirtualDiskVolumeSource
export convert, IoK8sApiCoreV1WeightedPodAffinityTerm
export convert, IoK8sApiCoreV1WindowsSecurityContextOptions
export convert, IoK8sApiCustomMetricsV1beta1MetricValue
export convert, IoK8sApiCustomMetricsV1beta1MetricValueList
export convert, IoK8sApiDiscoveryV1beta1Endpoint
export convert, IoK8sApiDiscoveryV1beta1EndpointConditions
export convert, IoK8sApiDiscoveryV1beta1EndpointPort
export convert, IoK8sApiDiscoveryV1beta1EndpointSlice
export convert, IoK8sApiDiscoveryV1beta1EndpointSliceList
export convert, IoK8sApiEventsV1beta1Event
export convert, IoK8sApiEventsV1beta1EventList
export convert, IoK8sApiEventsV1beta1EventSeries
export convert, IoK8sApiExtensionsV1beta1AllowedCSIDriver
export convert, IoK8sApiExtensionsV1beta1AllowedFlexVolume
export convert, IoK8sApiExtensionsV1beta1AllowedHostPath
export convert, IoK8sApiExtensionsV1beta1DaemonSet
export convert, IoK8sApiExtensionsV1beta1DaemonSetCondition
export convert, IoK8sApiExtensionsV1beta1DaemonSetList
export convert, IoK8sApiExtensionsV1beta1DaemonSetSpec
export convert, IoK8sApiExtensionsV1beta1DaemonSetStatus
export convert, IoK8sApiExtensionsV1beta1DaemonSetUpdateStrategy
export convert, IoK8sApiExtensionsV1beta1Deployment
export convert, IoK8sApiExtensionsV1beta1DeploymentCondition
export convert, IoK8sApiExtensionsV1beta1DeploymentList
export convert, IoK8sApiExtensionsV1beta1DeploymentRollback
export convert, IoK8sApiExtensionsV1beta1DeploymentSpec
export convert, IoK8sApiExtensionsV1beta1DeploymentStatus
export convert, IoK8sApiExtensionsV1beta1DeploymentStrategy
export convert, IoK8sApiExtensionsV1beta1FSGroupStrategyOptions
export convert, IoK8sApiExtensionsV1beta1HTTPIngressPath
export convert, IoK8sApiExtensionsV1beta1HTTPIngressRuleValue
export convert, IoK8sApiExtensionsV1beta1HostPortRange
export convert, IoK8sApiExtensionsV1beta1IDRange
export convert, IoK8sApiExtensionsV1beta1IPBlock
export convert, IoK8sApiExtensionsV1beta1Ingress
export convert, IoK8sApiExtensionsV1beta1IngressBackend
export convert, IoK8sApiExtensionsV1beta1IngressList
export convert, IoK8sApiExtensionsV1beta1IngressRule
export convert, IoK8sApiExtensionsV1beta1IngressSpec
export convert, IoK8sApiExtensionsV1beta1IngressStatus
export convert, IoK8sApiExtensionsV1beta1IngressTLS
export convert, IoK8sApiExtensionsV1beta1NetworkPolicy
export convert, IoK8sApiExtensionsV1beta1NetworkPolicyEgressRule
export convert, IoK8sApiExtensionsV1beta1NetworkPolicyIngressRule
export convert, IoK8sApiExtensionsV1beta1NetworkPolicyList
export convert, IoK8sApiExtensionsV1beta1NetworkPolicyPeer
export convert, IoK8sApiExtensionsV1beta1NetworkPolicyPort
export convert, IoK8sApiExtensionsV1beta1NetworkPolicySpec
export convert, IoK8sApiExtensionsV1beta1PodSecurityPolicy
export convert, IoK8sApiExtensionsV1beta1PodSecurityPolicyList
export convert, IoK8sApiExtensionsV1beta1PodSecurityPolicySpec
export convert, IoK8sApiExtensionsV1beta1ReplicaSet
export convert, IoK8sApiExtensionsV1beta1ReplicaSetCondition
export convert, IoK8sApiExtensionsV1beta1ReplicaSetList
export convert, IoK8sApiExtensionsV1beta1ReplicaSetSpec
export convert, IoK8sApiExtensionsV1beta1ReplicaSetStatus
export convert, IoK8sApiExtensionsV1beta1RollbackConfig
export convert, IoK8sApiExtensionsV1beta1RollingUpdateDaemonSet
export convert, IoK8sApiExtensionsV1beta1RollingUpdateDeployment
export convert, IoK8sApiExtensionsV1beta1RunAsGroupStrategyOptions
export convert, IoK8sApiExtensionsV1beta1RunAsUserStrategyOptions
export convert, IoK8sApiExtensionsV1beta1RuntimeClassStrategyOptions
export convert, IoK8sApiExtensionsV1beta1SELinuxStrategyOptions
export convert, IoK8sApiExtensionsV1beta1Scale
export convert, IoK8sApiExtensionsV1beta1ScaleSpec
export convert, IoK8sApiExtensionsV1beta1ScaleStatus
export convert, IoK8sApiExtensionsV1beta1SupplementalGroupsStrategyOptions
export convert, IoK8sApiFlowcontrolV1alpha1FlowDistinguisherMethod
export convert, IoK8sApiFlowcontrolV1alpha1FlowSchema
export convert, IoK8sApiFlowcontrolV1alpha1FlowSchemaCondition
export convert, IoK8sApiFlowcontrolV1alpha1FlowSchemaList
export convert, IoK8sApiFlowcontrolV1alpha1FlowSchemaSpec
export convert, IoK8sApiFlowcontrolV1alpha1FlowSchemaStatus
export convert, IoK8sApiFlowcontrolV1alpha1GroupSubject
export convert, IoK8sApiFlowcontrolV1alpha1LimitResponse
export convert, IoK8sApiFlowcontrolV1alpha1LimitedPriorityLevelConfiguration
export convert, IoK8sApiFlowcontrolV1alpha1NonResourcePolicyRule
export convert, IoK8sApiFlowcontrolV1alpha1PolicyRulesWithSubjects
export convert, IoK8sApiFlowcontrolV1alpha1PriorityLevelConfiguration
export convert, IoK8sApiFlowcontrolV1alpha1PriorityLevelConfigurationCondition
export convert, IoK8sApiFlowcontrolV1alpha1PriorityLevelConfigurationList
export convert, IoK8sApiFlowcontrolV1alpha1PriorityLevelConfigurationReference
export convert, IoK8sApiFlowcontrolV1alpha1PriorityLevelConfigurationSpec
export convert, IoK8sApiFlowcontrolV1alpha1PriorityLevelConfigurationStatus
export convert, IoK8sApiFlowcontrolV1alpha1QueuingConfiguration
export convert, IoK8sApiFlowcontrolV1alpha1ResourcePolicyRule
export convert, IoK8sApiFlowcontrolV1alpha1ServiceAccountSubject
export convert, IoK8sApiFlowcontrolV1alpha1Subject
export convert, IoK8sApiFlowcontrolV1alpha1UserSubject
export convert, IoK8sApiMetricsV1beta1ContainerMetrics
export convert, IoK8sApiMetricsV1beta1NodeMetrics
export convert, IoK8sApiMetricsV1beta1NodeMetricsList
export convert, IoK8sApiMetricsV1beta1PodMetrics
export convert, IoK8sApiMetricsV1beta1PodMetricsList
export convert, IoK8sApiNetworkingV1IPBlock
export convert, IoK8sApiNetworkingV1NetworkPolicy
export convert, IoK8sApiNetworkingV1NetworkPolicyEgressRule
export convert, IoK8sApiNetworkingV1NetworkPolicyIngressRule
export convert, IoK8sApiNetworkingV1NetworkPolicyList
export convert, IoK8sApiNetworkingV1NetworkPolicyPeer
export convert, IoK8sApiNetworkingV1NetworkPolicyPort
export convert, IoK8sApiNetworkingV1NetworkPolicySpec
export convert, IoK8sApiNetworkingV1beta1HTTPIngressPath
export convert, IoK8sApiNetworkingV1beta1HTTPIngressRuleValue
export convert, IoK8sApiNetworkingV1beta1Ingress
export convert, IoK8sApiNetworkingV1beta1IngressBackend
export convert, IoK8sApiNetworkingV1beta1IngressList
export convert, IoK8sApiNetworkingV1beta1IngressRule
export convert, IoK8sApiNetworkingV1beta1IngressSpec
export convert, IoK8sApiNetworkingV1beta1IngressStatus
export convert, IoK8sApiNetworkingV1beta1IngressTLS
export convert, IoK8sApiNodeV1alpha1Overhead
export convert, IoK8sApiNodeV1alpha1RuntimeClass
export convert, IoK8sApiNodeV1alpha1RuntimeClassList
export convert, IoK8sApiNodeV1alpha1RuntimeClassSpec
export convert, IoK8sApiNodeV1alpha1Scheduling
export convert, IoK8sApiNodeV1beta1Overhead
export convert, IoK8sApiNodeV1beta1RuntimeClass
export convert, IoK8sApiNodeV1beta1RuntimeClassList
export convert, IoK8sApiNodeV1beta1Scheduling
export convert, IoK8sApiPolicyV1beta1AllowedCSIDriver
export convert, IoK8sApiPolicyV1beta1AllowedFlexVolume
export convert, IoK8sApiPolicyV1beta1AllowedHostPath
export convert, IoK8sApiPolicyV1beta1Eviction
export convert, IoK8sApiPolicyV1beta1FSGroupStrategyOptions
export convert, IoK8sApiPolicyV1beta1HostPortRange
export convert, IoK8sApiPolicyV1beta1IDRange
export convert, IoK8sApiPolicyV1beta1PodDisruptionBudget
export convert, IoK8sApiPolicyV1beta1PodDisruptionBudgetList
export convert, IoK8sApiPolicyV1beta1PodDisruptionBudgetSpec
export convert, IoK8sApiPolicyV1beta1PodDisruptionBudgetStatus
export convert, IoK8sApiPolicyV1beta1PodSecurityPolicy
export convert, IoK8sApiPolicyV1beta1PodSecurityPolicyList
export convert, IoK8sApiPolicyV1beta1PodSecurityPolicySpec
export convert, IoK8sApiPolicyV1beta1RunAsGroupStrategyOptions
export convert, IoK8sApiPolicyV1beta1RunAsUserStrategyOptions
export convert, IoK8sApiPolicyV1beta1RuntimeClassStrategyOptions
export convert, IoK8sApiPolicyV1beta1SELinuxStrategyOptions
export convert, IoK8sApiPolicyV1beta1SupplementalGroupsStrategyOptions
export convert, IoK8sApiRbacV1AggregationRule
export convert, IoK8sApiRbacV1ClusterRole
export convert, IoK8sApiRbacV1ClusterRoleBinding
export convert, IoK8sApiRbacV1ClusterRoleBindingList
export convert, IoK8sApiRbacV1ClusterRoleList
export convert, IoK8sApiRbacV1PolicyRule
export convert, IoK8sApiRbacV1Role
export convert, IoK8sApiRbacV1RoleBinding
export convert, IoK8sApiRbacV1RoleBindingList
export convert, IoK8sApiRbacV1RoleList
export convert, IoK8sApiRbacV1RoleRef
export convert, IoK8sApiRbacV1Subject
export convert, IoK8sApiRbacV1alpha1AggregationRule
export convert, IoK8sApiRbacV1alpha1ClusterRole
export convert, IoK8sApiRbacV1alpha1ClusterRoleBinding
export convert, IoK8sApiRbacV1alpha1ClusterRoleBindingList
export convert, IoK8sApiRbacV1alpha1ClusterRoleList
export convert, IoK8sApiRbacV1alpha1PolicyRule
export convert, IoK8sApiRbacV1alpha1Role
export convert, IoK8sApiRbacV1alpha1RoleBinding
export convert, IoK8sApiRbacV1alpha1RoleBindingList
export convert, IoK8sApiRbacV1alpha1RoleList
export convert, IoK8sApiRbacV1alpha1RoleRef
export convert, IoK8sApiRbacV1alpha1Subject
export convert, IoK8sApiRbacV1beta1AggregationRule
export convert, IoK8sApiRbacV1beta1ClusterRole
export convert, IoK8sApiRbacV1beta1ClusterRoleBinding
export convert, IoK8sApiRbacV1beta1ClusterRoleBindingList
export convert, IoK8sApiRbacV1beta1ClusterRoleList
export convert, IoK8sApiRbacV1beta1PolicyRule
export convert, IoK8sApiRbacV1beta1Role
export convert, IoK8sApiRbacV1beta1RoleBinding
export convert, IoK8sApiRbacV1beta1RoleBindingList
export convert, IoK8sApiRbacV1beta1RoleList
export convert, IoK8sApiRbacV1beta1RoleRef
export convert, IoK8sApiRbacV1beta1Subject
export convert, IoK8sApiSchedulingV1PriorityClass
export convert, IoK8sApiSchedulingV1PriorityClassList
export convert, IoK8sApiSchedulingV1alpha1PriorityClass
export convert, IoK8sApiSchedulingV1alpha1PriorityClassList
export convert, IoK8sApiSchedulingV1beta1PriorityClass
export convert, IoK8sApiSchedulingV1beta1PriorityClassList
export convert, IoK8sApiSettingsV1alpha1PodPreset
export convert, IoK8sApiSettingsV1alpha1PodPresetList
export convert, IoK8sApiSettingsV1alpha1PodPresetSpec
export convert, IoK8sApiStorageV1CSINode
export convert, IoK8sApiStorageV1CSINodeDriver
export convert, IoK8sApiStorageV1CSINodeList
export convert, IoK8sApiStorageV1CSINodeSpec
export convert, IoK8sApiStorageV1StorageClass
export convert, IoK8sApiStorageV1StorageClassList
export convert, IoK8sApiStorageV1VolumeAttachment
export convert, IoK8sApiStorageV1VolumeAttachmentList
export convert, IoK8sApiStorageV1VolumeAttachmentSource
export convert, IoK8sApiStorageV1VolumeAttachmentSpec
export convert, IoK8sApiStorageV1VolumeAttachmentStatus
export convert, IoK8sApiStorageV1VolumeError
export convert, IoK8sApiStorageV1VolumeNodeResources
export convert, IoK8sApiStorageV1alpha1VolumeAttachment
export convert, IoK8sApiStorageV1alpha1VolumeAttachmentList
export convert, IoK8sApiStorageV1alpha1VolumeAttachmentSource
export convert, IoK8sApiStorageV1alpha1VolumeAttachmentSpec
export convert, IoK8sApiStorageV1alpha1VolumeAttachmentStatus
export convert, IoK8sApiStorageV1alpha1VolumeError
export convert, IoK8sApiStorageV1beta1CSIDriver
export convert, IoK8sApiStorageV1beta1CSIDriverList
export convert, IoK8sApiStorageV1beta1CSIDriverSpec
export convert, IoK8sApiStorageV1beta1CSINode
export convert, IoK8sApiStorageV1beta1CSINodeDriver
export convert, IoK8sApiStorageV1beta1CSINodeList
export convert, IoK8sApiStorageV1beta1CSINodeSpec
export convert, IoK8sApiStorageV1beta1StorageClass
export convert, IoK8sApiStorageV1beta1StorageClassList
export convert, IoK8sApiStorageV1beta1VolumeAttachment
export convert, IoK8sApiStorageV1beta1VolumeAttachmentList
export convert, IoK8sApiStorageV1beta1VolumeAttachmentSource
export convert, IoK8sApiStorageV1beta1VolumeAttachmentSpec
export convert, IoK8sApiStorageV1beta1VolumeAttachmentStatus
export convert, IoK8sApiStorageV1beta1VolumeError
export convert, IoK8sApiStorageV1beta1VolumeNodeResources
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1CustomResourceColumnDefinition
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1CustomResourceConversion
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1CustomResourceDefinition
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1CustomResourceDefinitionCondition
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1CustomResourceDefinitionList
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1CustomResourceDefinitionNames
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1CustomResourceDefinitionSpec
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1CustomResourceDefinitionStatus
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1CustomResourceDefinitionVersion
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1CustomResourceSubresourceScale
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1CustomResourceSubresourceStatus
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1CustomResourceSubresources
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1CustomResourceValidation
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1ExternalDocumentation
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1JSON
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1JSONSchemaProps
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1JSONSchemaPropsOrArray
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1JSONSchemaPropsOrBool
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1JSONSchemaPropsOrStringArray
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1ServiceReference
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1WebhookClientConfig
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1WebhookConversion
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceColumnDefinition
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceConversion
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceDefinition
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceDefinitionCondition
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceDefinitionList
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceDefinitionNames
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceDefinitionSpec
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceDefinitionStatus
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceDefinitionVersion
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceSubresourceScale
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceSubresourceStatus
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceSubresources
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1CustomResourceValidation
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1ExternalDocumentation
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1JSON
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1JSONSchemaProps
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1JSONSchemaPropsOrArray
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1JSONSchemaPropsOrBool
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1JSONSchemaPropsOrStringArray
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1ServiceReference
export convert, IoK8sApiextensionsApiserverPkgApisApiextensionsV1beta1WebhookClientConfig
export convert, IoK8sApimachineryPkgApiResourceQuantity
export convert, IoK8sApimachineryPkgApisMetaV1APIGroup
export convert, IoK8sApimachineryPkgApisMetaV1APIGroupList
export convert, IoK8sApimachineryPkgApisMetaV1APIResource
export convert, IoK8sApimachineryPkgApisMetaV1APIResourceList
export convert, IoK8sApimachineryPkgApisMetaV1APIVersions
export convert, IoK8sApimachineryPkgApisMetaV1DeleteOptions
export convert, IoK8sApimachineryPkgApisMetaV1Duration
export convert, IoK8sApimachineryPkgApisMetaV1FieldsV1
export convert, IoK8sApimachineryPkgApisMetaV1GroupVersionForDiscovery
export convert, IoK8sApimachineryPkgApisMetaV1LabelSelector
export convert, IoK8sApimachineryPkgApisMetaV1LabelSelectorRequirement
export convert, IoK8sApimachineryPkgApisMetaV1ListMeta
export convert, IoK8sApimachineryPkgApisMetaV1ManagedFieldsEntry
export convert, IoK8sApimachineryPkgApisMetaV1MicroTime
export convert, IoK8sApimachineryPkgApisMetaV1ObjectMeta
export convert, IoK8sApimachineryPkgApisMetaV1OwnerReference
export convert, IoK8sApimachineryPkgApisMetaV1Patch
export convert, IoK8sApimachineryPkgApisMetaV1Preconditions
export convert, IoK8sApimachineryPkgApisMetaV1ServerAddressByClientCIDR
export convert, IoK8sApimachineryPkgApisMetaV1Status
export convert, IoK8sApimachineryPkgApisMetaV1StatusCause
export convert, IoK8sApimachineryPkgApisMetaV1StatusDetails
export convert, IoK8sApimachineryPkgApisMetaV1Time
export convert, IoK8sApimachineryPkgApisMetaV1WatchEvent
export convert, IoK8sApimachineryPkgRuntimeRawExtension
export convert, IoK8sApimachineryPkgUtilIntstrIntOrString
export convert, IoK8sApimachineryPkgVersionInfo
export convert, IoK8sKubeAggregatorPkgApisApiregistrationV1APIService
export convert, IoK8sKubeAggregatorPkgApisApiregistrationV1APIServiceCondition
export convert, IoK8sKubeAggregatorPkgApisApiregistrationV1APIServiceList
export convert, IoK8sKubeAggregatorPkgApisApiregistrationV1APIServiceSpec
export convert, IoK8sKubeAggregatorPkgApisApiregistrationV1APIServiceStatus
export convert, IoK8sKubeAggregatorPkgApisApiregistrationV1ServiceReference
export convert, IoK8sKubeAggregatorPkgApisApiregistrationV1beta1APIService
export convert, IoK8sKubeAggregatorPkgApisApiregistrationV1beta1APIServiceCondition
export convert, IoK8sKubeAggregatorPkgApisApiregistrationV1beta1APIServiceList
export convert, IoK8sKubeAggregatorPkgApisApiregistrationV1beta1APIServiceSpec
export convert, IoK8sKubeAggregatorPkgApisApiregistrationV1beta1APIServiceStatus
export convert, IoK8sKubeAggregatorPkgApisApiregistrationV1beta1ServiceReference

# export operations
export convert, AdmissionregistrationApi, AdmissionregistrationV1Api, AdmissionregistrationV1beta1Api, ApiextensionsApi, ApiextensionsV1Api, ApiextensionsV1beta1Api, ApiregistrationApi, ApiregistrationV1Api, ApiregistrationV1beta1Api, ApisApi, AppsApi, AppsV1Api, AppsV1beta1Api, AppsV1beta2Api, AuditregistrationApi, AuditregistrationV1alpha1Api, AuthenticationApi, AuthenticationV1Api, AuthenticationV1beta1Api, AuthorizationApi, AuthorizationV1Api, AuthorizationV1beta1Api, AutoscalingApi, AutoscalingV1Api, AutoscalingV2beta1Api, AutoscalingV2beta2Api, BatchApi, BatchV1Api, BatchV1beta1Api, BatchV2alpha1Api, CertificatesApi, CertificatesV1beta1Api, CoordinationApi, CoordinationV1Api, CoordinationV1beta1Api, CoreApi, CoreV1Api, CustomMetricsV1beta1Api, DiscoveryApi, DiscoveryV1beta1Api, EventsApi, EventsV1beta1Api, ExtensionsApi, ExtensionsV1beta1Api, FlowcontrolApiserverApi, FlowcontrolApiserverV1alpha1Api, LogsApi, MetricsV1beta1Api, NetworkingApi, NetworkingV1Api, NetworkingV1beta1Api, NodeApi, NodeV1alpha1Api, NodeV1beta1Api, PolicyApi, PolicyV1beta1Api, RbacAuthorizationApi, RbacAuthorizationV1Api, RbacAuthorizationV1alpha1Api, RbacAuthorizationV1beta1Api, SchedulingApi, SchedulingV1Api, SchedulingV1alpha1Api, SchedulingV1beta1Api, SettingsApi, SettingsV1alpha1Api, StorageApi, StorageV1Api, StorageV1alpha1Api, StorageV1beta1Api, VersionApi

export check_required, field_name, property_type, hasproperty, propertynames, validate_property, convert

end

ext: jl


text:
### A Pluto.jl notebook ###
# v0.14.8

using Markdown
using InteractiveUtils

# ╔═╡ 837951f4-68ec-11eb-048d-6b27b9055428
using Pkg, DrWatson

# ╔═╡ 91489170-68ec-11eb-3611-150d5febf223
begin
	using Distributions
	using StatsPlots
	using StatsBase
	using LaTeXStrings
	using CSV
	using DataFrames
	using LinearAlgebra
	using Random
	using ParetoSmoothedImportanceSampling
	using StanQuap
	using StatisticalRethinking
	using StatisticalRethinkingPlots
end

# ╔═╡ 7046ea12-68ec-11eb-18ae-a724ca79a21f
md" ## Clip-07-35s.jl"

# ╔═╡ ace5ed4c-68ec-11eb-05ed-1f1ff2d72e1b
begin
	df = CSV.read(sr_datadir("WaffleDivorce.csv"), DataFrame);
	scale!(df, [:Marriage, :MedianAgeMarriage, :Divorce])
end;

# ╔═╡ 4c47f312-68ed-11eb-37de-ff782118d258
stan5_1_t = "
data {
 int < lower = 1 > N; // Sample size
 vector[N] D; // Outcome
 vector[N] A; // Predictor
}

parameters {
 real a; // Intercept
 real bA; // Slope (regression coefficients)
 real < lower = 0 > sigma;    // Error SD
}

transformed parameters {
	vector[N] mu;
	mu = a + + bA * A;
}

model {
  a ~ normal( 0 , 0.2 );
  bA ~ normal( 0 , 0.5 );
  sigma ~ exponential( 1 );
  D ~ student_t( 2, mu , sigma );
}
generated quantities{
	vector[N] log_lik;
	for (i in 1:N)
		log_lik[i] = student_t_lpdf(D[i] | 2, mu[i], sigma);
}
";

# ╔═╡ 4c482dfa-68ed-11eb-2db9-a54ab816beb7
begin
	data = (N=size(df, 1), D=df.Divorce_s, A=df.MedianAgeMarriage_s,
		M=df.Marriage_s)
	m5_1s_t = SampleModel("m5.1s_t", stan5_1_t)
	rc5_1s_t = stan_sample(m5_1s_t; data)

	if success(rc5_1s_t)
		post5_1s_t_df = read_samples(m5_1s_t, :dataframe)
		PRECIS(post5_1s_t_df[:, [:a, :bA, :sigma]])
	end
end

# ╔═╡ 806d4352-69b7-11eb-00a5-791917fa9d45
if success(rc5_1s_t)
	nt5_1s_t = read_samples(m5_1s_t, :namedtuple)
	log_lik_1_t = nt5_1s_t.log_lik'
	waic_m5_1s_t = waic(log_lik_1_t)
end

# ╔═╡ 6210f1ba-68ef-11eb-1d55-653d1c8a147c
begin
    b5_1s_t = post5_1s_t_df[:, [:a, :bA, :sigma]]
    mu5_1s_t = b5_1s_t.a .+ b5_1s_t.bA * df.MedianAgeMarriage_s'
	lp5_1s_t = logpdf.(TDist(2), mu5_1s_t)
	waic(lp5_1s_t)
end

# ╔═╡ 3a9ff05e-6a16-11eb-2ba0-530fb4bc18f4
size(mu5_1s_t)

# ╔═╡ 8f107504-68ed-11eb-002b-372884f598b0
stan5_2_t = "
data {
  int N;
  vector[N] D;
  vector[N] M;
}
parameters {
  real a;
  real bM;
  real<lower=0> sigma;
}
transformed parameters {
	vector[N] mu;
	mu = a + bM * M;
}
model {
  a ~ normal( 0 , 0.2 );
  bM ~ normal( 0 , 0.5 );
  sigma ~ exponential( 1 );
  D ~ student_t( 2, mu , sigma );
}
generated quantities{
	vector[N] log_lik;
	for (i in 1:N)
		log_lik[i] = student_t_lpdf(D[i] | 2, mu[i], sigma);
}
";

# ╔═╡ cbb9ef56-68ed-11eb-387b-252ff6dc5b21
begin
	m5_2s_t = SampleModel("m5.2_t", stan5_2_t);
	rc5_2s_t = stan_sample(m5_2s_t; data)
	if success(rc5_2s_t)
		post5_2s_t_df = read_samples(m5_2s_t, :dataframe)
		PRECIS(post5_2s_t_df[:, [:a, :bM, :sigma]])
	end
end

# ╔═╡ 5d216004-69b7-11eb-34d4-8be76d4ae47c
if success(rc5_2s_t)
	nt5_2s_t = read_samples(m5_2s_t, :namedtuple)
	log_lik_2_t = nt5_2s_t.log_lik'
	waic_m5_2s_t = waic(log_lik_2_t)
end

# ╔═╡ 87cd0b48-68f2-11eb-3704-af5e98a9c463
begin
    b5_2s_t = post5_2s_t_df[:, [:a, :bM, :sigma]]
    mu5_2s_t = b5_2s_t.a .+ b5_2s_t.bM * df.Marriage_s'
	lp5_2s_t = logpdf.(TDist.(2), mu5_2s_t)
	waic(lp5_2s_t)
end

# ╔═╡ 71a48f7a-68ee-11eb-1b0e-331393e95551
stan5_3_t = "
data {
  int N;
  vector[N] D;
  vector[N] M;
  vector[N] A;
}
parameters {
  real a;
  real bA;
  real bM;
  real<lower=0> sigma;
}
transformed parameters {
	vector[N] mu;
	mu = a + + bA * A + bM * M;
}
model {
  a ~ normal( 0 , 0.2 );
  bA ~ normal( 0 , 0.5 );
  bM ~ normal( 0 , 0.5 );
  sigma ~ exponential( 1 );
  D ~ student_t( 2, mu , sigma );
}
generated quantities{
	vector[N] log_lik;
	for (i in 1:N)
		log_lik[i] = student_t_lpdf(D[i] | 2, mu[i], sigma);
}
";

# ╔═╡ b5b487ec-68ee-11eb-3ee7-0d98367028ff
begin
	m5_3s_t = SampleModel("m5.3_t", stan5_3_t);
	rc5_3s_t = stan_sample(m5_3s_t; data);

	if success(rc5_3s_t)
		post5_3s_t_df = read_samples(m5_3s_t, :dataframe)
		PRECIS(post5_3s_t_df[:, [:a, :bA, :bM, :sigma]])
	end
end

# ╔═╡ 4e7a00e8-69b4-11eb-15ef-df1a53282396
if success(rc5_3s_t)
	nt5_3s_t = read_samples(m5_3s_t, :namedtuple)
	log_lik_3_t = nt5_3s_t.log_lik'
	waic_m5_3s_t = waic(log_lik_3_t)
end

# ╔═╡ 51d570db-4ff0-49b4-b4c1-8e709a6b1564
nt5_3s_t

# ╔═╡ c2ba84b0-68f2-11eb-3c5a-17e03541dcb1
begin
    b5_3s_t = post5_3s_t_df[:, [:a, :bA, :bM, :sigma]]
    mu5_3s_t = b5_3s_t.a .+ b5_3s_t.bM * df.Marriage_s' +
		b5_3s_t.bA * df.MedianAgeMarriage_s'
	lp5_3s_t = logpdf.(TDist.(2), mu5_3s_t)
	waic(lp5_3s_t)
end

# ╔═╡ 7b051a2e-68f3-11eb-3ee8-e77c639fc390
[waic_m5_1s_t.WAIC, waic_m5_2s_t.WAIC, waic_m5_3s_t.WAIC]

# ╔═╡ ed4469dc-68f3-11eb-3b0f-f54305283306
begin
	loo5_1s_t, loos5_1s_t, pk5_1s_t = psisloo(log_lik_1_t)
	loo5_2s_t, loos5_2s_t, pk5_2s_t = psisloo(log_lik_2_t)
	loo5_3s_t, loos5_3s_t, pk5_3s_t = psisloo(log_lik_3_t)
	[-2loo5_1s_t, -2loo5_2s_t, -2loo5_3s_t]
end

# ╔═╡ 2c4b5ffc-68f4-11eb-21d6-7d2db834d3f8
begin
	pk_plot(pk5_1s_t)
	annotate!([(13 + 1, pk5_1s_t[13] + 0.02, Plots.text(df[13, :Loc],
		6, :red, :right))])
end

# ╔═╡ 3766d148-695b-11eb-19dc-0b25e6704b3d
begin
	waic_5_1s_pw_t = waic(lp5_1s_t; pointwise=true)
	scatter(pk5_1s_t, waic_5_1s_pw_t.penalty,
		xlab="PSIS Pareto k", ylab="WAIC penalty", leg=false)
	vline!([0.5])
	for state in [13, 20, 34, 44, 50]
		annotate!([([pk5_1s_t[state] + 0.02], [waic_5_1s_pw_t.penalty[state]],
			Plots.text(df[state, :Loc], 6, :red, :right))])
	end
	plot!()
end

# ╔═╡ aedb425c-68f4-11eb-319d-a958c2aacde1
begin
	pk_plot(pk5_3s_t)
	annotate!([(13 + 1, pk5_3s_t[13] + 0.02, Plots.text(df[13, :Loc],
		6, :red, :right))])
end

# ╔═╡ 75ce4e64-6958-11eb-333e-dbee637ecdf2
begin
	waic_5_3s_pw_t = waic(lp5_3s_t; pointwise=true)
	scatter(pk5_3s_t, waic_5_3s_pw_t.penalty,
		xlab="PSIS Pareto k", ylab="WAIC penalty", leg=false)
	vline!([0.5])
	for state in [13, 20, 34, 44, 50]
		annotate!([([pk5_3s_t[state] + 0.02], [waic_5_3s_pw_t.penalty[state]],
			Plots.text(df[state, :Loc], 6, :red, :right))])
	end
	plot!()
end

# ╔═╡ 8ec864f0-697d-11eb-029b-93e11b2e247b
waic_5_3s_pw_t

# ╔═╡ eb6b3ee8-697d-11eb-3380-a99e3c132720
pk5_3s_t

# ╔═╡ 5eae5f80-68f4-11eb-2d8e-5db775fbc1c9
pk_plot(pk5_2s_t)

# ╔═╡ 56735994-695b-11eb-28dd-21ff7dfa325d
begin
	waic_5_2s_pw_t = waic(lp5_2s_t; pointwise=true)
	scatter(pk5_2s_t, waic_5_2s_pw_t.penalty,
		xlab="PSIS Pareto k", ylab="WAIC penalty", leg=false)
	vline!([0.5])
	for state in [13, 20, 34, 44, 50]
		annotate!([([pk5_2s_t[state] + 0.01], [waic_5_2s_pw_t.penalty[state] + 0.01],
			Plots.text(df[state, :Loc], 6, :red, :right))])
	end
	plot!()
end

# ╔═╡ c3169ed8-694e-11eb-0616-97d25d8b56e1
md" ## End of clip-07-35s.jl"

# ╔═╡ Cell order:
# ╟─7046ea12-68ec-11eb-18ae-a724ca79a21f
# ╠═837951f4-68ec-11eb-048d-6b27b9055428
# ╠═91489170-68ec-11eb-3611-150d5febf223
# ╠═ace5ed4c-68ec-11eb-05ed-1f1ff2d72e1b
# ╠═4c47f312-68ed-11eb-37de-ff782118d258
# ╠═4c482dfa-68ed-11eb-2db9-a54ab816beb7
# ╠═806d4352-69b7-11eb-00a5-791917fa9d45
# ╠═6210f1ba-68ef-11eb-1d55-653d1c8a147c
# ╠═3a9ff05e-6a16-11eb-2ba0-530fb4bc18f4
# ╠═8f107504-68ed-11eb-002b-372884f598b0
# ╠═cbb9ef56-68ed-11eb-387b-252ff6dc5b21
# ╠═5d216004-69b7-11eb-34d4-8be76d4ae47c
# ╠═87cd0b48-68f2-11eb-3704-af5e98a9c463
# ╠═71a48f7a-68ee-11eb-1b0e-331393e95551
# ╠═b5b487ec-68ee-11eb-3ee7-0d98367028ff
# ╠═4e7a00e8-69b4-11eb-15ef-df1a53282396
# ╠═51d570db-4ff0-49b4-b4c1-8e709a6b1564
# ╠═c2ba84b0-68f2-11eb-3c5a-17e03541dcb1
# ╠═7b051a2e-68f3-11eb-3ee8-e77c639fc390
# ╠═ed4469dc-68f3-11eb-3b0f-f54305283306
# ╠═2c4b5ffc-68f4-11eb-21d6-7d2db834d3f8
# ╠═3766d148-695b-11eb-19dc-0b25e6704b3d
# ╠═aedb425c-68f4-11eb-319d-a958c2aacde1
# ╠═75ce4e64-6958-11eb-333e-dbee637ecdf2
# ╠═8ec864f0-697d-11eb-029b-93e11b2e247b
# ╠═eb6b3ee8-697d-11eb-3380-a99e3c132720
# ╠═5eae5f80-68f4-11eb-2d8e-5db775fbc1c9
# ╠═56735994-695b-11eb-28dd-21ff7dfa325d
# ╟─c3169ed8-694e-11eb-0616-97d25d8b56e1


text:
import SpecialFunctions: besselj, hankelh1

@testset "Particle types and constructors" begin
    ω = 0.4
    medium = Medium(ρ=10.,c=2.0+3.0im)
    p_dirichlet = Specie(0.0,0.1) # ρ=0.0, r =0.1
    p_neumann = Specie(Inf,0.1) # ρ=0.0, r =0.1
    Z_dirichlet = Zn(ω, p_dirichlet, medium, 0)
    Z_neumann   = Zn(ω, p_neumann, medium, 0)
    @test Z_dirichlet == besselj(0, 0.1*ω/medium.c)/hankelh1(0, 0.1*ω/medium.c)
    @test Z_neumann == besselj(1, 0.1*ω/medium.c)/hankelh1(1, 0.1*ω/medium.c)

    medium = Medium(ρ=0.,c=2.0+3.0im)
    @test_throws ErrorException Zn(ω, p_dirichlet, medium, 0)
    @test Z_neumann == Zn(ω, p_neumann, medium, 0)

    f_tmp(x,y; kws...) = 0.0
    @test gray_square(rand(10),rand(10), f_tmp) == 0.0
end


text:
module Pi

using DataFrames
using CSV

export readPiFile

struct ModelANDParents
   relation::Any
   parents::Any
end

struct ModelORParents
   relation::Any
   posParents::Any
   negParents::Any
end

struct PIparents
   andPosParents::Array
   andNegParents::Array
   orPosParents::Array
   orNegParents::Array
end

# Assumptions:
## If there is only one parent it will be an AND relation

function readFile(fname)
    df = CSV.read(fname,
                  delim="\t",
                  header=["parentName", "childName", "posneg", "andor"],
                  types=[String, String, Int, Int])

    PIs = Dict{AbstractString,Any}()

    for row in eachrow(df)
        posnegbool = row[:posneg] == 1 ? true : false
        andBool = row[:andor] == 0 ? true : false
        if haskey(PIs, row[:childName])
            if posnegbool
                parents = andBool ?
                             PIs[row[:childName]].andPosParents :
                             PIs[row[:childName]].orPosParents
            else
                parents = andBool ?
                             PIs[row[:childName]].andNegParents :
                             PIs[row[:childName]].orNegParents
            end
            push!(parents, row[:parentName])
        else
            posParents = AbstractString[]
            negParents = AbstractString[]
            if posnegbool
                push!(posParents, row[:parentName])
            else
                push!(negParents, row[:parentName])
            end

            node = PIparents(andBool ? posParents : AbstractString[],
                             andBool ? negParents : AbstractString[],
                             andBool ? AbstractString[] : posParents,
                             andBool ? AbstractString[] : negParents)
            PIs[row[:childName]] = node
        end
    end

    for row in eachrow(df)
        if !haskey(PIs, row[:parentName])
            PIs[row[:parentName]] = PIparents(AbstractString[],AbstractString[],AbstractString[],AbstractString[])
        end
    end

    nodes = Dict{AbstractString,Any}()
    for nodeName in keys(PIs)
        parents = PIs[nodeName].andPosParents
        if (length(PIs[nodeName].andPosParents) + length(PIs[nodeName].andNegParents)) == 0
            if (length(PIs[nodeName].orPosParents) + length(PIs[nodeName].orNegParents)) > 0
                nodes[nodeName] = ModelORParents("OR", PIs[nodeName].orPosParents, PIs[nodeName].orNegParents)
            else
                nodes[nodeName] = ModelANDParents("ROOT", parents)
            end
        else
            if (length(PIs[nodeName].orPosParents) + length(PIs[nodeName].orNegParents)) > 0
                orNodeName = string(nodeName, "_OR")
                nodes[orNodeName] = ModelORParents("OR", PIs[nodeName].orPosParents, PIs[nodeName].orNegParents)
                push!(parents, orNodeName)
            end

            if ((length(PIs[nodeName].andNegParents) > 1) && (length(parents) == 0))
                pseudoParent = "PSEUDONODE_PARENT_$nodeName"
                push!(PIs[nodeName].andPosParents, pseudoParent)
                nodes[pseudoParent] = ModelANDParents("ROOT", AbstractString[])
                parents = PIs[nodeName].andPosParents
            end

            negParents = PIs[nodeName].andNegParents
            if length(parents) == 1 && length(negParents) == 1
                nodes[nodeName] = ModelANDParents("ANDNEG", union(parents, negParents))
            elseif length(parents) == 0 && length(negParents) == 1
                nodes[nodeName] = ModelANDParents("NEG", negParents)
            elseif length(parents) == 1 && length(negParents) == 0
                nodes[nodeName] = ModelANDParents("AND", parents)
            else
               pseudonodeIndex = 1
               childNodeName = parents[1]
               for i = 2:length(parents)
                   parenti = parents[i]
                   if length(negParents) == 0 && i == length(parents)
                       nodes[nodeName]= ModelANDParents("AND", AbstractString[childNodeName, parenti])
                       continue
                   else
                       newChildNodeName = string(childNodeName, "_PSEUDONODE_", parenti)
                       nodes[newChildNodeName]= ModelANDParents("AND", AbstractString[childNodeName, parenti])
                       childNodeName = newChildNodeName
                   end
               end

               for i = 1:length(negParents)
                   parenti = negParents[i]
                   if i == length(negParents)
                       nodes[nodeName]= ModelANDParents("ANDNEG", AbstractString[childNodeName, parenti])
                   else
                       newChildNodeName = string(childNodeName, "_PSEUDONODE_", parenti)
                       nodes[newChildNodeName]= ModelANDParents("ANDNEG", AbstractString[childNodeName, parenti])
                       childNodeName = newChildNodeName
                   end
               end
            end
        end

    end

    return nodes
end

end

max_stars_repo_name: OICR/mp-biopath

max_issues_repo_name: OICR/mp-biopath

max_forks_repo_name: OICR/mp-biopath


text:
using Sesam
using ModelingToolkit, DifferentialEquations

# see test_sesam for constructing and solving the system

using Plots
plot(sol, vars=[s.L,s.B])
plot(sol, vars=[s.I_N])
plot(sol)
# syn_B is the minimum of C_synBC and C_synBN
plot(sol, vars=[s.C_synBC, s.C_synBN, s.syn_B])
plot(sol, vars=[s.β_NR])

plot(sol, vars=[s.α_LT,s.α_RT, s.α_LT+s.α_RT])
plot(sol, vars=[s.revenue_L,s.revenue_R])
plot(sol, vars=[s.lim_C, s.lim_N])

# --------- why is R accumulating despite N limitation?
sol[s.u_PlantNmax]

# B is C limited
plot(sol, vars=[s.Φ_N, s.Φ_Nu, s.Φ_NB, s.Φ_Ntvr])
plot(sol, vars=[s.Φ_NB])
plot(sol, vars=[s.u_PlantN, s.u_PlantNmax])
# entire flux by tvr and u is taken up by plant
# only after R stocks increase towards a steady-state, enough replenishment
plot(sol, vars=[s.dec_L/s.β_NL, s.dec_R/s.β_NR])
#
plot(sol, vars=[s.dec_R, s.dec_RPot]) # negative dec_R?
plot(sol, vars=[s.α_R * s.syn_Enz]) # negative dec_R?
#plot(sol, vars=[s.α_R, s.α_RT, s.α_L, s.α_LT]) # negative dec_R?
plot(sol, vars=[s.α_R, s.α_L]) # other pools than R near steady-state, slowly accumulating, with it shifting towards its decomposition

Dict(p)[i_L]
# total C stock equals input
#plot(sol, vars=[R + L + B + cumresp])
#plot!(t -> Dict(p)[i_L]*t + sum(getindex.(Ref(Dict(u0)),[B,L,R])))
# biomass C balance
# plot(sol, tspan=(0.0,2.0), vars=[u_C, r_B+syn_B+syn_Enz])
# plot(sol,  vars=[s.u_C, s.r_B+s.syn_B+syn_Enz])
#
# biomass N balance
 plot(sol, tspan=(0.0,2.0), vars=[u_NOM, r_B+syn_B+syn_Enz])
# plot(sol,  vars=[u_C, r_B+syn_B+syn_Enz])


text:
mutable struct ElementaryPathLPSolver <: ElementaryPathSolver
  graph::SimpleDiGraph
  source::Int
  destination::Int

  solver

  # Optimisation model (reused by solve_linear).
  model # ::Model
  x # ::Vector{Variable}: index is edge

  function ElementaryPathLPSolver(solver)
    return new(DiGraph(0), -1, -1, solver, nothing, nothing)
  end
end

function _elementary_path_lazy_callback(solver::ElementaryPathLPSolver, cb_data)
  # Based on the hypothesis that the strengthening constraints have been added beforehand!
  # I.e. at most one edge incoming and at most one outgoing (except for source/destination).
  x = Dict(e => callback_value(cb_data, solver.x[e]) for e in edges(solver.graph))

  # Helper methods.
  inedges(g, v) = (edgetype(g)(x, v) for x in inneighbors(g, v))
  outedges(g, v) = (edgetype(g)(v, x) for x in outneighbors(g, v))

  # Find a subtour.
  current_node = solver.source # TODO: factor this loop out? Also useful for sorting edges.
  while current_node != solver.destination
    # Only one outgoing edge from the current node, as per the constraints.
    for e in outedges(solver.graph, current_node)
      if x[e] >= .5
        x[e] = 0.0
        current_node = dst(e)
        break
      end
    end
  end

  # Find the edges that remain after the path is removed.
  lhs_edges = Edge[]
  for e in edges(solver.graph)
    # Don't consider edges adjacent to the source or the destination
    if src(e) == solver.source || dst(e) == solver.destination
      continue
    end

    if x[e] >= .5
      push!(lhs_edges, e)
    end
  end

  # Nothing left? No subtour!
  if length(lhs_edges) == 0
    return
  end

  # Add lazy constraints (subtour elimination). Separate all subtours to generate constraints
  # as tight as possible.
  while length(lhs_edges) > 0
    # Find one subtour among these edges.
    con_edges = Edge[lhs_edges[1]]
    cur_node = dst(lhs_edges[1])
    while cur_node != src(lhs_edges[1])
      for (i, e) in enumerate(lhs_edges)
        if src(e) == cur_node
          cur_node = dst(e)
          push!(con_edges, e)
          deleteat!(lhs_edges, i)
        end
      end
    end

    # Build the corresponding constraint.
    con = @build_constraint(sum(x[e] for e in con_edges) <= length(con_edges) - 1)
    MOI.submit(solver.model, MOI.LazyConstraint(cb_data), con)
  end
end

function build!(solver::ElementaryPathLPSolver, graph::SimpleDiGraph, source::Int, destination::Int)
  n = nv(graph)
  solver.graph = graph
  solver.source = source
  solver.destination = destination

  # Helper methods.
  inedges(g, v) = (edgetype(g)(x, v) for x in inneighbors(g, v))
  outedges(g, v) = (edgetype(g)(v, x) for x in outneighbors(g, v))

  other_nodes = collect(filter(vertices(solver.graph)) do v; v != source && v != destination; end)

  # Build the optimisation model behind solve_linear.
  solver.model = Model(solver.solver)
  solver.x = @variable(solver.model, [e in edges(solver.graph)], binary=true)
  # Normally, with this formulation, explicitly having binary variables is not necessary,
  # but this is only valid if minimising a linear function. In all other cases, there is
  # no guarantee to have an integer-feasible solution.

  for e in edges(solver.graph)
    set_name(solver.x[e], "x_$(src(e))_$(dst(e))")
  end

  function edge_incidence(v)
    if length(inedges(solver.graph, v)) > 0
      ins = sum(solver.x[e] for e in inedges(solver.graph, v))
    else
      ins = 0.0
    end

    if length(outedges(solver.graph, v)) > 0
      outs = sum(solver.x[e] for e in outedges(solver.graph, v))
    else
      outs = 0.0
    end

    return ins - outs
  end

  @constraint(solver.model, edge_incidence(source) == -1)
  @constraint(solver.model, edge_incidence(destination) == 1)
  @constraint(solver.model, [v in other_nodes], edge_incidence(v) == 0)

  # # Eliminate a large number of subtours.
  @constraint(solver.model, sum(solver.x[e] for e in inedges(solver.graph, source)) == 0)
  @constraint(solver.model, sum(solver.x[e] for e in outedges(solver.graph, source)) == 1)
  @constraint(solver.model, sum(solver.x[e] for e in inedges(solver.graph, destination)) == 1)
  @constraint(solver.model, sum(solver.x[e] for e in outedges(solver.graph, destination)) == 0)
  for v in other_nodes
    @constraint(solver.model, sum(solver.x[e] for e in inedges(solver.graph, v)) <= 1)
    @constraint(solver.model, sum(solver.x[e] for e in outedges(solver.graph, v)) <= 1)
  end

  # Set the lazy-constraint callback to ensure the solution is always an elementary path.
  set_parameter(solver.model, "LazyConstraints", 1) # TODO: only works with Gurobi.
  MOI.set(solver.model, MOI.LazyConstraintCallback(), cb_data -> _elementary_path_lazy_callback(solver, cb_data))
end

has_lp_formulation(::ElementaryPathLPSolver) = true

function get_lp_formulation(solver::ElementaryPathLPSolver, reward::Dict{Tuple{Int, Int}, Float64})
  return solver.model,
    sum(reward[(i, j)] * solver.x[Edge(i, j)] for (i, j) in keys(reward)),
    Dict{Tuple{Int, Int}, JuMP.VariableRef}((i, j) => solver.x[Edge(i, j)] for (i, j) in keys(reward))
end

function _sort_path(path::Vector{Tuple{Int, Int}}, source::Int, destination::Int, n_vertices::Int)
  sorted = Tuple{Int, Int}[]
  current_node = source
  edges = copy(path)

  i = 0
  while length(edges) > 0
    # Find the corresponding edge (or the first one that matches).
    for i in 1:length(edges)
      e = edges[i]
      if e[1] == current_node
        push!(sorted, e)
        current_node = e[2]
        deleteat!(edges, i)
        break
      end
    end

    if current_node == destination
      break
    end

    # Safety: ensure this loop does not make too many iterations.
    i += 1
    if i > n_vertices
      error("Assertion failed: infinite loop when sorting the edges of the path $path")
    end
  end

  if length(edges) > 0
    error("Edges remaining after sorting the edges: the solution is likely to contain at least a subtour, $edges")
  end

  return sorted
end

function solve_linear(solver::ElementaryPathLPSolver, reward::Dict{Tuple{Int, Int}, Float64})
  m, obj, vars = get_lp_formulation(solver, reward)
  @objective(m, Max, obj)

  set_silent(m)
  optimize!(m)

  if termination_status(m) != MOI.OPTIMAL
    return Tuple{Int, Int}[]
  end
  sol = Tuple{Int, Int}[(i, j) for (i, j) in keys(reward) if value(vars[i, j]) > 0.5]
  return _sort_path(sol, solver.source, solver.destination, nv(solver.graph))
end

function solve_budgeted_linear(solver::ElementaryPathLPSolver,
                               reward::Dict{Tuple{Int, Int}, Float64},
                               weight::Dict{Tuple{Int, Int}, T},
                               budget::Int) where {T<:Number} # Handle both Int and Float64
  m, obj, vars = get_lp_formulation(solver, reward)
  @objective(m, Max, obj)

  # Add the budget constraint (or change the existing constraint).
  if :ElementaryPathLP in keys(m.ext)
    budget_constraint = m.ext[:ElementaryPathLP][:budget_constraint]
    set_normalized_rhs(budget_constraint, budget)
  else
    budget_constraint = @constraint(m, sum(weight[i] * vars[i] for i in keys(reward)) >= budget)
    m.ext[:ElementaryPathLP] = Dict(:budget_constraint => budget_constraint)
  end

  set_silent(m)
  optimize!(m)

  if termination_status(m) != MOI.OPTIMAL
    return Tuple{Int, Int}[]
  end

  sol = Tuple{Int, Int}[(i, j) for (i, j) in keys(reward) if value(vars[i, j]) > 0.5]
  return _sort_path(sol, solver.source, solver.destination, nv(solver.graph))
end


text:
# Whitening

## Solve whitening based on covariance
#
# finds W, such that W'CW = I
#
function cov_whitening(C::Cholesky{T}) where {T<:Real}
    cf = C.UL
    Matrix{T}(inv(istriu(cf) ? cf : cf'))
end

cov_whitening!(C::DenseMatrix{<:Real}) = cov_whitening(cholesky!(Hermitian(C, :U)))
cov_whitening(C::DenseMatrix{<:Real}) = cov_whitening!(copy(C))

cov_whitening!(C::DenseMatrix{<:Real}, regcoef::Real) = cov_whitening!(regularize_symmat!(C, regcoef))
cov_whitening(C::DenseMatrix{<:Real}, regcoef::Real) = cov_whitening!(copy(C), regcoef)

## Whitening type

struct Whitening{T<:Real}
    mean::Vector{T}
    W::Matrix{T}

    function Whitening{T}(mean::Vector{T}, W::Matrix{T}) where {T<:Real}
        d, d2 = size(W)
        d == d2 || error("W must be a square matrix.")
        isempty(mean) || length(mean) == d ||
        throw(DimensionMismatch("Sizes of mean and W are inconsistent."))
        return new(mean, W)
    end
end
Whitening(mean::Vector{T}, W::Matrix{T}) where {T<:Real} = Whitening{T}(mean, W)

indim(f::Whitening) = size(f.W, 1)
outdim(f::Whitening) = size(f.W, 2)
mean(f::Whitening) = fullmean(indim(f), f.mean)

transform(f::Whitening, x::AbstractVecOrMat) = transpose(f.W) * centralize(x, f.mean)

## Fit whitening to data

function fit(::Type{Whitening}, X::DenseMatrix{T};
             mean=nothing, regcoef::Real=zero(T)) where {T<:Real}
    n = size(X, 2)
    n > 1 || error("X must contain more than one sample.")
    mv = preprocess_mean(X, mean)
    Z = centralize(X, mv)
    C = rmul!(Z * transpose(Z), one(T) / (n - 1))
    return Whitening(mv, cov_whitening!(C, regcoef))
end

# invsqrtm

function _invsqrtm!(C::Matrix{<:Real})
    n = size(C, 1)
    size(C, 2) == n || error("C must be a square matrix.")
    E = eigen!(Symmetric(C))
    U = E.vectors
    evs = E.values
    for i = 1:n
        @inbounds evs[i] = 1.0 / sqrt(sqrt(evs[i]))
    end
    rmul!(U, Diagonal(evs))
    return U * transpose(U)
end

invsqrtm(C::DenseMatrix{<:Real}) = _invsqrtm!(copy(C))


text:
# This file was generated by the Julia Swagger Code Generator
# Do not modify this file directly. Modify the swagger specification instead.

mutable struct StorageAccountCheckNameAvailabilityParameters <: SwaggerModel
    name::Any # spec type: Union{ Nothing, String } # spec name: name
    type::Any # spec type: Union{ Nothing, String } # spec name: type

    function StorageAccountCheckNameAvailabilityParameters(;name=nothing, type=nothing)
        o = new()
        validate_property(StorageAccountCheckNameAvailabilityParameters, Symbol("name"), name)
        setfield!(o, Symbol("name"), name)
        validate_property(StorageAccountCheckNameAvailabilityParameters, Symbol("type"), type)
        setfield!(o, Symbol("type"), type)
        o
    end
end # type StorageAccountCheckNameAvailabilityParameters

const _property_map_StorageAccountCheckNameAvailabilityParameters = Dict{Symbol,Symbol}(Symbol("name")=>Symbol("name"), Symbol("type")=>Symbol("type"))
const _property_types_StorageAccountCheckNameAvailabilityParameters = Dict{Symbol,String}(Symbol("name")=>"String", Symbol("type")=>"String")
Base.propertynames(::Type{ StorageAccountCheckNameAvailabilityParameters }) = collect(keys(_property_map_StorageAccountCheckNameAvailabilityParameters))
Swagger.property_type(::Type{ StorageAccountCheckNameAvailabilityParameters }, name::Symbol) = Union{Nothing,eval(Meta.parse(_property_types_StorageAccountCheckNameAvailabilityParameters[name]))}
Swagger.field_name(::Type{ StorageAccountCheckNameAvailabilityParameters }, property_name::Symbol) =  _property_map_StorageAccountCheckNameAvailabilityParameters[property_name]

const _allowed_StorageAccountCheckNameAvailabilityParameters_type = ["Microsoft.Storage/storageAccounts"]

function check_required(o::StorageAccountCheckNameAvailabilityParameters)
    (getproperty(o, Symbol("name")) === nothing) && (return false)
    true
end

function validate_property(::Type{ StorageAccountCheckNameAvailabilityParameters }, name::Symbol, val)
    if name === Symbol("type")
        Swagger.validate_param(name, "StorageAccountCheckNameAvailabilityParameters", :enum, val, _allowed_StorageAccountCheckNameAvailabilityParameters_type)
    end
end


text:
"""
Using given mask to export roi of cell
"""
function export_cell(track, imgs, edge_mask)
    height, width = size(imgs[:,:,1]);
    crop_img = zeros(700, 700, length(track)*20);
    for t in 1:length(track)
        x, y = Int.(floor.(track[t]));
        xmin, xmax, ymin, ymax = x-349 , x+350,  y-349, y+350
        if xmin < 1
            xmax = xmax - xmin + 1
            xmin = 1
        end
        if xmax > 1900
            xmin = xmin - (xmax-1900)
            xmax = 1900
        end
        if ymin < 1
            ymax = ymax - ymin +1
            ymin = 1
        end
        if ymax > 1300
            ymin = ymin - (ymax-1300)
            ymax = 1300
        end
        masked_cell= (edge_mask[:,:,t] .== edge_mask[x, y, t] )
        for i in 1:20
            crop_img[:,:,20*(t-1)+i] =(masked_cell.*imgs[:,:,20*(t-1)+i])[xmin:xmax, ymin:ymax]
        end
    end
    crop_img;
end

# TODO: run again and again until best fitting
"""
Extract nucleus from sperated cell
"""
function extract_nucleus( img, watershed_segments::SegmentedImage{Array{Int64,2},Float64} )
    img_clear = zeros(N0f16, size(watershed_segments.image_indexmap));
    img_blur = imfilter(img, Kernel.gaussian(9));
    for label in watershed_segments.segment_labels
        cell = img_blur .* (watershed_segments.image_indexmap .== label);
        # only select 70% brigter region or fixed area
        gmm = GMM(3, [pixel for pixel in real(cell) if pixel > 1e-5]);
        nucleus_th = sort(gmm.μ, dims=1)[end-1];
        img_clear .+= ( remove_small_area(cell .> nucleus_th)) .*img;
    end
    img_clear;
end#
"""
Choose cloest neighborhood
"""
function find_nearest(root, next_level, maxdistance)
    nucleus_distance = [sum(abs.(root .- next_level[i])) for i in 1:length(next_level)]
    mindist, mindist_index = findmin(nucleus_distance);
    if mindist < maxdistance
        return mindist_index
    else
        return nothing
    end
end

"""
Find every child with given root
"""
function buildtree(root::Int, position)
    tree = []
    height = length(position)
    level = 2
    child = find_nearest(position[1][root], position[level], 100);
    while( child ≠ nothing && level<height)
        push!(tree, child)
        child = find_nearest(position[level][child], position[level+=1], 100)
        #print("$level ")
    end
    tree
end

"""
Extract long-life path
"""
function generate_path(pos_map)
    all_path = []
    for root in 1:length(pos_map[1])
        tree = buildtree(root, pos_map);
        if length(tree) > 70
            path = [pos_map[i+1][tree[i]] for i in 1:length(tree) ];
            push!(all_path, path)
        end
    end
    all_path;
end


text:
# ===== VSB Verifications: Velocity Profiles =====

println("=== BEGINNING Verifications4.jl ===")

# === Imports ===
println("   IMPORTING PACKAGES...")
using VSB
using Plots
pyplot()

cd("/Users/Damyn/Documents/BYU/FLOW Lab/VSB/verifications")

# === Geomerty of problem ===
println("   GENERATING GEOMETRY...")
NPTS = 250                              # Number of Points on Boundary
del_theta = (2*pi)/(NPTS - 1)           # Step in theta around body
R = 1.0                                 # Cylinder Radius
X_coor = zeros(NPTS)                    # X-coordinates
Y_coor = zeros(NPTS)                    # Y-coordinates
X_tHat = zeros(NPTS)                    # X Tangent Vector
Y_tHat = zeros(NPTS)                    # X Tangent Vector
X_nHat = zeros(NPTS)                    # Y Normal Vector
Y_nHat = zeros(NPTS)                    # Y Normal Vector
theta = zeros(NPTS)                     # Angle from positive X-axis
for i=1:NPTS
    X_coor[i] = R*cos((i-1)*del_theta)
    Y_coor[i] = R*sin((i-1)*del_theta)

    X_tHat[i] = sin((i-1)*del_theta)
    Y_tHat[i] = -cos((i-1)*del_theta)

    X_nHat[i] = cos((i-1)*del_theta)
    Y_nHat[i] = sin((i-1)*del_theta)

    theta[i] = (i-1)*del_theta
end
body_pts = [[X_coor[i], Y_coor[i], 0.0] for i in 1:NPTS]
t_hats = [[X_tHat[i], Y_tHat[i], 0.0] for i in 1:NPTS]
n_hats = [[X_nHat[i], Y_nHat[i], 0.0] for i in 1:NPTS]
body = VSB.Boundary(body_pts,t_hats,n_hats)

# === Vortex sheet calculations ===
println("   CALCULATING PROBLEM PARAMETERS...")
magU_inf = 1.0
U_inf(X) = magU_inf .* [1.0, 0.0, 0.0]

params = VSB.Parameters(body, U_inf)
alphas = params.alphas
U(X) = VSB.CalcVSVelocityCirlce(body, alphas, X)

# === Generate velocity field ===
println("   CALCULATING VELOCITY FIELD...")

println("=== END OF Verifications1.jl ===")


text:
"""
    struct LinearImpurityDensity{T <: SSDFloat} <: AbstractImpurityDensity{T}

Impurity density model which assumes a linear gradient in impurity density in each dimension of a Cartesian coordinate system.

## Fields
* `offsets::NTuple{3,T}`: impurity density values at the origin of each dimension.
* `gradients::NTuple{3,T}`: linear slopes in `x`, `y` and `z` direction.

## Definition in Configuration File

A `LinearImpurityDensity` is defined in the configuration file through the field `impurity_density`
(of a `passive` or `surrounding`) with `name: linear` and optional fields `x`, `y` and `z`
that can each contain `init` for initial values at 0 and `gradient` for gradients in that dimension.

An example definition of a linear impurity density looks like this:
```yaml
impurity_density:
  name: cylindrical
  x:  # impurity profile with linear gradient in x
    init: 1.0e10     # 1/m³
    gradient: 1.0e11 # 1/m⁴
```
"""
struct LinearImpurityDensity{T <: SSDFloat} <: AbstractImpurityDensity{T}
    offsets::NTuple{3, T}
    gradients::NTuple{3, T}
end

function ImpurityDensity(T::DataType, t::Val{:linear}, dict::Union{Dict{String, Any}, Dict{Any, Any}}, input_units::NamedTuple)
    offsets, gradients = zeros(T,3), zeros(T,3)
    density_unit = input_units.length^(-3)
    density_gradient_unit = input_units.length^(-4)
    if prod(map(k -> k in ["x","y","z"], collect(keys(dict)))) @warn "Only x, y and z are supported in the linear impurity density model.\nChange the impurity density model in the config file or remove all other entries." end
    if haskey(dict, "x")
        if haskey(dict["x"], "init")     offsets[1]   = _parse_value(T, dict["x"]["init"], density_unit) end
        if haskey(dict["x"], "gradient") gradients[1] = _parse_value(T, dict["x"]["gradient"], density_gradient_unit) end
    end
    if haskey(dict, "y")
        if haskey(dict["y"], "init")     offsets[2]   = _parse_value(T, dict["y"]["init"], density_unit) end
        if haskey(dict["y"], "gradient") gradients[2] = _parse_value(T, dict["y"]["gradient"], density_gradient_unit) end
    end
    if haskey(dict, "z")
        if haskey(dict["z"], "init")     offsets[3]   = _parse_value(T, dict["z"]["init"], density_unit) end
        if haskey(dict["z"], "gradient") gradients[3] = _parse_value(T, dict["z"]["gradient"], density_gradient_unit) end
    end
    LinearImpurityDensity{T}( NTuple{3, T}(offsets), NTuple{3, T}(gradients) )
end

function get_impurity_density(lcdm::LinearImpurityDensity{T}, pt::AbstractCoordinatePoint{T})::T where {T <: SSDFloat}
    pt::CartesianPoint{T} = CartesianPoint(pt)
    ρ::T = 0
    for i in eachindex(lcdm.offsets)
        ρ += (lcdm.offsets[i] + pt[i] * lcdm.gradients[i]) #* T(1e16) # * T(1e10) * T(1e6) -> 1/cm^3 -> 1/m^3
    end
    return ρ
end


text:
#function image_func(M::Map)
#  return M.header.image
#end
#
#function preim_func(M::Map)
#  return M.header.preim
#end

function show(io::IO, M::Map)
  @show_name(io, M)
  if get(io, :compact, false)
    print(io, domain(M), " --> ", codomain(M), "\n")
    return
  end
  io = Base.IOContext(io, :compact => true)
  print(io, "Map with following data\n")
  print(io, "Domain:\n")
  print(io, "=======\n")
  print(io, domain(M))
  print(io, "\nCodomain:\n")
  print(io, "=========\n")
  print(io, codomain(M))
  print(io, "\n")
end

function preimage(M::Map{D, C}, a) where {D, C}
  if isdefined(M.header, :preimage)
    p = M.header.preimage(a)::elem_type(D)
    @assert parent(p) === domain(M)
    return p
  end
  error("No preimage function known")
end

function image(M::Map{D, C}, a) where {D, C}
  if isdefined(M, :header)
    if isdefined(M.header, :image)
      return M.header.image(a)::elem_type(C)
    else
      error("No image function known")
    end
  else
    return M(a)
  end
end

function show(io::IO, M::InverseMap)
  @show_name(io, M)
  println(io, "inverse of")
  println(io, " ", M.origin)
end

function pseudo_inv(a::Map)
  return InverseMap(a)
end

#function show(io::IO, M::CoerceMap)
#  println(io, "Coerce: $(domain(M)) -> $(codomain(M))")
#end

\(f::Map, x) = preimage(f, x)

function change(D::Dict{K, V}, k::K, def::V, new::Function) where {K, V}
  i = Base.ht_keyindex2!(D, k)
  if i>0
    D.vals[i] = new(D.vals[i])
  else
    pos = -i
    D.keys[pos] = k
    D.vals[pos] = def
    D.count += 1
    if pos < D.idxfloor
      D.idxfloor = pos
    end
    D.slots[pos] = 0x1
  end
  return nothing
end

function inc(D::Dict{K, Int}, k::K, def::Int = 0) where K
  i = Base.ht_keyindex2!(D, k)
  if i>0
    D.vals[i] += 1
  else
    pos = -i
    D.keys[pos] = k
    D.vals[pos] = def
    D.count += 1
    if pos < D.idxfloor
      D.idxfloor = pos
    end
    D.slots[pos] = 0x1
  end
  return nothing
end

function _allow_cache!(M::Map, lim::Int, ::Type{D}, ::Type{C}, ::Type{De}, ::Type{Ce}) where {D, C, De, Ce}
  if isdefined(M.header, :cache)
#    println("Cache already installed")
  else
    M.header.cache = MapCache(domain(M), codomain(M), De, Ce, lim)
    M.header.cache.old_pr = M.header.preimage
    M.header.cache.old_im = M.header.image
  end

  if length(methods(M.header.image)) > 1
    println("Cannot do image cache, too many types")
  else
    function im(a::De)
      if haskey(M.header.cache.im, a)
        inc(M.header.cache.imStat, a)
        return M.header.cache.im[a]::Ce
      else
        b = M.header.cache.old_im(a)::Ce
        M.header.cache.im[a] = b
        M.header.cache.imStat[a] = 0
        return b
      end
    end
    M.header.image = im
  end

  if length(methods(M.header.preimage)) > 1
    println("Cannot do preimage cache, too many types")
  else
    function pr(a::Ce)
      i = Base.ht_keyindex(M.header.cache.pr, a)
      if i >= 0
        inc(M.header.cache.prStat, a)
        return M.header.cache.pr.vals[i]::De
      else
        b = M.header.cache.old_pr(a)::De
        M.header.cache.pr[a] = b
        M.header.cache.prStat[a] = 0
        return b
      end
    end
    M.header.preimage = pr
  end
  nothing
end

function allow_cache!(M::T, lim::Int = 100) where T <: Map
  return _allow_cache!(M, lim, typeof(domain(M)), typeof(codomain(M)), elem_type(domain(M)), elem_type(codomain(M)))
end

function stop_cache!(M::T) where T <: Map
  if isdefined(M.header, :cache)
    M.header.image = M.header.cache.old_im
    M.header.preimage = M.header.cache.old_pr
  end
  nothing
end


text:
using Pkg.TOML

# Fix the NPM version for now
# Now that we're not distributing Jupyter stuff via NPM, I'd rather just check
# in compiled assets (maybe using Artifacts if that's relatively easy, otherwise
# just as files in git).
const WEBIO_VERSION = "0.8.15"

const PACKAGES_PATH = normpath(joinpath(@__DIR__, "..", "packages"))
const BUNDLES_PATH = normpath(joinpath(@__DIR__, "bundles"))

function bundleurl(pkg::String, filename::String)
    return "https://unpkg.com/@webio/$(pkg)@$(WEBIO_VERSION)/dist/$(filename)"
end

const CORE_BUNDLE_PATH = joinpath(BUNDLES_PATH, "webio.bundle.js")
const CORE_BUNDLE_URL = bundleurl("webio", "webio.bundle.js")
const GENERIC_HTTP_BUNDLE_PATH = joinpath(BUNDLES_PATH, "generic-http.bundle.js")
const GENERIC_HTTP_BUNDLE_URL = bundleurl("generic-http-provider", "generic-http.bundle.js")
const MUX_BUNDLE_PATH = joinpath(BUNDLES_PATH, "mux.bundle.js")
const MUX_BUNDLE_URL = bundleurl("mux-provider", "mux.bundle.js")

# Deprecated! Remove for WebIO version 1.0.0
const BLINK_BUNDLE_PATH = joinpath(BUNDLES_PATH, "blink.bundle.js")
const BLINK_BUNDLE_URL = bundleurl("blink-provider", "blink.bundle.js")

function download_bundle(name::String, path::String, url::String)
    if !isfile(path)
        @info "Downloading WebIO $(name) bundle from unpkg..."
        download(url, path)
    end
end

# TODO: this is all an ugly hack to avoid trying to build JS when other packages (that use WebIO)
# are just trying to run their own tests. It desperately needs to be restructured.
function isci()
    return (
        get(ENV, "CI", "false") == "true" &&
        split(get(ENV, "GITHUB_REPOSITORY", "Foo/Bar.jl"), '/')[2] == "WebIO.jl"
    )
end

function download_js_bundles()
    if isci()
        # In CI, we always build the bundles from scratch.
        @info "Not downloading WebIO bundles in CI; building instead..."
        include("./_bundlejs.jl")
        return
    end

    mkpath(BUNDLES_PATH)
    download_bundle("core", CORE_BUNDLE_PATH, CORE_BUNDLE_URL)
    download_bundle("generic-http", GENERIC_HTTP_BUNDLE_PATH, GENERIC_HTTP_BUNDLE_URL)
    download_bundle("mux", MUX_BUNDLE_PATH, MUX_BUNDLE_URL)
    download_bundle("blink", BLINK_BUNDLE_PATH, BLINK_BUNDLE_URL)
end


text:
import Dates
import SHA

################
# NSCode
################

struct NSCode <: AbstNSCode
    __args::Tuple{Vararg{Symbol}}
    __kargs
    __code::Array{Tuple{Symbol,Any},1}
    __type
    __instances
    __link_instances::Bool
    __init::Array{Union{Nothing, NSTagFunc{:mth}}}
    __cls::NS
    _instances::Nothing
    _clr_instances::Nothing

    NSCode(args...; __link_instances=false, kargs...) =
        new(#= __args           =# args,
            #= __kargs          =# kargs,
            #= __code           =# [],
            #= __type           =# genNSX(),
            #= __instances      =# [],
            #= __link_instances =# __link_instances,
            #= __init           =# [nothing],
            #= __cls            =# NS(),
            #= _instances       =# nothing,
            #= _clr_instances   =# nothing)
end
#=
macro NSCode()
    return esc(:(NSCode(; __mdl=@__MODULE__)))
end
=#
function push_to_instance(o, atr, val)
    x = isa(val, NSCodecst_item) ? Base.getproperty(o, :cst) : o

    y = (isa(val, AbstNSCodeitem) && isa(val.obj, NSTagFunc)
         ? Base.getproperty(x, typeof(val.obj).parameters[1])
         : x)

    if !isa(val, AbstNSCodeitem)
        if atr == :exe
            val(y)
        else
            Base.setproperty!(y, atr, val)
        end
    elseif isa(val.obj, NSTagFunc)
        Base.setproperty!(y, atr, val.obj.fnc)
    else
        Base.setproperty!(y, atr, val.obj)
    end
end

(nsc::NSCode)(args...; kargs...) =
    begin
        o = nsc.__type()

        na = length(nsc.__args)
        nka = length(nsc.__kargs)

        length(args) < na &&
            Base.error("number of args should be equal to or larger than $na")

        for (atr, val) ∈ zip(nsc.__args, args[1:na])
            Base.setproperty!(o, atr, val)
        end

        for (atr, val) ∈ nsc.__kargs
            Base.setproperty!(o, atr, atr ∈ keys(kargs) ? kargs[atr] : val)
        end

        isnothing(nsc.__init[1]) ||
            nsc.__init[1](o)(args[na+1:end]...;
                             Dict((k,v)
                                  for (k,v) ∈ kargs if k ∉ keys(nsc.__kargs))...)

        for (atr, val) ∈ nsc.__code
            push_to_instance(o, atr, val)
        end

        nsc.__link_instances &&
            append!(nsc.__instances, [(a=args, k=values(kargs), o=o)])
        o
    end

Base.setproperty!(nsc::AbstNSCode, atr::Symbol, x) =
    begin
        hasfield(typeof(nsc), atr) &&
            (Base.setfield!(nsc, atr, x); return)

        atr == :init && (nsc.__init[1] = NSTagFunc{:mth}(x); return)

        haskey(_NSCodedict0, atr) &&
            Base.error("'" * string(atr) * "' can't be used for property")

        nsc.__link_instances &&
            [push_to_instance(i, atr, x) for (a, k, i) ∈ nsc.__instances]

        push!(nsc.__code, (atr, x))
    end

Base.getproperty(nsc::AbstNSCode, atr::Symbol) =
    begin
        Base.hasfield(typeof(nsc), atr) && (return Base.getfield(nsc, atr))
        haskey(_NSCodedict0, atr) && (return _NSCodedict0[atr](nsc))
        Base.getproperty(nsc.__cls, atr)
    end

################
# NSCodeitem
################

abstract type AbstNSCodeitem end

struct NSCodecst_item{T} <: AbstNSCodeitem
    obj::T
end

mutable struct NSCodenoncst_item{T} <: AbstNSCodeitem
    obj::T
end

################
# NSCodeTag
################

struct NSCodeTag{T, C} ___NSC_nsc::AbstNSCode end

Base.setproperty!(tag::NSCodeTag, atr::Symbol, f) =
        (Base.hasfield(typeof(tag), atr)
         ? Base.setproperty!(tag, atr, f)
         : Base.setproperty!(tag.___NSC_nsc, atr, _MakeItem(tag,f)))

################
# NSCodecst
################

struct NSCodecst{T <: AbstNSCode} ___NSC_nsc::T end

Base.getproperty(cst::NSCodecst, atr::Symbol) =
    begin
        hasfield(typeof(cst), atr) && (return Base.getfield(cst, atr))
        NSCodeTag{atr, true}(cst.___NSC_nsc)
    end

Base.setproperty!(cst::NSCodecst, atr::Symbol, o) =
    Base.setproperty!(cst.___NSC_nsc, atr, NSCodecst_item(o))

_MakeItem(x::NSCodecst, o) = NSCodecst_item(o)

################
# NSCodeTagFunc
################

struct NSCodeTagFunc{T, C} nsc::AbstNSCode end
_MakeItem(x::NSCodeTag{T,false}, f) where T = NSCodenoncst_item(NSTagFunc{T}(f))
_MakeItem(x::NSCodeTag{T, true}, f) where T = NSCodecst_item(NSTagFunc{T}(f))


text:
function Base.show(io::IO, gd::GroupedDataFrame;
                   allgroups::Bool = !get(io, :limit, false),
                   allrows::Bool = !get(io, :limit, false),
                   allcols::Bool = !get(io, :limit, false),
                   splitcols::Bool = get(io, :limit, false),
                   rowlabel::Symbol = :Row,
                   summary::Bool = true)
    N = length(gd)
    keys = join(':' .* string.(gd.cols), ", ")
    keystr = length(gd.cols) > 1 ? "keys" : "key"
    groupstr = N > 1 ? "groups" : "group"
    summary && print(io, "$(typeof(gd)) with $N $groupstr based on $keystr: $keys")
    if allgroups
        for i = 1:N
            nrows = size(gd[i], 1)
            rows = nrows > 1 ? "rows" : "row"
            print(io, "\nGroup $i: $nrows $rows")
            show(io, gd[i], summary=false,
                 allrows=allrows, allcols=allcols, rowlabel=rowlabel)
        end
    else
        if N > 0
            nrows = size(gd[1], 1)
            rows = nrows > 1 ? "rows" : "row"
            print(io, "\nFirst Group: $nrows $rows")
            show(io, gd[1], summary=false,
                 allrows=allrows, allcols=allcols, rowlabel=rowlabel)
        end
        if N > 1
            print(io, "\n⋮\n")
            nnrows = size(gd[N], 1)
            rows = nrows > 1 ? "rows" : "row"
            print(io, "Last Group: $nrows $rows")
            show(io, gd[N], summary=false,
                 allrows=allrows, allcols=allcols, rowlabel=rowlabel)
        end
    end
end

function Base.show(df::GroupedDataFrame;
                   allrows::Bool = !get(stdout, :limit, true),
                   allcols::Bool = !get(stdout, :limit, true),
                   allgroups::Bool = !get(stdout, :limit, true),
                   splitcols::Bool = get(stdout, :limit, true),
                   rowlabel::Symbol = :Row,
                   summary::Bool = true) # -> Nothing
    return show(stdout, df,
                allrows=allrows, allcols=allcols, allgroups=allgroups, splitcols=splitcols,
                rowlabel=rowlabel, summary=summary)
end