def divisible_by_7_graph(): '''set up divisibe-by-y graph by declaration of named nodes ''' allNodes = {e: t() for e in "abcdefg"} # create 7 alphabetically labelled nodes # Black Links White Links allNodes['a'].B = allNodes['b'] allNodes['a'].W = allNodes['a'] allNodes['a'].v = 'a' # node 'a' has a self loop allNodes['b'].B = allNodes['c'] allNodes['b'].W = allNodes['d'] allNodes['b'].v = 'b' allNodes['c'].B = allNodes['d'] allNodes['c'].W = allNodes['g'] allNodes['c'].v = 'c' allNodes['d'].B = allNodes['e'] allNodes['d'].W = allNodes['c'] allNodes['d'].v = 'd' allNodes['e'].B = allNodes['f'] allNodes['e'].W = allNodes['f'] allNodes['e'].v = 'e' # same destination node for Black and for White allNodes['f'].B = allNodes['g'] allNodes['f'].W = allNodes['b'] allNodes['f'].v = 'f' allNodes['g'].B = allNodes['a'] allNodes['g'].W = allNodes['e'] allNodes['g'].v = 'g' return allNodes['a']
def sample_config(): config = t() config.boo = 1 config.bar.alpha = 11 config.bar.beta = 22 config.bar.gamma = 'hello' config.bas.rock = 'bye' config.bas.scissors = 'hello' config.bas.paper = ['hh', 'ii', 'jj'] config.cas = [[1, 2], [3, 4], [5, 6]] config.dct = {'aa': 11, 'bb': 22, 'cc': 33} config.a.b.c.d.e.f.mtx = [[42, 43, 44], [11, 22, 33]] config.a.b.c.d.e.f.g.h.i.j = 42 config.a.b.c1 = 42 config.a.b.c.d1 = 42 config.a.b.c.d2.e = 42 config.a.b.c.d3 = 42 config.a.b.c2.d1 = 42 config.a.b.c2.d2 = 42 config.a.bb.c.d1 = 42 config.a.bbb.c.d1 = 42 # config.dag = config.bar # this works, but creates a DAG # config.a.b.c.cyc = config # this works, but creates a Cyclic Graph return config
def sample_json(): # json sample from json wikipedia page person = t() person.firstName = "John" person.lastName = "Smith" person.age = 25 person.address.streetAddress = "21 2nd Street" person.address.city = "New York" person.address.state = "NY" person.address.postalCode = "10021" person.phoneNumbers = [t(), t()] person.phoneNumbers[0].type = "home" person.phoneNumbers[0].number = "212 555-1234" person.phoneNumbers[1].type = "fax" person.phoneNumbers[1].number = "646 555-4567" person.sex.type = "male" return person
def make_treacl_table(nrows, ncols): '''example nR X nC table ''' tbl = t() tbl.rows = [t() for _ in range(nrows)] # list of row series tbl.cols = [t() for _ in range(ncols)] # list of column series for r in tbl.rows: r.s = [t() for x in tbl.cols ] # create series treacl instances for each row for ci, c in enumerate(tbl.cols): c.s = [r.s[ci] for r in tbl.rows] # cross-ref the instance into column series i = 0 for ri, r in enumerate(tbl.rows): for ci, c in enumerate(tbl.cols): tbl.rows[ri].s[ci].v = ascii_lowercase[ i % 26] #(ri,ci) # give each element in the table a value attribute (e.g. ".v" ) i += 1 return tbl
def divisible_by_7_graph_pathex(): '''set up divisibe-by-y graph by declaration of links This graph is identical to that of the function above, but expressed by decomposing it into a set of line path expressions ''' d7 = t() d7.B.B.B.B.B.B.B = d7 # Black loop d7.W = d7 # a; White forward and backward jumps d7.B.W = d7.B.B.B # b d7.B.B.W = d7.B.B.B.B.B.B # c d7.B.B.B.W = d7.B.B # d d7.B.B.B.B.W = d7.B.B.B.B.B # e d7.B.B.B.B.B.W = d7.B # f d7.B.B.B.B.B.B.W = d7.B.B.B.B # g return d7
def test_universe(): univ = t() univ.virgoSuperCluster.localGroup.milkyWay.orionCygnusArm.sun.earth.europe.uk.england.london.marylebone.langhamHotel.bar.pint.londonPride.head.bubble.co2.oxygen.neutron.upQuark = None univ.virgoSuperCluster.localGroup.milkyWay.orionCygnusArm.sun.earth.europe.uk.oxfordshire.oxford = None univ.virgoSuperCluster.localGroup.milkyWay.orionCygnusArm.sun.earth.europe.france.languedoc.perpignan.gare = None univ.virgoSuperCluster.localGroup.milkyWay.orionCygnusArm.sun.earth.europe.france.paris.arrondisement5.placeDuPantheon.pantheon.dome.focaulPendulum.sphere.lead.faceCenteredCube.atomPb204.proton.quark = None univ.virgoSuperCluster.localGroup.milkyWay.orionCygnusArm.sun.earth.us.california.inyoCounty.whitemountains.ancientBristleconePineForest.methuselahGrove.methuselah.trunk.branch.fascile.needle.stoma.parenchymaCell = None univ.virgoSuperCluster.localGroup.milkyWay.orionCygnusArm.sun.earth.us.colorado.gaithersburg.nist.nistF1Clock.fountain.opticalMolasses.cesium133.groundState.hyperFineTransition.fluorescentPhoton.frequency = None univ.virgoSuperCluster.localGroup.milkyWay.orionCygnusArm.sun.mars.chrysePlanitia.viking1Lander.biologicalExperimentSystem.labeledRelease.c14DetectorAssembly = None univ.virgoSuperCluster.localGroup.milkyWay.orionCygnusArm.sun.jupiter.ganymede.crater1 = None univ.virgoSuperCluster.localGroup.milkyWay.orionCygnusArm.sun.jupiter.bigRedSpot = None univ.virgoSuperCluster.localGroup.milkyWay.perseusArm.crabNebula = None univ.virgoSuperCluster.localGroup.milkyWay.sirius = None univ.virgoSuperCluster.localGroup.andromeda.mayaII = None univ.virgoSuperCluster.localGroup.andromeda.nucleues.p2.blackHole = None univ.virgoSuperCluster.localGroup.triangulum.inSpiral = None univ.virgoSuperCluster.localGroup.triangulum.isSpiral = None univ.virgoSuperCluster.localGroup.triangulum.ngc604 = None univ.virgoSuperCluster.localGroup.sextansA = None univ.virgoSuperCluster.localGroup.sextansB = None univ.virgoSuperCluster.virgoA.messier87 = None return univ
def make_treacl_3x2_table(): '''example 3x2 table ''' tbl = t() tbl.rows = [t(), t(), t()] # i.e. [ row1, row2, row3] = list of row series tbl.cols = [t(), t()] # i.e. [ col1, col2 ] = list of column series # put elements in row series (i.e. ".s") tbl.rows[0].s = [t(), t()] # a b tbl.rows[1].s = [t(), t()] # c d tbl.rows[2].s = [t(), t()] # e f # put *same* elements in column series (i.e. ".s") tbl.cols[0].s = [tbl.rows[0].s[0], tbl.rows[1].s[0], tbl.rows[2].s[0]] # a c e tbl.cols[1].s = [tbl.rows[0].s[1], tbl.rows[1].s[1], tbl.rows[2].s[1]] # b d f # give each element in the table a value attribute (e.g. ".v" ) tbl.rows[0].s[0].v = "a" tbl.rows[0].s[1].v = "b" tbl.rows[1].s[0].v = "c" tbl.rows[1].s[1].v = "d" tbl.rows[2].s[0].v = "e" tbl.rows[2].s[1].v = "f" return tbl
def sample_ssl_certificate(): Certificate = t() Certificate.Data.Version = "3 (0x2)" Certificate.Data.SerialNumber = "45:12:a3:02:83:5a:73:84:08:00:00:00:00:3a:95:59" Certificate.Data.SignatureAlgorithm = "sha256WithRSAEncryption" Certificate.Data.Issuer.C = "US" Certificate.Data.Issuer.O = "Google Trust Services" Certificate.Data.Issuer.CN = "GTS CA 1O1" Certificate.Data.Validity.NotBefore = "Apr 15 20:25:34 2020 GMT" Certificate.Data.Validity.NotAfter = "Jul 8 20:25:34 2020 GMT" Certificate.Data.Subject.C = "US" Certificate.Data.Subject.ST = "California" Certificate.Data.Subject.L = "Mountain View" Certificate.Data.Subject.O = "Google LLC" Certificate.Data.Subject.CN = "mail.google.com" Certificate.Data.Subject.PublicKeyInfo.PublicKeyAlgorithm = "id-ecPublicKey" Certificate.Data.Subject.PublicKeyInfo.Public_Key = "(256 bit)" Certificate.Data.Subject.PublicKeyInfo.pub = ( "04:dd:4f:35:71:0e:56:17:73:67:ec:25:30:32:68:" "66:75:57:be:d8:3e:c9:5d:e7:3f:30:04:bb:76:76:" "39:7b:4e:c3:e1:c0:50:2c:9a:61:8d:b1:5b:34:15:" "e6:12:80:d5:24:ef:84:d8:00:7d:75:00:b3:10:cf:" "ac:9e:c7:1d:47") Certificate.Data.Subject.PublicKeyInfo.ASN1_OID = "prime256v1" Certificate.Data.Subject.PublicKeyInfo.NIST_CURVE = "P-256" Certificate.Data.X509v3.extensions = [t() for _ in range(13)] Certificate.Data.X509v3.extensions[ 0].X509v3KeyUsage.critical = "Digital Signature" Certificate.Data.X509v3.extensions[ 1].X509v3ExtendedKeyUsage = "TLS Web Server Authentication" Certificate.Data.X509v3.extensions[ 2].X509v3BasicConstraints.critical = "CA:FALSE" Certificate.Data.X509v3.extensions[ 3].X509v3SubjectKeyIdentifier = "FC:DA:68:51:CF:C4:D6:F7:96:CD:F0:E8:5F:59:3D:A3:2A:E3:A1:74" Certificate.Data.X509v3.extensions[ 4].X509v3AuthorityKeyIdentifier = "keyid:98:D1:F8:6E:10:EB:CF:9B:EC:60:9F:18:90:1B:A0:EB:7D:09:FD:2B" Certificate.Data.X509v3.extensions[ 5].AuthorityInformationAccess.OCSP = "URI:http://ocsp.pki.goog/gts1o1" Certificate.Data.X509v3.extensions[ 6].AuthorityInformationAccess.CAIssuers = "URI:http://pki.goog/gsr2/GTS1O1.crt" Certificate.Data.X509v3.extensions[7].X509v3SubjectAlternativeName = [ "DNS:mail.google.com", "DNS:inbox.google.com" ] Certificate.Data.X509v3.extensions[8].X509v3CertificatePolicies = [ t(), t() ] Certificate.Data.X509v3.extensions[8].X509v3CertificatePolicies[ 0].Policy = "2.23.140.1.2.2" Certificate.Data.X509v3.extensions[8].X509v3CertificatePolicies[ 1].Policy = "1.3.6.1.4.1.11129.2.5.3" Certificate.Data.X509v3.extensions[ 11].X509v3CRLDistributionPoints.FullName = " URI:http://crl.pki.goog/GTS1O1.crl" Certificate.Data.X509v3.extensions[12].CTPrecertificateSCTs = [t(), t()] Certificate.Data.X509v3.extensions[12].CTPrecertificateSCTs[ 0].SignedCertificateTimestamp.Version = "v1 (0x0)" Certificate.Data.X509v3.extensions[12].CTPrecertificateSCTs[ 0].SignedCertificateTimestamp.LogID = ( "B2:1E:05:CC:8B:A2:CD:8A:20:4E:87:66:F9:2B:B9:8A:" "25:20:67:6B:DA:FA:70:E7:B2:49:53:2D:EF:8B:90:5E") Certificate.Data.X509v3.extensions[12].CTPrecertificateSCTs[ 0].SignedCertificateTimestamp.Timestamp = "Apr 15 21:25:34.560 2020 GMT" Certificate.Data.X509v3.extensions[12].CTPrecertificateSCTs[ 0].SignedCertificateTimestamp.Extensions = "none" Certificate.Data.X509v3.extensions[12].CTPrecertificateSCTs[ 0].SignedCertificateTimestamp.Signature = [ "ecdsa-with-SHA256", ("30:45:02:21:00:F3:F8:59:47:48:5B:18:50:58:05:7B:" "3C:44:AA:64:EA:C6:76:C1:5D:66:40:8B:B6:87:38:83:" "F3:3F:08:3A:22:02:20:3D:78:3B:BA:7C:97:60:58:C0:" "C2:CA:4A:46:C1:50:64:8D:D4:EE:0D:90:60:70:90:E1:" "0D:BD:24:3D:BE:37:1B") ] Certificate.Data.X509v3.extensions[12].CTPrecertificateSCTs[ 1].SignedCertificateTimestamp.Version = "v1 (0x0)" Certificate.Data.X509v3.extensions[12].CTPrecertificateSCTs[ 1].SignedCertificateTimestamp.LogID = ( "5E:A7:73:F9:DF:56:C0:E7:B5:36:48:7D:D0:49:E0:32:" "7A:91:9A:0C:84:A1:12:12:84:18:75:96:81:71:45:58") Certificate.Data.X509v3.extensions[12].CTPrecertificateSCTs[ 1].SignedCertificateTimestamp.Timestamp = "Apr 15 21:25:34.607 2020 GMT" Certificate.Data.X509v3.extensions[12].CTPrecertificateSCTs[ 1].SignedCertificateTimestamp.Extensions = "none" Certificate.Data.X509v3.extensions[12].CTPrecertificateSCTs[ 1].SignedCertificateTimestamp.Signature = [ "ecdsa-with-SHA256", ("30:46:02:21:00:99:31:D8:08:EB:1D:60:83:78:DC:93:" "F3:A9:09:E4:E2:DD:73:3C:6F:94:2A:88:DC:5E:66:E9:" "7B:EC:A2:6B:7C:02:21:00:C9:BE:C7:14:92:EF:53:68:" "61:24:22:33:F9:03:87:20:FF:4F:62:0D:EE:FF:04:E0:" "D2:2A:56:D5:95:16:B6:00") ] Certificate.SignatureAlgorithm = [ "sha256WithRSAEncryption", ("91:86:56:b4:b0:24:9a:dc:2c:7a:16:a4:50:52:e5:ca:e5:10:" "41:5f:8e:b7:71:ba:3f:d9:fd:04:57:6a:07:1b:6a:60:7c:31:" "fe:0a:6e:67:80:08:71:c5:ae:47:7f:0e:2e:6e:36:1b:23:8d:" "e6:b8:55:bd:9f:dc:0e:4f:87:da:d2:2f:e8:76:52:02:53:89:" "ec:78:8f:5c:01:44:2e:ff:10:89:f8:6f:78:e7:19:8f:e9:9a:" "3d:b1:df:4f:e5:e4:bc:e8:eb:45:55:fc:57:85:11:36:f2:2a:" "22:56:aa:71:2a:08:9f:c6:3e:37:76:1f:2c:59:b7:04:1a:dd:" "fb:59:c9:49:9f:d3:b4:48:cb:26:80:67:e2:9d:61:80:b2:cb:" "cd:b1:d2:12:fa:3b:b1:ca:80:7b:db:20:df:8e:53:1a:d6:1b:" "f0:b2:dd:cd:3a:9c:4e:16:28:8b:e7:f2:67:4f:67:d4:6e:a1:" "07:be:7e:4a:83:d6:fd:39:b1:26:3b:68:a9:5c:02:6f:48:e1:" "ff:a7:79:13:10:b4:43:9b:49:2b:79:79:f1:b5:73:6b:44:da:" "7e:3a:c3:1d:b5:d9:13:83:19:20:2e:97:4f:ba:27:66:a2:36:" "1e:59:9d:14:85:cd:3b:6a:04:f7:8b:d1:72:64:7f:e0:5d:05:" "a3:a7:34:c7") ] Certificate.encoded = [ "-----BEGIN CERTIFICATE-----", ("MIIE1DCCA7ygAwIBAgIQRRKjAoNac4QIAAAAADqVWTANBgkqhkiG9w0BAQsFADBC" "MQswCQYDVQQGEwJVUzEeMBwGA1UEChMVR29vZ2xlIFRydXN0IFNlcnZpY2VzMRMw" "EQYDVQQDEwpHVFMgQ0EgMU8xMB4XDTIwMDQxNTIwMjUzNFoXDTIwMDcwODIwMjUz" "NFowaTELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcT" "DU1vdW50YWluIFZpZXcxEzARBgNVBAoTCkdvb2dsZSBMTEMxGDAWBgNVBAMTD21h" "aWwuZ29vZ2xlLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABN1PNXEOVhdz" "Z+wlMDJoZnVXvtg+yV3nPzAEu3Z2OXtOw+HAUCyaYY2xWzQV5hKA1STvhNgAfXUA" "sxDPrJ7HHUejggJoMIICZDAOBgNVHQ8BAf8EBAMCB4AwEwYDVR0lBAwwCgYIKwYB" "BQUHAwEwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQU/NpoUc/E1veWzfDoX1k9o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bXZE4MZIC6XT7onZqI2HlmdFIXNO2oE94vRcmR/4F0Fo6c0xw=="), "-----END CERTIFICATE-----" ] return Certificate
def standard_model_interactions(): # elementary particles and their groupings ep = t(); ep.name = "elementary particles"; ep.addProp('type', "grouping") # fermions fm = t(); fm.name = "fermions"; fm.addProp('type', "grouping") # leptons lp = t(); lp.name = "leptons"; lp.addProp('type', "grouping") # neutral leptons lpn = t(); lpn.name = "neutral leptons"; lpn.addProp('type', "grouping") en = t(); en.name = "electron neutrino"; en.addProp('type', "elementary") tn = t(); tn.name = "tau neutrino"; tn.addProp('type', "elementary") mnn = t(); mnn.name = "muon neutrino"; mnn.addProp('type', "elementary") lpn.M = [en, tn, mnn] # charged leptons lpc = t(); lpc.name = "charged leptons"; lpc.addProp('type', "grouping") el = t(); el.name = "electron"; el.addProp('type', "elementary") tau = t(); tau.name = "tau"; tau.addProp('type', "elementary") mn = t(); mn.name = "muon"; mn.addProp('type', "elementary") lpc.M = [el, tau, mn] lp.M = [lpn, lpc] # quarks qk = t(); qk.name = "quarks"; qk.addProp('type', "grouping") # quarks up/down qkud = t(); qkud.name = "up/down quarks"; qkud.addProp('type', "grouping") qku = t(); qku.name = "up quark"; qku.addProp('type', "grouping") qkd = t(); qkd.name = "down quark"; qkd.addProp('type', "grouping") qkud.M = [qku, qkd] # quarks charm/strange qkcs = t(); qkcs.name = "charm strange quarks"; qkcs.addProp('type', "grouping") qkc = t(); qkc.name = "charm quark"; qkc.addProp('type', "elementary") qks = t(); qks.name = "strange quark"; qks.addProp('type', "elementary") qkcs.M = [qkc, qks] # quarks top/bottom qktb = t(); qktb.name = "top/bottom quarks"; qktb.addProp('type', "grouping") qkt = t(); qkt.name = "top quark"; qkt.addProp('type', "elementary") qkb = t(); qkb.name = "bottom quark"; qkb.addProp('type', "elementary") qktb.M = [qkt, qkb] qk.M = [qkud, qkcs, qktb] fm.M = [lp, qk] # bosons bn = t(); bn.name = "fermions"; bn.addProp('type', "grouping") # weak bosons wb = t(); wb.name = "weak bosons"; wb.addProp('type', "grouping") wp = t(); wp.name = "w-plus boson"; wp.addProp('type', "elementary") wm = t(); wm.name = "w-minus boson"; wm.addProp('type', "elementary") zb = t(); zb.name = "z boson"; zb.addProp('type', "elementary") wb.M = [wp, wm, zb] # gluon gn = t(); gn.name = "gluon"; gn.addProp('type', "elementary") # photon ph = t(); ph.name = "photon"; ph.addProp('type', "elementary") # BEH boson hg = t(); hg.name = "BEH"; hg.addProp('type', "elementary") bn.M = [wb, gn, ph, hg] ep.M = [fm, bn] # currently, it seems the universe consists of bosons and fermions # Interactions # add both-ways links to identify which particles/ groups of particles interact # self interactions are inherently both-ways gn.I = [gn, qk] ph.I = [lpc, wp, wm, qk] hg.I = [hg, wb, qk, lpc] wb.I = [wb, hg, lp, qk] lp.I = [wb] qk.I = [gn, ph, hg, wb] lpc.I = [ph, hg] wp.I = [ph] wp.I = [ph] # more properties # charge lpn.addProp('charge', '0') lpc.addProp('charge', '-1') qku.addProp('charge', '2/3') qkd.addProp('charge', '-1/3') qkc.addProp('charge', '2/3') qks.addProp('charge', '-1/3') qkt.addProp('charge', '2/3') qkb.addProp('charge', '-1/3') # spin ph.addProp('spin', '1/2') wb.addProp('spin', '1') gn.addProp('spin', '1') ph.addProp('spin', '1') hg.addProp('spin', '0') return ep # all elementary particles