Compare commits
No commits in common. "d5c907859b5e1cc2ea9bd87039c1be8ebda4297a" and "e18f58c0d00e7a736635e7ea359f62e344262094" have entirely different histories.
d5c907859b
...
e18f58c0d0
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,4 +1,2 @@
|
||||
*.bak
|
||||
.nyc_output
|
||||
.pytest_cache
|
||||
.coverage
|
||||
.nyc_output
|
@ -1,9 +0,0 @@
|
||||
Title: Lab Thirteen
|
||||
Date: 2022-10-26T08:30:00
|
||||
Tags: cs2613, lab, javascript
|
||||
|
||||
Sample description
|
||||
<!-- more -->
|
||||
|
||||
## Sample Body
|
||||
Sample Body
|
@ -1,9 +0,0 @@
|
||||
Title: Lab Fourteen
|
||||
Date: 2022-10-31T08:30:00
|
||||
Tags: cs2613, lab, python
|
||||
|
||||
Sample description
|
||||
<!-- more -->
|
||||
|
||||
## Sample Body
|
||||
Sample Body
|
@ -1,39 +0,0 @@
|
||||
// let str="";
|
||||
// for (let i=0; i<60; i++) {
|
||||
// console.log('\033c');
|
||||
// str+= "*";
|
||||
// console.log(str);
|
||||
// }
|
||||
|
||||
//console.log("all done!");
|
||||
|
||||
// function loop(i,str) {
|
||||
// if (i>0) {
|
||||
// console.log("\033c");
|
||||
// console.log(str);
|
||||
// setTimeout(function() { loop(i-1, str+"*"); }, 1000);
|
||||
// }
|
||||
// }
|
||||
|
||||
// loop(20,"*");
|
||||
|
||||
// console.log("all done!");
|
||||
|
||||
function animate(iterations) {
|
||||
let i=0;
|
||||
let str="*";
|
||||
let timer = null;
|
||||
function frame() {
|
||||
|
||||
console.log('\033c');
|
||||
console.log(str);
|
||||
if (i>=iterations) {
|
||||
clearInterval(timer);
|
||||
console.log("all done!");
|
||||
}
|
||||
|
||||
}
|
||||
timer=setInterval(frame,300);
|
||||
}
|
||||
|
||||
animate(20);
|
8
labs/L14/.idea/.gitignore
vendored
8
labs/L14/.idea/.gitignore
vendored
@ -1,8 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name=".coverage" uuid="af2f1fdd-3241-4470-93b5-53f58bcdd0d2">
|
||||
<driver-ref>sqlite.xerial</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||
<jdbc-url>jdbc:sqlite:C:\Users\Isaac\OneDrive - University of New Brunswick\Year 3 UNB\CS2613\Git\cs2613-ishoebot\labs\L14\.coverage</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
@ -1,6 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (L14)" project-jdk-type="Python SDK" />
|
||||
</project>
|
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/L14.iml" filepath="$PROJECT_DIR$/.idea/L14.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,16 +0,0 @@
|
||||
import humansize
|
||||
|
||||
|
||||
def approximate_size(size):
|
||||
"""Returns the size of a file in a human-readable format where kilobytes are 1000 bytes
|
||||
|
||||
:param size: the size of a file
|
||||
:return: string
|
||||
"""
|
||||
return humansize.approximate_size(size, False)
|
||||
|
||||
|
||||
if __name__ == '__main__': # pragma: no cover
|
||||
print(approximate_size(1_000))
|
||||
print(approximate_size(100_000_000))
|
||||
print(approximate_size(1_000_000_000))
|
@ -1,8 +0,0 @@
|
||||
import math
|
||||
|
||||
|
||||
def fraction(a, b):
|
||||
try:
|
||||
return a / b
|
||||
except ZeroDivisionError:
|
||||
return math.nan
|
@ -1,10 +0,0 @@
|
||||
if __name__ == '__main__':
|
||||
for i in range(1, 101):
|
||||
if i % 3 == 0 and i % 5 == 0:
|
||||
print("FizzBuzz")
|
||||
elif i % 3 == 0:
|
||||
print("Fizz")
|
||||
elif i % 5 == 0:
|
||||
print("Buzz")
|
||||
else:
|
||||
print(i)
|
@ -1,67 +0,0 @@
|
||||
"""Convert file sizes to human-readable form.
|
||||
|
||||
Available functions:
|
||||
approximate_size(size, a_kilobyte_is_1024_bytes)
|
||||
takes a file size and returns a human-readable string
|
||||
|
||||
Examples:
|
||||
>>> approximate_size(1024)
|
||||
'1.0 KiB'
|
||||
>>> approximate_size(1000, False)
|
||||
'1.0 KB'
|
||||
|
||||
"""
|
||||
|
||||
SUFFIXES = {1000: ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
|
||||
1024: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']}
|
||||
|
||||
|
||||
def approximate_size(size, a_kilobyte_is_1024_bytes=True):
|
||||
"""Convert a file size to human-readable form.
|
||||
|
||||
Keyword arguments:
|
||||
size -- file size in bytes
|
||||
a_kilobyte_is_1024_bytes -- if True (default), use multiples of 1024
|
||||
if False, use multiples of 1000
|
||||
|
||||
Returns: string
|
||||
|
||||
"""
|
||||
if size < 0:
|
||||
raise ValueError('number must be non-negative')
|
||||
|
||||
multiple = 1024 if a_kilobyte_is_1024_bytes else 1000
|
||||
for suffix in SUFFIXES[multiple]:
|
||||
size /= multiple
|
||||
if size < multiple:
|
||||
return '{0:.1f} {1}'.format(size, suffix)
|
||||
|
||||
raise ValueError('number too large')
|
||||
|
||||
|
||||
if __name__ == '__main__': # pragma: no cover
|
||||
print(approximate_size(1000000000000, False))
|
||||
print(approximate_size(1000000000000))
|
||||
|
||||
# Copyright (c) 2009, Mark Pilgrim, All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS'
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
@ -1,18 +0,0 @@
|
||||
import pytest
|
||||
from client import approximate_size
|
||||
|
||||
|
||||
def test_1kb():
|
||||
assert approximate_size(1_000) == "1.0 KB"
|
||||
|
||||
|
||||
def test_100mb():
|
||||
assert approximate_size(100_000_000) == "100.0 MB"
|
||||
|
||||
|
||||
def test_1gb():
|
||||
assert approximate_size(1_000_000_000) == "1.0 GB"
|
||||
|
||||
|
||||
def test_docstring():
|
||||
assert approximate_size.__doc__ is not None
|
@ -1,10 +0,0 @@
|
||||
from divisive import fraction
|
||||
import math
|
||||
|
||||
|
||||
def test_fraction_int():
|
||||
assert fraction(4, 2) == 2
|
||||
|
||||
|
||||
def test_fraction_NaN():
|
||||
assert math.isnan(fraction(4, 0))
|
@ -1,20 +0,0 @@
|
||||
import pytest
|
||||
from humansize import approximate_size
|
||||
|
||||
|
||||
def test_1000():
|
||||
assert approximate_size(1000000000000, False) == "1.0 TB"
|
||||
|
||||
|
||||
def test_1024():
|
||||
assert approximate_size(1000000000000) == "931.3 GiB"
|
||||
|
||||
|
||||
def test_negative():
|
||||
with pytest.raises(ValueError):
|
||||
approximate_size(-1)
|
||||
|
||||
|
||||
def test_huge_number():
|
||||
with pytest.raises(ValueError):
|
||||
approximate_size(1_000_000_000_000_000_000_000_000_000_000)
|
Loading…
Reference in New Issue
Block a user