prompt
large_stringlengths 72
9.34k
| completion
large_stringlengths 0
7.61k
|
---|---|
<|file_name|>override_autoescaped.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""
templatetricks.override_autoescaped<|fim▁hole|>
Override which templates are autoescaped
http://flask.pocoo.org/snippets/41/
"""
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from flask import Flask
class JHtmlEscapingFlask(Flask):
def select_jinja_autoescape(self, filename):
if filename.endswith('.jhtml'):
return True
return Flask.select_jinja_autoescape(self, filename)
app = JHtmlEscapingFlask(__name__)<|fim▁end|> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
<|file_name|>override_autoescaped.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""
templatetricks.override_autoescaped
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Override which templates are autoescaped
http://flask.pocoo.org/snippets/41/
"""
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from flask import Flask
class JHtmlEscapingFlask(Flask):
<|fim_middle|>
app = JHtmlEscapingFlask(__name__)
<|fim▁end|> | def select_jinja_autoescape(self, filename):
if filename.endswith('.jhtml'):
return True
return Flask.select_jinja_autoescape(self, filename) |
<|file_name|>override_autoescaped.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""
templatetricks.override_autoescaped
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Override which templates are autoescaped
http://flask.pocoo.org/snippets/41/
"""
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from flask import Flask
class JHtmlEscapingFlask(Flask):
def select_jinja_autoescape(self, filename):
<|fim_middle|>
app = JHtmlEscapingFlask(__name__)
<|fim▁end|> | if filename.endswith('.jhtml'):
return True
return Flask.select_jinja_autoescape(self, filename) |
<|file_name|>override_autoescaped.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""
templatetricks.override_autoescaped
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Override which templates are autoescaped
http://flask.pocoo.org/snippets/41/
"""
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from flask import Flask
class JHtmlEscapingFlask(Flask):
def select_jinja_autoescape(self, filename):
if filename.endswith('.jhtml'):
<|fim_middle|>
return Flask.select_jinja_autoescape(self, filename)
app = JHtmlEscapingFlask(__name__)
<|fim▁end|> | return True |
<|file_name|>override_autoescaped.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*-
"""
templatetricks.override_autoescaped
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Override which templates are autoescaped
http://flask.pocoo.org/snippets/41/
"""
import os
import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
from flask import Flask
class JHtmlEscapingFlask(Flask):
def <|fim_middle|>(self, filename):
if filename.endswith('.jhtml'):
return True
return Flask.select_jinja_autoescape(self, filename)
app = JHtmlEscapingFlask(__name__)
<|fim▁end|> | select_jinja_autoescape |
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|>"""Custom Exception Classes for Phylotyper Module
"""
class PhylotyperError(Exception):
"""Basic exception for errors raised by Phylotyper modules"""
def __init__(self, subtype, msg=None):
if msg is None:
msg = "An error occured for subtype {}".format(subtype)
super(PhylotyperError, self).__init__(msg)
self.subtype = subtype
class ValuesError(PhylotyperError):
"""Unknown subtype"""
def __init__(self, subtype, msg=None):
super(PhylotyperError, self).__init__(
subtype, msg="Unrecognized subtype {}".format(subtype))
class DatabaseError(PhylotyperError):
"""Missing data in Database"""<|fim▁hole|><|fim▁end|> | def __init__(self, subtype, data, msg=None):
m = "Database is missing data {} for {}".format(data, subtype)
super(PhylotyperError, self).__init__(subtype, m)
self.data = data |
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|>"""Custom Exception Classes for Phylotyper Module
"""
class PhylotyperError(Exception):
<|fim_middle|>
class ValuesError(PhylotyperError):
"""Unknown subtype"""
def __init__(self, subtype, msg=None):
super(PhylotyperError, self).__init__(
subtype, msg="Unrecognized subtype {}".format(subtype))
class DatabaseError(PhylotyperError):
"""Missing data in Database"""
def __init__(self, subtype, data, msg=None):
m = "Database is missing data {} for {}".format(data, subtype)
super(PhylotyperError, self).__init__(subtype, m)
self.data = data<|fim▁end|> | """Basic exception for errors raised by Phylotyper modules"""
def __init__(self, subtype, msg=None):
if msg is None:
msg = "An error occured for subtype {}".format(subtype)
super(PhylotyperError, self).__init__(msg)
self.subtype = subtype |
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|>"""Custom Exception Classes for Phylotyper Module
"""
class PhylotyperError(Exception):
"""Basic exception for errors raised by Phylotyper modules"""
def __init__(self, subtype, msg=None):
<|fim_middle|>
class ValuesError(PhylotyperError):
"""Unknown subtype"""
def __init__(self, subtype, msg=None):
super(PhylotyperError, self).__init__(
subtype, msg="Unrecognized subtype {}".format(subtype))
class DatabaseError(PhylotyperError):
"""Missing data in Database"""
def __init__(self, subtype, data, msg=None):
m = "Database is missing data {} for {}".format(data, subtype)
super(PhylotyperError, self).__init__(subtype, m)
self.data = data<|fim▁end|> | if msg is None:
msg = "An error occured for subtype {}".format(subtype)
super(PhylotyperError, self).__init__(msg)
self.subtype = subtype |
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|>"""Custom Exception Classes for Phylotyper Module
"""
class PhylotyperError(Exception):
"""Basic exception for errors raised by Phylotyper modules"""
def __init__(self, subtype, msg=None):
if msg is None:
msg = "An error occured for subtype {}".format(subtype)
super(PhylotyperError, self).__init__(msg)
self.subtype = subtype
class ValuesError(PhylotyperError):
<|fim_middle|>
class DatabaseError(PhylotyperError):
"""Missing data in Database"""
def __init__(self, subtype, data, msg=None):
m = "Database is missing data {} for {}".format(data, subtype)
super(PhylotyperError, self).__init__(subtype, m)
self.data = data<|fim▁end|> | """Unknown subtype"""
def __init__(self, subtype, msg=None):
super(PhylotyperError, self).__init__(
subtype, msg="Unrecognized subtype {}".format(subtype)) |
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|>"""Custom Exception Classes for Phylotyper Module
"""
class PhylotyperError(Exception):
"""Basic exception for errors raised by Phylotyper modules"""
def __init__(self, subtype, msg=None):
if msg is None:
msg = "An error occured for subtype {}".format(subtype)
super(PhylotyperError, self).__init__(msg)
self.subtype = subtype
class ValuesError(PhylotyperError):
"""Unknown subtype"""
def __init__(self, subtype, msg=None):
<|fim_middle|>
class DatabaseError(PhylotyperError):
"""Missing data in Database"""
def __init__(self, subtype, data, msg=None):
m = "Database is missing data {} for {}".format(data, subtype)
super(PhylotyperError, self).__init__(subtype, m)
self.data = data<|fim▁end|> | super(PhylotyperError, self).__init__(
subtype, msg="Unrecognized subtype {}".format(subtype)) |
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|>"""Custom Exception Classes for Phylotyper Module
"""
class PhylotyperError(Exception):
"""Basic exception for errors raised by Phylotyper modules"""
def __init__(self, subtype, msg=None):
if msg is None:
msg = "An error occured for subtype {}".format(subtype)
super(PhylotyperError, self).__init__(msg)
self.subtype = subtype
class ValuesError(PhylotyperError):
"""Unknown subtype"""
def __init__(self, subtype, msg=None):
super(PhylotyperError, self).__init__(
subtype, msg="Unrecognized subtype {}".format(subtype))
class DatabaseError(PhylotyperError):
<|fim_middle|>
<|fim▁end|> | """Missing data in Database"""
def __init__(self, subtype, data, msg=None):
m = "Database is missing data {} for {}".format(data, subtype)
super(PhylotyperError, self).__init__(subtype, m)
self.data = data |
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|>"""Custom Exception Classes for Phylotyper Module
"""
class PhylotyperError(Exception):
"""Basic exception for errors raised by Phylotyper modules"""
def __init__(self, subtype, msg=None):
if msg is None:
msg = "An error occured for subtype {}".format(subtype)
super(PhylotyperError, self).__init__(msg)
self.subtype = subtype
class ValuesError(PhylotyperError):
"""Unknown subtype"""
def __init__(self, subtype, msg=None):
super(PhylotyperError, self).__init__(
subtype, msg="Unrecognized subtype {}".format(subtype))
class DatabaseError(PhylotyperError):
"""Missing data in Database"""
def __init__(self, subtype, data, msg=None):
<|fim_middle|>
<|fim▁end|> | m = "Database is missing data {} for {}".format(data, subtype)
super(PhylotyperError, self).__init__(subtype, m)
self.data = data |
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|>"""Custom Exception Classes for Phylotyper Module
"""
class PhylotyperError(Exception):
"""Basic exception for errors raised by Phylotyper modules"""
def __init__(self, subtype, msg=None):
if msg is None:
<|fim_middle|>
super(PhylotyperError, self).__init__(msg)
self.subtype = subtype
class ValuesError(PhylotyperError):
"""Unknown subtype"""
def __init__(self, subtype, msg=None):
super(PhylotyperError, self).__init__(
subtype, msg="Unrecognized subtype {}".format(subtype))
class DatabaseError(PhylotyperError):
"""Missing data in Database"""
def __init__(self, subtype, data, msg=None):
m = "Database is missing data {} for {}".format(data, subtype)
super(PhylotyperError, self).__init__(subtype, m)
self.data = data<|fim▁end|> | msg = "An error occured for subtype {}".format(subtype) |
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|>"""Custom Exception Classes for Phylotyper Module
"""
class PhylotyperError(Exception):
"""Basic exception for errors raised by Phylotyper modules"""
def <|fim_middle|>(self, subtype, msg=None):
if msg is None:
msg = "An error occured for subtype {}".format(subtype)
super(PhylotyperError, self).__init__(msg)
self.subtype = subtype
class ValuesError(PhylotyperError):
"""Unknown subtype"""
def __init__(self, subtype, msg=None):
super(PhylotyperError, self).__init__(
subtype, msg="Unrecognized subtype {}".format(subtype))
class DatabaseError(PhylotyperError):
"""Missing data in Database"""
def __init__(self, subtype, data, msg=None):
m = "Database is missing data {} for {}".format(data, subtype)
super(PhylotyperError, self).__init__(subtype, m)
self.data = data<|fim▁end|> | __init__ |
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|>"""Custom Exception Classes for Phylotyper Module
"""
class PhylotyperError(Exception):
"""Basic exception for errors raised by Phylotyper modules"""
def __init__(self, subtype, msg=None):
if msg is None:
msg = "An error occured for subtype {}".format(subtype)
super(PhylotyperError, self).__init__(msg)
self.subtype = subtype
class ValuesError(PhylotyperError):
"""Unknown subtype"""
def <|fim_middle|>(self, subtype, msg=None):
super(PhylotyperError, self).__init__(
subtype, msg="Unrecognized subtype {}".format(subtype))
class DatabaseError(PhylotyperError):
"""Missing data in Database"""
def __init__(self, subtype, data, msg=None):
m = "Database is missing data {} for {}".format(data, subtype)
super(PhylotyperError, self).__init__(subtype, m)
self.data = data<|fim▁end|> | __init__ |
<|file_name|>exceptions.py<|end_file_name|><|fim▁begin|>"""Custom Exception Classes for Phylotyper Module
"""
class PhylotyperError(Exception):
"""Basic exception for errors raised by Phylotyper modules"""
def __init__(self, subtype, msg=None):
if msg is None:
msg = "An error occured for subtype {}".format(subtype)
super(PhylotyperError, self).__init__(msg)
self.subtype = subtype
class ValuesError(PhylotyperError):
"""Unknown subtype"""
def __init__(self, subtype, msg=None):
super(PhylotyperError, self).__init__(
subtype, msg="Unrecognized subtype {}".format(subtype))
class DatabaseError(PhylotyperError):
"""Missing data in Database"""
def <|fim_middle|>(self, subtype, data, msg=None):
m = "Database is missing data {} for {}".format(data, subtype)
super(PhylotyperError, self).__init__(subtype, m)
self.data = data<|fim▁end|> | __init__ |
<|file_name|>test_dispatch.py<|end_file_name|><|fim▁begin|>import pytest
import urllib.error
from urlpathlib import UrlPath
def test_scheme():
# does not raise NotImplementedError
UrlPath('/dev/null').touch()
def test_scheme_not_supported():
with pytest.raises(NotImplementedError):
UrlPath('http:///tmp/test').touch()
def test_scheme_not_listed():
with pytest.raises(NotImplementedError):
UrlPath('test:///tmp/test').touch()
def test_file_additional():
assert UrlPath('.').resolve() == UrlPath.cwd()
def test_scheme_alias():
# does not raise NotImplementedError
with pytest.raises(urllib.error.URLError):<|fim▁hole|><|fim▁end|> | UrlPath('https://localhost/test').exists() |
<|file_name|>test_dispatch.py<|end_file_name|><|fim▁begin|>import pytest
import urllib.error
from urlpathlib import UrlPath
def test_scheme():
# does not raise NotImplementedError
<|fim_middle|>
def test_scheme_not_supported():
with pytest.raises(NotImplementedError):
UrlPath('http:///tmp/test').touch()
def test_scheme_not_listed():
with pytest.raises(NotImplementedError):
UrlPath('test:///tmp/test').touch()
def test_file_additional():
assert UrlPath('.').resolve() == UrlPath.cwd()
def test_scheme_alias():
# does not raise NotImplementedError
with pytest.raises(urllib.error.URLError):
UrlPath('https://localhost/test').exists()
<|fim▁end|> | UrlPath('/dev/null').touch() |
<|file_name|>test_dispatch.py<|end_file_name|><|fim▁begin|>import pytest
import urllib.error
from urlpathlib import UrlPath
def test_scheme():
# does not raise NotImplementedError
UrlPath('/dev/null').touch()
def test_scheme_not_supported():
<|fim_middle|>
def test_scheme_not_listed():
with pytest.raises(NotImplementedError):
UrlPath('test:///tmp/test').touch()
def test_file_additional():
assert UrlPath('.').resolve() == UrlPath.cwd()
def test_scheme_alias():
# does not raise NotImplementedError
with pytest.raises(urllib.error.URLError):
UrlPath('https://localhost/test').exists()
<|fim▁end|> | with pytest.raises(NotImplementedError):
UrlPath('http:///tmp/test').touch() |
<|file_name|>test_dispatch.py<|end_file_name|><|fim▁begin|>import pytest
import urllib.error
from urlpathlib import UrlPath
def test_scheme():
# does not raise NotImplementedError
UrlPath('/dev/null').touch()
def test_scheme_not_supported():
with pytest.raises(NotImplementedError):
UrlPath('http:///tmp/test').touch()
def test_scheme_not_listed():
<|fim_middle|>
def test_file_additional():
assert UrlPath('.').resolve() == UrlPath.cwd()
def test_scheme_alias():
# does not raise NotImplementedError
with pytest.raises(urllib.error.URLError):
UrlPath('https://localhost/test').exists()
<|fim▁end|> | with pytest.raises(NotImplementedError):
UrlPath('test:///tmp/test').touch() |
<|file_name|>test_dispatch.py<|end_file_name|><|fim▁begin|>import pytest
import urllib.error
from urlpathlib import UrlPath
def test_scheme():
# does not raise NotImplementedError
UrlPath('/dev/null').touch()
def test_scheme_not_supported():
with pytest.raises(NotImplementedError):
UrlPath('http:///tmp/test').touch()
def test_scheme_not_listed():
with pytest.raises(NotImplementedError):
UrlPath('test:///tmp/test').touch()
def test_file_additional():
<|fim_middle|>
def test_scheme_alias():
# does not raise NotImplementedError
with pytest.raises(urllib.error.URLError):
UrlPath('https://localhost/test').exists()
<|fim▁end|> | assert UrlPath('.').resolve() == UrlPath.cwd() |
<|file_name|>test_dispatch.py<|end_file_name|><|fim▁begin|>import pytest
import urllib.error
from urlpathlib import UrlPath
def test_scheme():
# does not raise NotImplementedError
UrlPath('/dev/null').touch()
def test_scheme_not_supported():
with pytest.raises(NotImplementedError):
UrlPath('http:///tmp/test').touch()
def test_scheme_not_listed():
with pytest.raises(NotImplementedError):
UrlPath('test:///tmp/test').touch()
def test_file_additional():
assert UrlPath('.').resolve() == UrlPath.cwd()
def test_scheme_alias():
# does not raise NotImplementedError
<|fim_middle|>
<|fim▁end|> | with pytest.raises(urllib.error.URLError):
UrlPath('https://localhost/test').exists() |
<|file_name|>test_dispatch.py<|end_file_name|><|fim▁begin|>import pytest
import urllib.error
from urlpathlib import UrlPath
def <|fim_middle|>():
# does not raise NotImplementedError
UrlPath('/dev/null').touch()
def test_scheme_not_supported():
with pytest.raises(NotImplementedError):
UrlPath('http:///tmp/test').touch()
def test_scheme_not_listed():
with pytest.raises(NotImplementedError):
UrlPath('test:///tmp/test').touch()
def test_file_additional():
assert UrlPath('.').resolve() == UrlPath.cwd()
def test_scheme_alias():
# does not raise NotImplementedError
with pytest.raises(urllib.error.URLError):
UrlPath('https://localhost/test').exists()
<|fim▁end|> | test_scheme |
<|file_name|>test_dispatch.py<|end_file_name|><|fim▁begin|>import pytest
import urllib.error
from urlpathlib import UrlPath
def test_scheme():
# does not raise NotImplementedError
UrlPath('/dev/null').touch()
def <|fim_middle|>():
with pytest.raises(NotImplementedError):
UrlPath('http:///tmp/test').touch()
def test_scheme_not_listed():
with pytest.raises(NotImplementedError):
UrlPath('test:///tmp/test').touch()
def test_file_additional():
assert UrlPath('.').resolve() == UrlPath.cwd()
def test_scheme_alias():
# does not raise NotImplementedError
with pytest.raises(urllib.error.URLError):
UrlPath('https://localhost/test').exists()
<|fim▁end|> | test_scheme_not_supported |
<|file_name|>test_dispatch.py<|end_file_name|><|fim▁begin|>import pytest
import urllib.error
from urlpathlib import UrlPath
def test_scheme():
# does not raise NotImplementedError
UrlPath('/dev/null').touch()
def test_scheme_not_supported():
with pytest.raises(NotImplementedError):
UrlPath('http:///tmp/test').touch()
def <|fim_middle|>():
with pytest.raises(NotImplementedError):
UrlPath('test:///tmp/test').touch()
def test_file_additional():
assert UrlPath('.').resolve() == UrlPath.cwd()
def test_scheme_alias():
# does not raise NotImplementedError
with pytest.raises(urllib.error.URLError):
UrlPath('https://localhost/test').exists()
<|fim▁end|> | test_scheme_not_listed |
<|file_name|>test_dispatch.py<|end_file_name|><|fim▁begin|>import pytest
import urllib.error
from urlpathlib import UrlPath
def test_scheme():
# does not raise NotImplementedError
UrlPath('/dev/null').touch()
def test_scheme_not_supported():
with pytest.raises(NotImplementedError):
UrlPath('http:///tmp/test').touch()
def test_scheme_not_listed():
with pytest.raises(NotImplementedError):
UrlPath('test:///tmp/test').touch()
def <|fim_middle|>():
assert UrlPath('.').resolve() == UrlPath.cwd()
def test_scheme_alias():
# does not raise NotImplementedError
with pytest.raises(urllib.error.URLError):
UrlPath('https://localhost/test').exists()
<|fim▁end|> | test_file_additional |
<|file_name|>test_dispatch.py<|end_file_name|><|fim▁begin|>import pytest
import urllib.error
from urlpathlib import UrlPath
def test_scheme():
# does not raise NotImplementedError
UrlPath('/dev/null').touch()
def test_scheme_not_supported():
with pytest.raises(NotImplementedError):
UrlPath('http:///tmp/test').touch()
def test_scheme_not_listed():
with pytest.raises(NotImplementedError):
UrlPath('test:///tmp/test').touch()
def test_file_additional():
assert UrlPath('.').resolve() == UrlPath.cwd()
def <|fim_middle|>():
# does not raise NotImplementedError
with pytest.raises(urllib.error.URLError):
UrlPath('https://localhost/test').exists()
<|fim▁end|> | test_scheme_alias |
<|file_name|>test_edalizer.py<|end_file_name|><|fim▁begin|># Copyright FuseSoC contributors
# Licensed under the 2-Clause BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-2-Clause
def test_generators():
import os
import tempfile
from fusesoc.config import Config
from fusesoc.coremanager import CoreManager
from fusesoc.edalizer import Edalizer
from fusesoc.librarymanager import Library
from fusesoc.vlnv import Vlnv
tests_dir = os.path.dirname(__file__)
cores_dir = os.path.join(tests_dir, "capi2_cores", "misc", "generate")
lib = Library("edalizer", cores_dir)
cm = CoreManager(Config())
cm.add_library(lib)
<|fim▁hole|> build_root = tempfile.mkdtemp(prefix="export_")
cache_root = tempfile.mkdtemp(prefix="export_cache_")
export_root = os.path.join(build_root, "exported_files")
edalizer = Edalizer(
toplevel=core.name,
flags={"tool": "icarus"},
core_manager=cm,
cache_root=cache_root,
work_root=os.path.join(build_root, "work"),
export_root=export_root,
system_name=None,
)
edalizer.run()
gendir = os.path.join(
cache_root, "generated", "generate-testgenerate_without_params_0"
)
assert os.path.isfile(os.path.join(gendir, "generated.core"))
assert os.path.isfile(os.path.join(gendir, "testgenerate_without_params_input.yml"))
gendir = os.path.join(
cache_root, "generated", "generate-testgenerate_with_params_0"
)
assert os.path.isfile(os.path.join(gendir, "generated.core"))
assert os.path.isfile(os.path.join(gendir, "testgenerate_with_params_input.yml"))<|fim▁end|> | core = cm.get_core(Vlnv("::generate"))
|
<|file_name|>test_edalizer.py<|end_file_name|><|fim▁begin|># Copyright FuseSoC contributors
# Licensed under the 2-Clause BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-2-Clause
def test_generators():
<|fim_middle|>
<|fim▁end|> | import os
import tempfile
from fusesoc.config import Config
from fusesoc.coremanager import CoreManager
from fusesoc.edalizer import Edalizer
from fusesoc.librarymanager import Library
from fusesoc.vlnv import Vlnv
tests_dir = os.path.dirname(__file__)
cores_dir = os.path.join(tests_dir, "capi2_cores", "misc", "generate")
lib = Library("edalizer", cores_dir)
cm = CoreManager(Config())
cm.add_library(lib)
core = cm.get_core(Vlnv("::generate"))
build_root = tempfile.mkdtemp(prefix="export_")
cache_root = tempfile.mkdtemp(prefix="export_cache_")
export_root = os.path.join(build_root, "exported_files")
edalizer = Edalizer(
toplevel=core.name,
flags={"tool": "icarus"},
core_manager=cm,
cache_root=cache_root,
work_root=os.path.join(build_root, "work"),
export_root=export_root,
system_name=None,
)
edalizer.run()
gendir = os.path.join(
cache_root, "generated", "generate-testgenerate_without_params_0"
)
assert os.path.isfile(os.path.join(gendir, "generated.core"))
assert os.path.isfile(os.path.join(gendir, "testgenerate_without_params_input.yml"))
gendir = os.path.join(
cache_root, "generated", "generate-testgenerate_with_params_0"
)
assert os.path.isfile(os.path.join(gendir, "generated.core"))
assert os.path.isfile(os.path.join(gendir, "testgenerate_with_params_input.yml")) |
<|file_name|>test_edalizer.py<|end_file_name|><|fim▁begin|># Copyright FuseSoC contributors
# Licensed under the 2-Clause BSD License, see LICENSE for details.
# SPDX-License-Identifier: BSD-2-Clause
def <|fim_middle|>():
import os
import tempfile
from fusesoc.config import Config
from fusesoc.coremanager import CoreManager
from fusesoc.edalizer import Edalizer
from fusesoc.librarymanager import Library
from fusesoc.vlnv import Vlnv
tests_dir = os.path.dirname(__file__)
cores_dir = os.path.join(tests_dir, "capi2_cores", "misc", "generate")
lib = Library("edalizer", cores_dir)
cm = CoreManager(Config())
cm.add_library(lib)
core = cm.get_core(Vlnv("::generate"))
build_root = tempfile.mkdtemp(prefix="export_")
cache_root = tempfile.mkdtemp(prefix="export_cache_")
export_root = os.path.join(build_root, "exported_files")
edalizer = Edalizer(
toplevel=core.name,
flags={"tool": "icarus"},
core_manager=cm,
cache_root=cache_root,
work_root=os.path.join(build_root, "work"),
export_root=export_root,
system_name=None,
)
edalizer.run()
gendir = os.path.join(
cache_root, "generated", "generate-testgenerate_without_params_0"
)
assert os.path.isfile(os.path.join(gendir, "generated.core"))
assert os.path.isfile(os.path.join(gendir, "testgenerate_without_params_input.yml"))
gendir = os.path.join(
cache_root, "generated", "generate-testgenerate_with_params_0"
)
assert os.path.isfile(os.path.join(gendir, "generated.core"))
assert os.path.isfile(os.path.join(gendir, "testgenerate_with_params_input.yml"))
<|fim▁end|> | test_generators |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># This file is part of Indico.
# Copyright (C) 2002 - 2022 CERN
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see the
# LICENSE file for more details.
import os
from indico.core import signals
from indico.core.db import db
from .logger import logger
from .oauth2 import require_oauth
<|fim▁hole|>@signals.core.app_created.connect
def _no_ssl_required_on_debug(app, **kwargs):
if app.debug or app.testing:
os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1'
@signals.users.merged.connect
def _delete_merged_user_tokens(target, source, **kwargs):
target_app_links = {link.application: link for link in target.oauth_app_links}
for source_link in source.oauth_app_links.all():
try:
target_link = target_app_links[source_link.application]
except KeyError:
logger.info('merge: reassigning %r to %r', source_link, target)
source_link.user = target
else:
logger.info('merge: merging %r into %r', source_link, target_link)
target_link.update_scopes(set(source_link.scopes))
target_link.tokens.extend(source_link.tokens)
db.session.delete(source_link)<|fim▁end|> | __all__ = ['require_oauth']
|
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># This file is part of Indico.
# Copyright (C) 2002 - 2022 CERN
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see the
# LICENSE file for more details.
import os
from indico.core import signals
from indico.core.db import db
from .logger import logger
from .oauth2 import require_oauth
__all__ = ['require_oauth']
@signals.core.app_created.connect
def _no_ssl_required_on_debug(app, **kwargs):
<|fim_middle|>
@signals.users.merged.connect
def _delete_merged_user_tokens(target, source, **kwargs):
target_app_links = {link.application: link for link in target.oauth_app_links}
for source_link in source.oauth_app_links.all():
try:
target_link = target_app_links[source_link.application]
except KeyError:
logger.info('merge: reassigning %r to %r', source_link, target)
source_link.user = target
else:
logger.info('merge: merging %r into %r', source_link, target_link)
target_link.update_scopes(set(source_link.scopes))
target_link.tokens.extend(source_link.tokens)
db.session.delete(source_link)
<|fim▁end|> | if app.debug or app.testing:
os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1' |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># This file is part of Indico.
# Copyright (C) 2002 - 2022 CERN
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see the
# LICENSE file for more details.
import os
from indico.core import signals
from indico.core.db import db
from .logger import logger
from .oauth2 import require_oauth
__all__ = ['require_oauth']
@signals.core.app_created.connect
def _no_ssl_required_on_debug(app, **kwargs):
if app.debug or app.testing:
os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1'
@signals.users.merged.connect
def _delete_merged_user_tokens(target, source, **kwargs):
<|fim_middle|>
<|fim▁end|> | target_app_links = {link.application: link for link in target.oauth_app_links}
for source_link in source.oauth_app_links.all():
try:
target_link = target_app_links[source_link.application]
except KeyError:
logger.info('merge: reassigning %r to %r', source_link, target)
source_link.user = target
else:
logger.info('merge: merging %r into %r', source_link, target_link)
target_link.update_scopes(set(source_link.scopes))
target_link.tokens.extend(source_link.tokens)
db.session.delete(source_link) |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># This file is part of Indico.
# Copyright (C) 2002 - 2022 CERN
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see the
# LICENSE file for more details.
import os
from indico.core import signals
from indico.core.db import db
from .logger import logger
from .oauth2 import require_oauth
__all__ = ['require_oauth']
@signals.core.app_created.connect
def _no_ssl_required_on_debug(app, **kwargs):
if app.debug or app.testing:
<|fim_middle|>
@signals.users.merged.connect
def _delete_merged_user_tokens(target, source, **kwargs):
target_app_links = {link.application: link for link in target.oauth_app_links}
for source_link in source.oauth_app_links.all():
try:
target_link = target_app_links[source_link.application]
except KeyError:
logger.info('merge: reassigning %r to %r', source_link, target)
source_link.user = target
else:
logger.info('merge: merging %r into %r', source_link, target_link)
target_link.update_scopes(set(source_link.scopes))
target_link.tokens.extend(source_link.tokens)
db.session.delete(source_link)
<|fim▁end|> | os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1' |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># This file is part of Indico.
# Copyright (C) 2002 - 2022 CERN
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see the
# LICENSE file for more details.
import os
from indico.core import signals
from indico.core.db import db
from .logger import logger
from .oauth2 import require_oauth
__all__ = ['require_oauth']
@signals.core.app_created.connect
def _no_ssl_required_on_debug(app, **kwargs):
if app.debug or app.testing:
os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1'
@signals.users.merged.connect
def _delete_merged_user_tokens(target, source, **kwargs):
target_app_links = {link.application: link for link in target.oauth_app_links}
for source_link in source.oauth_app_links.all():
try:
target_link = target_app_links[source_link.application]
except KeyError:
logger.info('merge: reassigning %r to %r', source_link, target)
source_link.user = target
else:
<|fim_middle|>
<|fim▁end|> | logger.info('merge: merging %r into %r', source_link, target_link)
target_link.update_scopes(set(source_link.scopes))
target_link.tokens.extend(source_link.tokens)
db.session.delete(source_link) |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># This file is part of Indico.
# Copyright (C) 2002 - 2022 CERN
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see the
# LICENSE file for more details.
import os
from indico.core import signals
from indico.core.db import db
from .logger import logger
from .oauth2 import require_oauth
__all__ = ['require_oauth']
@signals.core.app_created.connect
def <|fim_middle|>(app, **kwargs):
if app.debug or app.testing:
os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1'
@signals.users.merged.connect
def _delete_merged_user_tokens(target, source, **kwargs):
target_app_links = {link.application: link for link in target.oauth_app_links}
for source_link in source.oauth_app_links.all():
try:
target_link = target_app_links[source_link.application]
except KeyError:
logger.info('merge: reassigning %r to %r', source_link, target)
source_link.user = target
else:
logger.info('merge: merging %r into %r', source_link, target_link)
target_link.update_scopes(set(source_link.scopes))
target_link.tokens.extend(source_link.tokens)
db.session.delete(source_link)
<|fim▁end|> | _no_ssl_required_on_debug |
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|># This file is part of Indico.
# Copyright (C) 2002 - 2022 CERN
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see the
# LICENSE file for more details.
import os
from indico.core import signals
from indico.core.db import db
from .logger import logger
from .oauth2 import require_oauth
__all__ = ['require_oauth']
@signals.core.app_created.connect
def _no_ssl_required_on_debug(app, **kwargs):
if app.debug or app.testing:
os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1'
@signals.users.merged.connect
def <|fim_middle|>(target, source, **kwargs):
target_app_links = {link.application: link for link in target.oauth_app_links}
for source_link in source.oauth_app_links.all():
try:
target_link = target_app_links[source_link.application]
except KeyError:
logger.info('merge: reassigning %r to %r', source_link, target)
source_link.user = target
else:
logger.info('merge: merging %r into %r', source_link, target_link)
target_link.update_scopes(set(source_link.scopes))
target_link.tokens.extend(source_link.tokens)
db.session.delete(source_link)
<|fim▁end|> | _delete_merged_user_tokens |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00<|fim▁hole|>
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals<|fim▁end|> | score_total = 0.00 |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
<|fim_middle|>
<|fim▁end|> | def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
<|fim_middle|>
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score() |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
<|fim_middle|>
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0 |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
<|fim_middle|>
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | return self.daily_weights[day_of_week] |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
<|fim_middle|>
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10) |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
<|fim_middle|>
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
<|fim_middle|>
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
<|fim_middle|>
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | return self.location |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
<|fim_middle|>
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
<|fim_middle|>
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | return self.final_weighted |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
<|fim_middle|>
def get_evals(self):
return self.evals
<|fim▁end|> | return self.weight_rank |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
<|fim_middle|>
<|fim▁end|> | return self.evals |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
<|fim_middle|>
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score() |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
<|fim_middle|>
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | value /= ( maximum - minimum ) |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
<|fim_middle|>
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | value = 0 |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
<|fim_middle|>
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1 |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
<|fim_middle|>
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day] |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
<|fim_middle|>
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | self.daily_weights[day] = 0 |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
<|fim_middle|>
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | weights *= 1.15 # 15% Boost |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
<|fim_middle|>
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | weights *= (PARTIAL_HOURS/FULL_HOURS) |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
<|fim_middle|>
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | weights *= (HALF_HOURS/FULL_HOURS) |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
<|fim_middle|>
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | weights *= (SPARSE_HOURS/FULL_HOURS) |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
<|fim_middle|>
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | weights *= (1.00/FULL_HOURS) |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def <|fim_middle|>(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | __init__ |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def <|fim_middle|>(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | reset_daily_weights |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def <|fim_middle|>(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | get_daily_weight |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def <|fim_middle|>(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | normalize_final_weighted_score |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def <|fim_middle|>(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | calculate_final_weighted_score |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def <|fim_middle|>(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | adjust_utilization |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def <|fim_middle|>(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | get_location |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def <|fim_middle|>(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | find_location |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def <|fim_middle|>(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | get_final_weighted_score |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def <|fim_middle|>(self):
return self.weight_rank
def get_evals(self):
return self.evals
<|fim▁end|> | get_score_rank |
<|file_name|>location.py<|end_file_name|><|fim▁begin|>from rec import CourseRecord
from score import RoomScore
from evaluation import ScheduleEvaluation
FULL_HOURS = 8 # 8:00AM - 4:00PM utilization
PARTIAL_HOURS = FULL_HOURS * 0.75 #75%
HALF_HOURS = FULL_HOURS * 0.50 #50%
SPARSE_HOURS = FULL_HOURS * 0.25 #25%
class LocationScore:
def __init__(self, evals=None):
self.evals = evals
self.courses = None
self.location = None
self.daily_weights = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.daily_totals = {"M": {}, "T": {}, "W": {}, "R": {}, "F": {} ,"S": {}}
self.final_weighted = 0
self.weight_rank = 0 # 0 = worst, 1 = best
if evals != None:
self.courses = self.evals.get_records()
self.location = self.find_location()
self.final_weighted = self.calculate_final_weighted_score()
def reset_daily_weights(self):
for day in ["M", "T", "W", "R", "F", "S"]:
self.daily_weights[day] = 0
self.daily_totals[day] = 0
def get_daily_weight(self,day_of_week):
return self.daily_weights[day_of_week]
def normalize_final_weighted_score(self,minimum,maximum):
value = self.final_weighted
value -= minimum
if maximum - minimum > 0:
value /= ( maximum - minimum )
else:
value = 0
self.weight_rank = "{0:.2f}".format(value * 10)
def calculate_final_weighted_score(self):
score_sum = 0.00
score_total = 0.00
#reset daily stuff
self.reset_daily_weights()
for course, score in self.courses:
days = course.rec["DAYS_OF_WEEK"]
#score_sum += score.get_weighted_score(course)
score_total += 1.00
for day in ["M", "T", "W", "R", "F", "S"]:
if day in days:
self.daily_weights[day] += score.get_weighted_score(course)
self.daily_totals[day] += 1
for day in ["M", "T", "W", "R", "F", "S"]:
if self.daily_totals[day] > 0:
self.daily_weights[day] /= self.daily_totals[day]
self.daily_weights[day] = self.adjust_utilization(self.daily_weights[day],self.daily_totals[day])
score_sum += self.daily_weights[day]
else:
self.daily_weights[day] = 0
return score_sum / score_total
def adjust_utilization(self,weights,totals):
max_score = 1.00
if totals >= FULL_HOURS: # 8 Hours or more, give slight boost to score
weights *= 1.15 # 15% Boost
elif totals >= PARTIAL_HOURS: # Small Penalty
weights *= (PARTIAL_HOURS/FULL_HOURS)
elif totals >= HALF_HOURS: # Medium Penalty
weights *= (HALF_HOURS/FULL_HOURS)
elif totals > SPARSE_HOURS: # Large Penalty
weights *= (SPARSE_HOURS/FULL_HOURS)
else: # Very Large Penalty
weights *= (1.00/FULL_HOURS)
return weights
def get_location(self):
return self.location
def find_location(self):
for course, score in self.courses:
location = str( course.rec["BUILDING"] )+ " " + str( course.rec["ROOM"] )
# just need to find the first one, so break after this happens
break
return location
def get_final_weighted_score(self):
return self.final_weighted
def get_score_rank(self):
return self.weight_rank
def <|fim_middle|>(self):
return self.evals
<|fim▁end|> | get_evals |
<|file_name|>recursive_auto_encoder.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging, os
logging.basicConfig(level=logging.INFO)
from deepy.networks import RecursiveAutoEncoder
from deepy.trainers import SGDTrainer, LearningRateAnnealer
from util import get_data, VECTOR_SIZE
model_path = os.path.join(os.path.dirname(__file__), "models", "rae1.gz")
if __name__ == '__main__':<|fim▁hole|>
trainer = SGDTrainer(model)
annealer = LearningRateAnnealer()
trainer.run(get_data(), epoch_controllers=[annealer])
model.save_params(model_path)<|fim▁end|> | model = RecursiveAutoEncoder(input_dim=VECTOR_SIZE, rep_dim=10) |
<|file_name|>recursive_auto_encoder.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging, os
logging.basicConfig(level=logging.INFO)
from deepy.networks import RecursiveAutoEncoder
from deepy.trainers import SGDTrainer, LearningRateAnnealer
from util import get_data, VECTOR_SIZE
model_path = os.path.join(os.path.dirname(__file__), "models", "rae1.gz")
if __name__ == '__main__':
<|fim_middle|>
<|fim▁end|> | model = RecursiveAutoEncoder(input_dim=VECTOR_SIZE, rep_dim=10)
trainer = SGDTrainer(model)
annealer = LearningRateAnnealer()
trainer.run(get_data(), epoch_controllers=[annealer])
model.save_params(model_path) |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
return [i for i in xrange(10)]
<|fim▁hole|>
@pytest.fixture
def average_list():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def test_sorted(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_worst(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_average(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_repeats():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def test_multiple_types():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']<|fim▁end|> | @pytest.fixture
def reverse_list():
return [i for i in xrange(9, -1, -1)] |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
<|fim_middle|>
@pytest.fixture
def reverse_list():
return [i for i in xrange(9, -1, -1)]
@pytest.fixture
def average_list():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def test_sorted(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_worst(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_average(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_repeats():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def test_multiple_types():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']
<|fim▁end|> | return [i for i in xrange(10)] |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
return [i for i in xrange(10)]
@pytest.fixture
def reverse_list():
<|fim_middle|>
@pytest.fixture
def average_list():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def test_sorted(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_worst(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_average(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_repeats():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def test_multiple_types():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']
<|fim▁end|> | return [i for i in xrange(9, -1, -1)] |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
return [i for i in xrange(10)]
@pytest.fixture
def reverse_list():
return [i for i in xrange(9, -1, -1)]
@pytest.fixture
def average_list():
<|fim_middle|>
def test_sorted(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_worst(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_average(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_repeats():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def test_multiple_types():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']
<|fim▁end|> | return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3] |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
return [i for i in xrange(10)]
@pytest.fixture
def reverse_list():
return [i for i in xrange(9, -1, -1)]
@pytest.fixture
def average_list():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def test_sorted(sorted_list):
<|fim_middle|>
def test_worst(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_average(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_repeats():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def test_multiple_types():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']
<|fim▁end|> | insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
return [i for i in xrange(10)]
@pytest.fixture
def reverse_list():
return [i for i in xrange(9, -1, -1)]
@pytest.fixture
def average_list():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def test_sorted(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_worst(reverse_list):
<|fim_middle|>
def test_average(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_repeats():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def test_multiple_types():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']
<|fim▁end|> | insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
return [i for i in xrange(10)]
@pytest.fixture
def reverse_list():
return [i for i in xrange(9, -1, -1)]
@pytest.fixture
def average_list():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def test_sorted(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_worst(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_average(average_list):
<|fim_middle|>
def test_repeats():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def test_multiple_types():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']
<|fim▁end|> | insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
return [i for i in xrange(10)]
@pytest.fixture
def reverse_list():
return [i for i in xrange(9, -1, -1)]
@pytest.fixture
def average_list():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def test_sorted(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_worst(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_average(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_repeats():
<|fim_middle|>
def test_multiple_types():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']
<|fim▁end|> | l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9] |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
return [i for i in xrange(10)]
@pytest.fixture
def reverse_list():
return [i for i in xrange(9, -1, -1)]
@pytest.fixture
def average_list():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def test_sorted(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_worst(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_average(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_repeats():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def test_multiple_types():
<|fim_middle|>
<|fim▁end|> | l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo'] |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def <|fim_middle|>():
return [i for i in xrange(10)]
@pytest.fixture
def reverse_list():
return [i for i in xrange(9, -1, -1)]
@pytest.fixture
def average_list():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def test_sorted(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_worst(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_average(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_repeats():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def test_multiple_types():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']
<|fim▁end|> | sorted_list |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
return [i for i in xrange(10)]
@pytest.fixture
def <|fim_middle|>():
return [i for i in xrange(9, -1, -1)]
@pytest.fixture
def average_list():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def test_sorted(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_worst(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_average(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_repeats():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def test_multiple_types():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']
<|fim▁end|> | reverse_list |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
return [i for i in xrange(10)]
@pytest.fixture
def reverse_list():
return [i for i in xrange(9, -1, -1)]
@pytest.fixture
def <|fim_middle|>():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def test_sorted(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_worst(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_average(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_repeats():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def test_multiple_types():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']
<|fim▁end|> | average_list |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
return [i for i in xrange(10)]
@pytest.fixture
def reverse_list():
return [i for i in xrange(9, -1, -1)]
@pytest.fixture
def average_list():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def <|fim_middle|>(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_worst(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_average(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_repeats():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def test_multiple_types():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']
<|fim▁end|> | test_sorted |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
return [i for i in xrange(10)]
@pytest.fixture
def reverse_list():
return [i for i in xrange(9, -1, -1)]
@pytest.fixture
def average_list():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def test_sorted(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def <|fim_middle|>(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_average(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_repeats():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def test_multiple_types():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']
<|fim▁end|> | test_worst |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
return [i for i in xrange(10)]
@pytest.fixture
def reverse_list():
return [i for i in xrange(9, -1, -1)]
@pytest.fixture
def average_list():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def test_sorted(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_worst(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def <|fim_middle|>(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_repeats():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def test_multiple_types():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']
<|fim▁end|> | test_average |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
return [i for i in xrange(10)]
@pytest.fixture
def reverse_list():
return [i for i in xrange(9, -1, -1)]
@pytest.fixture
def average_list():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def test_sorted(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_worst(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_average(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def <|fim_middle|>():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def test_multiple_types():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']
<|fim▁end|> | test_repeats |
<|file_name|>test_insertion_sort.py<|end_file_name|><|fim▁begin|># -*- coding utf-8 -*-
from __future__ import unicode_literals
import pytest
from structures.insertion_sort import insertion_sort
@pytest.fixture
def sorted_list():
return [i for i in xrange(10)]
@pytest.fixture
def reverse_list():
return [i for i in xrange(9, -1, -1)]
@pytest.fixture
def average_list():
return [5, 9, 2, 4, 1, 6, 8, 7, 0, 3]
def test_sorted(sorted_list):
insertion_sort(sorted_list)
assert sorted_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_worst(reverse_list):
insertion_sort(reverse_list)
assert reverse_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_average(average_list):
insertion_sort(average_list)
assert average_list == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
def test_repeats():
l = [3, 6, 7, 3, 9, 5, 2, 7]
insertion_sort(l)
assert l == [2, 3, 3, 5, 6, 7, 7, 9]
def <|fim_middle|>():
l = [3, 'foo', 2.8, True, []]
# python 2 sorting is crazy
insertion_sort(l)
assert l == [True, 2.8, 3, [], 'foo']
<|fim▁end|> | test_multiple_types |
<|file_name|>test_util.py<|end_file_name|><|fim▁begin|>import unittest
import numpy as np
from bayesnet.image.util import img2patch, patch2img
class TestImg2Patch(unittest.TestCase):
def test_img2patch(self):
img = np.arange(16).reshape(1, 4, 4, 1)
patch = img2patch(img, size=3, step=1)
expected = np.asarray([
[img[0, 0:3, 0:3, 0], img[0, 0:3, 1:4, 0]],
[img[0, 1:4, 0:3, 0], img[0, 1:4, 1:4, 0]]
])
expected = expected[None, ..., None]
self.assertTrue((patch == expected).all())
imgs = [
np.random.randn(2, 5, 6, 3),
np.random.randn(3, 10, 10, 2),
np.random.randn(1, 23, 17, 5)
]
sizes = [
(1, 1),
2,
(3, 4)
]
steps = [
(1, 2),
(3, 1),
3
]
shapes = [
(2, 5, 3, 1, 1, 3),
(3, 3, 9, 2, 2, 2),
(1, 7, 5, 3, 4, 5)
]
for img, size, step, shape in zip(imgs, sizes, steps, shapes):
self.assertEqual(shape, img2patch(img, size, step).shape)
class TestPatch2Img(unittest.TestCase):
def test_patch2img(self):
img = np.arange(16).reshape(1, 4, 4, 1)
patch = img2patch(img, size=2, step=2)
self.assertTrue((img == patch2img(patch, (2, 2), (1, 4, 4, 1))).all())
patch = img2patch(img, size=3, step=1)
expected = np.arange(0, 32, 2).reshape(1, 4, 4, 1)
expected[0, 0, 0, 0] /= 2
expected[0, 0, -1, 0] /= 2
expected[0, -1, 0, 0] /= 2
expected[0, -1, -1, 0] /= 2
expected[0, 1:3, 1:3, 0] *= 2
self.assertTrue((expected == patch2img(patch, (1, 1), (1, 4, 4, 1))).all())
<|fim▁hole|><|fim▁end|> |
if __name__ == '__main__':
unittest.main() |
<|file_name|>test_util.py<|end_file_name|><|fim▁begin|>import unittest
import numpy as np
from bayesnet.image.util import img2patch, patch2img
class TestImg2Patch(unittest.TestCase):
<|fim_middle|>
class TestPatch2Img(unittest.TestCase):
def test_patch2img(self):
img = np.arange(16).reshape(1, 4, 4, 1)
patch = img2patch(img, size=2, step=2)
self.assertTrue((img == patch2img(patch, (2, 2), (1, 4, 4, 1))).all())
patch = img2patch(img, size=3, step=1)
expected = np.arange(0, 32, 2).reshape(1, 4, 4, 1)
expected[0, 0, 0, 0] /= 2
expected[0, 0, -1, 0] /= 2
expected[0, -1, 0, 0] /= 2
expected[0, -1, -1, 0] /= 2
expected[0, 1:3, 1:3, 0] *= 2
self.assertTrue((expected == patch2img(patch, (1, 1), (1, 4, 4, 1))).all())
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | def test_img2patch(self):
img = np.arange(16).reshape(1, 4, 4, 1)
patch = img2patch(img, size=3, step=1)
expected = np.asarray([
[img[0, 0:3, 0:3, 0], img[0, 0:3, 1:4, 0]],
[img[0, 1:4, 0:3, 0], img[0, 1:4, 1:4, 0]]
])
expected = expected[None, ..., None]
self.assertTrue((patch == expected).all())
imgs = [
np.random.randn(2, 5, 6, 3),
np.random.randn(3, 10, 10, 2),
np.random.randn(1, 23, 17, 5)
]
sizes = [
(1, 1),
2,
(3, 4)
]
steps = [
(1, 2),
(3, 1),
3
]
shapes = [
(2, 5, 3, 1, 1, 3),
(3, 3, 9, 2, 2, 2),
(1, 7, 5, 3, 4, 5)
]
for img, size, step, shape in zip(imgs, sizes, steps, shapes):
self.assertEqual(shape, img2patch(img, size, step).shape) |
<|file_name|>test_util.py<|end_file_name|><|fim▁begin|>import unittest
import numpy as np
from bayesnet.image.util import img2patch, patch2img
class TestImg2Patch(unittest.TestCase):
def test_img2patch(self):
<|fim_middle|>
class TestPatch2Img(unittest.TestCase):
def test_patch2img(self):
img = np.arange(16).reshape(1, 4, 4, 1)
patch = img2patch(img, size=2, step=2)
self.assertTrue((img == patch2img(patch, (2, 2), (1, 4, 4, 1))).all())
patch = img2patch(img, size=3, step=1)
expected = np.arange(0, 32, 2).reshape(1, 4, 4, 1)
expected[0, 0, 0, 0] /= 2
expected[0, 0, -1, 0] /= 2
expected[0, -1, 0, 0] /= 2
expected[0, -1, -1, 0] /= 2
expected[0, 1:3, 1:3, 0] *= 2
self.assertTrue((expected == patch2img(patch, (1, 1), (1, 4, 4, 1))).all())
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | img = np.arange(16).reshape(1, 4, 4, 1)
patch = img2patch(img, size=3, step=1)
expected = np.asarray([
[img[0, 0:3, 0:3, 0], img[0, 0:3, 1:4, 0]],
[img[0, 1:4, 0:3, 0], img[0, 1:4, 1:4, 0]]
])
expected = expected[None, ..., None]
self.assertTrue((patch == expected).all())
imgs = [
np.random.randn(2, 5, 6, 3),
np.random.randn(3, 10, 10, 2),
np.random.randn(1, 23, 17, 5)
]
sizes = [
(1, 1),
2,
(3, 4)
]
steps = [
(1, 2),
(3, 1),
3
]
shapes = [
(2, 5, 3, 1, 1, 3),
(3, 3, 9, 2, 2, 2),
(1, 7, 5, 3, 4, 5)
]
for img, size, step, shape in zip(imgs, sizes, steps, shapes):
self.assertEqual(shape, img2patch(img, size, step).shape) |
<|file_name|>test_util.py<|end_file_name|><|fim▁begin|>import unittest
import numpy as np
from bayesnet.image.util import img2patch, patch2img
class TestImg2Patch(unittest.TestCase):
def test_img2patch(self):
img = np.arange(16).reshape(1, 4, 4, 1)
patch = img2patch(img, size=3, step=1)
expected = np.asarray([
[img[0, 0:3, 0:3, 0], img[0, 0:3, 1:4, 0]],
[img[0, 1:4, 0:3, 0], img[0, 1:4, 1:4, 0]]
])
expected = expected[None, ..., None]
self.assertTrue((patch == expected).all())
imgs = [
np.random.randn(2, 5, 6, 3),
np.random.randn(3, 10, 10, 2),
np.random.randn(1, 23, 17, 5)
]
sizes = [
(1, 1),
2,
(3, 4)
]
steps = [
(1, 2),
(3, 1),
3
]
shapes = [
(2, 5, 3, 1, 1, 3),
(3, 3, 9, 2, 2, 2),
(1, 7, 5, 3, 4, 5)
]
for img, size, step, shape in zip(imgs, sizes, steps, shapes):
self.assertEqual(shape, img2patch(img, size, step).shape)
class TestPatch2Img(unittest.TestCase):
<|fim_middle|>
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | def test_patch2img(self):
img = np.arange(16).reshape(1, 4, 4, 1)
patch = img2patch(img, size=2, step=2)
self.assertTrue((img == patch2img(patch, (2, 2), (1, 4, 4, 1))).all())
patch = img2patch(img, size=3, step=1)
expected = np.arange(0, 32, 2).reshape(1, 4, 4, 1)
expected[0, 0, 0, 0] /= 2
expected[0, 0, -1, 0] /= 2
expected[0, -1, 0, 0] /= 2
expected[0, -1, -1, 0] /= 2
expected[0, 1:3, 1:3, 0] *= 2
self.assertTrue((expected == patch2img(patch, (1, 1), (1, 4, 4, 1))).all()) |
<|file_name|>test_util.py<|end_file_name|><|fim▁begin|>import unittest
import numpy as np
from bayesnet.image.util import img2patch, patch2img
class TestImg2Patch(unittest.TestCase):
def test_img2patch(self):
img = np.arange(16).reshape(1, 4, 4, 1)
patch = img2patch(img, size=3, step=1)
expected = np.asarray([
[img[0, 0:3, 0:3, 0], img[0, 0:3, 1:4, 0]],
[img[0, 1:4, 0:3, 0], img[0, 1:4, 1:4, 0]]
])
expected = expected[None, ..., None]
self.assertTrue((patch == expected).all())
imgs = [
np.random.randn(2, 5, 6, 3),
np.random.randn(3, 10, 10, 2),
np.random.randn(1, 23, 17, 5)
]
sizes = [
(1, 1),
2,
(3, 4)
]
steps = [
(1, 2),
(3, 1),
3
]
shapes = [
(2, 5, 3, 1, 1, 3),
(3, 3, 9, 2, 2, 2),
(1, 7, 5, 3, 4, 5)
]
for img, size, step, shape in zip(imgs, sizes, steps, shapes):
self.assertEqual(shape, img2patch(img, size, step).shape)
class TestPatch2Img(unittest.TestCase):
def test_patch2img(self):
<|fim_middle|>
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | img = np.arange(16).reshape(1, 4, 4, 1)
patch = img2patch(img, size=2, step=2)
self.assertTrue((img == patch2img(patch, (2, 2), (1, 4, 4, 1))).all())
patch = img2patch(img, size=3, step=1)
expected = np.arange(0, 32, 2).reshape(1, 4, 4, 1)
expected[0, 0, 0, 0] /= 2
expected[0, 0, -1, 0] /= 2
expected[0, -1, 0, 0] /= 2
expected[0, -1, -1, 0] /= 2
expected[0, 1:3, 1:3, 0] *= 2
self.assertTrue((expected == patch2img(patch, (1, 1), (1, 4, 4, 1))).all()) |
<|file_name|>test_util.py<|end_file_name|><|fim▁begin|>import unittest
import numpy as np
from bayesnet.image.util import img2patch, patch2img
class TestImg2Patch(unittest.TestCase):
def test_img2patch(self):
img = np.arange(16).reshape(1, 4, 4, 1)
patch = img2patch(img, size=3, step=1)
expected = np.asarray([
[img[0, 0:3, 0:3, 0], img[0, 0:3, 1:4, 0]],
[img[0, 1:4, 0:3, 0], img[0, 1:4, 1:4, 0]]
])
expected = expected[None, ..., None]
self.assertTrue((patch == expected).all())
imgs = [
np.random.randn(2, 5, 6, 3),
np.random.randn(3, 10, 10, 2),
np.random.randn(1, 23, 17, 5)
]
sizes = [
(1, 1),
2,
(3, 4)
]
steps = [
(1, 2),
(3, 1),
3
]
shapes = [
(2, 5, 3, 1, 1, 3),
(3, 3, 9, 2, 2, 2),
(1, 7, 5, 3, 4, 5)
]
for img, size, step, shape in zip(imgs, sizes, steps, shapes):
self.assertEqual(shape, img2patch(img, size, step).shape)
class TestPatch2Img(unittest.TestCase):
def test_patch2img(self):
img = np.arange(16).reshape(1, 4, 4, 1)
patch = img2patch(img, size=2, step=2)
self.assertTrue((img == patch2img(patch, (2, 2), (1, 4, 4, 1))).all())
patch = img2patch(img, size=3, step=1)
expected = np.arange(0, 32, 2).reshape(1, 4, 4, 1)
expected[0, 0, 0, 0] /= 2
expected[0, 0, -1, 0] /= 2
expected[0, -1, 0, 0] /= 2
expected[0, -1, -1, 0] /= 2
expected[0, 1:3, 1:3, 0] *= 2
self.assertTrue((expected == patch2img(patch, (1, 1), (1, 4, 4, 1))).all())
if __name__ == '__main__':
<|fim_middle|>
<|fim▁end|> | unittest.main() |
<|file_name|>test_util.py<|end_file_name|><|fim▁begin|>import unittest
import numpy as np
from bayesnet.image.util import img2patch, patch2img
class TestImg2Patch(unittest.TestCase):
def <|fim_middle|>(self):
img = np.arange(16).reshape(1, 4, 4, 1)
patch = img2patch(img, size=3, step=1)
expected = np.asarray([
[img[0, 0:3, 0:3, 0], img[0, 0:3, 1:4, 0]],
[img[0, 1:4, 0:3, 0], img[0, 1:4, 1:4, 0]]
])
expected = expected[None, ..., None]
self.assertTrue((patch == expected).all())
imgs = [
np.random.randn(2, 5, 6, 3),
np.random.randn(3, 10, 10, 2),
np.random.randn(1, 23, 17, 5)
]
sizes = [
(1, 1),
2,
(3, 4)
]
steps = [
(1, 2),
(3, 1),
3
]
shapes = [
(2, 5, 3, 1, 1, 3),
(3, 3, 9, 2, 2, 2),
(1, 7, 5, 3, 4, 5)
]
for img, size, step, shape in zip(imgs, sizes, steps, shapes):
self.assertEqual(shape, img2patch(img, size, step).shape)
class TestPatch2Img(unittest.TestCase):
def test_patch2img(self):
img = np.arange(16).reshape(1, 4, 4, 1)
patch = img2patch(img, size=2, step=2)
self.assertTrue((img == patch2img(patch, (2, 2), (1, 4, 4, 1))).all())
patch = img2patch(img, size=3, step=1)
expected = np.arange(0, 32, 2).reshape(1, 4, 4, 1)
expected[0, 0, 0, 0] /= 2
expected[0, 0, -1, 0] /= 2
expected[0, -1, 0, 0] /= 2
expected[0, -1, -1, 0] /= 2
expected[0, 1:3, 1:3, 0] *= 2
self.assertTrue((expected == patch2img(patch, (1, 1), (1, 4, 4, 1))).all())
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | test_img2patch |
<|file_name|>test_util.py<|end_file_name|><|fim▁begin|>import unittest
import numpy as np
from bayesnet.image.util import img2patch, patch2img
class TestImg2Patch(unittest.TestCase):
def test_img2patch(self):
img = np.arange(16).reshape(1, 4, 4, 1)
patch = img2patch(img, size=3, step=1)
expected = np.asarray([
[img[0, 0:3, 0:3, 0], img[0, 0:3, 1:4, 0]],
[img[0, 1:4, 0:3, 0], img[0, 1:4, 1:4, 0]]
])
expected = expected[None, ..., None]
self.assertTrue((patch == expected).all())
imgs = [
np.random.randn(2, 5, 6, 3),
np.random.randn(3, 10, 10, 2),
np.random.randn(1, 23, 17, 5)
]
sizes = [
(1, 1),
2,
(3, 4)
]
steps = [
(1, 2),
(3, 1),
3
]
shapes = [
(2, 5, 3, 1, 1, 3),
(3, 3, 9, 2, 2, 2),
(1, 7, 5, 3, 4, 5)
]
for img, size, step, shape in zip(imgs, sizes, steps, shapes):
self.assertEqual(shape, img2patch(img, size, step).shape)
class TestPatch2Img(unittest.TestCase):
def <|fim_middle|>(self):
img = np.arange(16).reshape(1, 4, 4, 1)
patch = img2patch(img, size=2, step=2)
self.assertTrue((img == patch2img(patch, (2, 2), (1, 4, 4, 1))).all())
patch = img2patch(img, size=3, step=1)
expected = np.arange(0, 32, 2).reshape(1, 4, 4, 1)
expected[0, 0, 0, 0] /= 2
expected[0, 0, -1, 0] /= 2
expected[0, -1, 0, 0] /= 2
expected[0, -1, -1, 0] /= 2
expected[0, 1:3, 1:3, 0] *= 2
self.assertTrue((expected == patch2img(patch, (1, 1), (1, 4, 4, 1))).all())
if __name__ == '__main__':
unittest.main()
<|fim▁end|> | test_patch2img |
<|file_name|>read_job.py<|end_file_name|><|fim▁begin|># JoeTraffic - Web-Log Analysis Application utilizing the JoeAgent Framework.
# Copyright (C) 2004 Rhett Garber
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from JoeAgent import job, event
import db_interface
import os, os.path
import logging
import log_parser
LINEINCR = 30
log = logging.getLogger("agent.LogReader")
class ReadLogCompleteEvent(event.Event):
"""Event to indicate the file is completely read. This event will
be caught by the FindLogJob that is watching it. The file will
continue to be checked for modifications"""
pass
class ReadLogContinueEvent(event.Event):
"""Event to indicate we should continue reading the file. Log file
processing will be done in chunks so as not to block the agent for
too long."""
pass
class ReadLogJob(job.Job):
def __init__(self, agent_obj, logfile):
job.Job.__init__(self, agent_obj)
assert os.path.isfile(logfile), "Not a file: %s" % str(logfile)
self._log_size = os.stat(logfile).st_size
log.debug("Log size is %d" % self._log_size)
self._logfile_path = logfile
self._logfile_hndl = open(logfile, 'r')
self._progress = 0 # Data read from file
self._db = db_interface.getDB()
def getFilePath(self):
return self._logfile_path
def getBytesRead(self):
return self._progress
def getBytesTotal(self):
return self._log_size
def run(self):
evt = ReadLogContinueEvent(self)
self.getAgent().addEvent(evt)
def notify(self, evt):
job.Job.notify(self, evt)
if isinstance(evt, ReadLogContinueEvent) and evt.getSource() == self:
log.debug("Continuing read of file")
# Continue to read the log
try:
self._progress += log_parser.read_log(
self._logfile_hndl, self._db, LINEINCR)
log.debug("Read %d %% of file (%d / %d)" % (self.getProgress(),
self._progress,<|fim▁hole|> self._progress = self._log_size
# Log file is complete, updated the db entry
self._mark_complete()
# Add an event to notify that the file is complete
self._logfile_hndl.close()
new_evt = ReadLogCompleteEvent(self)
self.getAgent().addEvent(new_evt)
except log_parser.InvalidLogException, e:
log.warning("Invalid log file: %s" % str(e))
self._logfile_hndl.close()
new_evt = ReadLogCompleteEvent(self)
self.getAgent().addEvent(new_evt)
else:
# Add an event to continue reading
new_evt = ReadLogContinueEvent(self)
self.getAgent().addEvent(new_evt)
def _update_db(self):
"""Update the entry in the database for this logfile"""
log.debug("Updating file %s" % self._logfile_path)
pass
def _mark_invalid(self):
"""Update the database to indicate that this is not a valid log file"""
log.debug("Marking file %s invalid" % self._logfile_path)
pass
def _mark_complete(self):
log.debug("Marking file %s complete" % self._logfile_path)
pass
def getProgress(self):
"""Return a percentage complete value"""
if self._log_size == 0:
return 0
return int((float(self._progress) / self._log_size) * 100)<|fim▁end|> | self._log_size))
except log_parser.EndOfLogException, e:
|