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

get_country_object causes tests to fail with latest version of dependencies #46

Closed
brendan-m-murphy opened this issue Jan 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@brendan-m-murphy
Copy link
Contributor

I'm not sure which dependency update is causing this error, but test_full_inversion, which previously worked, now fails with this error:

      def __init__(self, domain, country_file=None):
    
            if country_file is None:
                if not os.path.exists(os.path.join(openghginv_path, 'countries/')):
                    os.makedirs(os.path.join(openghginv_path, 'countries/'))
                    raise FileNotFoundError ("Country definition file not found."
                                             f" Please add to {openghginv_path}/countries/")
                else:
                    country_directory = os.path.join(openghginv_path, 'countries/')
    
                filename=glob.glob(os.path.join(country_directory, f"country_{domain}.nc"))
                f = xr.open_dataset(filename[0])
            else:
                filename = country_file
                f = xr.open_dataset(filename)
    
            lon = f.variables['lon'][:].values
            lat = f.variables['lat'][:].values
    
            #Get country indices and names
            if "country" in f.variables:
                country = f.variables['country'][:, :]
            elif "region" in f.variables:
                country = f.variables['region'][:, :]
    
    #         if (ukmo is True) or (uk_split is True):
    #             name_temp = f.variables['name'][:]
    #             f.close()
    #             name=np.asarray(name_temp)
    
    #         else:
            name_temp = f.variables['name'].values
            f.close()
    
            name_temp = np.ma.filled(name_temp,fill_value=None)
    
            name=[]
            for ii in range(len(name_temp)):
                if type(name_temp[ii]) is not str:
                    #name.append(''.os.path.join(name_temp[ii].decode("utf-8")))
>                   name.append(os.path.join(name_temp[ii].decode("utf-8")))
E                   AttributeError: 'numpy.str_' object has no attribute 'decode'. Did you mean: 'encode'?
@brendan-m-murphy brendan-m-murphy added the bug Something isn't working label Jan 26, 2024
@brendan-m-murphy
Copy link
Contributor Author

This is already fixed in #28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant