|
| 1 | +import numpy as np |
| 2 | +from something import some_function as my_function |
| 3 | +def unrelated(): |
| 4 | + unkwown_function() |
| 5 | + np.busday_offset('2012-05' , 1, roll='forward') |
| 6 | + def other_function(): ... |
| 7 | + other_function() |
| 8 | + np.busday_offset('2012-05' , 1, roll='forward', weekmask=other_function()) |
| 9 | + my_function() |
| 10 | + |
| 11 | +def some_cases(): |
| 12 | + offset = np.busday_offset('2012-05', 1, roll='forward', weekmask='0111100') |
| 13 | + offset = np.busday_offset('2012-05', 1, roll='forward', weekmask=[0, 1, 1, 1, 1, 0, 0]) |
| 14 | + offset = np.busday_offset('2012-05', 1, roll='forward', weekmask="Tue Wed Thu Fri") |
| 15 | + offset = np.busday_offset('2012-05', 1, roll='forward', weekmask="Tue Wed Thu Fri Fri") |
| 16 | + offset = np.busday_offset('2012-05', 1, roll='forward', weekmask="TueWedThuFriFri") |
| 17 | + offset = np.busday_offset('2012-05', 1, roll='forward', weekmask="TueWedThuFri Fri") |
| 18 | + offset = np.busday_offset('2012-05', 1, weekmask="TueWed ThuFri Fri") |
| 19 | + offset = np.busday_offset('2012-05', 1, 'forward', "TueWed ThuFri Fri") |
| 20 | + |
| 21 | + offset = np.busday_offset('2012-05', 1, 'forward', "TueWed ThuFri igpifdjpigdg") # Noncompliant {{String must be either 7 characters long and contain only 0 and 1, or contain abbreviated weekdays.}} |
| 22 | + #^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 23 | + offset = np.busday_offset('2012-05', 1, roll='forward', weekmask='01') # Noncompliant {{String must be either 7 characters long and contain only 0 and 1, or contain abbreviated weekdays.}} |
| 24 | + #^^^^ |
| 25 | + offset = np.busday_offset('2012-05', 1, roll='forward', weekmask="fsfdiopj") # Noncompliant {{String must be either 7 characters long and contain only 0 and 1, or contain abbreviated weekdays.}} |
| 26 | + #^^^^^^^^^^ |
| 27 | + offset = np.busday_offset('2012-05', 1, roll='forward', weekmask=[1,1,1,1,1,1,1,1]) # Noncompliant {{Array must have 7 elements, all of which are 0 or 1.}} |
| 28 | + #^^^^^^^^^^^^^^^^^ |
| 29 | + offset = np.busday_offset('2012-05', 1, roll='forward', weekmask=[1,1]) # Noncompliant |
| 30 | + offset = np.busday_offset('2012-05', 1, roll='forward', weekmask=["a", "b", "c"]) # Noncompliant {{Array must have 7 elements, all of which are 0 or 1.}} |
| 31 | + #^^^^^^^^^^^^^^^ |
| 32 | + offset = np.busday_offset('2012-05', 1, roll='forward', weekmask=[1,1,1,"1",1,1,1]) # Noncompliant {{Array must have 7 elements, all of which are 0 or 1.}} |
| 33 | + #^^^^^^^^^^^^^^^^^ |
| 34 | + offset = np.busday_offset('2012-05', 1, roll='forward', weekmask=[1,1,0,"0",1,1,1]) # Noncompliant {{Array must have 7 elements, all of which are 0 or 1.}} |
| 35 | + #^^^^^^^^^^^^^^^^^ |
| 36 | +def with_assigned_values(): |
| 37 | + weekmask1 = "Tue Wed Thu Fri" |
| 38 | + offset1 = np.busday_offset('2012-05', 1, roll='forward', weekmask=weekmask1) |
| 39 | + |
| 40 | + weekmask2 = "0111100" |
| 41 | + offset2 = np.busday_offset('2012-05', 1, roll='forward', weekmask=weekmask2) |
| 42 | + |
| 43 | + weekmask3 = [0, 1, 1, 1, 1, 0, 0] |
| 44 | + offset3 = np.busday_offset('2012-05', 1, roll='forward', weekmask=weekmask3) |
| 45 | + |
| 46 | + weekmask4 = "sdfgsdfgsdg" |
| 47 | + offset4 = np.busday_offset('2012-05', 1, roll='forward', weekmask=weekmask4) # Noncompliant |
| 48 | + |
| 49 | + weekmask5 = [1,1,1,1,1,1,1,1] |
| 50 | + #^^^^^^^^^^^^^^^^^> 1 {{Invalid mask is created here.}} |
| 51 | + offset5 = np.busday_offset('2012-05', 1, roll='forward', weekmask=weekmask5) # Noncompliant {{Array must have 7 elements, all of which are 0 or 1.}} |
| 52 | + #^^^^^^^^^ |
| 53 | + weekmask6 = [1,1] |
| 54 | + offset6 = np.busday_offset('2012-05', 1, roll='forward', weekmask=weekmask6) # Noncompliant |
| 55 | + |
| 56 | + weekmask7 = ["a", "b", "c"] |
| 57 | + offset7 = np.busday_offset('2012-05', 1, roll='forward', weekmask=weekmask7) # Noncompliant |
| 58 | + |
| 59 | + weekmask8 = "01" |
| 60 | + #^^^^> 1 {{Invalid mask is created here.}} |
| 61 | + offset8 = np.busday_offset('2012-05', 1, roll='forward', weekmask=weekmask8) # Noncompliant {{String must be either 7 characters long and contain only 0 and 1, or contain abbreviated weekdays.}} |
| 62 | + #^^^^^^^^^ |
| 63 | + weekmask9 = ("TueWed") |
| 64 | + offset9 = np.busday_offset('2012-05', 1, roll='forward', weekmask=weekmask9) |
| 65 | + |
| 66 | + weekmask10 = [1,1,1,1,1,1,2] |
| 67 | + offset10 = np.busday_offset('2012-05', 1, roll='forward', weekmask=weekmask10) # Noncompliant {{Array must have 7 elements, all of which are 0 or 1.}} |
| 68 | + |
| 69 | +def busday_count(): |
| 70 | + offset = np.busday_count('2012-05', '2012-06', weekmask="TueWed ThuFri Fri") |
| 71 | + offset = np.busday_count('2012-05', '2012-06', weekmask="TueWed ThuFri igpifdjpigdg") # Noncompliant |
| 72 | + offset = np.busday_count('2012-05', '2012-06', weekmask='01') # Noncompliant |
| 73 | + offset = np.busday_count('2012-05', '2012-06', weekmask="fsfdiopj") # Noncompliant |
| 74 | + offset = np.busday_count('2012-05', '2012-06', weekmask=[1,1,1,1,1,1,1,1]) # Noncompliant |
| 75 | + offset = np.busday_count('2012-05', '2012-06', weekmask=[1,1,1,1,1,1,1]) |
| 76 | + offset = np.busday_count('2012-05', '2012-06', weekmask=[1,1]) # Noncompliant |
| 77 | + offset = np.busday_count('2012-05', '2012-06', weekmask=["a", "b", "c"]) # Noncompliant |
| 78 | + offset = np.busday_count('2012-05', '2012-06', weekmask=[1,1,1,1,1,1,2]) # Noncompliant |
| 79 | + offset = np.busday_count('2012-05', '2012-06', weekmask=[1,1,1,1,0,1,1,1,1]) # Noncompliant |
| 80 | + offset = np.busday_count('2012-05', '2012-06', weekmask="Tue Wed Thu Fri") |
| 81 | + offset = np.busday_count('2012-05', '2012-06', weekmask="Tue Wed Thu Fri Fri") |
| 82 | + offset = np.busday_count('2012-05', '2012-06', weekmask="TueWedThuFriFri", holidays=["2012-05-01", "2012-05-02"]) |
| 83 | + |
| 84 | +def is_busday(): |
| 85 | + bools = np.is_busday(['2012-05', '2012-06', '2012-07'], weekmask="TueWed ThuFri Fri") |
| 86 | + bools = np.is_busday(['2012-05', '2012-06', '2012-07'], weekmask="TueWed ThuFri igpifdjpigdg") # Noncompliant |
| 87 | + bools = np.is_busday(['2012-05', '2012-06', '2012-07'], weekmask='01') # Noncompliant |
| 88 | + bools = np.is_busday(['2012-05', '2012-06', '2012-07'], weekmask="fsfdiopj") # Noncompliant |
| 89 | + bools = np.is_busday(['2012-05', '2012-06', '2012-07'], weekmask=[1,1,1,1,1,1,1,1]) # Noncompliant |
| 90 | + bools = np.is_busday(['2012-05', '2012-06', '2012-07'], weekmask=[1,1,1,0,1,1,1]) |
| 91 | + bools = np.is_busday(['2012-05', '2012-06', '2012-07'], weekmask=[1,1]) # Noncompliant |
| 92 | + bools = np.is_busday(['2012-05', '2012-06', '2012-07'], weekmask=["a", "b", "c"]) # Noncompliant |
| 93 | + bools = np.is_busday(['2012-05', '2012-06', '2012-07'], weekmask=[1,1,1,1,1,1,2]) # Noncompliant |
| 94 | + bools = np.is_busday(['2012-05', '2012-06', '2012-07'], weekmask=[1,1,1,1,0,1,1,1,1]) # Noncompliant |
| 95 | + bools = np.is_busday(['2012-05', '2012-06', '2012-07'], weekmask="Tue Wed Thu Fri") |
| 96 | + bools = np.is_busday(['2012-05', '2012-06', '2012-07'], weekmask="Tue Wed Thu Fri Fri") |
| 97 | + bools = np.is_busday(['2012-05', '2012-06', '2012-07'], weekmask="TueWedThuFriFri") |
| 98 | + bools = np.is_busday(['2012-05', '2012-06', '2012-07'], holidays=["2012-05-01", "2012-05-02"], weekmask="TueWedThuFriFri") |
| 99 | + |
| 100 | +def busdaycalendar(): |
| 101 | + np.busdaycalendar(weekmask="TueWed ThuFri Fri") |
| 102 | + np.busdaycalendar(weekmask="TueWed ThuFri igpifdjpigdg") # Noncompliant |
| 103 | + np.busdaycalendar(weekmask='01') # Noncompliant |
| 104 | + np.busdaycalendar(weekmask="fsfdiopj") # Noncompliant |
| 105 | + np.busdaycalendar(weekmask=[1,1,1,1,1,1,1,1]) # Noncompliant |
| 106 | + np.busdaycalendar(weekmask=[1,1,1,0,1,1,1]) |
| 107 | + np.busdaycalendar(weekmask=[1,1]) # Noncompliant |
| 108 | + np.busdaycalendar(weekmask=["a", "b", "c"]) # Noncompliant |
| 109 | + np.busdaycalendar(weekmask=[1,1,1,1,1,1,2]) # Noncompliant |
| 110 | + np.busdaycalendar(weekmask=[1,1,1,1,0,1,1,1,1]) # Noncompliant |
| 111 | + np.busdaycalendar(weekmask="Tue Wed Thu Fri") |
| 112 | + np.busdaycalendar(weekmask="Tue Wed Thu Fri Fri", holidays=["2012-05-01", "2012-05-02"]) |
| 113 | + np.busdaycalendar(holidays=["2012-05-01", "2012-05-02"], weekmask="Tue Wed Thu Fri Fri") |
| 114 | + |
| 115 | + np.busdaycalendar(weekmask="Sun TueWed \x0b") |
| 116 | + np.busdaycalendar(weekmask="Sun TueWed \x0b", holidays=["2012-05-01", "2012-05-02"]) |
| 117 | + np.busdaycalendar(weekmask="Sun TueWed \x0b \t \t \n\r \x0c Fri") |
0 commit comments