Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8746491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:12:08+00:00 2026-06-13T12:12:08+00:00

I have a function: from django.contrib.gis.measure import Distance, D def RunLengthCalc(mod_ewdim, mod_ewspacing, cols): y

  • 0

I have a function:

from django.contrib.gis.measure import Distance, D

def RunLengthCalc(mod_ewdim, mod_ewspacing, cols):
    y = D(inch=mod_ewspacing)  # user input
    x = D(inch=mod_ewdim)  # user input
    z = D(inch=3)  # constant
    lrun = ((x * cols) + (y * (cols - 1))) + zrun
    return lrun

and my test:

def test_run_length_calculation(self):
    l = RunLengthCalc(26.5, 1, 25)
    self.assertEquals(l, D(inch=689.5))

but when I run the test I get this very confusing error:

AssertionError: Distance(inch=689.5) != Distance(inch=689.5)

I can’t work out what the problem is here.

Any help would be much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:12:09+00:00Added an answer on June 13, 2026 at 12:12 pm

    There seems to be some funny business with how the Distance class equality is actually implemented:

    https://github.com/django/django/blob/master/django/contrib/gis/measure.py#L87

    Reading that code, it looks like what you have should work… but apparently it doesn’t.

    I suspect you can fix your problem by comparing specific unit values like so:


    self.assertEquals(l.inch, D(inch=689.5).inch)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small function like so: from django.contrib.gis.measure import Distance def RailTest(mod_ewdim, mod_ewspacing,
Assuming that I have function get_a_color in a Django views.py: from django.utils import simplejson
Good day, I have the following in my URLConf: from django.contrib.auth.decorators import user_passes_test urlpatterns
I have a models.py like so: from django.db import models from django.contrib.auth.models import User
In my views.py I have from django.conf import settings def site_view(request): ... if some_var
I have a function from django-registration which re-sends an activation email to the given
I have the following models code : from django.db import models from categories.models import
This view function: @login_required def dashboard(request): from myproject.myapp.models import UserProfile k = UserProfile.objects.get( user=request.user.pk
I have this code in my views.py: from django.http import HttpResponse, Http404 from django.shortcuts
I have the following model: from django.db import models import datetime class Club(models.Model): establishment

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.