Code Monkey home page Code Monkey logo

cuuats.snt.lts's People

Contributors

edmondklai avatar

Watchers

 avatar  avatar

cuuats.snt.lts's Issues

BLTS code cleanup

  • Move configuration variables (paths, feature class names, etc.) into environment variables or a git-ignored config file.
  • Call factory with register=false, add fields to the class, then register. (Removes the need for hacky field registration logic.)
  • Make the calculate_* methods into class methods. Remove the field_name argument, except where the method is called directly by a calculated field.
  • Create a function to do score assignment (see #1).

Calculate LTS scores in a method

Instead of using nested if...then statements, it would be preferable to calculate LTS scores using a testable method. Here is one possible structure for that method using eval:

from numbers import Number


def calculate_score(self, scores, *condition_sets):
    score = scores
    for condition_set in condition_sets:
        assert len(score) == len(condition_set)
        # Loop through an enumeration of the conditions in this set, evaluating
        # each one. When a condition evalutes to True:
        # - Set score = score[i], where i is the index of the condition
        # - Break out of the inner loop.

    assert isinstance(score, Number)
    return score


def calculate_bikeLaneWithParkingLane(self):
    return self.calculate_score(
        [[[1, 2, 3],
          [4, 5, 6],
          [7, 8, 9],
          [10, 11, 12]],
         [[13, 14, 15],
          [16, 17, 18],
          [19, 20, 21],
          [22, 23, 24]]],

        ['self.LanesPerDirection in (0, 1)',
         'self.LanesPerDirection >= 2'],

        ['self.IDOTAADT <= 1000',
         'self.IDOTAADT <= 3000',
         'self.IDOTAADT <= 30000',
         'True'],

        ['self.BicycleFacilityWidth + self.ParkingLaneWidth >= 15',
         'self.BicycleFacilityWidth + self.ParkingLaneWidth > 13',
         'True'])


Segment.calculate_score = calculate_score
Segment.calculate_bikeLaneWithParkingLane = calculate_bikeLaneWithParkingLane

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.