Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inifinite loop when checking for nominal values #4

Open
gireeshramji opened this issue Dec 28, 2015 · 0 comments
Open

Inifinite loop when checking for nominal values #4

gireeshramji opened this issue Dec 28, 2015 · 0 comments

Comments

@gireeshramji
Copy link

When setting up datasets with nominal values and subsequently using instance-to-map or instance-to-vector to inspect individual instances in the dataset, the termination condition in data/instance-value-at is not guaranteed to be met, due to the comparison between a float and an int here:

(defn instance-value-at [instance pos]
  "Returns the value of an instance attribute"
  (let [attr (.attribute instance pos)]
    (if (.isNominal attr)
      (let [val (.value instance pos)
            a (println "val " val)
            key-vals (dataset-values-at instance pos)
            key-val (loop [ks (keys key-vals)]
                      (if (= (get key-vals (first ks))
                             val)
                        (first ks)
                        (recur (rest ks))))]
        key-val)
      (.value instance pos))))

Here val is a float, while the vals of the map returned by dataset-values-at are ints. Comparing 0 to 0.0 in the terminal condition results in false leading to an infinite loop. I had this issue even with the example mentioned in the readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant